From 22914889aaa010dfc7426ecc9b21169216ace88b Mon Sep 17 00:00:00 2001 From: sdburns1998 <49877861+sdburns1998@users.noreply.github.com> Date: Fri, 5 Jul 2019 01:11:31 +0200 Subject: [PATCH] plugins: reduce config calls by saving and reusing values, misc performance tweaks. (#799) * Save config values -- AgilityPlugin * Static state value map * Don't run area in the for loop * Checking for bounds is enough for widget null check * Cache font settings * SAve config values -- AntiDragPlugin * Save config values -- AoEPlugin * Save config values -- AttackStylesPlugin * Save config values -- BankPlugin * Check if player is in kingdom * Save hideAutoRetaliate -- AttackStylesPlugin * Save config values -- BanListPlugin * Save config values -- BarbaranAssaultPlugin * Save config values -- BarrowsPlugin * Checkstyle * Move up updateConfig.java * Save config values -- BlackjackPlugin * Save config values -- BlastFurnacePlugin * Save config values -- BlastMinePlugin * Save config values -- BoostsPlugin * Save config values -- CannonPlugin * Fix bank plugin test * Parallelize plugin loading * Fix sidebar going AWOL * Save config values -- ChatFilterPlugin * Save config values -- ChatHistoryPlugin * Save config values -- ChatNotificationsPlugin * Save config values -- ChatTranslationPlugin * Save config values -- ClanChatPlugin * Save config values -- ClueScrollPlugin * Cleanup CombatCounterPlugin * Save config values -- CombatCounter * Checkstyle * Save config values -- CombatLevelPlugin * Convert game thread events without mutable field to singletons These should be safe to convert, events with mutable field should be checked * Checkstyle * Fix test * Save config values -- CookingPlugin * Save config values -- CorpPlugin * SAve config values -- CoxPlugin * Save config values -- DailyTasksPlugin * Save config values -- DiscordPlugin * Coxhelper checkstyle * Save config values -- EquipmentInspectorPlugin * SAve cofig values -- XpDropPlugin * Save config values -- FairyRingPlugin * Save config values -- FightCavePlugin * Save config values -- FishingPlugin * Save config values and refactor -- FlexoPlugin * Save config values -- FlinchingPlugin * Save config values -- FreezeTimersPlugin * Save config values -- GpuPlugin * Save config values -- GrandExchangePlugin * Save config values -- GroundItemsPlugin * Save config values -- GroundMarkerPlugin * Save config values -- GroundMarkerPlugin * Save config values -- HerbiboarPlugin * Save config values -- HidePrayersPlugin * Save config values -- HighAlchemyPlugin * Save config values -- HunterPlugin * Save config values -- BabyHydraPlugin * Fix Flexo * Checkstyle * Save config values -- IdleNotifierPlugin * Save config values -- ImplingsPlugin * Save config values and cleanup -- InfernoPlugin * Use EqualsAndHashCode for GroundMarkerPoint * Save config values -- InterfaceStylesPlugin * Save config values -- InventoryGridPlugin * Save config values -- InventorySetupPlugin * Checkstyle * Save config values -- InventoryTagsPlugin * Save config values -- InventoryViewerPlugin * Save config values -- ItemChargePlugin * Save config values -- ItemIdentificationPlugin * Save config values -- ItemPricesPlugin * Save config values -- ItemStatPlugin * Save config values -- KeyRemappingPlugin * Save config values -- KourendLibraryPlugin * Save config values -- LearnToClickPlugin * Save config values -- LizardmenShamanPlugin * Save config values -- LoginScreenPlugin * Cleanup LootAssistOverlay * Remove unused LootAssistConfig * Save config values -- LootTrackerPlugin * Save config values -- MetronomePlugin * Add border color ground items * Save config values -- WorstPluginEverPlugin * Fix inferno plugin * Save config values -- MinimapPlugin * Save config values -- MiningPlugin * Save config values -- MotherlodePlugin * Save config values -- MouseHighlightPlugin * Save config values -- MTAPlugin * Save config values -- MultiIndicatorsPlugin * Save config values -- NightmareZonePlugin * Save config values -- NpcIndicatorsPlugin * Save config values -- NpcStatusPlugin * Save config values -- NpcAggroAreaPlugin * Save config values -- ObjectIndicatorsPlugin * Save config values -- OpponentInfoPlugin * Save config values -- PartyPlugin * Save config values -- PerformanceStatsPlugin * Save config values and cleanup -- PestcontrolPlugin * Save config values , cleanup and refactor -- PileIndicatorsPlugin * Save config values -- PlayerIndicatorsPlugin * Save config values -- PlayerInfoPlugin * Save config values -- PluginSorterPlugin * Save config values -- PohPlugin * Checkstyle * Save config values -- PoisonPlugin * Save config values -- PrayAgainstPlayerPlugin * Save config values -- PrayerPlugin * Save config values -- PrayerAlertPlugin * Checkstyle * Save config values -- PuzzleSolverPlugin * Save config values -- PvpToolsPlugin * Save config values -- PyramidPlunderPlugin * Save config values -- RaidsPlugin * Save config values -- ShortcutPlugin * Save config values -- RaidsThievingPlugin * Oopsie * Save config values -- RegenMeterPlugin * Save config values -- ReportButtonPlugin * Save config values -- RunecraftPlugin * Save config values -- RunedokuPlugin * Save config values -- RunepouchPlugin * Save config values -- SafeSpotPlugin * Save config values -- ScreenshotPlugin * Save config values -- ShiftWalkerPlugin * Save config values -- SlayerPlugin * Save config values -- SmeltingPlugin * Save config values -- SpawnTimerPlugin * Save config values -- SpellbookPlugin * Save config values -- StatusBarsPlugin * Save config values -- ThievingPlugin * Checkstyle * Cleanup Zulrah * Save config values -- XpTrackerPlugin * Save config values -- XpGlobesPlugin * Save config values -- WorldMapPlugin * Save config values -- TheatrePlugin * Save config values -- TickTimersPlugin * Save config values -- TileIndicatorsPlugin * Save config values -- TimersPlugin * Save config values -- TitheFarmPlugin * Save config values -- TMorphPlugin * Save config values -- WarIndicatorPlugin * Save config values -- WhaleWatchersPlugin * Save config values -- WildernessLocationsPlugin * Save config values -- WintertodtPlugin * Save config values -- WorldHopperPlugin * Save config values -- WoodcuttingPlugin * Cleanup * Checkstyle * Fix tests --- .../main/java/net/runelite/api/GameState.java | 18 +- .../java/net/runelite/api/Perspective.java | 7 +- .../net/runelite/api/events/BeforeRender.java | 6 + .../runelite/api/events/CannonballFired.java | 6 + .../api/events/CanvasSizeChanged.java | 6 + .../net/runelite/api/events/ClientTick.java | 6 + .../net/runelite/api/events/GameTick.java | 9 +- .../runelite/api/events/LocalPlayerDeath.java | 6 + .../runelite/api/events/UsernameChanged.java | 6 + .../runelite/api/events/WidgetPositioned.java | 9 +- .../net/runelite/client/callback/Hooks.java | 7 +- .../client/plugins/PluginManager.java | 119 ++- .../client/plugins/account/AccountPlugin.java | 2 + .../DiaryRequirementsPlugin.java | 2 + .../plugins/agility/AgilityOverlay.java | 24 +- .../client/plugins/agility/AgilityPlugin.java | 72 +- .../plugins/agility/AgilitySession.java | 2 +- .../client/plugins/agility/Courses.java | 9 +- .../plugins/agility/LapCounterOverlay.java | 14 +- .../plugins/alchemicalhydra/HydraOverlay.java | 2 +- .../plugins/alchemicalhydra/HydraPlugin.java | 2 + .../alchemicalhydra/HydraSceneOverlay.java | 2 +- .../client/plugins/ammo/AmmoCounter.java | 3 +- .../client/plugins/ammo/AmmoPlugin.java | 2 + .../AnimationSmoothingPlugin.java | 2 + .../plugins/antidrag/AntiDragConfig.java | 1 - .../plugins/antidrag/AntiDragOverlay.java | 10 +- .../plugins/antidrag/AntiDragPlugin.java | 64 +- .../client/plugins/antidrag/CustomCursor.java | 4 +- .../plugins/aoewarnings/AoeProjectile.java | 3 +- .../aoewarnings/AoeWarningOverlay.java | 16 +- .../plugins/aoewarnings/AoeWarningPlugin.java | 209 ++++-- .../plugins/aoewarnings/BombOverlay.java | 13 +- .../plugins/aoewarnings/CrystalBomb.java | 11 +- .../attackstyles/AttackStylesOverlay.java | 8 +- .../attackstyles/AttackStylesPlugin.java | 57 +- .../client/plugins/bank/BankCalculation.java | 12 +- .../client/plugins/bank/BankPlugin.java | 65 +- .../plugins/banktags/BankTagsPlugin.java | 2 + .../client/plugins/banlist/BanListConfig.java | 1 - .../client/plugins/banlist/BanListPlugin.java | 32 +- .../barbarianassault/AboveSceneOverlay.java | 13 +- .../barbarianassault/AboveWidgetsOverlay.java | 26 +- .../BarbarianAssaultMenu.java | 51 +- .../BarbarianAssaultPlugin.java | 165 ++++- .../plugins/barbarianassault/Scorecard.java | 2 +- .../plugins/barbarianassault/Timer.java | 3 +- .../plugins/barbarianassault/TimerBox.java | 2 + .../client/plugins/barbarianassault/Wave.java | 1 - .../barrows/BarrowsBrotherSlainOverlay.java | 4 +- .../plugins/barrows/BarrowsBrothers.java | 7 +- .../plugins/barrows/BarrowsOverlay.java | 16 +- .../client/plugins/barrows/BarrowsPlugin.java | 47 +- .../plugins/blackjack/BlackjackPlugin.java | 22 +- .../BlastFurnaceClickBoxOverlay.java | 10 +- .../BlastFurnaceCofferOverlay.java | 4 +- .../blastfurnace/BlastFurnaceOverlay.java | 4 +- .../blastfurnace/BlastFurnacePlugin.java | 28 + .../blastmine/BlastMineOreCountOverlay.java | 10 +- .../plugins/blastmine/BlastMinePlugin.java | 34 +- .../plugins/blastmine/BlastMineRock.java | 5 +- .../blastmine/BlastMineRockOverlay.java | 16 +- .../plugins/blastmine/BlastMineRockType.java | 3 +- .../client/plugins/boosts/BoostIndicator.java | 13 +- .../client/plugins/boosts/BoostsOverlay.java | 12 +- .../client/plugins/boosts/BoostsPlugin.java | 58 +- .../plugins/boosts/CombatIconsOverlay.java | 14 +- .../plugins/bosstimer/BossTimersPlugin.java | 2 + .../plugins/bosstimer/RespawnTimer.java | 2 +- .../client/plugins/cannon/CannonOverlay.java | 10 +- .../client/plugins/cannon/CannonPlugin.java | 51 +- .../plugins/cannon/CannonSpotOverlay.java | 8 +- .../plugins/cerberus/CerberusGhost.java | 3 +- .../ChatboxPerformancePlugin.java | 2 + .../chatcommands/ChatCommandsPlugin.java | 2 + .../plugins/chatfilter/ChatFilterPlugin.java | 40 +- .../chathistory/ChatHistoryPlugin.java | 29 +- .../ChatNotificationsPlugin.java | 39 +- .../ChatTranslationPlugin.java | 37 +- .../plugins/clanchat/ClanChatIndicator.java | 4 +- .../plugins/clanchat/ClanChatPlugin.java | 71 +- .../ClanManModeMinimapOverlay.java | 2 +- .../clanmanmode/ClanManModeOverlay.java | 2 +- .../clanmanmode/ClanManModePlugin.java | 3 +- .../clanmanmode/ClanManModeService.java | 2 +- .../clanmanmode/ClanManModeTileOverlay.java | 4 +- .../cluescrolls/ClueScrollEmoteOverlay.java | 4 +- .../cluescrolls/ClueScrollMusicOverlay.java | 4 +- .../cluescrolls/ClueScrollOverlay.java | 4 +- .../plugins/cluescrolls/ClueScrollPlugin.java | 21 +- .../cluescrolls/ClueScrollServiceImpl.java | 2 +- .../cluescrolls/ClueScrollWorldMapPoint.java | 2 +- .../cluescrolls/ClueScrollWorldOverlay.java | 4 +- .../plugins/combatcounter/CombatCounter.java | 108 ++- .../plugins/combatcounter/CombatOverlay.java | 22 +- .../plugins/combatcounter/DamageOverlay.java | 19 +- .../combatcounter/NPCDamageCounter.java | 14 +- .../combatlevel/CombatLevelOverlay.java | 10 +- .../combatlevel/CombatLevelPlugin.java | 24 +- .../client/plugins/config/ConfigPanel.java | 2 + .../client/plugins/config/ConfigPlugin.java | 5 +- .../client/plugins/config/HotkeyButton.java | 7 +- .../client/plugins/config/PluginListItem.java | 6 +- .../plugins/cooking/CookingOverlay.java | 4 +- .../client/plugins/cooking/CookingPlugin.java | 30 +- .../plugins/cooking/CookingSession.java | 2 + .../client/plugins/cooking/FermentTimer.java | 2 + .../client/plugins/corp/CoreOverlay.java | 7 +- .../plugins/corp/CorpDamageOverlay.java | 8 +- .../client/plugins/corp/CorpPlugin.java | 24 +- .../client/plugins/coxhelper/CoxInfoBox.java | 10 +- .../client/plugins/coxhelper/CoxOverlay.java | 70 +- .../client/plugins/coxhelper/CoxPlugin.java | 78 ++ .../plugins/coxhelper/NPCContainer.java | 37 +- .../client/plugins/coxhelper/PrayAgainst.java | 3 +- .../crystalmathlabs/CrystalMathLabs.java | 2 + .../plugins/customcursor/CustomCursor.java | 5 +- .../customcursor/CustomCursorPlugin.java | 2 + .../dailytaskindicators/DailyTasksPlugin.java | 55 +- .../deathindicator/DeathIndicatorPlugin.java | 2 + .../defaultworld/DefaultWorldPlugin.java | 2 + .../demonicgorilla/DemonicGorillaOverlay.java | 9 +- .../demonicgorilla/DemonicGorillaPlugin.java | 54 +- .../demonicgorilla/MemorizedPlayer.java | 13 +- .../demonicgorilla/PendingGorillaAttack.java | 14 +- .../plugins/discord/DiscordGameEventType.java | 3 +- .../client/plugins/discord/DiscordPlugin.java | 48 +- .../client/plugins/discord/DiscordState.java | 12 +- .../client/plugins/emojis/EmojiPlugin.java | 2 + .../entityhider/EntityHiderPlugin.java | 2 + .../EquipmentInspectorConfig.java | 2 +- .../EquipmentInspectorPlugin.java | 49 +- .../plugins/equipmentinspector/normal.png | Bin 624 -> 0 bytes .../client/plugins/examine/CacheKey.java | 2 +- .../client/plugins/examine/ExaminePlugin.java | 2 + .../plugins/experiencedrop/XpDropOverlay.java | 12 +- .../plugins/experiencedrop/XpDropPlugin.java | 44 +- .../plugins/fairyring/FairyRingPlugin.java | 24 +- .../client/plugins/feed/FeedPanel.java | 2 + .../client/plugins/feed/FeedPlugin.java | 2 + .../plugins/fightcave/FightCaveContainer.java | 8 +- .../plugins/fightcave/FightCaveOverlay.java | 22 +- .../plugins/fightcave/FightCavePlugin.java | 38 +- .../client/plugins/fightcave/WaveOverlay.java | 4 +- .../plugins/fishing/FishingOverlay.java | 8 +- .../client/plugins/fishing/FishingPlugin.java | 51 +- .../plugins/fishing/FishingSession.java | 5 +- .../fishing/FishingSpotMinimapOverlay.java | 8 +- .../plugins/fishing/FishingSpotOverlay.java | 16 +- .../client/plugins/flexo/FlexoOverlay.java | 29 +- .../client/plugins/flexo/FlexoPlugin.java | 125 +++- .../plugins/flinching/FlinchingOverlay.java | 13 +- .../plugins/flinching/FlinchingPlugin.java | 38 +- .../plugins/flinching/FlinchingTarget.java | 5 +- .../client/plugins/fps/FpsDrawListener.java | 2 +- .../client/plugins/fps/FpsOverlay.java | 4 +- .../client/plugins/fps/FpsPlugin.java | 2 + .../plugins/freezetimers/FontStyle.java | 3 +- .../plugins/freezetimers/FreezeInfo.java | 5 +- .../freezetimers/FreezeTimersOverlay.java | 49 +- .../freezetimers/FreezeTimersPlugin.java | 52 +- .../freezetimers/PlayerSpellEffect.java | 15 +- .../plugins/freezetimers/PrayerTracker.java | 4 +- .../client/plugins/freezetimers/Timers.java | 14 +- .../plugins/friendlist/FriendListPlugin.java | 2 + .../friendnotes/FriendNoteOverlay.java | 4 +- .../friendnotes/FriendNotesPlugin.java | 2 + .../friendtagging/FriendTaggingPlugin.java | 3 +- .../runelite/client/plugins/gpu/GLUtil.java | 18 +- .../client/plugins/gpu/GpuFloatBuffer.java | 4 +- .../client/plugins/gpu/GpuIntBuffer.java | 5 - .../client/plugins/gpu/GpuPlugin.java | 66 +- .../client/plugins/gpu/SceneUploader.java | 68 +- .../GrandExchangeInputListener.java | 4 +- .../grandexchange/GrandExchangeItemPanel.java | 2 + .../grandexchange/GrandExchangeOfferSlot.java | 4 +- .../GrandExchangeOffersPanel.java | 4 +- .../grandexchange/GrandExchangePanel.java | 7 +- .../grandexchange/GrandExchangePlugin.java | 28 +- .../GrandExchangeSearchPanel.java | 7 +- .../grotesqueguardians/DuskAttack.java | 2 +- .../GrotesqueGuardiansOverlay.java | 4 +- .../GrotesqueGuardiansPlugin.java | 14 +- .../GrotesqueGuardiansPrayerOverlay.java | 4 +- .../grounditems/GroundItemInputListener.java | 7 +- .../grounditems/GroundItemsOverlay.java | 34 +- .../grounditems/GroundItemsPlugin.java | 183 ++++- .../grounditems/MenuEntryWithCount.java | 5 +- .../grounditems/WildcardMatchLoader.java | 2 +- .../GroundMarkerInputListener.java | 4 +- .../GroundMarkerMinimapOverlay.java | 18 +- .../groundmarkers/GroundMarkerOverlay.java | 16 +- .../groundmarkers/GroundMarkerPlugin.java | 47 +- .../groundmarkers/GroundMarkerPoint.java | 21 +- .../groundmarkers/GroundMarkerWorldPoint.java | 2 +- .../herbiboars/HerbiboarMinimapOverlay.java | 11 +- .../plugins/herbiboars/HerbiboarOverlay.java | 32 +- .../plugins/herbiboars/HerbiboarPlugin.java | 87 ++- .../hideprayers/HidePrayersPlugin.java | 235 ++++-- .../highalchemy/HighAlchemyOverlay.java | 12 +- .../highalchemy/HighAlchemyPlugin.java | 28 +- .../client/plugins/hiscore/HiscorePanel.java | 2 + .../client/plugins/hiscore/HiscorePlugin.java | 14 +- .../plugins/hiscore/NameAutocompleter.java | 2 +- .../client/plugins/hunter/HunterPlugin.java | 32 +- .../client/plugins/hunter/HunterTrap.java | 17 +- .../client/plugins/hunter/TrapOverlay.java | 14 +- .../hydra/BabyHydraIndicatorOverlay.java | 4 +- .../plugins/hydra/BabyHydraOverlay.java | 9 +- .../client/plugins/hydra/BabyHydraPlugin.java | 30 +- .../plugins/hydra/BabyHydraPrayOverlay.java | 4 +- .../idlenotifier/IdleNotifierPlugin.java | 116 ++- .../implings/ImplingCounterOverlay.java | 11 +- .../implings/ImplingMinimapOverlay.java | 10 +- .../client/plugins/implings/ImplingSpawn.java | 3 +- .../client/plugins/implings/ImplingType.java | 3 +- .../plugins/implings/ImplingsConfig.java | 11 - .../plugins/implings/ImplingsOverlay.java | 14 +- .../plugins/implings/ImplingsPlugin.java | 129 +++- .../client/plugins/inferno/InfernoConfig.java | 76 +- .../plugins/inferno/InfernoInfobox.java | 15 +- .../plugins/inferno/InfernoJadAttack.java | 28 +- .../plugins/inferno/InfernoJadOverlay.java | 61 +- .../client/plugins/inferno/InfernoNPC.java | 39 +- .../inferno/InfernoNibblerOverlay.java | 13 +- .../plugins/inferno/InfernoOverlay.java | 28 +- .../client/plugins/inferno/InfernoPlugin.java | 146 ++-- .../plugins/inferno/InfernoWaveMappings.java | 7 +- .../plugins/inferno/InfernoWaveOverlay.java | 23 +- .../client/plugins/info/InfoPlugin.java | 2 + .../client/plugins/info/JRichTextPane.java | 4 +- .../instancemap/InstanceMapOverlay.java | 17 +- .../instancemap/InstanceMapPlugin.java | 10 +- .../interfacestyles/HealthbarOverride.java | 5 +- .../InterfaceStylesPlugin.java | 35 +- .../client/plugins/interfacestyles/Skin.java | 3 +- .../interfacestyles/SpriteOverride.java | 3 +- .../plugins/interfacestyles/WidgetOffset.java | 3 +- .../interfacestyles/WidgetOverride.java | 5 +- .../inventorygrid/InventoryGridOverlay.java | 20 +- .../inventorygrid/InventoryGridPlugin.java | 43 ++ .../InventorySetupBankOverlay.java | 8 +- .../inventorysetups/InventorySetupPlugin.java | 34 +- .../ui/InventorySetupContainerPanel.java | 10 +- .../ui/InventorySetupEquipmentPanel.java | 2 + .../ui/InventorySetupInventoryPanel.java | 3 +- .../ui/InventorySetupPluginPanel.java | 2 + .../ui/InventorySetupSlot.java | 8 +- .../inventorytags/InventoryTagsOverlay.java | 4 +- .../inventorytags/InventoryTagsPlugin.java | 34 +- .../inventoryviewer/InventoryViewerMode.java | 3 +- .../InventoryViewerOverlay.java | 16 +- .../InventoryViewerPlugin.java | 33 + .../plugins/itemcharges/ItemChargeConfig.java | 95 ++- .../itemcharges/ItemChargeInfobox.java | 15 +- .../itemcharges/ItemChargeOverlay.java | 64 +- .../plugins/itemcharges/ItemChargePlugin.java | 179 ++++- .../itemcharges/ItemRecoilOverlay.java | 9 +- .../plugins/itemcharges/ItemWithCharge.java | 3 +- .../plugins/itemcharges/ItemWithSlot.java | 3 +- .../ItemIdentificationOverlay.java | 18 +- .../ItemIdentificationPlugin.java | 42 ++ .../plugins/itemprices/ItemPricesOverlay.java | 26 +- .../plugins/itemprices/ItemPricesPlugin.java | 41 ++ .../itemskeptondeath/AlwaysLostItem.java | 3 +- .../itemskeptondeath/FixedPriceItem.java | 3 +- .../ItemsKeptOnDeathPlugin.java | 2 + .../plugins/itemstats/ItemStatOverlay.java | 43 +- .../plugins/itemstats/ItemStatPlugin.java | 51 +- .../client/plugins/itemstats/Positivity.java | 12 +- .../keyremapping/KeyRemappingListener.java | 29 +- .../keyremapping/KeyRemappingPlugin.java | 36 +- .../kingdomofmiscellania/KingdomCounter.java | 4 +- .../kingdomofmiscellania/KingdomPlugin.java | 14 +- .../client/plugins/kourendlibrary/Book.java | 15 +- .../plugins/kourendlibrary/BookPanel.java | 4 +- .../plugins/kourendlibrary/Bookcase.java | 13 +- .../kourendlibrary/KourendLibraryOverlay.java | 8 +- .../kourendlibrary/KourendLibraryPlugin.java | 20 +- .../plugins/kourendlibrary/Library.java | 7 +- .../kourendlibrary/LibraryCustomer.java | 5 +- .../learntoclick/LearnToClickPlugin.java | 45 +- .../LizardmenShamanPlugin.java | 28 +- .../lizardmenshaman/LizardmenShamanSpawn.java | 5 +- .../lizardmenshaman/ShamanSpawnOverlay.java | 4 +- .../loginscreen/LoginScreenPlugin.java | 39 +- .../plugins/lootassist/LootAssistOverlay.java | 23 +- .../plugins/lootassist/LootAssistPlugin.java | 11 +- .../plugins/lootassist/LootAssitConfig.java | 20 - .../client/plugins/lootassist/LootPile.java | 11 +- .../LootingBagViewerOverlay.java | 4 +- .../LootingBagViewerPlugin.java | 7 +- .../LootingBagViewerWidgetOverlay.java | 10 +- .../plugins/loottracker/LootTrackerBox.java | 2 +- .../plugins/loottracker/LootTrackerItem.java | 13 +- .../plugins/loottracker/LootTrackerPanel.java | 6 +- .../loottracker/LootTrackerPlugin.java | 74 +- .../plugins/lowmemory/LowMemoryPlugin.java | 2 + .../client/plugins/maxhit/MaxHitPlugin.java | 3 +- .../maxhit/equipment/EquipmentSlotItem.java | 2 +- .../MenuEntrySwapperPlugin.java | 686 ++++++++++++------ .../ShiftClickInputListener.java | 2 + .../plugins/metronome/MetronomePlugin.java | 48 +- .../client/plugins/minimap/MinimapPlugin.java | 44 +- .../plugins/mining/MiningCoalBagOverlay.java | 10 +- .../client/plugins/mining/MiningOverlay.java | 4 +- .../client/plugins/mining/MiningPlugin.java | 35 +- .../client/plugins/mining/RockRespawn.java | 3 +- .../motherlode/MotherlodeGemOverlay.java | 11 +- .../motherlode/MotherlodeOreOverlay.java | 9 +- .../plugins/motherlode/MotherlodeOverlay.java | 15 +- .../plugins/motherlode/MotherlodePlugin.java | 57 +- .../motherlode/MotherlodeRocksOverlay.java | 14 +- .../motherlode/MotherlodeSackOverlay.java | 10 +- .../plugins/motherlode/MotherlodeSession.java | 17 +- .../mousehighlight/MouseHighlightOverlay.java | 16 +- .../mousehighlight/MouseHighlightPlugin.java | 44 +- .../plugins/mta/MTAInventoryOverlay.java | 4 +- .../client/plugins/mta/MTAPlugin.java | 6 +- .../runelite/client/plugins/mta/MTARoom.java | 2 +- .../client/plugins/mta/MTASceneOverlay.java | 4 +- .../plugins/mta/alchemy/AlchemyItem.java | 2 +- .../plugins/mta/alchemy/AlchemyRoom.java | 20 +- .../plugins/mta/alchemy/AlchemyRoomTimer.java | 4 +- .../mta/enchantment/EnchantmentRoom.java | 20 +- .../mta/graveyard/GraveyardCounter.java | 2 +- .../plugins/mta/graveyard/GraveyardRoom.java | 21 +- .../client/plugins/mta/telekinetic/Maze.java | 2 +- .../mta/telekinetic/TelekineticRoom.java | 20 +- .../plugins/multiindicators/MapLocations.java | 28 +- .../MultiIndicatorsMinimapOverlay.java | 26 +- .../MultiIndicatorsOverlay.java | 17 +- .../MultiIndicatorsPlugin.java | 71 +- .../musicindicator/MusicIndicatorPlugin.java | 3 +- .../plugins/musiclist/MusicListPlugin.java | 2 + .../nightmarezone/AbsorptionCounter.java | 3 +- .../nightmarezone/NightmareZoneOverlay.java | 31 +- .../nightmarezone/NightmareZonePlugin.java | 72 +- .../client/plugins/notes/NotesPanel.java | 4 +- .../client/plugins/notes/NotesPlugin.java | 2 + .../plugins/npchighlight/MemorizedNpc.java | 21 +- .../npchighlight/NpcIndicatorsPlugin.java | 37 +- .../npchighlight/NpcMinimapOverlay.java | 13 +- .../plugins/npchighlight/NpcSceneOverlay.java | 16 +- .../plugins/npcstatus/MemorizedNPC.java | 19 +- .../plugins/npcstatus/NpcStatusConfig.java | 6 +- .../plugins/npcstatus/NpcStatusOverlay.java | 4 +- .../plugins/npcstatus/NpcStatusPlugin.java | 33 +- .../npcunaggroarea/AggressionTimer.java | 7 +- .../NpcAggroAreaNotWorkingOverlay.java | 8 +- .../npcunaggroarea/NpcAggroAreaOverlay.java | 8 +- .../npcunaggroarea/NpcAggroAreaPlugin.java | 60 +- .../ObjectIndicatorsOverlay.java | 14 +- .../ObjectIndicatorsPlugin.java | 37 + .../opponentinfo/OpponentInfoOverlay.java | 17 +- .../opponentinfo/OpponentInfoPlugin.java | 30 + .../opponentinfo/PlayerComparisonOverlay.java | 8 +- .../plugins/party/PartyPingOverlay.java | 2 + .../client/plugins/party/PartyPlugin.java | 50 +- .../plugins/party/PartyStatsOverlay.java | 8 +- .../plugins/party/PartyWorldMapPoint.java | 2 +- .../plugins/performancestats/Performance.java | 9 +- .../PerformanceStatsOverlay.java | 8 +- .../PerformanceStatsPlugin.java | 28 +- .../client/plugins/pestcontrol/Game.java | 29 +- .../plugins/pestcontrol/GangplankOverlay.java | 6 +- .../plugins/pestcontrol/HintArrowOverlay.java | 6 +- .../pestcontrol/NpcHighlightContext.java | 7 +- .../pestcontrol/NpcHighlightOverlay.java | 6 +- .../plugins/pestcontrol/PestControlNpc.java | 65 +- .../pestcontrol/PestControlPlugin.java | 101 ++- .../pestcontrol/PestControlRepairObject.java | 15 +- .../pestcontrol/PointsInfoboxCounter.java | 7 +- .../client/plugins/pestcontrol/Portal.java | 13 +- .../plugins/pestcontrol/PortalColor.java | 3 +- .../plugins/pestcontrol/PortalRotation.java | 2 +- .../pestcontrol/PortalWeaknessOverlay.java | 16 +- .../plugins/pestcontrol/RepairOverlay.java | 18 +- .../plugins/pestcontrol/TimerOverlay.java | 6 +- .../plugins/pestcontrol/WidgetOverlay.java | 6 +- .../plugins/pestcontrol/WidgetPortal.java | 3 +- .../pileindicators/PileIndicatorsConfig.java | 142 ++-- .../pileindicators/PileIndicatorsOverlay.java | 26 +- .../pileindicators/PileIndicatorsPlugin.java | 89 ++- .../PlayerIndicatorsConfig.java | 22 +- .../PlayerIndicatorsMinimapOverlay.java | 21 +- .../PlayerIndicatorsOverlay.java | 24 +- .../PlayerIndicatorsPlugin.java | 152 +++- .../PlayerIndicatorsService.java | 46 +- .../PlayerIndicatorsTileOverlay.java | 11 +- .../playerinfo/PlayerInfoCustomIndicator.java | 25 +- .../plugins/playerinfo/PlayerInfoPlugin.java | 47 +- .../pluginsorter/PluginSorterPlugin.java | 41 +- .../client/plugins/poh/BurnerOverlay.java | 8 +- .../client/plugins/poh/IncenseBurner.java | 5 +- .../client/plugins/poh/PohOverlay.java | 33 +- .../client/plugins/poh/PohPlugin.java | 58 ++ .../plugins/poison/PoisonActorOverlay.java | 4 +- .../client/plugins/poison/PoisonInfobox.java | 2 +- .../client/plugins/poison/PoisonOverlay.java | 2 + .../client/plugins/poison/PoisonPlugin.java | 45 +- .../prayagainstplayer/PlayerContainer.java | 2 +- .../PrayAgainstPlayerOverlay.java | 40 +- .../PrayAgainstPlayerOverlayPrayerTab.java | 8 +- .../PrayAgainstPlayerPlugin.java | 92 ++- .../plugins/prayer/PrayerBarOverlay.java | 22 +- .../client/plugins/prayer/PrayerCounter.java | 5 +- .../plugins/prayer/PrayerDoseOverlay.java | 12 +- .../plugins/prayer/PrayerFlickOverlay.java | 12 +- .../client/plugins/prayer/PrayerItems.java | 3 +- .../client/plugins/prayer/PrayerPlugin.java | 48 +- .../plugins/prayer/PrayerRestoreType.java | 2 +- .../client/plugins/prayer/PrayerType.java | 3 +- .../prayeralert/PrayerAlertOverlay.java | 14 +- .../prayeralert/PrayerAlertPlugin.java | 28 +- .../client/plugins/profiles/ProfilePanel.java | 4 +- .../plugins/profiles/ProfilesPanel.java | 4 +- .../plugins/profiles/ProfilesPlugin.java | 3 +- .../puzzlesolver/PuzzleSolverOverlay.java | 16 +- .../puzzlesolver/PuzzleSolverPlugin.java | 32 + .../puzzlesolver/VarrockMuseumAnswer.java | 3 +- .../client/plugins/pvptools/AttackMode.java | 2 +- .../pvptools/CurrentPlayersJFrame.java | 10 +- .../pvptools/MissingPlayersJFrame.java | 10 +- .../plugins/pvptools/PlayerCountOverlay.java | 8 +- .../plugins/pvptools/PvpToolsOverlay.java | 25 +- .../plugins/pvptools/PvpToolsPanel.java | 2 + .../plugins/pvptools/PvpToolsPlugin.java | 115 ++- .../client/plugins/pvptools/skull.png | Bin 448 -> 0 bytes .../pyramidplunder/PyramidPlunderConfig.java | 32 +- .../pyramidplunder/PyramidPlunderOverlay.java | 68 +- .../pyramidplunder/PyramidPlunderPlugin.java | 40 +- .../pyramidplunder/PyramidPlunderTimer.java | 4 +- .../plugins/questlist/QuestListPlugin.java | 10 +- .../runelite/client/plugins/raids/Raid.java | 5 +- .../client/plugins/raids/RaidRoom.java | 25 +- .../client/plugins/raids/RaidsOverlay.java | 73 +- .../client/plugins/raids/RaidsPanel.java | 7 +- .../plugins/raids/RaidsPartyOverlay.java | 4 +- .../client/plugins/raids/RaidsPlugin.java | 164 ++++- .../plugins/raids/RaidsPointsOverlay.java | 4 +- .../client/plugins/raids/RaidsTimer.java | 5 +- .../raids/shortcuts/ShortcutOverlay.java | 8 +- .../raids/shortcuts/ShortcutPlugin.java | 31 +- .../client/plugins/raids/solver/Layout.java | 7 +- .../plugins/raids/solver/LayoutSolver.java | 8 +- .../client/plugins/raids/solver/Room.java | 15 +- .../plugins/raids/solver/RotationSolver.java | 19 +- .../raidsthieving/BatSolver/BatSolver.java | 7 +- .../BatSolver/ChestIdentifier.java | 5 +- .../raidsthieving/BatSolver/SolutionSet.java | 7 +- .../BatSolver/ThievingRoomType.java | 2 +- .../plugins/raidsthieving/ChestOverlay.java | 14 +- .../plugins/raidsthieving/InstancePoint.java | 9 +- .../raidsthieving/RaidsThievingPlugin.java | 33 +- .../plugins/raidsthieving/ThievingChest.java | 12 +- .../plugins/regenmeter/RegenMeterOverlay.java | 43 +- .../plugins/regenmeter/RegenMeterPlugin.java | 39 +- .../reorderprayers/ReorderPrayersPlugin.java | 2 + .../reportbutton/ReportButtonPlugin.java | 17 +- .../plugins/reportbutton/TimeStyle.java | 2 +- .../plugins/roguesden/RoguesDenOverlay.java | 4 +- .../plugins/roguesden/RoguesDenPlugin.java | 2 + .../plugins/runecraft/AbyssOverlay.java | 38 +- .../client/plugins/runecraft/AbyssRifts.java | 7 +- .../plugins/runecraft/RunecraftOverlay.java | 7 +- .../plugins/runecraft/RunecraftPlugin.java | 72 +- .../plugins/runedoku/RunedokuConfig.java | 114 +-- .../plugins/runedoku/RunedokuOverlay.java | 8 +- .../plugins/runedoku/RunedokuPiece.java | 2 +- .../plugins/runedoku/RunedokuPlugin.java | 59 +- .../client/plugins/runedoku/RunedokuUtil.java | 49 +- .../client/plugins/runedoku/Sudoku.java | 13 +- .../runeliteplus/RuneLitePlusPlugin.java | 8 +- .../plugins/runenergy/RunEnergyOverlay.java | 2 + .../plugins/runenergy/RunEnergyPlugin.java | 2 + .../plugins/runepouch/RunepouchOverlay.java | 24 +- .../plugins/runepouch/RunepouchPlugin.java | 37 + .../client/plugins/runepouch/Runes.java | 11 +- .../plugins/safespot/SafeSpotOverlay.java | 8 +- .../plugins/safespot/SafeSpotPlugin.java | 60 +- .../ScreenMarkerCreationOverlay.java | 2 + .../ScreenMarkerMouseListener.java | 4 +- .../screenmarkers/ScreenMarkerOverlay.java | 7 +- .../screenmarkers/ScreenMarkerPlugin.java | 6 +- .../screenmarkers/ScreenMarkerRenderable.java | 4 +- .../ui/ScreenMarkerCreationPanel.java | 4 +- .../screenmarkers/ui/ScreenMarkerPanel.java | 4 +- .../ui/ScreenMarkerPluginPanel.java | 9 +- .../plugins/screenshot/ScreenshotOverlay.java | 4 +- .../plugins/screenshot/ScreenshotPlugin.java | 165 +++-- .../ShayzienInfirmaryOverlay.java | 6 +- .../ShayzienInfirmaryPlugin.java | 11 +- .../shiftwalker/ShiftWalkerInputListener.java | 2 + .../shiftwalker/ShiftWalkerPlugin.java | 26 +- .../skillcalculator/BankedCalculator.java | 12 +- .../skillcalculator/CacheSkillData.java | 2 +- .../skillcalculator/CalculatorType.java | 3 +- .../skillcalculator/SkillCalculator.java | 4 +- .../skillcalculator/SkillCalculatorPanel.java | 4 +- .../SkillCalculatorPlugin.java | 2 + .../plugins/skillcalculator/UIActionSlot.java | 2 + .../UICalculatorInputArea.java | 5 +- .../skillcalculator/UICombinedActionSlot.java | 4 +- .../banked/beans/Activity.java | 7 +- .../banked/beans/ActivitySecondaries.java | 5 +- .../banked/beans/SecondaryItem.java | 7 +- .../banked/ui/CriticalItemPanel.java | 7 +- .../skillcalculator/beans/SkillData.java | 3 +- .../skillcalculator/beans/SkillDataBonus.java | 3 +- .../skillcalculator/beans/SkillDataEntry.java | 3 +- .../client/plugins/skybox/SkyboxPlugin.java | 2 + .../client/plugins/slayer/KnapsackSolver.java | 2 + .../client/plugins/slayer/NPCPresence.java | 7 +- .../client/plugins/slayer/RenderStyle.java | 2 +- .../client/plugins/slayer/SlayerOverlay.java | 8 +- .../client/plugins/slayer/SlayerPlugin.java | 86 ++- .../plugins/slayer/SlayerTaskPanel.java | 2 + .../plugins/slayer/TargetClickboxOverlay.java | 16 +- .../plugins/slayer/TargetMinimapOverlay.java | 14 +- .../plugins/slayer/TargetWeaknessOverlay.java | 8 +- .../runelite/client/plugins/slayer/Task.java | 3 +- .../client/plugins/slayer/TaskBox.java | 2 + .../client/plugins/slayer/TaskCounter.java | 2 +- .../slayermusiq/SlayermusiqPlugin.java | 3 +- .../plugins/smelting/SmeltingOverlay.java | 4 +- .../plugins/smelting/SmeltingPlugin.java | 19 +- .../plugins/spawntimer/SpawnTimerConfig.java | 4 +- .../plugins/spawntimer/SpawnTimerOverlay.java | 32 +- .../plugins/spawntimer/SpawnTimerPlugin.java | 66 +- .../client/plugins/specbar/SpecBarPlugin.java | 3 +- .../client/plugins/specialcounter/Boss.java | 3 +- .../specialcounter/SpecialCounter.java | 4 +- .../specialcounter/SpecialCounterPlugin.java | 2 + .../specialcounter/SpecialCounterUpdate.java | 2 +- .../plugins/specialcounter/SpecialWeapon.java | 3 +- .../client/plugins/spellbook/Spellbook.java | 5 +- .../plugins/spellbook/SpellbookConfig.java | 45 -- .../spellbook/SpellbookDragOverlay.java | 2 +- .../spellbook/SpellbookMouseListener.java | 10 +- .../plugins/spellbook/SpellbookPlugin.java | 45 +- .../plugins/statusbars/StatusBarsOverlay.java | 10 +- .../plugins/statusbars/StatusBarsPlugin.java | 49 +- .../client/plugins/statusbars/Viewport.java | 3 +- .../plugins/statusbars/config/BarMode.java | 3 +- .../statusbars/renderer/BarRenderer.java | 55 +- .../statusbars/renderer/EnergyRenderer.java | 13 +- .../renderer/HitPointsRenderer.java | 13 +- .../statusbars/renderer/PrayerRenderer.java | 13 +- .../renderer/SpecialAttackRenderer.java | 13 +- .../stonedloottracker/ItemSortTypes.java | 3 +- .../StonedLootTrackerPlugin.java | 3 +- .../stonedloottracker/data/BossTab.java | 3 +- .../stonedloottracker/data/LootRecord.java | 5 +- .../data/LootRecordCustom.java | 5 +- .../data/LootTrackerItemEntry.java | 5 +- .../plugins/stonedloottracker/data/Pet.java | 5 +- .../stonedloottracker/data/UniqueItem.java | 9 +- .../stonedloottracker/ui/ItemPanel.java | 7 +- .../stonedloottracker/ui/LootGrid.java | 4 +- .../stonedloottracker/ui/LootPanel.java | 4 +- .../stonedloottracker/ui/LootTrackerBox.java | 6 +- .../ui/LootTrackerPanel.java | 4 +- .../stonedloottracker/ui/SelectionPanel.java | 6 +- .../stonedloottracker/ui/TextPanel.java | 5 +- .../stonedloottracker/ui/UniqueItemPanel.java | 7 +- .../stretchedmode/StretchedModePlugin.java | 2 + .../stretchedmode/TranslateMouseListener.java | 4 +- .../TranslateMouseWheelListener.java | 4 +- .../suppliestracker/BlowpipeDartType.java | 3 +- .../plugins/suppliestracker/ItemType.java | 3 +- .../plugins/suppliestracker/MenuAction.java | 11 +- .../plugins/suppliestracker/SuppliesBox.java | 6 +- .../suppliestracker/SuppliesTrackerItem.java | 6 +- .../suppliestracker/SuppliesTrackerPanel.java | 3 +- .../SuppliesTrackerPlugin.java | 3 +- .../plugins/tarnslair/TarnsLairOverlay.java | 4 +- .../plugins/tarnslair/TarnsLairPlugin.java | 3 +- .../plugins/teamcapes/TeamCapesOverlay.java | 4 +- .../plugins/teamcapes/TeamCapesPlugin.java | 2 + .../TearsOfGuthixExperienceOverlay.java | 2 + .../tearsofguthix/TearsOfGuthixOverlay.java | 4 +- .../tearsofguthix/TearsOfGuthixPlugin.java | 2 + .../client/plugins/theatre/RoomHandler.java | 10 +- .../plugins/theatre/TheatreOverlay.java | 12 +- .../client/plugins/theatre/TheatrePlugin.java | 105 ++- .../plugins/theatre/rooms/BloatHandler.java | 13 +- .../plugins/theatre/rooms/MaidenHandler.java | 13 +- .../client/plugins/theatre/rooms/Nylos.java | 9 +- .../theatre/rooms/SotetsegHandler.java | 17 +- .../plugins/theatre/rooms/VerzikHandler.java | 31 +- .../theatre/rooms/nylocas/NyloHandler.java | 34 +- .../theatre/rooms/nylocas/NyloOverlay.java | 23 +- .../theatre/rooms/nylocas/NyloPredictor.java | 23 +- .../theatre/rooms/xarpus/XarpusCounter.java | 13 +- .../theatre/rooms/xarpus/XarpusHandler.java | 18 +- .../plugins/theatre/timers/RoomTimer.java | 2 +- .../plugins/thieving/ThievingOverlay.java | 4 +- .../plugins/thieving/ThievingPlugin.java | 23 +- .../plugins/thieving/ThievingSession.java | 2 +- .../plugins/ticktimers/NPCContainer.java | 11 +- .../plugins/ticktimers/TickTimersConfig.java | 3 +- .../plugins/ticktimers/TickTimersPlugin.java | 47 +- .../plugins/ticktimers/TimersOverlay.java | 20 +- .../tileindicators/TileIndicatorsConfig.java | 36 +- .../tileindicators/TileIndicatorsOverlay.java | 20 +- .../tileindicators/TileIndicatorsPlugin.java | 45 ++ .../client/plugins/timers/GameIndicator.java | 4 +- .../client/plugins/timers/GameTimer.java | 19 +- .../plugins/timers/IndicatorIndicator.java | 5 +- .../client/plugins/timers/TimerTimer.java | 4 +- .../client/plugins/timers/TimersPlugin.java | 161 ++-- .../plugins/timestamp/TimestampPlugin.java | 2 + .../plugins/tithefarm/TitheFarmPlant.java | 17 +- .../tithefarm/TitheFarmPlantOverlay.java | 12 +- .../plugins/tithefarm/TitheFarmPlantType.java | 9 +- .../plugins/tithefarm/TitheFarmPlugin.java | 26 +- .../client/plugins/tmorph/TMorph.java | 376 +++++++--- .../tobdamagecount/DamageCounterPlugin.java | 7 +- .../client/plugins/twitch/TwitchPlugin.java | 2 + .../client/plugins/twitch/irc/Message.java | 3 +- .../plugins/twitch/irc/TwitchIRCClient.java | 2 +- .../client/plugins/vetion/VetionPlugin.java | 3 +- .../virtuallevels/VirtualLevelsPlugin.java | 2 + .../client/plugins/vorkath/Vorkath.java | 2 +- .../client/plugins/vorkath/VorkathAttack.java | 3 +- .../plugins/vorkath/VorkathOverlay.java | 4 +- .../client/plugins/vorkath/VorkathPlugin.java | 2 + .../vorkath/ZombifiedSpawnOverlay.java | 4 +- .../warindicators/WarIndicatorConfig.java | 1 - .../WarIndicatorMiniMapOverlay.java | 14 +- .../warindicators/WarIndicatorOverlay.java | 16 +- .../warindicators/WarIndicatorPlugin.java | 64 +- .../warindicators/WarIndicatorService.java | 20 +- .../WhaleWatchersGloryOverlay.java | 9 +- .../whalewatchers/WhaleWatchersOverlay.java | 17 +- .../whalewatchers/WhaleWatchersPlugin.java | 56 +- .../WhaleWatchersProtOverlay.java | 9 +- .../WhaleWatchersSmiteableOverlay.java | 4 +- .../client/plugins/wiki/WikiPlugin.java | 2 + .../wiki/WikiSearchChatboxTextInput.java | 3 +- .../client/plugins/wiki/WikiSprite.java | 5 +- .../WildernessLocationsOverlay.java | 9 +- .../WildernessLocationsPlugin.java | 27 +- .../wintertodt/WintertodtActivity.java | 3 +- .../wintertodt/WintertodtInterruptType.java | 3 +- .../plugins/wintertodt/WintertodtOverlay.java | 4 +- .../plugins/wintertodt/WintertodtPlugin.java | 27 +- .../config/WintertodtNotifyMode.java | 3 +- .../client/plugins/woodcutting/Axe.java | 3 +- .../client/plugins/woodcutting/Tree.java | 5 +- .../woodcutting/WoodcuttingOverlay.java | 8 +- .../woodcutting/WoodcuttingPlugin.java | 42 +- .../woodcutting/WoodcuttingSession.java | 6 +- .../woodcutting/WoodcuttingTreesOverlay.java | 8 +- .../worldhopper/WorldHopperPlugin.java | 54 +- .../worldhopper/WorldSwitcherPanel.java | 2 + .../plugins/worldhopper/WorldTableHeader.java | 2 + .../plugins/worldhopper/WorldTableRow.java | 2 + .../worldhopper/ping/IcmpEchoReply.java | 2 +- .../plugins/worldmap/WorldMapPlugin.java | 87 ++- .../client/plugins/xpglobes/XpGlobe.java | 5 +- .../plugins/xpglobes/XpGlobesOverlay.java | 53 +- .../plugins/xpglobes/XpGlobesPlugin.java | 56 +- .../client/plugins/xptracker/XpInfoBox.java | 9 +- .../plugins/xptracker/XpInfoBoxOverlay.java | 7 +- .../client/plugins/xptracker/XpPanel.java | 4 +- .../plugins/xptracker/XpTrackerPlugin.java | 46 +- .../plugins/zulrah/ImagePanelComponent.java | 13 +- .../client/plugins/zulrah/TextComponent.java | 7 +- .../client/plugins/zulrah/ZulrahConfig.java | 16 +- .../client/plugins/zulrah/ZulrahInstance.java | 6 +- .../client/plugins/zulrah/ZulrahPlugin.java | 7 +- .../overlays/ZulrahCurrentPhaseOverlay.java | 6 +- .../zulrah/overlays/ZulrahImageManager.java | 8 +- .../overlays/ZulrahNextPhaseOverlay.java | 4 +- .../zulrah/overlays/ZulrahOverlay.java | 13 +- .../zulrah/overlays/ZulrahPrayerOverlay.java | 4 +- .../zulrah/patterns/ZulrahPattern.java | 2 +- .../plugins/zulrah/phase/ZulrahPhase.java | 5 - .../runelite/client/ui/ContainableFrame.java | 11 + .../client/ui/overlay/OverlayRenderer.java | 32 +- .../plugins/bank/BankCalculationTest.java | 3 +- .../plugins/cerberus/CerberusPluginTest.java | 2 +- .../chatfilter/ChatFilterPluginTest.java | 31 +- .../plugins/cooking/CookingPluginTest.java | 3 +- .../idlenotifier/IdleNotifierPluginTest.java | 52 +- .../npchighlight/NpcIndicatorsPluginTest.java | 3 +- .../screenshot/ScreenshotPluginTest.java | 16 +- .../plugins/slayer/SlayerPluginTest.java | 24 +- .../plugins/timers/TimersPluginTest.java | 8 +- .../net/runelite/mixins/RSActorMixin.java | 2 +- .../net/runelite/mixins/RSClientMixin.java | 8 +- .../net/runelite/mixins/RSWidgetMixin.java | 2 +- 694 files changed, 9824 insertions(+), 4525 deletions(-) delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/normal.png delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/lootassist/LootAssitConfig.java delete mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/pvptools/skull.png diff --git a/runelite-api/src/main/java/net/runelite/api/GameState.java b/runelite-api/src/main/java/net/runelite/api/GameState.java index 5f9083f9ca..6a61fcfe59 100644 --- a/runelite-api/src/main/java/net/runelite/api/GameState.java +++ b/runelite-api/src/main/java/net/runelite/api/GameState.java @@ -24,6 +24,11 @@ */ package net.runelite.api; +import java.util.Arrays; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + /** * An enumeration of game states the client is in. */ @@ -66,6 +71,10 @@ public enum GameState */ HOPPING(45); + private static final Map stateValueMap = + Arrays.stream(GameState.values()) + .collect(Collectors.toMap(gs -> gs.state, Function.identity())); + /** * The raw state value. */ @@ -85,13 +94,6 @@ public enum GameState */ public static GameState of(int state) { - for (GameState gs : GameState.values()) - { - if (gs.state == state) - { - return gs; - } - } - return UNKNOWN; + return stateValueMap.getOrDefault(state, UNKNOWN); } } diff --git a/runelite-api/src/main/java/net/runelite/api/Perspective.java b/runelite-api/src/main/java/net/runelite/api/Perspective.java index 4d3f312386..5c1955f249 100644 --- a/runelite-api/src/main/java/net/runelite/api/Perspective.java +++ b/runelite-api/src/main/java/net/runelite/api/Perspective.java @@ -24,6 +24,7 @@ */ package net.runelite.api; +import java.awt.geom.Path2D; import static net.runelite.api.Constants.TILE_FLAG_BRIDGE; import java.awt.FontMetrics; import java.awt.Graphics2D; @@ -549,7 +550,7 @@ public class Perspective ) { int radius = 5; - Area geometry = new Area(); + Path2D.Double geometry = new Path2D.Double(); final int tileHeight = getTileHeight(client, point, client.getPlane()); @@ -607,10 +608,10 @@ public class Perspective continue; } - geometry.add(new Area(clickableRect)); + geometry.append(clickableRect, false); } - return geometry; + return new Area(geometry); } private static Area getAABB( diff --git a/runelite-api/src/main/java/net/runelite/api/events/BeforeRender.java b/runelite-api/src/main/java/net/runelite/api/events/BeforeRender.java index 741041e1e0..73c004d4b3 100644 --- a/runelite-api/src/main/java/net/runelite/api/events/BeforeRender.java +++ b/runelite-api/src/main/java/net/runelite/api/events/BeforeRender.java @@ -29,4 +29,10 @@ package net.runelite.api.events; */ public class BeforeRender { + public static final BeforeRender INSTANCE = new BeforeRender(); + + private BeforeRender() + { + // noop + } } diff --git a/runelite-api/src/main/java/net/runelite/api/events/CannonballFired.java b/runelite-api/src/main/java/net/runelite/api/events/CannonballFired.java index 077a88096d..c44789965a 100644 --- a/runelite-api/src/main/java/net/runelite/api/events/CannonballFired.java +++ b/runelite-api/src/main/java/net/runelite/api/events/CannonballFired.java @@ -29,4 +29,10 @@ package net.runelite.api.events; */ public class CannonballFired { + public static final CannonballFired INSTANCE = new CannonballFired(); + + private CannonballFired() + { + // noop + } } diff --git a/runelite-api/src/main/java/net/runelite/api/events/CanvasSizeChanged.java b/runelite-api/src/main/java/net/runelite/api/events/CanvasSizeChanged.java index e76e82dd6d..0efef18d0d 100644 --- a/runelite-api/src/main/java/net/runelite/api/events/CanvasSizeChanged.java +++ b/runelite-api/src/main/java/net/runelite/api/events/CanvasSizeChanged.java @@ -29,4 +29,10 @@ package net.runelite.api.events; */ public class CanvasSizeChanged { + public static final CanvasSizeChanged INSTANCE = new CanvasSizeChanged(); + + private CanvasSizeChanged() + { + // noop + } } diff --git a/runelite-api/src/main/java/net/runelite/api/events/ClientTick.java b/runelite-api/src/main/java/net/runelite/api/events/ClientTick.java index 369ff7982a..6874f4145c 100644 --- a/runelite-api/src/main/java/net/runelite/api/events/ClientTick.java +++ b/runelite-api/src/main/java/net/runelite/api/events/ClientTick.java @@ -29,4 +29,10 @@ package net.runelite.api.events; */ public class ClientTick { + public static final ClientTick INSTANCE = new ClientTick(); + + private ClientTick() + { + // noop + } } diff --git a/runelite-api/src/main/java/net/runelite/api/events/GameTick.java b/runelite-api/src/main/java/net/runelite/api/events/GameTick.java index aefa7fc3e4..2bf035633d 100644 --- a/runelite-api/src/main/java/net/runelite/api/events/GameTick.java +++ b/runelite-api/src/main/java/net/runelite/api/events/GameTick.java @@ -24,8 +24,6 @@ */ package net.runelite.api.events; -import lombok.Data; - // The NPC update event seem to run every server tick, // but having the game tick event after all packets // have been processed is typically more useful. @@ -43,7 +41,12 @@ import lombok.Data; * Note that occurrences that take place purely on the client, such as right * click menus, are independent of the game tick. */ -@Data public class GameTick { + public static final GameTick INSTANCE = new GameTick(); + + private GameTick() + { + // noop + } } diff --git a/runelite-api/src/main/java/net/runelite/api/events/LocalPlayerDeath.java b/runelite-api/src/main/java/net/runelite/api/events/LocalPlayerDeath.java index e46b815f49..0cf8f33c76 100644 --- a/runelite-api/src/main/java/net/runelite/api/events/LocalPlayerDeath.java +++ b/runelite-api/src/main/java/net/runelite/api/events/LocalPlayerDeath.java @@ -29,4 +29,10 @@ package net.runelite.api.events; */ public class LocalPlayerDeath { + public static final LocalPlayerDeath INSTANCE = new LocalPlayerDeath(); + + private LocalPlayerDeath() + { + // noop + } } diff --git a/runelite-api/src/main/java/net/runelite/api/events/UsernameChanged.java b/runelite-api/src/main/java/net/runelite/api/events/UsernameChanged.java index 91bed8a304..3dea001150 100644 --- a/runelite-api/src/main/java/net/runelite/api/events/UsernameChanged.java +++ b/runelite-api/src/main/java/net/runelite/api/events/UsernameChanged.java @@ -32,4 +32,10 @@ package net.runelite.api.events; */ public class UsernameChanged { + public static final UsernameChanged INSTANCE = new UsernameChanged(); + + private UsernameChanged() + { + // noop + } } diff --git a/runelite-api/src/main/java/net/runelite/api/events/WidgetPositioned.java b/runelite-api/src/main/java/net/runelite/api/events/WidgetPositioned.java index d5479e3485..6f58e9fe07 100644 --- a/runelite-api/src/main/java/net/runelite/api/events/WidgetPositioned.java +++ b/runelite-api/src/main/java/net/runelite/api/events/WidgetPositioned.java @@ -24,13 +24,16 @@ */ package net.runelite.api.events; -import lombok.Value; - /** * An event where the position of a {@link net.runelite.api.widgets.Widget} * relative to its parent has changed. */ -@Value public class WidgetPositioned { + public static final WidgetPositioned INSTANCE = new WidgetPositioned(); + + private WidgetPositioned() + { + // noop + } } diff --git a/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java b/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java index ca25fa84a8..5c53677308 100644 --- a/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java +++ b/runelite-client/src/main/java/net/runelite/client/callback/Hooks.java @@ -87,9 +87,6 @@ public class Hooks implements Callbacks private static final OverlayRenderer renderer = injector.getInstance(OverlayRenderer.class); private static final OverlayManager overlayManager = injector.getInstance(OverlayManager.class); - private static final GameTick GAME_TICK = new GameTick(); - private static final BeforeRender BEFORE_RENDER = new BeforeRender(); - @Inject private EventBus eventBus; @@ -151,13 +148,13 @@ public class Hooks implements Callbacks deferredEventBus.replay(); - eventBus.post(GAME_TICK); + eventBus.post(GameTick.INSTANCE); int tick = client.getTickCount(); client.setTickCount(tick + 1); } - eventBus.post(BEFORE_RENDER); + eventBus.post(BeforeRender.INSTANCE); clientThread.invoke(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java index 805b99005e..52488fb4e3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java @@ -43,11 +43,16 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.stream.Collectors; import javax.inject.Inject; @@ -228,7 +233,6 @@ public class PluginManager .directed() .build(); - List scannedPlugins = new ArrayList<>(); ClassPath classPath = ClassPath.from(classLoader); ImmutableSet classes = packageName == null ? classPath.getAllClasses() @@ -285,24 +289,47 @@ public class PluginManager throw new RuntimeException("Plugin dependency graph contains a cycle!"); } - List> sortedPlugins = topologicalSort(graph); + List>> sortedPlugins = topologicalGroupSort(graph); sortedPlugins = Lists.reverse(sortedPlugins); - for (Class pluginClazz : sortedPlugins) - { - Plugin plugin; - try - { - plugin = instantiate(scannedPlugins, (Class) pluginClazz); - } - catch (PluginInstantiationException ex) - { - log.warn("Error instantiating plugin!", ex); - continue; - } + final long start = System.currentTimeMillis(); - scannedPlugins.add(plugin); - } + // some plugins get stuck on IO, so add some extra threads + ExecutorService exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2); + + List scannedPlugins = new CopyOnWriteArrayList<>(); + sortedPlugins.forEach(group -> + { + List> curGroup = new ArrayList<>(); + group.forEach(pluginClazz -> + curGroup.add(exec.submit(() -> + { + Plugin plugin; + try + { + plugin = instantiate(scannedPlugins, (Class) pluginClazz); + } + catch (PluginInstantiationException e) + { + log.warn("Error instantiating plugin!", e); + return; + } + scannedPlugins.add(plugin); + }))); + curGroup.forEach(future -> + { + try + { + future.get(); + } + catch (InterruptedException | ExecutionException e) + { + e.printStackTrace(); + } + }); + }); + + log.info("Plugin instantiation took {}ms", System.currentTimeMillis() - start); return scannedPlugins; } @@ -515,40 +542,54 @@ public class PluginManager } /** - * Topologically sort a graph. Uses Kahn's algorithm. - * + * Topologically sort a graph into separate groups. + * Each group represents the dependency level of the plugins. + * Plugins in group (index) 0 has no dependents. + * Plugins in group 1 has dependents in group 0. + * Plugins in group 2 has dependents in group 1, etc. + * This allows for loading dependent groups serially, starting from the last group, + * while loading plugins within each group in parallel. * @param graph * @param * @return */ - private List topologicalSort(Graph graph) + private List> topologicalGroupSort(Graph graph) { - MutableGraph graphCopy = Graphs.copyOf(graph); - List l = new ArrayList<>(); - Set s = graphCopy.nodes().stream() - .filter(node -> graphCopy.inDegree(node) == 0) + final Set root = graph.nodes().stream() + .filter(node -> graph.inDegree(node) == 0) .collect(Collectors.toSet()); - while (!s.isEmpty()) - { - Iterator it = s.iterator(); - T n = it.next(); - it.remove(); + final Map dependencyCount = new HashMap<>(); - l.add(n); + root.forEach(n -> dependencyCount.put(n, 0)); + root.forEach(n -> graph.successors(n) + .forEach(m -> incrementChildren(graph, dependencyCount, m, dependencyCount.get(n) + 1))); - for (T m : graphCopy.successors(n)) + // create list dependency grouping + final List> dependencyGroups = new ArrayList<>(); + final int[] curGroup = {-1}; + + dependencyCount.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .forEach(entry -> { - graphCopy.removeEdge(n, m); - if (graphCopy.inDegree(m) == 0) + if (entry.getValue() != curGroup[0]) { - s.add(m); + curGroup[0] = entry.getValue(); + dependencyGroups.add(new ArrayList<>()); } - } - } - if (!graphCopy.edges().isEmpty()) + dependencyGroups.get(dependencyGroups.size() - 1).add(entry.getKey()); + }); + + return dependencyGroups; + } + + private void incrementChildren(Graph graph, Map dependencyCount, T n, int val) + { + if (!dependencyCount.containsKey(n) || dependencyCount.get(n) < val) { - throw new RuntimeException("Graph has at least one cycle"); + dependencyCount.put(n, val); + graph.successors(n).forEach(m -> + incrementChildren(graph, dependencyCount, m, val + 1)); } - return l; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/account/AccountPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/account/AccountPlugin.java index 55ab81fbe3..07bd977a81 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/account/AccountPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/account/AccountPlugin.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.account; import java.awt.image.BufferedImage; import java.util.concurrent.ScheduledExecutorService; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.JOptionPane; import lombok.extern.slf4j.Slf4j; import net.runelite.client.account.AccountSession; @@ -47,6 +48,7 @@ import net.runelite.client.util.ImageUtil; loadWhenOutdated = true ) @Slf4j +@Singleton public class AccountPlugin extends Plugin { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/DiaryRequirementsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/DiaryRequirementsPlugin.java index ee77f19ecc..bc67f82a8c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/DiaryRequirementsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/DiaryRequirementsPlugin.java @@ -32,6 +32,7 @@ import java.util.List; import java.util.Map; import java.util.regex.Pattern; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.FontTypeFace; @@ -66,6 +67,7 @@ import net.runelite.client.util.Text; description = "Display level requirements in Achievement Diary interface", tags = {"achievements", "tasks"} ) +@Singleton public class DiaryRequirementsPlugin extends Plugin { private static final String AND_JOINER = ", "; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityOverlay.java index aa88396038..7db0667088 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityOverlay.java @@ -32,45 +32,43 @@ import java.awt.Polygon; import java.awt.geom.Area; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Point; import net.runelite.api.Tile; -import net.runelite.api.coords.LocalPoint; import net.runelite.client.game.AgilityShortcut; 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; +@Singleton class AgilityOverlay extends Overlay { private static final Color SHORTCUT_HIGH_LEVEL_COLOR = Color.ORANGE; private final Client client; private final AgilityPlugin plugin; - private final AgilityConfig config; @Inject - private AgilityOverlay(Client client, AgilityPlugin plugin, AgilityConfig config) + private AgilityOverlay(final Client client, final AgilityPlugin plugin) { super(plugin); setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); this.client = client; this.plugin = plugin; - this.config = config; } @Override public Dimension render(Graphics2D graphics) { - LocalPoint playerLocation = client.getLocalPlayer().getLocalLocation(); Point mousePosition = client.getMouseCanvasPosition(); final List marksOfGrace = plugin.getMarksOfGrace(); plugin.getObstacles().forEach((object, obstacle) -> { - if (Obstacles.SHORTCUT_OBSTACLE_IDS.containsKey(object.getId()) && !config.highlightShortcuts() || - Obstacles.TRAP_OBSTACLE_IDS.contains(object.getId()) && !config.showTrapOverlay()) + if (Obstacles.SHORTCUT_OBSTACLE_IDS.containsKey(object.getId()) && !plugin.isHighlightShortcuts() || + Obstacles.TRAP_OBSTACLE_IDS.contains(object.getId()) && !plugin.isShowTrapOverlay()) { return; } @@ -84,7 +82,7 @@ class AgilityOverlay extends Overlay Polygon polygon = object.getCanvasTilePoly(); if (polygon != null) { - OverlayUtil.renderPolygon(graphics, polygon, config.getTrapColor()); + OverlayUtil.renderPolygon(graphics, polygon, plugin.getTrapColor()); } return; } @@ -92,10 +90,10 @@ class AgilityOverlay extends Overlay if (objectClickbox != null) { AgilityShortcut agilityShortcut = obstacle.getShortcut(); - Color configColor = agilityShortcut == null || agilityShortcut.getLevel() <= plugin.getAgilityLevel() ? config.getOverlayColor() : SHORTCUT_HIGH_LEVEL_COLOR; - if (config.highlightMarks() && !marksOfGrace.isEmpty()) + Color configColor = agilityShortcut == null || agilityShortcut.getLevel() <= plugin.getAgilityLevel() ? plugin.getOverlayColor() : SHORTCUT_HIGH_LEVEL_COLOR; + if (plugin.isHighlightMarks() && !marksOfGrace.isEmpty()) { - configColor = config.getMarkColor(); + configColor = plugin.getMarkColor(); } if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY())) @@ -115,7 +113,7 @@ class AgilityOverlay extends Overlay }); - if (config.highlightMarks() && !marksOfGrace.isEmpty()) + if (plugin.isHighlightMarks() && !marksOfGrace.isEmpty()) { for (Tile markOfGraceTile : marksOfGrace) { @@ -128,7 +126,7 @@ class AgilityOverlay extends Overlay continue; } - OverlayUtil.renderPolygon(graphics, poly, config.getMarkColor()); + OverlayUtil.renderPolygon(graphics, poly, plugin.getMarkColor()); } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityPlugin.java index abe18393d8..043cc4e23a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilityPlugin.java @@ -32,6 +32,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; @@ -83,14 +85,15 @@ import net.runelite.client.util.ColorUtil; tags = {"grace", "marks", "overlay", "shortcuts", "skilling", "traps"} ) @Slf4j +@Singleton public class AgilityPlugin extends Plugin { private static final int AGILITY_ARENA_REGION_ID = 11157; - @Getter + @Getter(AccessLevel.PACKAGE) private final Map obstacles = new HashMap<>(); - @Getter + @Getter(AccessLevel.PACKAGE) private final List marksOfGrace = new ArrayList<>(); @Inject @@ -117,13 +120,13 @@ public class AgilityPlugin extends Plugin @Inject private ItemManager itemManager; - @Getter + @Getter(AccessLevel.PACKAGE) private AgilitySession session; private int lastAgilityXp; private WorldPoint lastArenaTicketPosition; - @Getter + @Getter(AccessLevel.PACKAGE) private int agilityLevel; @Provides @@ -132,9 +135,36 @@ public class AgilityPlugin extends Plugin return configManager.getConfig(AgilityConfig.class); } + // Config values + @Getter(AccessLevel.PACKAGE) + private boolean showLapCount; + @Getter(AccessLevel.PACKAGE) + private int lapTimeout; + @Getter(AccessLevel.PACKAGE) + private boolean lapsToLevel; + @Getter(AccessLevel.PACKAGE) + private boolean lapsToGoal; + @Getter(AccessLevel.PACKAGE) + private Color overlayColor; + @Getter(AccessLevel.PACKAGE) + private boolean highlightMarks; + @Getter(AccessLevel.PACKAGE) + private Color markColor; + @Getter(AccessLevel.PACKAGE) + private boolean highlightShortcuts; + @Getter(AccessLevel.PACKAGE) + private boolean showTrapOverlay; + @Getter(AccessLevel.PACKAGE) + private Color trapColor; + private boolean notifyAgilityArena; + private boolean showAgilityArenaTimer; + private boolean showShortcutLevel; + @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(agilityOverlay); overlayManager.add(lapCounterOverlay); agilityLevel = client.getBoostedSkillLevel(Skill.AGILITY); @@ -179,16 +209,40 @@ public class AgilityPlugin extends Plugin @Subscribe public void onConfigChanged(ConfigChanged event) { - if (!config.showAgilityArenaTimer()) + if (!event.getGroup().equals("agility")) + { + return; + } + + updateConfig(); + + if (!this.showAgilityArenaTimer) { removeAgilityArenaTimer(); } } + public void updateConfig() + { + this.showLapCount = config.showLapCount(); + this.lapTimeout = config.lapTimeout(); + this.lapsToLevel = config.lapsToLevel(); + this.lapsToGoal = config.lapsToGoal(); + this.overlayColor = config.getOverlayColor(); + this.highlightMarks = config.highlightMarks(); + this.markColor = config.getMarkColor(); + this.highlightShortcuts = config.highlightShortcuts(); + this.showTrapOverlay = config.showTrapOverlay(); + this.trapColor = config.getTrapColor(); + this.notifyAgilityArena = config.notifyAgilityArena(); + this.showAgilityArenaTimer = config.showAgilityArenaTimer(); + this.showShortcutLevel = config.showShortcutLevel(); + } + @Subscribe public void onExperienceChanged(ExperienceChanged event) { - if (event.getSkill() != AGILITY || !config.showLapCount()) + if (event.getSkill() != AGILITY || !this.showLapCount) { return; } @@ -272,12 +326,12 @@ public class AgilityPlugin extends Plugin { log.debug("Ticked position moved from {} to {}", oldTickPosition, newTicketPosition); - if (config.notifyAgilityArena()) + if (this.notifyAgilityArena) { notifier.notify("Ticket location changed"); } - if (config.showAgilityArenaTimer()) + if (this.showAgilityArenaTimer) { showNewAgilityArenaTimer(); } @@ -430,7 +484,7 @@ public class AgilityPlugin extends Plugin @Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { - if (!config.showShortcutLevel()) + if (!this.showShortcutLevel) { return; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilitySession.java b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilitySession.java index 72e9a0dd07..1c6e413a46 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilitySession.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/agility/AgilitySession.java @@ -42,7 +42,7 @@ class AgilitySession private int lapsTillLevel; private int lapsTillGoal; - AgilitySession(Courses course) + AgilitySession(final Courses course) { this.course = course; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/agility/Courses.java b/runelite-client/src/main/java/net/runelite/client/plugins/agility/Courses.java index cc732561c0..91812e30f8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/agility/Courses.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/agility/Courses.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.agility; import com.google.common.collect.ImmutableMap; import java.util.Map; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.coords.WorldPoint; @@ -50,16 +51,16 @@ enum Courses private final static Map coursesByRegion; - @Getter + @Getter(AccessLevel.PACKAGE) private final double totalXp; - @Getter + @Getter(AccessLevel.PACKAGE) private final int lastObstacleXp; - @Getter + @Getter(AccessLevel.PACKAGE) private final int regionId; - @Getter + @Getter(AccessLevel.PACKAGE) private final WorldPoint[] courseEndWorldPoints; static diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/agility/LapCounterOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/agility/LapCounterOverlay.java index 04c60d4430..e8d0a2771c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/agility/LapCounterOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/agility/LapCounterOverlay.java @@ -29,6 +29,7 @@ import java.awt.Graphics2D; import java.time.Duration; import java.time.Instant; import javax.inject.Inject; +import javax.inject.Singleton; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.client.ui.overlay.Overlay; import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE; @@ -39,21 +40,20 @@ import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; +@Singleton class LapCounterOverlay extends Overlay { private final AgilityPlugin plugin; - private final AgilityConfig config; private final PanelComponent panelComponent = new PanelComponent(); @Inject - private LapCounterOverlay(AgilityPlugin plugin, AgilityConfig config) + private LapCounterOverlay(final AgilityPlugin plugin) { super(plugin); setPosition(OverlayPosition.TOP_LEFT); setPriority(OverlayPriority.LOW); this.plugin = plugin; - this.config = config; getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Agility overlay")); } @@ -62,7 +62,7 @@ class LapCounterOverlay extends Overlay { AgilitySession session = plugin.getSession(); - if (!config.showLapCount() || + if (!plugin.isShowLapCount() || session == null || session.getLastLapCompleted() == null || session.getCourse() == null) @@ -70,7 +70,7 @@ class LapCounterOverlay extends Overlay return null; } - Duration lapTimeout = Duration.ofMinutes(config.lapTimeout()); + Duration lapTimeout = Duration.ofMinutes(plugin.getLapTimeout()); Duration sinceLap = Duration.between(session.getLastLapCompleted(), Instant.now()); if (sinceLap.compareTo(lapTimeout) >= 0) @@ -85,12 +85,12 @@ class LapCounterOverlay extends Overlay tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT); tableComponent.addRow("Total Laps:", Integer.toString(session.getTotalLaps())); - if (config.lapsToLevel() && session.getLapsTillLevel() > 0) + if (plugin.isLapsToLevel() && session.getLapsTillLevel() > 0) { tableComponent.addRow("Laps until level:", Integer.toString(session.getLapsTillLevel())); } - if (config.lapsToGoal() && session.getLapsTillGoal() > 0) + if (plugin.isLapsToGoal() && session.getLapsTillGoal() > 0) { tableComponent.addRow("Laps until goal:", Integer.toString(session.getLapsTillGoal())); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/alchemicalhydra/HydraOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/alchemicalhydra/HydraOverlay.java index e5860abcd0..a84ec94887 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/alchemicalhydra/HydraOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/alchemicalhydra/HydraOverlay.java @@ -54,7 +54,7 @@ class HydraOverlay extends Overlay private final PanelComponent panelComponent = new PanelComponent(); @Inject - HydraOverlay(HydraPlugin plugin, Client client, SpriteManager spriteManager) + HydraOverlay(final HydraPlugin plugin, final Client client, final SpriteManager spriteManager) { this.plugin = plugin; this.client = client; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/alchemicalhydra/HydraPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/alchemicalhydra/HydraPlugin.java index b92b6f3875..fe94944427 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/alchemicalhydra/HydraPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/alchemicalhydra/HydraPlugin.java @@ -30,6 +30,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -59,6 +60,7 @@ import net.runelite.client.ui.overlay.OverlayManager; enabledByDefault = false ) @Slf4j +@Singleton public class HydraPlugin extends Plugin { @Getter(AccessLevel.PACKAGE) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/alchemicalhydra/HydraSceneOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/alchemicalhydra/HydraSceneOverlay.java index 52e02fadca..a38fa4ecfc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/alchemicalhydra/HydraSceneOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/alchemicalhydra/HydraSceneOverlay.java @@ -55,7 +55,7 @@ class HydraSceneOverlay extends Overlay private final Client client; @Inject - public HydraSceneOverlay(Client client, HydraPlugin plugin) + public HydraSceneOverlay(final Client client, final HydraPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.UNDER_WIDGETS); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoCounter.java b/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoCounter.java index a9a25512a4..4350c80699 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoCounter.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoCounter.java @@ -29,6 +29,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.time.Duration; import java.time.Instant; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.client.plugins.Plugin; import net.runelite.client.ui.overlay.infobox.Counter; @@ -36,7 +37,7 @@ import net.runelite.client.util.StackFormatter; class AmmoCounter extends Counter { - @Getter + @Getter(AccessLevel.PACKAGE) private int itemID; private String name; private int total; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoPlugin.java index 5336fccd66..ee2b31666b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ammo/AmmoPlugin.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.ammo; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.EquipmentInventorySlot; import net.runelite.api.InventoryID; @@ -45,6 +46,7 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager; description = "Shows the current ammo the player has equipped", tags = {"bolts", "darts", "chinchompa", "equipment"} ) +@Singleton public class AmmoPlugin extends Plugin { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/animsmoothing/AnimationSmoothingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/animsmoothing/AnimationSmoothingPlugin.java index 40cc9fc1b9..6a23856217 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/animsmoothing/AnimationSmoothingPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/animsmoothing/AnimationSmoothingPlugin.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.animsmoothing; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.events.ConfigChanged; import net.runelite.client.config.ConfigManager; @@ -39,6 +40,7 @@ import net.runelite.client.plugins.PluginDescriptor; tags = {"npcs", "objects", "players"}, enabledByDefault = false ) +@Singleton public class AnimationSmoothingPlugin extends Plugin { static final String CONFIG_GROUP = "animationSmoothing"; 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 69a54cc971..bd3de31419 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 @@ -37,7 +37,6 @@ import net.runelite.client.config.ModifierlessKeybind; @ConfigGroup("antiDrag") public interface AntiDragConfig extends Config { - @ConfigItem( position = 0, keyName = "alwaysOn", 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 index c35d9ac0b9..e1550efe33 100644 --- 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 @@ -42,13 +42,13 @@ public class AntiDragOverlay extends Overlay { private static final int RADIUS = 20; - private Client client; - private AntiDragConfig config; + private final Client client; + private final AntiDragPlugin plugin; @Inject - private AntiDragOverlay(Client client, AntiDragConfig config) + private AntiDragOverlay(final Client client, final AntiDragPlugin plugin) { - this.config = config; + this.plugin = plugin; this.client = client; setPosition(OverlayPosition.TOOLTIP); setPriority(OverlayPriority.HIGHEST); @@ -58,7 +58,7 @@ public class AntiDragOverlay extends Overlay @Override public Dimension render(Graphics2D g) { - final Color color = config.color(); + final Color color = plugin.getColor(); g.setColor(color); final net.runelite.api.Point mouseCanvasPosition = client.getMouseCanvasPosition(); 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 687ee9bc20..3a1eddfd4c 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 @@ -26,11 +26,16 @@ package net.runelite.client.plugins.antidrag; import com.google.inject.Provides; +import java.awt.Color; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.FocusChanged; import net.runelite.client.config.ConfigManager; +import net.runelite.client.config.Keybind; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.input.KeyManager; import net.runelite.client.plugins.Plugin; @@ -48,11 +53,11 @@ import net.runelite.client.util.HotkeyListener; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton public class AntiDragPlugin extends Plugin { private static final int DEFAULT_DELAY = 5; - + private boolean toggleDrag; @Inject @@ -82,14 +87,27 @@ public class AntiDragPlugin extends Plugin return configManager.getConfig(AntiDragConfig.class); } + private boolean alwaysOn; + private boolean keybind; + private Keybind key; + private int dragDelay; + private boolean reqfocus; + @Getter(AccessLevel.PACKAGE) + private boolean configOverlay; + @Getter(AccessLevel.PACKAGE) + private Color color; + private boolean changeCursor; + private CustomCursor selectedCursor; + @Override protected void startUp() throws Exception { - if (config.keybind()) + updateConfig(); + if (this.keybind) { keyManager.registerKeyListener(hotkeyListener); } - client.setInventoryDragDelay(config.alwaysOn() ? config.dragDelay() : DEFAULT_DELAY); + client.setInventoryDragDelay(this.alwaysOn ? this.dragDelay : DEFAULT_DELAY); } @Override @@ -106,9 +124,11 @@ public class AntiDragPlugin extends Plugin { if (event.getGroup().equals("antiDrag")) { + updateConfig(); + if (event.getKey().equals("keybind")) { - if (config.keybind()) + if (this.keybind) { keyManager.registerKeyListener(hotkeyListener); } @@ -119,17 +139,30 @@ public class AntiDragPlugin extends Plugin } if (event.getKey().equals("alwaysOn")) { - client.setInventoryDragDelay(config.alwaysOn() ? config.dragDelay() : DEFAULT_DELAY); + client.setInventoryDragDelay(this.alwaysOn ? this.dragDelay : DEFAULT_DELAY); } } } + public void updateConfig() + { + this.alwaysOn = config.alwaysOn(); + this.keybind = config.keybind(); + this.key = config.key(); + this.dragDelay = config.dragDelay(); + this.reqfocus = config.reqfocus(); + this.configOverlay = config.overlay(); + this.color = config.color(); + this.changeCursor = config.changeCursor(); + this.selectedCursor = config.selectedCursor(); + } + @Subscribe public void onFocusChanged(FocusChanged focusChanged) { - if (!config.alwaysOn()) + if (!this.alwaysOn) { - if (!focusChanged.isFocused() && config.reqfocus()) + if (!focusChanged.isFocused() && this.reqfocus) { client.setInventoryDragDelay(DEFAULT_DELAY); overlayManager.remove(overlay); @@ -137,33 +170,32 @@ public class AntiDragPlugin extends Plugin } } - private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.key()) + private final HotkeyListener hotkeyListener = new HotkeyListener(() -> this.key) { @Override public void hotkeyPressed() { - if (!config.alwaysOn()) + if (!alwaysOn) { toggleDrag = !toggleDrag; if (toggleDrag) { - if (config.overlay()) + if (configOverlay) { overlayManager.add(overlay); } - if (config.changeCursor()) + if (changeCursor) { - CustomCursor selectedCursor = config.selectedCursor(); clientUI.setCursor(selectedCursor.getCursorImage(), selectedCursor.toString()); } - client.setInventoryDragDelay(config.dragDelay()); + client.setInventoryDragDelay(dragDelay); } else { overlayManager.remove(overlay); client.setInventoryDragDelay(DEFAULT_DELAY); - if (config.changeCursor()) + if (changeCursor) { net.runelite.client.plugins.customcursor.CustomCursor selectedCursor = configManager.getConfig(CustomCursorConfig.class).selectedCursor(); clientUI.setCursor(selectedCursor.getCursorImage(), selectedCursor.toString()); @@ -172,4 +204,4 @@ public class AntiDragPlugin extends Plugin } } }; -} +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/CustomCursor.java b/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/CustomCursor.java index 27b3706c78..e6e3b5da8e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/CustomCursor.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/antidrag/CustomCursor.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.antidrag; import java.awt.image.BufferedImage; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.client.plugins.customcursor.CustomCursorPlugin; import net.runelite.client.util.ImageUtil; @@ -43,7 +44,8 @@ public enum CustomCursor ZAMORAK_GODSWORD("Zamorak Godsword", "cursor-zamorak-godsword.png"); private final String name; - @Getter + + @Getter(AccessLevel.PACKAGE) private final BufferedImage cursorImage; CustomCursor(String name, String icon) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeProjectile.java b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeProjectile.java index a00d79e403..f875cae629 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeProjectile.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeProjectile.java @@ -28,11 +28,12 @@ package net.runelite.client.plugins.aoewarnings; import java.time.Instant; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.coords.LocalPoint; -@Getter +@Getter(AccessLevel.PACKAGE) @AllArgsConstructor class AoeProjectile { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningOverlay.java index 48491da688..d70d63c4be 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/AoeWarningOverlay.java @@ -37,6 +37,7 @@ import java.time.Instant; import java.util.Iterator; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.Point; @@ -48,6 +49,7 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; import static net.runelite.client.util.ColorUtil.setAlphaComponent; +@Singleton public class AoeWarningOverlay extends Overlay { private static final int FILL_START_ALPHA = 25; @@ -55,16 +57,14 @@ public class AoeWarningOverlay extends Overlay private final Client client; private final AoeWarningPlugin plugin; - private final AoeWarningConfig config; @Inject - public AoeWarningOverlay(Client client, AoeWarningPlugin plugin, AoeWarningConfig config) + public AoeWarningOverlay(final Client client, final AoeWarningPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.UNDER_WIDGETS); this.client = client; this.plugin = plugin; - this.config = config; } @Override @@ -115,7 +115,7 @@ public class AoeWarningOverlay extends Overlay int tickProgress = aoeProjectile.getFinalTick() - client.getTickCount(); int fillAlpha, outlineAlpha; - if (config.isFadeEnabled()) + if (plugin.isConfigFadeEnabled()) { fillAlpha = (int) ((1 - progress) * FILL_START_ALPHA);//alpha drop off over lifetime outlineAlpha = (int) ((1 - progress) * OUTLINE_START_ALPHA); @@ -152,12 +152,12 @@ public class AoeWarningOverlay extends Overlay outlineAlpha = 255; } - if (config.isOutlineEnabled()) + if (plugin.isConfigOutlineEnabled()) { - graphics.setColor(new Color(setAlphaComponent(config.overlayColor().getRGB(), outlineAlpha), true)); + graphics.setColor(new Color(setAlphaComponent(plugin.getOverlayColor().getRGB(), outlineAlpha), true)); graphics.drawPolygon(tilePoly); } - if (config.tickTimers()) + if (plugin.isTickTimers()) { if (tickProgress >= 0) { @@ -165,7 +165,7 @@ public class AoeWarningOverlay extends Overlay plugin.getFontStyle(), color, centerPoint(tilePoly.getBounds()), plugin.isShadows(), 0); } } - graphics.setColor(new Color(setAlphaComponent(config.overlayColor().getRGB(), fillAlpha), true)); + graphics.setColor(new Color(setAlphaComponent(plugin.getOverlayColor().getRGB(), fillAlpha), true)); graphics.fillPolygon(tilePoly); } return null; 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 00ed024a44..730e36b204 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 @@ -28,6 +28,7 @@ package net.runelite.client.plugins.aoewarnings; import com.google.inject.Provides; +import java.awt.Color; import java.time.Instant; import java.util.ArrayList; import java.util.HashMap; @@ -35,6 +36,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -70,12 +72,13 @@ import net.runelite.client.ui.overlay.OverlayManager; type = PluginType.PVM, enabledByDefault = false ) - +@Singleton @Slf4j public class AoeWarningPlugin extends Plugin { - @Getter + @Getter(AccessLevel.PACKAGE) private final Map bombs = new HashMap<>(); + @Getter(AccessLevel.PACKAGE) private final Map projectiles = new HashMap<>(); @Inject public AoeWarningConfig config; @@ -97,12 +100,6 @@ public class AoeWarningPlugin extends Plugin private List CrystalSpike = new ArrayList<>(); @Getter(AccessLevel.PACKAGE) private List WintertodtSnowFall = new ArrayList<>(); - @Getter(AccessLevel.PACKAGE) - private boolean shadows; - @Getter(AccessLevel.PACKAGE) - private int textSize; - @Getter(AccessLevel.PACKAGE) - private int fontStyle; @Provides AoeWarningConfig getConfig(ConfigManager configManager) @@ -110,17 +107,73 @@ public class AoeWarningPlugin extends Plugin return configManager.getConfig(AoeWarningConfig.class); } - Map getProjectiles() - { - return projectiles; - } + // Config values + private boolean aoeNotifyAll; + @Getter(AccessLevel.PACKAGE) + private Color overlayColor; + @Getter(AccessLevel.PACKAGE) + private boolean configOutlineEnabled; + private int delay; + @Getter(AccessLevel.PACKAGE) + private boolean configFadeEnabled; + @Getter(AccessLevel.PACKAGE) + private boolean tickTimers; + @Getter(AccessLevel.PACKAGE) + private int fontStyle; + @Getter(AccessLevel.PACKAGE) + private int textSize; + @Getter(AccessLevel.PACKAGE) + private boolean shadows; + private boolean configShamansEnabled; + private boolean configShamansNotifyEnabled; + private boolean configArchaeologistEnabled; + private boolean configArchaeologistNotifyEnabled; + private boolean configIceDemonEnabled; + private boolean configIceDemonNotifyEnabled; + private boolean configVasaEnabled; + private boolean configVasaNotifyEnabled; + private boolean configTektonEnabled; + private boolean configTektonNotifyEnabled; + private boolean configVorkathEnabled; + private boolean configVorkathNotifyEnabled; + private boolean configGalvekEnabled; + private boolean configGalvekNotifyEnabled; + private boolean configGargBossEnabled; + private boolean configGargBossNotifyEnabled; + private boolean configVetionEnabled; + private boolean configVetionNotifyEnabled; + private boolean configChaosFanaticEnabled; + private boolean configChaosFanaticNotifyEnabled; + private boolean configOlmEnabled; + private boolean configOlmNotifyEnabled; + @Getter(AccessLevel.PACKAGE) + private boolean configbombDisplay; + private boolean configbombDisplayNotifyEnabled; + private boolean configLightningTrail; + private boolean configLightningTrailNotifyEnabled; + private boolean configCorpEnabled; + private boolean configCorpNotifyEnabled; + private boolean configWintertodtEnabled; + private boolean configWintertodtNotifyEnabled; + private boolean configXarpusEnabled; + private boolean configXarpusNotifyEnabled; + private boolean configaddyDrags; + private boolean configaddyDragsNotifyEnabled; + private boolean configDrakeEnabled; + private boolean configDrakeNotifyEnabled; + private boolean configCerbFireEnabled; + private boolean configCerbFireNotifyEnabled; + private boolean configDemonicGorillaEnabled; + private boolean configDemonicGorillaNotifyEnabled; @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(coreOverlay); overlayManager.add(bombOverlay); - reset(true); + reset(); } @Override @@ -128,7 +181,7 @@ public class AoeWarningPlugin extends Plugin { overlayManager.remove(coreOverlay); overlayManager.remove(bombOverlay); - reset(false); + reset(); } @Subscribe @@ -139,18 +192,7 @@ public class AoeWarningPlugin extends Plugin return; } - switch (event.getKey()) - { - case "fontStyle": - fontStyle = config.fontStyle().getFont(); - break; - case "textSize": - textSize = config.textSize(); - break; - case "shadows": - shadows = config.shadows(); - break; - } + updateConfig(); } @Subscribe @@ -159,7 +201,7 @@ public class AoeWarningPlugin extends Plugin Projectile projectile = event.getProjectile(); int projectileId = projectile.getId(); - int projectileLifetime = config.delay() + (projectile.getRemainingCycles() * 20); + int projectileLifetime = this.delay + (projectile.getRemainingCycles() * 20); int ticksRemaining = projectile.getRemainingCycles() / 30; if (!isTickTimersEnabledForProjectileID(projectileId)) { @@ -174,7 +216,7 @@ public class AoeWarningPlugin extends Plugin AoeProjectile aoeProjectile = new AoeProjectile(Instant.now(), targetPoint, aoeProjectileInfo, projectileLifetime, tickCycle); projectiles.put(projectile, aoeProjectile); - if (config.aoeNotifyAll() || isConfigEnabledForProjectileId(projectileId, true)) + if (this.aoeNotifyAll || isConfigEnabledForProjectileId(projectileId, true)) { notifier.notify("AoE attack detected!"); } @@ -192,7 +234,7 @@ public class AoeWarningPlugin extends Plugin case ObjectID.CRYSTAL_BOMB: bombs.put(wp, new CrystalBomb(gameObject, client.getTickCount())); - if (config.aoeNotifyAll() || config.bombDisplayNotifyEnabled()) + if (this.aoeNotifyAll || this.configbombDisplayNotifyEnabled) { notifier.notify("Bomb!"); } @@ -205,11 +247,11 @@ public class AoeWarningPlugin extends Plugin break; case NullObjectID.NULL_26690: //Wintertodt Snowfall - if (config.isWintertodtEnabled()) + if (this.configWintertodtEnabled) { WintertodtSnowFall.add(wp); - if (config.aoeNotifyAll() || config.isWintertodtNotifyEnabled()) + if (this.aoeNotifyAll || this.configWintertodtNotifyEnabled) { notifier.notify("Snow Fall!"); } @@ -236,7 +278,7 @@ public class AoeWarningPlugin extends Plugin break; case NullObjectID.NULL_26690: //Wintertodt Snowfall - if (config.isWintertodtEnabled()) + if (this.configWintertodtEnabled) { WintertodtSnowFall.remove(wp); } @@ -256,7 +298,7 @@ public class AoeWarningPlugin extends Plugin @Subscribe public void onGameTick(GameTick event) { - if (config.LightningTrail()) + if (this.configLightningTrail) { LightningTrail.clear(); for (GraphicsObject o : client.getGraphicsObjects()) @@ -265,7 +307,7 @@ public class AoeWarningPlugin extends Plugin { LightningTrail.add(WorldPoint.fromLocal(client, o.getLocation())); - if (config.aoeNotifyAll() || config.LightningTrailNotifyEnabled()) + if (this.aoeNotifyAll || this.configLightningTrailNotifyEnabled) { notifier.notify("Lightning!"); } @@ -350,7 +392,7 @@ public class AoeWarningPlugin extends Plugin return false; } - if (notify && config.aoeNotifyAll()) + if (notify && this.aoeNotifyAll) { return true; } @@ -358,57 +400,110 @@ public class AoeWarningPlugin extends Plugin switch (projectileInfo) { case LIZARDMAN_SHAMAN_AOE: - return notify ? config.isShamansNotifyEnabled() : config.isShamansEnabled(); + return notify ? this.configShamansNotifyEnabled : this.configShamansEnabled; case CRAZY_ARCHAEOLOGIST_AOE: - return notify ? config.isArchaeologistNotifyEnabled() : config.isArchaeologistEnabled(); + return notify ? this.configArchaeologistNotifyEnabled : this.configArchaeologistEnabled; case ICE_DEMON_RANGED_AOE: case ICE_DEMON_ICE_BARRAGE_AOE: - return notify ? config.isIceDemonNotifyEnabled() : config.isIceDemonEnabled(); + return notify ? this.configIceDemonNotifyEnabled : this.configIceDemonEnabled; case VASA_AWAKEN_AOE: case VASA_RANGED_AOE: - return notify ? config.isVasaNotifyEnabled() : config.isVasaEnabled(); + return notify ? this.configVasaNotifyEnabled : this.configVasaEnabled; case TEKTON_METEOR_AOE: - return notify ? config.isTektonNotifyEnabled() : config.isTektonEnabled(); + return notify ? this.configTektonNotifyEnabled : this.configTektonEnabled; case VORKATH_BOMB: case VORKATH_POISON_POOL: case VORKATH_SPAWN: case VORKATH_TICK_FIRE: - return notify ? config.isVorkathNotifyEnabled() : config.isVorkathEnabled(); + return notify ? this.configVorkathNotifyEnabled : this.configVorkathEnabled; case VETION_LIGHTNING: - return notify ? config.isVetionNotifyEnabled() : config.isVetionEnabled(); + return notify ? this.configVetionNotifyEnabled : this.configVetionEnabled; case CHAOS_FANATIC: - return notify ? config.isChaosFanaticNotifyEnabled() : config.isChaosFanaticEnabled(); + return notify ? this.configChaosFanaticNotifyEnabled : this.configChaosFanaticEnabled; case GALVEK_BOMB: case GALVEK_MINE: - return notify ? config.isGalvekNotifyEnabled() : config.isGalvekEnabled(); + return notify ? this.configGalvekNotifyEnabled : this.configGalvekEnabled; case DAWN_FREEZE: case DUSK_CEILING: - return notify ? config.isGargBossNotifyEnabled() : config.isGargBossEnabled(); + return notify ? this.configGargBossNotifyEnabled : this.configGargBossEnabled; case OLM_FALLING_CRYSTAL: case OLM_BURNING: case OLM_FALLING_CRYSTAL_TRAIL: case OLM_ACID_TRAIL: case OLM_FIRE_LINE: - return notify ? config.isOlmNotifyEnabled() : config.isOlmEnabled(); + return notify ? this.configOlmNotifyEnabled : this.configOlmEnabled; case CORPOREAL_BEAST: case CORPOREAL_BEAST_DARK_CORE: - return notify ? config.isCorpNotifyEnabled() : config.isCorpEnabled(); + return notify ? this.configCorpNotifyEnabled : this.configCorpEnabled; case XARPUS_POISON_AOE: - return notify ? config.isXarpusNotifyEnabled() : config.isXarpusEnabled(); + return notify ? this.configXarpusNotifyEnabled : this.configXarpusEnabled; case ADDY_DRAG_POISON: - return notify ? config.addyDragsNotifyEnabled() : config.addyDrags(); + return notify ? this.configaddyDragsNotifyEnabled : this.configaddyDrags; case DRAKE_BREATH: - return notify ? config.isDrakeNotifyEnabled() : config.isDrakeEnabled(); + return notify ? this.configDrakeNotifyEnabled : this.configDrakeEnabled; case CERB_FIRE: - return notify ? config.isCerbFireNotifyEnabled() : config.isCerbFireEnabled(); + return notify ? this.configCerbFireNotifyEnabled : this.configCerbFireEnabled; case DEMONIC_GORILLA_BOULDER: - return notify ? config.isDemonicGorillaNotifyEnabled() : config.isDemonicGorillaEnabled(); + return notify ? this.configDemonicGorillaNotifyEnabled : this.configDemonicGorillaEnabled; } return false; } - private void reset(boolean setConfig) + public void updateConfig() + { + this.aoeNotifyAll = config.aoeNotifyAll(); + this.overlayColor = config.overlayColor(); + this.configOutlineEnabled = config.isOutlineEnabled(); + this.delay = config.delay(); + this.configFadeEnabled = config.isFadeEnabled(); + this.tickTimers = config.tickTimers(); + this.fontStyle = config.fontStyle().getFont(); + this.textSize = config.textSize(); + this.shadows = config.shadows(); + this.configShamansEnabled = config.isShamansEnabled(); + this.configShamansNotifyEnabled = config.isShamansNotifyEnabled(); + this.configArchaeologistEnabled = config.isArchaeologistEnabled(); + this.configArchaeologistNotifyEnabled = config.isArchaeologistNotifyEnabled(); + this.configIceDemonEnabled = config.isIceDemonEnabled(); + this.configIceDemonNotifyEnabled = config.isIceDemonNotifyEnabled(); + this.configVasaEnabled = config.isVasaEnabled(); + this.configVasaNotifyEnabled = config.isVasaNotifyEnabled(); + this.configTektonEnabled = config.isTektonEnabled(); + this.configTektonNotifyEnabled = config.isTektonNotifyEnabled(); + this.configVorkathEnabled = config.isVorkathEnabled(); + this.configVorkathNotifyEnabled = config.isVorkathNotifyEnabled(); + this.configGalvekEnabled = config.isGalvekEnabled(); + this.configGalvekNotifyEnabled = config.isGalvekNotifyEnabled(); + this.configGargBossEnabled = config.isGargBossEnabled(); + this.configGargBossNotifyEnabled = config.isGargBossNotifyEnabled(); + this.configVetionEnabled = config.isVetionEnabled(); + this.configVetionNotifyEnabled = config.isVetionNotifyEnabled(); + this.configChaosFanaticEnabled = config.isChaosFanaticEnabled(); + this.configChaosFanaticNotifyEnabled = config.isChaosFanaticNotifyEnabled(); + this.configOlmEnabled = config.isOlmEnabled(); + this.configOlmNotifyEnabled = config.isOlmNotifyEnabled(); + this.configbombDisplay = config.bombDisplay(); + this.configbombDisplayNotifyEnabled = config.bombDisplayNotifyEnabled(); + this.configLightningTrail = config.LightningTrail(); + this.configLightningTrailNotifyEnabled = config.LightningTrailNotifyEnabled(); + this.configCorpEnabled = config.isCorpEnabled(); + this.configCorpNotifyEnabled = config.isCorpNotifyEnabled(); + this.configWintertodtEnabled = config.isWintertodtEnabled(); + this.configWintertodtNotifyEnabled = config.isWintertodtNotifyEnabled(); + this.configXarpusEnabled = config.isXarpusEnabled(); + this.configXarpusNotifyEnabled = config.isXarpusNotifyEnabled(); + this.configaddyDrags = config.addyDrags(); + this.configaddyDragsNotifyEnabled = config.addyDragsNotifyEnabled(); + this.configDrakeEnabled = config.isDrakeEnabled(); + this.configDrakeNotifyEnabled = config.isDrakeNotifyEnabled(); + this.configCerbFireEnabled = config.isCerbFireEnabled(); + this.configCerbFireNotifyEnabled = config.isCerbFireNotifyEnabled(); + this.configDemonicGorillaEnabled = config.isDemonicGorillaEnabled(); + this.configDemonicGorillaNotifyEnabled = config.isDemonicGorillaNotifyEnabled(); + } + + private void reset() { LightningTrail.clear(); AcidTrail.clear(); @@ -416,11 +511,5 @@ public class AoeWarningPlugin extends Plugin WintertodtSnowFall.clear(); bombs.clear(); projectiles.clear(); - if (setConfig) - { - fontStyle = config.fontStyle().getFont(); - textSize = config.textSize(); - shadows = config.shadows(); - } } -} \ No newline at end of file +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/BombOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/BombOverlay.java index 317f5ad04b..d51b52aee3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/BombOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/BombOverlay.java @@ -32,10 +32,10 @@ import java.awt.Polygon; import java.text.DecimalFormat; import java.text.NumberFormat; import java.time.Instant; -import java.util.Iterator; import java.util.Locale; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.Perspective; @@ -50,6 +50,7 @@ import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; @Slf4j +@Singleton public class BombOverlay extends Overlay { @@ -81,15 +82,13 @@ public class BombOverlay extends Overlay } private final Client client; - private final AoeWarningConfig config; private final AoeWarningPlugin plugin; @Inject - public BombOverlay(Client client, AoeWarningPlugin plugin, AoeWarningConfig config) + public BombOverlay(final Client client, final AoeWarningPlugin plugin) { this.client = client; this.plugin = plugin; - this.config = config; setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); setPriority(OverlayPriority.MED); @@ -98,7 +97,7 @@ public class BombOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (config.bombDisplay()) + if (plugin.isConfigbombDisplay()) { drawBombs(graphics); } @@ -108,10 +107,8 @@ public class BombOverlay extends Overlay private void drawBombs(Graphics2D graphics) //I can condense drawDangerZone into this. Ambivalent though. { - Iterator> it = plugin.getBombs().entrySet().iterator(); - while (it.hasNext()) + for (Map.Entry entry : plugin.getBombs().entrySet()) { - Map.Entry entry = it.next(); CrystalBomb bomb = entry.getValue(); drawDangerZone(graphics, bomb); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/CrystalBomb.java b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/CrystalBomb.java index 5e871dca12..0a63fa4b97 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/CrystalBomb.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/aoewarnings/CrystalBomb.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.aoewarnings; import java.time.Instant; +import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.GameObject; @@ -33,20 +34,20 @@ import net.runelite.api.coords.WorldPoint; @Slf4j class CrystalBomb { - @Getter + @Getter(AccessLevel.PACKAGE) private Instant plantedOn; - @Getter + @Getter(AccessLevel.PACKAGE) private Instant lastClockUpdate; - @Getter + @Getter(AccessLevel.PACKAGE) private int objectId; - @Getter + @Getter(AccessLevel.PACKAGE) private int tickStarted; // - @Getter + @Getter(AccessLevel.PACKAGE) private WorldPoint worldLocation; CrystalBomb(GameObject gameObject, int startTick) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/attackstyles/AttackStylesOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/attackstyles/AttackStylesOverlay.java index 0660c1e659..b2112f1420 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/attackstyles/AttackStylesOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/attackstyles/AttackStylesOverlay.java @@ -28,6 +28,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.client.ui.overlay.Overlay; import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE; @@ -36,19 +37,18 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.TitleComponent; +@Singleton class AttackStylesOverlay extends Overlay { private final AttackStylesPlugin plugin; - private final AttackStylesConfig config; private final PanelComponent panelComponent = new PanelComponent(); @Inject - private AttackStylesOverlay(AttackStylesPlugin plugin, AttackStylesConfig config) + private AttackStylesOverlay(final AttackStylesPlugin plugin) { super(plugin); setPosition(OverlayPosition.ABOVE_CHATBOX_RIGHT); this.plugin = plugin; - this.config = config; getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Attack style overlay")); } @@ -58,7 +58,7 @@ class AttackStylesOverlay extends Overlay panelComponent.getChildren().clear(); boolean warnedSkillSelected = plugin.isWarnedSkillSelected(); - if (warnedSkillSelected || config.alwaysShowStyle()) + if (warnedSkillSelected || plugin.isAlwaysShowStyle()) { final String attackStyleString = plugin.getAttackStyle().getName(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/attackstyles/AttackStylesPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/attackstyles/AttackStylesPlugin.java index db7a9ed751..776cc3cd72 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/attackstyles/AttackStylesPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/attackstyles/AttackStylesPlugin.java @@ -31,6 +31,9 @@ import com.google.inject.Provides; import java.util.HashSet; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.Skill; @@ -60,6 +63,7 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Show your current attack style as an overlay", tags = {"combat", "defence", "magic", "overlay", "ranged", "strength", "warn", "pure"} ) +@Singleton public class AttackStylesPlugin extends Plugin { private int attackStyleVarbit = -1; @@ -91,9 +95,22 @@ public class AttackStylesPlugin extends Plugin return configManager.getConfig(AttackStylesConfig.class); } + // config values + @Getter(AccessLevel.PACKAGE) + private boolean alwaysShowStyle; + private boolean warnForDefence; + private boolean warnForAttack; + private boolean warnForStrength; + private boolean warnForRanged; + private boolean warnForMagic; + private boolean hideAutoRetaliate; + private boolean removeWarnedStyles; + @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(overlay); if (client.getGameState() == GameState.LOGGED_IN) @@ -104,11 +121,11 @@ public class AttackStylesPlugin extends Plugin private void start() { - updateWarnedSkills(config.warnForAttack(), Skill.ATTACK); - updateWarnedSkills(config.warnForStrength(), Skill.STRENGTH); - updateWarnedSkills(config.warnForDefence(), Skill.DEFENCE); - updateWarnedSkills(config.warnForRanged(), Skill.RANGED); - updateWarnedSkills(config.warnForMagic(), Skill.MAGIC); + updateWarnedSkills(warnForAttack, Skill.ATTACK); + updateWarnedSkills(warnForStrength, Skill.STRENGTH); + updateWarnedSkills(warnForDefence, Skill.DEFENCE); + updateWarnedSkills(warnForRanged, Skill.RANGED); + updateWarnedSkills(warnForMagic, Skill.MAGIC); attackStyleVarbit = client.getVar(VarPlayer.ATTACK_STYLE); equippedWeaponTypeVarbit = client.getVar(Varbits.EQUIPPED_WEAPON_TYPE); castingModeVarbit = client.getVar(Varbits.DEFENSIVE_CASTING_MODE); @@ -134,7 +151,7 @@ public class AttackStylesPlugin extends Plugin return attackStyle; } - public boolean isWarnedSkillSelected() + boolean isWarnedSkillSelected() { return warnedSkillSelected; } @@ -175,7 +192,7 @@ public class AttackStylesPlugin extends Plugin hideWidget(client.getWidget(widgetKey), widgetsToHide.get(equippedWeaponType, widgetKey)); } } - hideWidget(client.getWidget(WidgetInfo.COMBAT_AUTO_RETALIATE), config.hideAutoRetaliate()); + hideWidget(client.getWidget(WidgetInfo.COMBAT_AUTO_RETALIATE), this.hideAutoRetaliate); } @Subscribe @@ -183,11 +200,11 @@ public class AttackStylesPlugin extends Plugin { if (event.getGameState() == GameState.LOGGED_IN) { - updateWarnedSkills(config.warnForAttack(), Skill.ATTACK); - updateWarnedSkills(config.warnForStrength(), Skill.STRENGTH); - updateWarnedSkills(config.warnForDefence(), Skill.DEFENCE); - updateWarnedSkills(config.warnForRanged(), Skill.RANGED); - updateWarnedSkills(config.warnForMagic(), Skill.MAGIC); + updateWarnedSkills(this.warnForAttack, Skill.ATTACK); + updateWarnedSkills(this.warnForStrength, Skill.STRENGTH); + updateWarnedSkills(this.warnForDefence, Skill.DEFENCE); + updateWarnedSkills(this.warnForRanged, Skill.RANGED); + updateWarnedSkills(this.warnForMagic, Skill.MAGIC); } } @@ -224,6 +241,8 @@ public class AttackStylesPlugin extends Plugin { if (event.getGroup().equals("attackIndicator")) { + updateConfig(); + boolean enabled = event.getNewValue().equals("true"); switch (event.getKey()) { @@ -250,6 +269,18 @@ public class AttackStylesPlugin extends Plugin } } + public void updateConfig() + { + this.alwaysShowStyle = config.alwaysShowStyle(); + this.warnForDefence = config.warnForDefence(); + this.warnForAttack = config.warnForAttack(); + this.warnForStrength = config.warnForStrength(); + this.warnForRanged = config.warnForRanged(); + this.warnForMagic = config.warnForMagic(); + this.hideAutoRetaliate = config.hideAutoRetaliate(); + this.removeWarnedStyles = config.removeWarnedStyles(); + } + private void updateAttackStyle(int equippedWeaponType, int attackStyleIndex, int castingMode) { AttackStyle[] attackStyles = WeaponType.getWeaponType(equippedWeaponType).getAttackStyles(); @@ -298,7 +329,7 @@ public class AttackStylesPlugin extends Plugin } } } - hideWarnedStyles(config.removeWarnedStyles()); + hideWarnedStyles(this.removeWarnedStyles); } private void hideWarnedStyles(boolean enabled) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankCalculation.java b/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankCalculation.java index 13398e22f7..5a9fd695fd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankCalculation.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankCalculation.java @@ -58,7 +58,7 @@ class BankCalculation Varbits.BANK_TAB_NINE_COUNT ); - private final BankConfig config; + private final BankPlugin plugin; private final ItemManager itemManager; private final Client client; @@ -72,10 +72,10 @@ class BankCalculation private long haPrice; @Inject - BankCalculation(ItemManager itemManager, BankConfig config, Client client) + BankCalculation(ItemManager itemManager, BankPlugin plugin, Client client) { this.itemManager = itemManager; - this.config = config; + this.plugin = plugin; this.client = client; } @@ -142,12 +142,12 @@ class BankCalculation continue; } - if (config.showGE()) + if (plugin.isShowGE()) { itemIds.add(item.getId()); } - if (config.showHA()) + if (plugin.isShowHA()) { long alchValue = itemManager.getAlchValue(item.getId()); @@ -159,7 +159,7 @@ class BankCalculation } // Now do the calculations - if (config.showGE() && !itemIds.isEmpty()) + if (plugin.isShowGE() && !itemIds.isEmpty()) { for (Item item : items) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankPlugin.java index f30ba0115f..2cf7e2b746 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/bank/BankPlugin.java @@ -28,8 +28,12 @@ package net.runelite.client.plugins.bank; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.MenuEntry; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.MenuShouldLeftClick; import net.runelite.api.events.ScriptCallbackEvent; @@ -46,6 +50,7 @@ import net.runelite.client.util.StackFormatter; description = "Modifications to the banking interface", tags = {"grand", "exchange", "high", "alchemy", "prices", "deposit"} ) +@Singleton public class BankPlugin extends Plugin { private static final String DEPOSIT_WORN = "Deposit worn items"; @@ -75,6 +80,21 @@ public class BankPlugin extends Plugin return configManager.getConfig(BankConfig.class); } + @Getter(AccessLevel.PACKAGE) + private boolean showGE; + @Getter(AccessLevel.PACKAGE) + private boolean showHA; + private boolean showExact; + private boolean rightClickBankInventory; + private boolean rightClickBankEquip; + private boolean rightClickBankLoot; + + @Override + protected void startUp() throws Exception + { + updateConfig(); + } + @Override protected void shutDown() { @@ -94,9 +114,9 @@ public class BankPlugin extends Plugin MenuEntry[] menuEntries = client.getMenuEntries(); for (MenuEntry entry : menuEntries) { - if ((entry.getOption().equals(DEPOSIT_WORN) && config.rightClickBankEquip()) - || (entry.getOption().equals(DEPOSIT_INVENTORY) && config.rightClickBankInventory()) - || (entry.getOption().equals(DEPOSIT_LOOT) && config.rightClickBankLoot())) + if ((entry.getOption().equals(DEPOSIT_WORN) && this.rightClickBankEquip) + || (entry.getOption().equals(DEPOSIT_INVENTORY) && this.rightClickBankInventory) + || (entry.getOption().equals(DEPOSIT_LOOT) && this.rightClickBankLoot)) { event.setForceRightClick(true); return; @@ -107,9 +127,9 @@ public class BankPlugin extends Plugin @Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { - if ((event.getOption().equals(DEPOSIT_WORN) && config.rightClickBankEquip()) - || (event.getOption().equals(DEPOSIT_INVENTORY) && config.rightClickBankInventory()) - || (event.getOption().equals(DEPOSIT_LOOT) && config.rightClickBankLoot())) + if ((event.getOption().equals(DEPOSIT_WORN) && this.rightClickBankEquip) + || (event.getOption().equals(DEPOSIT_INVENTORY) && this.rightClickBankInventory) + || (event.getOption().equals(DEPOSIT_LOOT) && this.rightClickBankLoot)) { forceRightClickFlag = true; } @@ -128,16 +148,16 @@ public class BankPlugin extends Plugin long gePrice = bankCalculation.getGePrice(); long haPrice = bankCalculation.getHaPrice(); - if (config.showGE() && gePrice != 0) + if (this.showGE && gePrice != 0) { strCurrentTab += " ("; - if (config.showHA()) + if (this.showHA) { strCurrentTab += "EX: "; } - if (config.showExact()) + if (this.showExact) { strCurrentTab += StackFormatter.formatNumber(gePrice) + ")"; } @@ -147,16 +167,16 @@ public class BankPlugin extends Plugin } } - if (config.showHA() && haPrice != 0) + if (this.showHA && haPrice != 0) { strCurrentTab += " ("; - if (config.showGE()) + if (this.showGE) { strCurrentTab += "HA: "; } - if (config.showExact()) + if (this.showExact) { strCurrentTab += StackFormatter.formatNumber(haPrice) + ")"; } @@ -171,4 +191,25 @@ public class BankPlugin extends Plugin stringStack[stringStackSize - 1] += strCurrentTab; } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("bank")) + { + return; + } + + updateConfig(); + } + + public void updateConfig() + { + this.showGE = config.showGE(); + this.showHA = config.showHA(); + this.showExact = config.showExact(); + this.rightClickBankInventory = config.rightClickBankInventory(); + this.rightClickBankEquip = config.rightClickBankEquip(); + this.rightClickBankLoot = config.rightClickBankLoot(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/banktags/BankTagsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/banktags/BankTagsPlugin.java index d593b9f0aa..9b3d72fa53 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/banktags/BankTagsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/banktags/BankTagsPlugin.java @@ -36,6 +36,7 @@ import java.util.Collection; import java.util.regex.Pattern; import java.util.stream.Collectors; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.InventoryID; import net.runelite.api.Item; @@ -82,6 +83,7 @@ import net.runelite.client.util.Text; tags = {"searching", "tagging"} ) @PluginDependency(ClueScrollPlugin.class) +@Singleton public class BankTagsPlugin extends Plugin implements MouseWheelListener, KeyListener { public static final String CONFIG_GROUP = "banktags"; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/banlist/BanListConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/banlist/BanListConfig.java index 75c9668cf7..4278c295b4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/banlist/BanListConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/banlist/BanListConfig.java @@ -8,7 +8,6 @@ import net.runelite.client.config.ConfigItem; public interface BanListConfig extends Config { - @ConfigItem( keyName = "bannedPlayers", name = "Manual Scammer List", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/banlist/BanListPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/banlist/BanListPlugin.java index 92371331cc..c382e703b7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/banlist/BanListPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/banlist/BanListPlugin.java @@ -31,6 +31,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; import net.runelite.api.ClanMember; @@ -67,7 +68,7 @@ import okhttp3.Response; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton @Slf4j public class BanListPlugin extends Plugin { @@ -94,9 +95,16 @@ public class BanListPlugin extends Plugin return configManager.getConfig(BanListConfig.class); } + // save config values + private boolean enableWDR; + private boolean enableRuneWatch; + private boolean highlightInClan; + private boolean highlightInTrade; + @Override protected void startUp() throws Exception { + updateConfig(); manualBans.addAll(Text.fromCSV(config.getBannedPlayers())); fetchFromWebsites(); } @@ -128,6 +136,14 @@ public class BanListPlugin extends Plugin } } + public void updateConfig() + { + this.enableWDR = config.enableWDR(); + this.enableRuneWatch = config.enableRuneWatch(); + this.highlightInClan = config.highlightInClan(); + this.highlightInTrade = config.highlightInTrade(); + } + /** * Event to keep making sure player names are highlighted red in clan chat, since the red name goes away frequently */ @@ -138,7 +154,7 @@ public class BanListPlugin extends Plugin || client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN) != null || client.getViewportWidget() == null || client.getWidget(WidgetInfo.CLAN_CHAT) == null - || !config.highlightInClan()) + || !this.highlightInClan) { return; } @@ -163,7 +179,7 @@ public class BanListPlugin extends Plugin if (scamList != null) { sendWarning(Text.standardize(member.getUsername()), scamList); - if (config.highlightInClan()) + if (this.highlightInClan) { highlightRedInCC(); } @@ -172,7 +188,7 @@ public class BanListPlugin extends Plugin if (toxicList != null) { sendWarning(Text.standardize(member.getUsername()), toxicList); - if (config.highlightInClan()) + if (this.highlightInClan) { highlightRedInCC(); } @@ -185,7 +201,7 @@ public class BanListPlugin extends Plugin @Subscribe public void onWidgetLoaded(WidgetLoaded widgetLoaded) { - if (config.highlightInTrade()) + if (this.highlightInTrade) { if (widgetLoaded.getGroupId() == 335) { //if trading window was loaded @@ -211,7 +227,7 @@ public class BanListPlugin extends Plugin */ private ListType checkScamList(String nameToBeChecked) { - if (wdrScamArrayList.size() > 0 && config.enableWDR()) + if (wdrScamArrayList.size() > 0 && this.enableWDR) { if (wdrScamArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase)) { @@ -219,7 +235,7 @@ public class BanListPlugin extends Plugin } } - if (runeWatchArrayList.size() > 0 && config.enableRuneWatch()) + if (runeWatchArrayList.size() > 0 && this.enableRuneWatch) { if (runeWatchArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase)) { @@ -241,7 +257,7 @@ public class BanListPlugin extends Plugin private ListType checkToxicList(String nameToBeChecked) { - if (wdrToxicArrayList.size() > 0 && config.enableWDR()) + if (wdrToxicArrayList.size() > 0 && this.enableWDR) { if (wdrToxicArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase)) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/AboveSceneOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/AboveSceneOverlay.java index ecfb8251ce..96aafeef5e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/AboveSceneOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/AboveSceneOverlay.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.barbarianassault; import com.google.common.collect.ImmutableMap; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.Point; @@ -46,7 +47,7 @@ import java.awt.Stroke; import java.awt.BasicStroke; import java.util.Map; - +@Singleton class AboveSceneOverlay extends Overlay { private static final int HEALTH_BAR_HEIGHT = 20; @@ -62,18 +63,16 @@ class AboveSceneOverlay extends Overlay private final Client client; private final BarbarianAssaultPlugin game; - private final BarbarianAssaultConfig config; @Inject - private AboveSceneOverlay(Client client, BarbarianAssaultPlugin game, BarbarianAssaultConfig config) + private AboveSceneOverlay(final Client client, final BarbarianAssaultPlugin game) { super(game); setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); this.client = client; this.game = game; - this.config = config; } @Override @@ -88,11 +87,11 @@ class AboveSceneOverlay extends Overlay { case HEALER: - if (config.showTeammateHealthbars()) + if (game.isShowTeammateHealthbars()) { renderHealthBars(graphics); } - if (config.healerCodes()) + if (game.isHealerCodes()) { renderHealerCodes(graphics); } @@ -100,7 +99,7 @@ class AboveSceneOverlay extends Overlay case COLLECTOR: - if (config.highlightCollectorEggs()) + if (game.isHighlightCollectorEggs()) { renderEggs(graphics); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/AboveWidgetsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/AboveWidgetsOverlay.java index 6c140ef4b3..b89bc86148 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/AboveWidgetsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/AboveWidgetsOverlay.java @@ -32,6 +32,7 @@ import java.awt.Rectangle; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Point; import net.runelite.api.widgets.Widget; @@ -43,7 +44,7 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.util.ImageUtil; - +@Singleton class AboveWidgetsOverlay extends Overlay { private static final int OFFSET_X_TEXT_QUANTITY = 0; @@ -51,18 +52,15 @@ class AboveWidgetsOverlay extends Overlay private final Client client; private final BarbarianAssaultPlugin game; - private final BarbarianAssaultConfig config; - @Inject - private AboveWidgetsOverlay(Client client, BarbarianAssaultPlugin game, BarbarianAssaultConfig config) + private AboveWidgetsOverlay(final Client client, final BarbarianAssaultPlugin game) { super(game); setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); this.client = client; this.game = game; - this.config = config; } @Override @@ -75,7 +73,7 @@ class AboveWidgetsOverlay extends Overlay Role role = game.getRole(); - if (config.showTimer()) + if (game.isShowTimer()) { renderTimer(graphics, role); } @@ -83,23 +81,23 @@ class AboveWidgetsOverlay extends Overlay switch (role) { case ATTACKER: - if (config.highlightArrows()) + if (game.isHighlightArrows()) { - renderInventoryHighlights(graphics, game.getRole().getListenItem(game.getLastListenText()), config.highlightArrowColor()); + renderInventoryHighlights(graphics, game.getRole().getListenItem(game.getLastListenText()), game.getHighlightArrowColor()); } break; case DEFENDER: - if (config.highlightBait()) + if (game.isHighlightBait()) { - renderInventoryHighlights(graphics, game.getRole().getListenItem(game.getLastListenText()), config.highlightBaitColor()); + renderInventoryHighlights(graphics, game.getRole().getListenItem(game.getLastListenText()), game.getHighlightBaitColor()); } break; case HEALER: - if (config.highlightPoison()) + if (game.isHighlightPoison()) { - renderInventoryHighlights(graphics, game.getRole().getListenItem(game.getLastListenText()), config.highlightPoisonColor()); + renderInventoryHighlights(graphics, game.getRole().getListenItem(game.getLastListenText()), game.getHighlightPoisonColor()); } } return null; @@ -115,11 +113,11 @@ class AboveWidgetsOverlay extends Overlay return; } - if (role == Role.COLLECTOR && config.showEggCountOverlay() && game.getWave() != null) + if (role == Role.COLLECTOR && game.isShowEggCountOverlay() && game.getWave() != null) { roleText.setText("(" + game.getWave().getCollectedEggCount() + ") " + formatClock()); } - else if (role == Role.HEALER && config.showHpCountOverlay() && game.getWave() != null) + else if (role == Role.HEALER && game.isShowHpCountOverlay() && game.getWave() != null) { roleText.setText("(" + game.getWave().getHpHealed() + ") " + formatClock()); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultMenu.java b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultMenu.java index 0f8f843fd8..10e56c8ac8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultMenu.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultMenu.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.barbarianassault; import com.google.common.collect.Sets; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import net.runelite.client.menus.ComparableEntry; @@ -40,19 +41,19 @@ class BarbarianAssaultMenu { private final MenuManager menuManager; private final BarbarianAssaultPlugin game; - private final BarbarianAssaultConfig config; private final ArrayList tracker = new ArrayList<>(); - @Getter @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private boolean hornUpdated = false; - @Getter @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private boolean rebuildForced = false; @Inject - BarbarianAssaultMenu(MenuManager menuManager, BarbarianAssaultPlugin game, BarbarianAssaultConfig config) + BarbarianAssaultMenu(final MenuManager menuManager, final BarbarianAssaultPlugin game) { this.menuManager = menuManager; this.game = game; - this.config = config; } private boolean isHornOptionHidden(String option) @@ -100,24 +101,24 @@ class BarbarianAssaultMenu case TELL_BLUE_ATTACKER_HORN: case TELL_GREEN_ATTACKER_HORN: case TELL_RED_ATTACKER_HORN: - return ((role == Role.ATTACKER && isHornOptionHidden(entry.getOption())) || role == null) && config.removeIncorrectCalls(); + return ((role == Role.ATTACKER && isHornOptionHidden(entry.getOption())) || role == null) && game.isRemoveIncorrectCalls(); case ATTACK_PENANCE_FIGHTER: case ATTACK_PENANCE_RANGER: case GET_SPIKES_PETRIFIED_MUSHROOM: case TAKE_ATTACKER_ITEM_MACHINE: - return (role != Role.ATTACKER && role != null) && config.removeUnusedMenus(); + return (role != Role.ATTACKER && role != null) && game.isRemoveUnusedMenus(); // Defender role Options case TELL_MEAT_DEFENDER_HORN: case TELL_TOFU_DEFENDER_HORN: case TELL_WORMS_DEFENDER_HORN: - return ((role == Role.DEFENDER && isHornOptionHidden(entry.getOption())) || role == null) && config.removeIncorrectCalls(); + return ((role == Role.DEFENDER && isHornOptionHidden(entry.getOption())) || role == null) && game.isRemoveIncorrectCalls(); case BLOCK_PENANCE_CAVE: - return ((role != Role.DEFENDER && role != null) && config.removeUnusedMenus()) - || (role == Role.DEFENDER && config.removePenanceCave()); + return ((role != Role.DEFENDER && role != null) && game.isRemoveUnusedMenus()) + || (role == Role.DEFENDER && game.isRemovePenanceCave()); case DUNK_LAVA_CRATER: case FIX: @@ -125,7 +126,7 @@ class BarbarianAssaultMenu case TAKE_DEFENDER_ITEM_MACHINE: case TAKE_HAMMER: case TAKE_LOGS: - return (role != Role.DEFENDER && role != null) && config.removeUnusedMenus(); + return (role != Role.DEFENDER && role != null) && game.isRemoveUnusedMenus(); // Collector role options @@ -133,7 +134,7 @@ class BarbarianAssaultMenu case TELL_AGGRESSIVE_COLLECTOR_HORN: case TELL_CONTROLLED_COLLECTOR_HORN: case TELL_DEFENSIVE_COLLECTOR_HORN: - return ((role == Role.COLLECTOR && isHornOptionHidden(entry.getOption())) || role == null) && config.removeIncorrectCalls(); + return ((role == Role.COLLECTOR && isHornOptionHidden(entry.getOption())) || role == null) && game.isRemoveIncorrectCalls(); case CONVERT_COLLECTOR_CONVERTER: case LOAD_EGG_HOPPER: @@ -141,40 +142,40 @@ class BarbarianAssaultMenu case TAKE_GREEN_EGG: case TAKE_RED_EGG: case TAKE_YELLOW_EGG: - return (role != Role.COLLECTOR && role != null) && config.removeUnusedMenus(); + return (role != Role.COLLECTOR && role != null) && game.isRemoveUnusedMenus(); // Healer role options case TELL_CRACKERS_HEALER_HORN: case TELL_TOFU_HEALER_HORN: case TELL_WORMS_HEALER_HORN: - return ((role == Role.HEALER && isHornOptionHidden(entry.getOption())) || role == null) && config.removeIncorrectCalls(); + return ((role == Role.HEALER && isHornOptionHidden(entry.getOption())) || role == null) && game.isRemoveIncorrectCalls(); case DUNK_POISON_CRATER: case STOCK_UP_HEALER_ITEM_MACHINE: case TAKE_HEALER_ITEM_MACHINE: case TAKE_FROM_HEALER_SPRING: case DRINK_FROM_HEALER_SPRING: - return (role != Role.HEALER && role != null) && config.removeUnusedMenus(); + return (role != Role.HEALER && role != null) && game.isRemoveUnusedMenus(); case USE_VIAL_GROUND: case USE_VIAL_ITEM: case USE_VIAL_NPC: case USE_VIAL_WIDGET: - return role == Role.HEALER && config.removeUnusedMenus(); + return role == Role.HEALER && game.isRemoveUnusedMenus(); // Any role options case DROP_HORN: case EXAMINE_HORN: case USE_HORN: - return config.removeIncorrectCalls(); + return game.isRemoveIncorrectCalls(); case MEDIC_HORN: - return config.removeIncorrectCalls() && !hornUpdated; + return game.isRemoveIncorrectCalls() && !hornUpdated; default: - return role != null && config.removeUnusedMenus(); + return role != null && game.isRemoveUnusedMenus(); } }); @@ -189,15 +190,15 @@ class BarbarianAssaultMenu void enableSwaps() { - if (config.swapLadder()) + if (game.isSwapLadder()) { menuManager.addSwap("climb-down", "ladder", "quick-start", "ladder"); } - if (config.swapCollectorBag()) + if (game.isSwapCollectorBag()) { menuManager.addSwap("look-in", "collection bag", "empty", "collection bag"); } - if (config.swapDestroyEggs()) + if (game.isSwapDestroyEggs()) { menuManager.addSwap("use", "blue egg", "destroy", "blue egg"); menuManager.addSwap("use", "green egg", "destroy", "green egg"); @@ -207,17 +208,17 @@ class BarbarianAssaultMenu void disableSwaps(boolean force) { - if (!config.swapLadder() || force) + if (!game.isSwapLadder() || force) { menuManager.removeSwap("climb-down", "ladder", "quick-start", "ladder"); } - if (!config.swapCollectorBag() || force) + if (!game.isSwapCollectorBag() || force) { menuManager.removeSwap("look-in", "collection bag", "empty", "collection bag"); } - if (!config.swapDestroyEggs() || force) + if (!game.isSwapDestroyEggs() || force) { menuManager.removeSwap("use", "blue egg", "destroy", "blue egg"); menuManager.removeSwap("use", "green egg", "destroy", "green egg"); 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 be97a5755c..241ea3bb0b 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,6 +30,7 @@ package net.runelite.client.plugins.barbarianassault; import com.google.common.collect.ImmutableList; import com.google.inject.Provides; +import java.awt.Color; import java.awt.Font; import java.awt.event.KeyEvent; import java.awt.image.BufferedImage; @@ -42,6 +43,8 @@ import java.util.Map; import java.util.Objects; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -108,6 +111,7 @@ import org.apache.commons.lang3.StringUtils; tags = {"minigame", "overlay", "timer"}, type = PluginType.PVM // don't remove this, added this because our barbarian assault plugin is big time modified ) +@Singleton public class BarbarianAssaultPlugin extends Plugin implements KeyListener { private static final String ENDGAME_REWARD_NEEDLE_TEXT = "
5"; @@ -241,16 +245,71 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener private String poisonUsed = null; - @Provides BarbarianAssaultConfig provideConfig(ConfigManager configManager) { return configManager.getConfig(BarbarianAssaultConfig.class); } + // save config values + @Getter(AccessLevel.PACKAGE) + private boolean swapLadder; + @Getter(AccessLevel.PACKAGE) + private boolean showTimer; + @Getter(AccessLevel.PACKAGE) + private boolean removeIncorrectCalls; + @Getter(AccessLevel.PACKAGE) + private boolean removeUnusedMenus; + private boolean prayerMetronome; + private int prayerMetronomeVolume; + private boolean showDeathTimes; + private DeathTimesMode showDeathTimesMode; + private boolean waveTimes; + private boolean showTotalRewards; + @Getter(AccessLevel.PACKAGE) + private boolean highlightArrows; + @Getter(AccessLevel.PACKAGE) + private Color highlightArrowColor; + private boolean removeIncorrectAttackStyles; + private boolean tagging; + @Getter(AccessLevel.PACKAGE) + private boolean highlightBait; + @Getter(AccessLevel.PACKAGE) + private Color highlightBaitColor; + private boolean showDefTimer; + private boolean deprioritizeBait; + @Getter(AccessLevel.PACKAGE) + private boolean removePenanceCave; + @Getter(AccessLevel.PACKAGE) + private boolean highlightPoison; + @Getter(AccessLevel.PACKAGE) + private Color highlightPoisonColor; + private boolean highlightNotification; + private Color highlightNotificationColor; + @Getter(AccessLevel.PACKAGE) + private boolean showHpCountOverlay; + @Getter(AccessLevel.PACKAGE) + private boolean showTeammateHealthbars; + @Getter(AccessLevel.PACKAGE) + private boolean healerCodes; + private boolean healerMenuOption; + private boolean shiftOverstock; + private boolean controlHealer; + @Getter(AccessLevel.PACKAGE) + private boolean swapCollectorBag; + @Getter(AccessLevel.PACKAGE) + private boolean swapDestroyEggs; + @Getter(AccessLevel.PACKAGE) + private boolean highlightCollectorEggs; + private boolean deprioritizeIncorrectEggs; + @Getter(AccessLevel.PACKAGE) + private boolean showEggCountOverlay; + @Override protected void startUp() throws Exception { + updateConfig(); + font = FontManager.getRunescapeFont().deriveFont(Font.BOLD, 24); torsoImage = itemManager.getImage(ItemID.FIGHTER_TORSO); clockImage = ImageUtil.getResourceStreamFromClass(getClass(), "clock.png"); @@ -329,10 +388,12 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener return; } + updateConfig(); + switch (configChanged.getKey()) { case "showTimer": - if (!config.showTimer()) + if (!this.showTimer) { showRoleSprite(); } @@ -352,7 +413,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener break; case "showDefTimer": - if (config.showDefTimer() && getRole() == Role.DEFENDER) + if (this.showDefTimer && getRole() == Role.DEFENDER) { addTickTimer(); } @@ -364,9 +425,9 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener case "showDeathTimes": case "showDeathTimesMode": - if (config.showDeathTimes() - && (config.showDeathTimesMode() == DeathTimesMode.INFO_BOX - || config.showDeathTimesMode() == DeathTimesMode.BOTH)) + if (this.showDeathTimes + && (this.showDeathTimesMode == DeathTimesMode.INFO_BOX + || this.showDeathTimesMode == DeathTimesMode.BOTH)) { addAllDeathTimes(); } @@ -383,7 +444,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener break; case "removeIncorrectAttackStyles": - if (!config.removeIncorrectAttackStyles()) + if (!this.removeIncorrectAttackStyles) { clientThread.invoke(this::showAllStyles); } @@ -391,6 +452,44 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener } } + public void updateConfig() + { + this.swapLadder = config.swapLadder(); + this.showTimer = config.showTimer(); + this.removeIncorrectCalls = config.removeIncorrectCalls(); + this.removeUnusedMenus = config.removeUnusedMenus(); + this.prayerMetronome = config.prayerMetronome(); + this.prayerMetronomeVolume = config.prayerMetronomeVolume(); + this.showDeathTimes = config.showDeathTimes(); + this.showDeathTimesMode = config.showDeathTimesMode(); + this.waveTimes = config.waveTimes(); + this.showTotalRewards = config.showTotalRewards(); + this.highlightArrows = config.highlightArrows(); + this.highlightArrowColor = config.highlightArrowColor(); + this.removeIncorrectAttackStyles = config.removeIncorrectAttackStyles(); + this.tagging = config.tagging(); + this.highlightBait = config.highlightBait(); + this.highlightBaitColor = config.highlightBaitColor(); + this.showDefTimer = config.showDefTimer(); + this.deprioritizeBait = config.deprioritizeBait(); + this.removePenanceCave = config.removePenanceCave(); + this.highlightPoison = config.highlightPoison(); + this.highlightPoisonColor = config.highlightPoisonColor(); + this.highlightNotification = config.highlightNotification(); + this.highlightNotificationColor = config.highlightNotificationColor(); + this.showHpCountOverlay = config.showHpCountOverlay(); + this.showTeammateHealthbars = config.showTeammateHealthbars(); + this.healerCodes = config.healerCodes(); + this.healerMenuOption = config.healerMenuOption(); + this.shiftOverstock = config.shiftOverstock(); + this.controlHealer = config.controlHealer(); + this.swapCollectorBag = config.swapCollectorBag(); + this.swapDestroyEggs = config.swapDestroyEggs(); + this.highlightCollectorEggs = config.highlightCollectorEggs(); + this.deprioritizeIncorrectEggs = config.deprioritizeIncorrectEggs(); + this.showEggCountOverlay = config.showEggCountOverlay(); + } + @Subscribe public void onWidgetLoaded(WidgetLoaded event) { @@ -408,7 +507,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener Widget pointsWidget = client.getWidget(WidgetInfo.BA_REWARD_TEXT); if (!rewardWidget.getText().contains(ENDGAME_REWARD_NEEDLE_TEXT)) { - if (config.showTotalRewards() && pointsWidget != null) + if (this.showTotalRewards && pointsWidget != null) { // The wave will be null if the plugin is disabled mid game, but // the wave points will still be accurate if it is re-enabled @@ -433,7 +532,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener { announceGameTime(); - if (config.showTotalRewards() && scorecard != null && scorecard.getNumberOfWaves() == 9) + if (this.showTotalRewards && scorecard != null && scorecard.getNumberOfWaves() == 9) { announce(scorecard.getGameSummary()); } @@ -496,11 +595,11 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener wave.setHpHealed(wave.getHpHealed() + health); } } - else if (message.contains("the wrong type of poisoned food to use") && config.highlightNotification()) + else if (message.contains("the wrong type of poisoned food to use") && this.highlightNotification) { final MessageNode messageNode = chatMessage.getMessageNode(); final String nodeValue = Text.removeTags(messageNode.getValue()); - messageNode.setValue(ColorUtil.wrapWithColorTag(nodeValue, config.highlightNotificationColor())); + messageNode.setValue(ColorUtil.wrapWithColorTag(nodeValue, this.highlightNotificationColor)); chatMessageManager.update(messageNode); } else if (message.startsWith("All of the Penance")) @@ -528,9 +627,9 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener break; } - if (config.showDeathTimes() && wave != null - && (config.showDeathTimesMode() == DeathTimesMode.CHAT_BOX - || config.showDeathTimesMode() == DeathTimesMode.BOTH)) + if (this.showDeathTimes && wave != null + && (this.showDeathTimesMode == DeathTimesMode.CHAT_BOX + || this.showDeathTimesMode == DeathTimesMode.BOTH)) { final MessageNode node = chatMessage.getMessageNode(); final String nodeValue = Text.removeTags(node.getValue()); @@ -635,9 +734,9 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener tickCounter.setCount(tickNum); } - if (config.prayerMetronome() && isAnyPrayerActive()) + if (this.prayerMetronome && isAnyPrayerActive()) { - for (int i = 0; i < config.prayerMetronomeVolume(); i++) + for (int i = 0; i < this.prayerMetronomeVolume; i++) { client.playSoundEffect(SoundEffectID.GE_INCREMENT_PLOP); } @@ -821,7 +920,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener // This doesn't have to be done in BeforeRender. And although it is // inefficient, it's only being done while in the instance. Will // likely be changed in the future - if (getRole() == Role.ATTACKER && config.removeIncorrectAttackStyles()) + if (getRole() == Role.ATTACKER && this.removeIncorrectAttackStyles) { Widget weapon = client.getWidget(WidgetInfo.COMBAT_WEAPON); @@ -891,7 +990,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener switch (getRole()) { case ATTACKER: - if (config.tagging() && option.equals("attack") && (target.startsWith("penance fighter") || target.startsWith("penance ranger"))) + if (this.tagging && option.equals("attack") && (target.startsWith("penance fighter") || target.startsWith("penance ranger"))) { String tag = StringUtils.substringBefore(entry.getTarget(), ")"); @@ -932,7 +1031,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener priority.add(entry); continue; } - else if (config.deprioritizeIncorrectEggs() + else if (this.deprioritizeIncorrectEggs && option.equals("take") && (target.equals("blue egg") || target.equals("green egg") || target.equals("red egg"))) { @@ -954,7 +1053,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener priority.add(entry); continue; } - else if (config.deprioritizeBait() + else if (this.deprioritizeBait && option.equals("take") && (target.equals("tofu") || target.equals("crackers") || target.equals("worms"))) { @@ -963,7 +1062,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener break; case HEALER: - if (config.healerMenuOption() && target.contains("penance healer") && healers.containsKey(identifier)) + if (this.healerMenuOption && target.contains("penance healer") && healers.containsKey(identifier)) { String tag = StringUtils.substringBefore(entry.getTarget(), " ("); int time = healers.get(identifier).timeToPoison(); @@ -978,17 +1077,17 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener if ((target.startsWith("poisoned meat ->") || target.startsWith("poisoned tofu ->") || target.startsWith("poisoned worms ->"))) { // Poison should only be used on healers - if (config.removeUnusedMenus() && !target.contains("penance healer")) + if (this.removeUnusedMenus && !target.contains("penance healer")) { continue; } - else if (config.controlHealer() && controlDown && identifier == lastHealerPoisoned && target.contains("penance healer")) + else if (this.controlHealer && controlDown && identifier == lastHealerPoisoned && target.contains("penance healer")) { selected.add(entry); continue; } } - else if (config.shiftOverstock() && target.equals("healer item machine") && shiftDown) + else if (this.shiftOverstock && target.equals("healer item machine") && shiftDown) { if (option.contains(listen)) { @@ -996,7 +1095,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener continue; } } - else if (config.removeUnusedMenus()) + else if (this.removeUnusedMenus) { // Vials that are empty should only be used on spring if (target.startsWith("healing vial ->") && !target.endsWith("healer spring")) @@ -1312,12 +1411,12 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener private void validateWidgets() { - if (!config.showTimer()) + if (!this.showTimer) { showRoleSprite(); } - if (config.showDefTimer() && getRole() == Role.DEFENDER) + if (this.showDefTimer && getRole() == Role.DEFENDER) { addTickTimer(); } @@ -1326,9 +1425,9 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener removeTickTimer(); } - if (config.showDeathTimes() - && (config.showDeathTimesMode() == DeathTimesMode.INFO_BOX - || config.showDeathTimesMode() == DeathTimesMode.BOTH)) + if (this.showDeathTimes + && (this.showDeathTimesMode == DeathTimesMode.INFO_BOX + || this.showDeathTimesMode == DeathTimesMode.BOTH)) { addAllDeathTimes(); } @@ -1388,7 +1487,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener deathTimes.add(box); - if (config.showDeathTimes() && (config.showDeathTimesMode() == DeathTimesMode.INFO_BOX || config.showDeathTimesMode() == DeathTimesMode.BOTH)) + if (this.showDeathTimes && (this.showDeathTimesMode == DeathTimesMode.INFO_BOX || this.showDeathTimesMode == DeathTimesMode.BOTH)) { infoBoxManager.addInfoBox(box); } @@ -1454,7 +1553,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener private void announceWaveTime() { - if (config.waveTimes() && wave != null) + if (this.waveTimes && wave != null) { announceTime("Wave " + getStage() + " duration: ", wave.getWaveTimer().getElapsedTimeFormatted()); } @@ -1462,7 +1561,7 @@ public class BarbarianAssaultPlugin extends Plugin implements KeyListener private void announceGameTime() { - if (config.waveTimes() && gameTimer != null) + if (this.waveTimes && gameTimer != null) { announceTime("Game finished, duration: ", gameTimer.getElapsedTimeFormatted()); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Scorecard.java b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Scorecard.java index e33c798a83..2e2f6635e1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Scorecard.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Scorecard.java @@ -35,7 +35,7 @@ import net.runelite.client.chat.ChatMessageBuilder; import net.runelite.client.eventbus.Subscribe; -@Getter +@Getter(AccessLevel.PACKAGE) public class Scorecard { private BarbarianAssaultPlugin game; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Timer.java b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Timer.java index 69347915a6..18e9077e38 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Timer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Timer.java @@ -24,6 +24,7 @@ */ package net.runelite.client.plugins.barbarianassault; +import lombok.AccessLevel; import lombok.Getter; import java.time.Duration; @@ -33,7 +34,7 @@ import java.time.format.DateTimeFormatter; class Timer { - @Getter + @Getter(AccessLevel.PACKAGE) private final Instant startTime; Timer() diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/TimerBox.java b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/TimerBox.java index 8efa4fe917..b3261d53c3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/TimerBox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/TimerBox.java @@ -26,12 +26,14 @@ package net.runelite.client.plugins.barbarianassault; import lombok.Data; +import lombok.EqualsAndHashCode; import net.runelite.client.plugins.Plugin; import net.runelite.client.ui.overlay.infobox.InfoBox; import java.awt.Color; import java.awt.image.BufferedImage; +@EqualsAndHashCode(callSuper = true) @Data public class TimerBox extends InfoBox { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Wave.java b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Wave.java index a392312b75..feee859d9a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Wave.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Wave.java @@ -37,7 +37,6 @@ import net.runelite.client.chat.ChatMessageBuilder; import java.awt.Color; - @Data public class Wave { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsBrotherSlainOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsBrotherSlainOverlay.java index a72d2dfccf..f732d6bd07 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsBrotherSlainOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsBrotherSlainOverlay.java @@ -28,6 +28,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.api.Varbits; @@ -43,13 +44,14 @@ import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; import net.runelite.client.util.ColorUtil; +@Singleton public class BarrowsBrotherSlainOverlay extends Overlay { private final Client client; private final PanelComponent panelComponent = new PanelComponent(); @Inject - private BarrowsBrotherSlainOverlay(BarrowsPlugin plugin, Client client) + private BarrowsBrotherSlainOverlay(final BarrowsPlugin plugin, final Client client) { super(plugin); setPosition(OverlayPosition.TOP_LEFT); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsBrothers.java b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsBrothers.java index 6b2f3edab4..c2053439e1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsBrothers.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsBrothers.java @@ -24,6 +24,7 @@ */ package net.runelite.client.plugins.barrows; +import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; import net.runelite.api.Varbits; @@ -39,10 +40,10 @@ public enum BarrowsBrothers TORAG("Torag", new WorldPoint(3553, 3283, 0), Varbits.BARROWS_KILLED_TORAG), VERAC("Verac", new WorldPoint(3557, 3298, 0), Varbits.BARROWS_KILLED_VERAC); - @Getter + @Getter(AccessLevel.PACKAGE) private final String name; - @Getter + @Getter(AccessLevel.PACKAGE) private final WorldPoint location; - @Getter + @Getter(AccessLevel.PACKAGE) private final Varbits killedVarbit; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsOverlay.java index 8e668d1697..12b3494af7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsOverlay.java @@ -30,6 +30,7 @@ import java.awt.Graphics2D; import java.awt.Rectangle; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.GameObject; import net.runelite.api.NPC; @@ -44,22 +45,21 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; +@Singleton class BarrowsOverlay extends Overlay { private static final int MAX_DISTANCE = 2350; private final Client client; private final BarrowsPlugin plugin; - private final BarrowsConfig config; @Inject - private BarrowsOverlay(Client client, BarrowsPlugin plugin, BarrowsConfig config) + private BarrowsOverlay(final Client client, final BarrowsPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); this.client = client; this.plugin = plugin; - this.config = config; } @Override @@ -71,7 +71,7 @@ class BarrowsOverlay extends Overlay Widget puzzleAnswer = plugin.getPuzzleAnswer(); // tunnels are only on z=0 - if (!plugin.getWalls().isEmpty() && client.getPlane() == 0 && config.showMinimap()) + if (!plugin.getWalls().isEmpty() && client.getPlane() == 0 && plugin.isShowMinimap()) { // NPC dots graphics.setColor(npcColor); @@ -117,12 +117,12 @@ class BarrowsOverlay extends Overlay graphics.setColor(playerColor); graphics.fillRect(local.getMinimapLocation().getX(), local.getMinimapLocation().getY(), 3, 3); } - else if (config.showBrotherLoc()) + else if (plugin.isShowBrotherLoc()) { renderBarrowsBrothers(graphics); } - if (puzzleAnswer != null && config.showPuzzleAnswer() && !puzzleAnswer.isHidden()) + if (puzzleAnswer != null && plugin.isShowPuzzleAnswer() && !puzzleAnswer.isHidden()) { Rectangle answerRect = puzzleAnswer.getBounds(); graphics.setColor(Color.GREEN); @@ -230,11 +230,11 @@ class BarrowsOverlay extends Overlay if (client.getVar(brother.getKilledVarbit()) > 0) { - graphics.setColor(config.deadBrotherLocColor()); + graphics.setColor(plugin.getDeadBrotherLocColor()); } else { - graphics.setColor(config.brotherLocColor()); + graphics.setColor(plugin.getBrotherLocColor()); } graphics.drawString(brotherLetter, minimapText.getX(), minimapText.getY()); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsPlugin.java index 2b5c044f82..a3bbf6461f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/barrows/BarrowsPlugin.java @@ -27,10 +27,12 @@ package net.runelite.client.plugins.barrows; import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; import com.google.inject.Provides; +import java.awt.Color; import java.time.temporal.ChronoUnit; import java.util.HashSet; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.ChatMessageType; @@ -77,6 +79,7 @@ import net.runelite.client.util.StackFormatter; description = "Show helpful information for the Barrows minigame", tags = {"combat", "minigame", "minimap", "bosses", "pve", "pvm"} ) +@Singleton public class BarrowsPlugin extends Plugin { @Getter(AccessLevel.PACKAGE) @@ -144,9 +147,23 @@ public class BarrowsPlugin extends Plugin return configManager.getConfig(BarrowsConfig.class); } + @Getter(AccessLevel.PACKAGE) + private boolean showMinimap; + @Getter(AccessLevel.PACKAGE) + private boolean showBrotherLoc; + private boolean showChestValue; + @Getter(AccessLevel.PACKAGE) + private Color brotherLocColor; + @Getter(AccessLevel.PACKAGE) + private Color deadBrotherLocColor; + @Getter(AccessLevel.PACKAGE) + private boolean showPuzzleAnswer; + private boolean showPrayerDrainTimer; + @Override protected void startUp() throws Exception { + updateConfig(); overlayManager.add(barrowsOverlay); overlayManager.add(brotherOverlay); } @@ -179,12 +196,28 @@ public class BarrowsPlugin extends Plugin @Subscribe public void onConfigChanged(ConfigChanged event) { - if (event.getGroup().equals("barrows") && !config.showPrayerDrainTimer()) + if (event.getGroup().equals("barrows")) { - stopPrayerDrainTimer(); + updateConfig(); + + if (!this.showPrayerDrainTimer) + { + stopPrayerDrainTimer(); + } } } + public void updateConfig() + { + this.showMinimap = config.showMinimap(); + this.showBrotherLoc = config.showBrotherLoc(); + this.showChestValue = config.showChestValue(); + this.brotherLocColor = config.brotherLocColor(); + this.deadBrotherLocColor = config.deadBrotherLocColor(); + this.showPuzzleAnswer = config.showPuzzleAnswer(); + this.showPrayerDrainTimer = config.showPrayerDrainTimer(); + } + @Subscribe public void onWallObjectSpawned(WallObjectSpawned event) { @@ -276,10 +309,14 @@ public class BarrowsPlugin extends Plugin @Subscribe public void onWidgetLoaded(WidgetLoaded event) { - if (event.getGroupId() == WidgetID.BARROWS_REWARD_GROUP_ID && config.showChestValue()) + if (event.getGroupId() == WidgetID.BARROWS_REWARD_GROUP_ID && this.showChestValue) { ItemContainer barrowsRewardContainer = client.getItemContainer(InventoryID.BARROWS_REWARD); - Item[] items = barrowsRewardContainer.getItems(); + Item[] items = new Item[0]; + if (barrowsRewardContainer != null) + { + items = barrowsRewardContainer.getItems(); + } long chestPrice = 0; for (Item item : items) @@ -320,7 +357,7 @@ public class BarrowsPlugin extends Plugin private void startPrayerDrainTimer() { - if (config.showPrayerDrainTimer()) + if (this.showPrayerDrainTimer) { final LoopTimer loopTimer = new LoopTimer( PRAYER_DRAIN_INTERVAL_MS, diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/blackjack/BlackjackPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/blackjack/BlackjackPlugin.java index b5d6c2f635..d23a8c238c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/blackjack/BlackjackPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/blackjack/BlackjackPlugin.java @@ -35,10 +35,10 @@ import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.Varbits; import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.MenuEntryAdded; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.menus.MenuManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginType; @@ -56,7 +56,6 @@ import org.apache.commons.lang3.RandomUtils; type = PluginType.SKILLING, enabledByDefault = false ) - @Singleton @Slf4j public class BlackjackPlugin extends Plugin @@ -68,10 +67,9 @@ public class BlackjackPlugin extends Plugin @Inject private Client client; @Inject - private MenuManager menuManager; - @Inject private BlackjackConfig config; + private boolean pickpocketOnAggro; @Provides BlackjackConfig getConfig(ConfigManager configManager) @@ -79,6 +77,20 @@ public class BlackjackPlugin extends Plugin return configManager.getConfig(BlackjackConfig.class); } + @Override + protected void startUp() throws Exception + { + this.pickpocketOnAggro = config.pickpocketOnAggro(); + } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("blackjack")) + { + this.pickpocketOnAggro = config.pickpocketOnAggro(); + } + } @Subscribe public void onMenuEntryAdded(MenuEntryAdded event) @@ -107,7 +119,7 @@ public class BlackjackPlugin extends Plugin { if (event.getType() == ChatMessageType.SPAM) { - if (event.getMessage().equals(SUCCESS_BLACKJACK) ^ (event.getMessage().equals(FAILED_BLACKJACK) && config.pickpocketOnAggro())) + if (event.getMessage().equals(SUCCESS_BLACKJACK) ^ (event.getMessage().equals(FAILED_BLACKJACK) && this.pickpocketOnAggro)) { nextKnockOutTick = client.getTickCount() + RandomUtils.nextInt(3, 4); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceClickBoxOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceClickBoxOverlay.java index 9dba17df30..4e7b818f90 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceClickBoxOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceClickBoxOverlay.java @@ -29,6 +29,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.geom.Area; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.EquipmentInventorySlot; import net.runelite.api.GameObject; @@ -42,21 +43,20 @@ import net.runelite.api.coords.LocalPoint; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; +@Singleton class BlastFurnaceClickBoxOverlay extends Overlay { private static final int MAX_DISTANCE = 2350; private final Client client; private final BlastFurnacePlugin plugin; - private final BlastFurnaceConfig config; @Inject - private BlastFurnaceClickBoxOverlay(Client client, BlastFurnacePlugin plugin, BlastFurnaceConfig config) + private BlastFurnaceClickBoxOverlay(final Client client, final BlastFurnacePlugin plugin) { setPosition(OverlayPosition.DYNAMIC); this.client = client; this.plugin = plugin; - this.config = config; } @Override @@ -64,13 +64,13 @@ class BlastFurnaceClickBoxOverlay extends Overlay { int dispenserState = client.getVar(Varbits.BAR_DISPENSER); - if (config.showConveyorBelt() && plugin.getConveyorBelt() != null) + if (plugin.isShowConveyorBelt() && plugin.getConveyorBelt() != null) { Color color = dispenserState == 1 ? Color.RED : Color.GREEN; renderObject(plugin.getConveyorBelt(), graphics, color); } - if (config.showBarDispenser() && plugin.getBarDispenser() != null) + if (plugin.isShowBarDispenser() && plugin.getBarDispenser() != null) { boolean hasIceGloves = hasIceGloves(); Color color = dispenserState == 2 && hasIceGloves ? Color.GREEN : (dispenserState == 3 ? Color.GREEN : Color.RED); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceCofferOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceCofferOverlay.java index 49242d63a8..12c1353973 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceCofferOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceCofferOverlay.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.blastfurnace; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import static net.runelite.api.Varbits.BLAST_FURNACE_COFFER; @@ -41,6 +42,7 @@ import net.runelite.client.ui.overlay.components.table.TableComponent; import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.util.StackFormatter; +@Singleton class BlastFurnaceCofferOverlay extends Overlay { private final Client client; @@ -48,7 +50,7 @@ class BlastFurnaceCofferOverlay extends Overlay private final PanelComponent panelComponent = new PanelComponent(); @Inject - private BlastFurnaceCofferOverlay(Client client, BlastFurnacePlugin plugin) + private BlastFurnaceCofferOverlay(final Client client, final BlastFurnacePlugin plugin) { super(plugin); setPosition(OverlayPosition.TOP_LEFT); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceOverlay.java index 0d17c94bb7..2a83c6965d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnaceOverlay.java @@ -28,6 +28,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.client.game.ItemManager; @@ -39,6 +40,7 @@ import net.runelite.client.ui.overlay.components.ComponentOrientation; import net.runelite.client.ui.overlay.components.ImageComponent; import net.runelite.client.ui.overlay.components.PanelComponent; +@Singleton class BlastFurnaceOverlay extends Overlay { private final Client client; @@ -49,7 +51,7 @@ class BlastFurnaceOverlay extends Overlay private ItemManager itemManager; @Inject - BlastFurnaceOverlay(Client client, BlastFurnacePlugin plugin) + BlastFurnaceOverlay(final Client client, final BlastFurnacePlugin plugin) { super(plugin); this.plugin = plugin; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnacePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnacePlugin.java index 15d602a324..7c50696f55 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnacePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/blastfurnace/BlastFurnacePlugin.java @@ -29,6 +29,7 @@ import com.google.inject.Provides; import java.time.Duration; import java.time.Instant; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Client; @@ -37,6 +38,7 @@ import net.runelite.api.GameState; import static net.runelite.api.NullObjectID.NULL_9092; import static net.runelite.api.ObjectID.CONVEYOR_BELT; import net.runelite.api.Skill; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameObjectDespawned; import net.runelite.api.events.GameObjectSpawned; import net.runelite.api.events.GameStateChanged; @@ -57,6 +59,7 @@ import net.runelite.client.util.Text; description = "Show helpful information for the Blast Furnace minigame", tags = {"minigame", "overlay", "skilling", "smithing"} ) +@Singleton public class BlastFurnacePlugin extends Plugin { private static final int BAR_DISPENSER = NULL_9092; @@ -91,9 +94,19 @@ public class BlastFurnacePlugin extends Plugin @Inject private InfoBoxManager infoBoxManager; + @Inject + private BlastFurnaceConfig config; + + @Getter(AccessLevel.PACKAGE) + private boolean showConveyorBelt; + @Getter(AccessLevel.PACKAGE) + private boolean showBarDispenser; + @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(overlay); overlayManager.add(cofferOverlay); overlayManager.add(clickBoxOverlay); @@ -117,6 +130,15 @@ public class BlastFurnacePlugin extends Plugin return configManager.getConfig(BlastFurnaceConfig.class); } + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("blastfurnace")) + { + updateConfig(); + } + } + @Subscribe public void onGameObjectSpawned(GameObjectSpawned event) { @@ -187,4 +209,10 @@ public class BlastFurnacePlugin extends Plugin } } } + + public void updateConfig() + { + this.showBarDispenser = config.showBarDispenser(); + this.showConveyorBelt = config.showConveyorBelt(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMineOreCountOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMineOreCountOverlay.java index 8cff73bd55..0c4e15120d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMineOreCountOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMineOreCountOverlay.java @@ -28,6 +28,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.ItemID; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; @@ -43,20 +44,21 @@ import net.runelite.client.ui.overlay.components.ComponentOrientation; import net.runelite.client.ui.overlay.components.ImageComponent; import net.runelite.client.ui.overlay.components.PanelComponent; +@Singleton class BlastMineOreCountOverlay extends Overlay { private final Client client; - private final BlastMinePluginConfig config; + private final BlastMinePlugin plugin; private final ItemManager itemManager; private final PanelComponent panelComponent = new PanelComponent(); @Inject - private BlastMineOreCountOverlay(BlastMinePlugin plugin, Client client, BlastMinePluginConfig config, ItemManager itemManager) + private BlastMineOreCountOverlay(final BlastMinePlugin plugin, final Client client, final ItemManager itemManager) { super(plugin); setPosition(OverlayPosition.TOP_LEFT); this.client = client; - this.config = config; + this.plugin = plugin; this.itemManager = itemManager; panelComponent.setOrientation(ComponentOrientation.HORIZONTAL); getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Blast mine overlay")); @@ -74,7 +76,7 @@ class BlastMineOreCountOverlay extends Overlay panelComponent.getChildren().clear(); - if (config.showOreOverlay()) + if (plugin.isShowOreOverlay()) { blastMineWidget.setHidden(true); panelComponent.getChildren().add(new ImageComponent(getImage(ItemID.COAL, client.getVar(Varbits.BLAST_MINE_COAL)))); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMinePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMinePlugin.java index 7ddc7e8a80..88d98cebbf 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMinePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMinePlugin.java @@ -25,9 +25,12 @@ package net.runelite.client.plugins.blastmine; import com.google.inject.Provides; +import java.awt.Color; import java.util.HashMap; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.GameObject; @@ -49,9 +52,10 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Show helpful information for the Blast Mine minigame", tags = {"explode", "explosive", "mining", "minigame", "skilling"} ) +@Singleton public class BlastMinePlugin extends Plugin { - @Getter + @Getter(AccessLevel.PACKAGE) private final Map rocks = new HashMap<>(); @Inject @@ -66,15 +70,33 @@ public class BlastMinePlugin extends Plugin @Inject private BlastMineOreCountOverlay blastMineOreCountOverlay; + @Inject + private BlastMinePluginConfig config; + @Provides BlastMinePluginConfig getConfig(ConfigManager configManager) { return configManager.getConfig(BlastMinePluginConfig.class); } + @Getter(AccessLevel.PACKAGE) + private boolean showOreOverlay; + @Getter(AccessLevel.PACKAGE) + private boolean showRockIconOverlay; + @Getter(AccessLevel.PACKAGE) + private boolean showTimerOverlay; + @Getter(AccessLevel.PACKAGE) + private boolean showWarningOverlay; + @Getter(AccessLevel.PACKAGE) + private Color timerColor; + @Getter(AccessLevel.PACKAGE) + private Color warningColor; + @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(blastMineRockOverlay); overlayManager.add(blastMineOreCountOverlay); } @@ -132,4 +154,14 @@ public class BlastMinePlugin extends Plugin (rock.getRemainingTimeRelative() == 1 && rock.getType() != BlastMineRockType.NORMAL) || (rock.getRemainingFuseTimeRelative() == 1 && rock.getType() == BlastMineRockType.LIT)); } + + private void updateConfig() + { + this.showOreOverlay = config.showOreOverlay(); + this.showRockIconOverlay = config.showRockIconOverlay(); + this.showTimerOverlay = config.showTimerOverlay(); + this.showWarningOverlay = config.showWarningOverlay(); + this.timerColor = config.getTimerColor(); + this.warningColor = config.getWarningColor(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMineRock.java b/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMineRock.java index 1f1cec4fb5..441d836f3b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMineRock.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMineRock.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.blastmine; import java.time.Duration; import java.time.Instant; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.GameObject; @@ -34,10 +35,10 @@ class BlastMineRock private static final Duration PLANT_TIME = Duration.ofSeconds(30); private static final Duration FUSE_TIME = Duration.ofMillis(4200); - @Getter + @Getter(AccessLevel.PACKAGE) private final GameObject gameObject; - @Getter + @Getter(AccessLevel.PACKAGE) private final BlastMineRockType type; private final Instant creationTime = Instant.now(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMineRockOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMineRockOverlay.java index 92fbdfe221..5199a9bd4f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMineRockOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMineRockOverlay.java @@ -32,6 +32,7 @@ import java.awt.Polygon; import java.awt.image.BufferedImage; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.GameObject; import net.runelite.api.ItemID; @@ -49,6 +50,7 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.components.ProgressPieComponent; +@Singleton public class BlastMineRockOverlay extends Overlay { private static final int MAX_DISTANCE = 16; @@ -62,20 +64,18 @@ public class BlastMineRockOverlay extends Overlay private final Client client; private final BlastMinePlugin plugin; - private final BlastMinePluginConfig config; private final BufferedImage chiselIcon; private final BufferedImage dynamiteIcon; private final BufferedImage tinderboxIcon; @Inject - private BlastMineRockOverlay(Client client, BlastMinePlugin plugin, BlastMinePluginConfig config, ItemManager itemManager) + private BlastMineRockOverlay(final Client client, final BlastMinePlugin plugin, final ItemManager itemManager) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); this.client = client; this.plugin = plugin; - this.config = config; chiselIcon = itemManager.getImage(ItemID.CHISEL); dynamiteIcon = itemManager.getImage(ItemID.DYNAMITE); tinderboxIcon = itemManager.getImage(ItemID.TINDERBOX); @@ -114,8 +114,8 @@ public class BlastMineRockOverlay extends Overlay drawIconOnRock(graphics, rock, tinderboxIcon); break; case LIT: - drawTimerOnRock(graphics, rock, config.getTimerColor()); - drawAreaWarning(graphics, rock, config.getWarningColor(), tiles); + drawTimerOnRock(graphics, rock, plugin.getTimerColor()); + drawAreaWarning(graphics, rock, plugin.getWarningColor(), tiles); break; } } @@ -125,7 +125,7 @@ public class BlastMineRockOverlay extends Overlay private void drawIconOnRock(Graphics2D graphics, BlastMineRock rock, BufferedImage icon) { - if (!config.showRockIconOverlay()) + if (!plugin.isShowRockIconOverlay()) { return; } @@ -140,7 +140,7 @@ public class BlastMineRockOverlay extends Overlay private void drawTimerOnRock(Graphics2D graphics, BlastMineRock rock, Color color) { - if (!config.showTimerOverlay()) + if (!plugin.isShowTimerOverlay()) { return; } @@ -161,7 +161,7 @@ public class BlastMineRockOverlay extends Overlay private void drawAreaWarning(Graphics2D graphics, BlastMineRock rock, Color color, Tile[][][] tiles) { - if (!config.showWarningOverlay()) + if (!plugin.isShowWarningOverlay()) { return; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMineRockType.java b/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMineRockType.java index 20e1d37f58..0960fcfb5d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMineRockType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMineRockType.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.blastmine; import com.google.common.collect.ImmutableMap; import java.util.Map; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.ObjectID; @@ -54,7 +55,7 @@ public enum BlastMineRockType rockTypes = builder.build(); } - @Getter + @Getter(AccessLevel.PACKAGE) private final int[] objectIds; BlastMineRockType(int... objectIds) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostIndicator.java b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostIndicator.java index 00a0a97561..50a1db0b8a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostIndicator.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostIndicator.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.boosts; import java.awt.Color; import java.awt.image.BufferedImage; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.Skill; @@ -35,17 +36,15 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxPriority; public class BoostIndicator extends InfoBox { private final BoostsPlugin plugin; - private final BoostsConfig config; private final Client client; - @Getter + @Getter(AccessLevel.PACKAGE) private final Skill skill; - BoostIndicator(Skill skill, BufferedImage image, BoostsPlugin plugin, Client client, BoostsConfig config) + BoostIndicator(final Skill skill, final BufferedImage image, final BoostsPlugin plugin, final Client client) { super(image, plugin); this.plugin = plugin; - this.config = config; this.client = client; this.skill = skill; setTooltip(skill.getName() + " boost"); @@ -55,7 +54,7 @@ public class BoostIndicator extends InfoBox @Override public String getText() { - if (!config.useRelativeBoost()) + if (!plugin.isUseRelativeBoost()) { return String.valueOf(client.getBoostedSkillLevel(skill)); } @@ -81,13 +80,13 @@ public class BoostIndicator extends InfoBox return new Color(238, 51, 51); } - return boosted - base <= config.boostThreshold() ? Color.YELLOW : Color.GREEN; + return boosted - base <= plugin.getBoostThreshold() ? Color.YELLOW : Color.GREEN; } @Override public boolean render() { - if (config.displayInfoboxes() && plugin.canShowBoosts() && plugin.getShownSkills().contains(getSkill())) + if (plugin.isDisplayInfoboxes() && plugin.canShowBoosts() && plugin.getShownSkills().contains(getSkill())) { return client.getBoostedSkillLevel(skill) != client.getRealSkillLevel(skill); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsOverlay.java index 54a4f62b8f..977fe0b5a0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/BoostsOverlay.java @@ -28,6 +28,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.api.Skill; @@ -41,20 +42,19 @@ import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; import net.runelite.client.util.ColorUtil; +@Singleton class BoostsOverlay extends Overlay { private final Client client; - private final BoostsConfig config; private final PanelComponent panelComponent = new PanelComponent(); private final BoostsPlugin plugin; @Inject - private BoostsOverlay(Client client, BoostsConfig config, BoostsPlugin plugin) + private BoostsOverlay(final Client client, final BoostsPlugin plugin) { super(plugin); this.plugin = plugin; this.client = client; - this.config = config; setPosition(OverlayPosition.TOP_LEFT); setPriority(OverlayPriority.MED); getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Boosts overlay")); @@ -63,7 +63,7 @@ class BoostsOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (config.displayInfoboxes() || config.displayIcons()) + if (plugin.isDisplayInfoboxes() || plugin.isDisplayIcons()) { return null; } @@ -103,7 +103,7 @@ class BoostsOverlay extends Overlay final Color strColor = getTextColor(boost); String str; - if (config.useRelativeBoost()) + if (plugin.isUseRelativeBoost()) { str = String.valueOf(boost); if (boost > 0) @@ -133,7 +133,7 @@ class BoostsOverlay extends Overlay return new Color(238, 51, 51); } - return boost <= config.boostThreshold() ? Color.YELLOW : Color.GREEN; + return boost <= plugin.getBoostThreshold() ? Color.YELLOW : Color.GREEN; } } 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 5dabff0736..a3ea8a41de 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 @@ -33,6 +33,7 @@ import java.util.List; import java.util.Set; import javax.inject.Inject; import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.Constants; @@ -107,6 +108,21 @@ public class BoostsPlugin extends Plugin private long lastTickMillis; private List boostedSkillsChanged = new ArrayList<>(); + private boolean enableSkill; + @Getter(AccessLevel.PACKAGE) + private boolean useRelativeBoost; + @Getter(AccessLevel.PACKAGE) + private boolean displayInfoboxes; + @Getter(AccessLevel.PACKAGE) + private boolean displayIcons; + @Getter(AccessLevel.PACKAGE) + private boolean boldIconFont; + private BoostsConfig.DisplayChangeMode displayNextBuffChange; + private BoostsConfig.DisplayChangeMode displayNextDebuffChange; + @Getter(AccessLevel.PACKAGE) + private int boostThreshold; + private boolean groupNotifications; + @Provides BoostsConfig provideConfig(ConfigManager configManager) { @@ -116,6 +132,8 @@ public class BoostsPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(boostsOverlay); overlayManager.add(combatIconsOverlay); updateShownSkills(); @@ -130,7 +148,7 @@ public class BoostsPlugin extends Plugin { if (skill != Skill.OVERALL) { - infoBoxManager.addInfoBox(new BoostIndicator(skill, skillIconManager.getSkillImage(skill), this, client, config)); + infoBoxManager.addInfoBox(new BoostIndicator(skill, skillIconManager.getSkillImage(skill), this, client)); } } } @@ -169,14 +187,15 @@ public class BoostsPlugin extends Plugin return; } + updateConfig(); updateShownSkills(); - if (config.displayNextBuffChange() == BoostsConfig.DisplayChangeMode.NEVER) + if (this.displayNextBuffChange == BoostsConfig.DisplayChangeMode.NEVER) { lastChangeDown = -1; } - if (config.displayNextDebuffChange() == BoostsConfig.DisplayChangeMode.NEVER) + if (this.displayNextDebuffChange == BoostsConfig.DisplayChangeMode.NEVER) { lastChangeUp = -1; } @@ -211,7 +230,7 @@ public class BoostsPlugin extends Plugin lastSkillLevels[skillIdx] = cur; updateBoostedStats(); - int boostThreshold = config.boostThreshold(); + int boostThreshold = this.boostThreshold; if (boostThreshold != 0) { @@ -220,7 +239,7 @@ public class BoostsPlugin extends Plugin int boost = cur - real; if (boost <= boostThreshold && boostThreshold < lastBoost) { - if (config.groupNotifications()) + if (this.groupNotifications) { boostedSkillsChanged.add(skill.getName()); } @@ -237,7 +256,7 @@ public class BoostsPlugin extends Plugin { lastTickMillis = System.currentTimeMillis(); - if (config.groupNotifications() && !boostedSkillsChanged.isEmpty()) + if (this.groupNotifications && !boostedSkillsChanged.isEmpty()) { if (boostedSkillsChanged.size() == 1) { @@ -268,7 +287,7 @@ public class BoostsPlugin extends Plugin if (getChangeUpTicks() <= 0) { - switch (config.displayNextDebuffChange()) + switch (this.displayNextDebuffChange) { case ALWAYS: if (lastChangeUp != -1) @@ -286,7 +305,7 @@ public class BoostsPlugin extends Plugin if (getChangeDownTicks() <= 0) { - switch (config.displayNextBuffChange()) + switch (this.displayNextBuffChange) { case ALWAYS: if (lastChangeDown != -1) @@ -305,7 +324,7 @@ public class BoostsPlugin extends Plugin private void updateShownSkills() { - if (config.enableSkill()) + if (this.enableSkill) { shownSkills.addAll(BOOSTABLE_NON_COMBAT_SKILLS); } @@ -368,8 +387,8 @@ public class BoostsPlugin extends Plugin int getChangeDownTicks() { if (lastChangeDown == -1 || - config.displayNextBuffChange() == BoostsConfig.DisplayChangeMode.NEVER || - (config.displayNextBuffChange() == BoostsConfig.DisplayChangeMode.BOOSTED && !isChangedUp)) + this.displayNextBuffChange == BoostsConfig.DisplayChangeMode.NEVER || + (this.displayNextBuffChange == BoostsConfig.DisplayChangeMode.BOOSTED && !isChangedUp)) { return -1; } @@ -396,8 +415,8 @@ public class BoostsPlugin extends Plugin int getChangeUpTicks() { if (lastChangeUp == -1 || - config.displayNextDebuffChange() == BoostsConfig.DisplayChangeMode.NEVER || - (config.displayNextDebuffChange() == BoostsConfig.DisplayChangeMode.BOOSTED && !isChangedDown)) + this.displayNextDebuffChange == BoostsConfig.DisplayChangeMode.NEVER || + (this.displayNextDebuffChange == BoostsConfig.DisplayChangeMode.BOOSTED && !isChangedDown)) { return -1; } @@ -418,4 +437,17 @@ public class BoostsPlugin extends Plugin final long diff = System.currentTimeMillis() - lastTickMillis; return time != -1 ? (int) ((time * Constants.GAME_TICK_LENGTH - diff) / 1000d) : time; } + + private void updateConfig() + { + this.enableSkill = config.enableSkill(); + this.useRelativeBoost = config.useRelativeBoost(); + this.displayInfoboxes = config.displayInfoboxes(); + this.displayIcons = config.displayIcons(); + this.boldIconFont = config.boldIconFont(); + this.displayNextBuffChange = config.displayNextDebuffChange(); + this.displayNextDebuffChange = config.displayNextDebuffChange(); + this.boostThreshold = config.boostThreshold(); + this.groupNotifications = config.groupNotifications(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/boosts/CombatIconsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/CombatIconsOverlay.java index 2e4c9c5ab9..c3c69d9561 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/boosts/CombatIconsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/boosts/CombatIconsOverlay.java @@ -6,6 +6,7 @@ import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.api.Skill; @@ -23,21 +24,20 @@ import net.runelite.client.ui.FontManager; import net.runelite.client.util.ColorUtil; import net.runelite.client.util.ImageUtil; +@Singleton class CombatIconsOverlay extends Overlay { private final Client client; - private final BoostsConfig config; private final PanelComponent panelComponent = new PanelComponent(); private final SkillIconManager iconManager; private final BoostsPlugin plugin; @Inject - private CombatIconsOverlay(Client client, BoostsConfig config, BoostsPlugin plugin, SkillIconManager iconManager) + private CombatIconsOverlay(final Client client, final BoostsPlugin plugin, final SkillIconManager iconManager) { super(plugin); this.plugin = plugin; this.client = client; - this.config = config; this.iconManager = iconManager; setPosition(OverlayPosition.TOP_LEFT); setPriority(OverlayPriority.MED); @@ -47,12 +47,12 @@ class CombatIconsOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (config.displayInfoboxes() || !config.displayIcons()) + if (plugin.isDisplayInfoboxes() || !plugin.isDisplayIcons()) { return null; } - if (config.boldIconFont()) + if (plugin.isBoldIconFont()) { graphics.setFont(FontManager.getRunescapeBoldFont()); } @@ -79,7 +79,7 @@ class CombatIconsOverlay extends Overlay final Color strColor = getTextColor(boost); String str; - if (config.useRelativeBoost()) + if (plugin.isUseRelativeBoost()) { str = String.valueOf(boost); if (boost > 0) @@ -137,7 +137,7 @@ class CombatIconsOverlay extends Overlay return new Color(238, 51, 51); } - return boost <= config.boostThreshold() ? Color.YELLOW : Color.GREEN; + return boost <= plugin.getBoostThreshold() ? Color.YELLOW : Color.GREEN; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/bosstimer/BossTimersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/bosstimer/BossTimersPlugin.java index 0e6b98c907..d5faf547dc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/bosstimer/BossTimersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/bosstimer/BossTimersPlugin.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.bosstimer; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.NPC; import net.runelite.api.events.NpcDespawned; @@ -40,6 +41,7 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager; description = "Show boss spawn timer overlays", tags = {"combat", "pve", "overlay", "spawn"} ) +@Singleton @Slf4j public class BossTimersPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/bosstimer/RespawnTimer.java b/runelite-client/src/main/java/net/runelite/client/plugins/bosstimer/RespawnTimer.java index 1d9d077f25..6d3a03a85a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/bosstimer/RespawnTimer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/bosstimer/RespawnTimer.java @@ -33,7 +33,7 @@ class RespawnTimer extends Timer { private final Boss boss; - public RespawnTimer(Boss boss, BufferedImage bossImage, Plugin plugin) + RespawnTimer(Boss boss, BufferedImage bossImage, Plugin plugin) { super(boss.getSpawnTime().toMillis(), ChronoUnit.MILLIS, bossImage, plugin); this.boss = boss; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonOverlay.java index 06d0500155..84b7423ab3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonOverlay.java @@ -29,6 +29,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Polygon; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import static net.runelite.api.Perspective.LOCAL_TILE_SIZE; @@ -40,22 +41,21 @@ import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.ui.overlay.components.TextComponent; +@Singleton class CannonOverlay extends Overlay { private static final int MAX_DISTANCE = 2500; private final Client client; - private final CannonConfig config; private final CannonPlugin plugin; private final TextComponent textComponent = new TextComponent(); @Inject - CannonOverlay(Client client, CannonConfig config, CannonPlugin plugin) + CannonOverlay(final Client client, final CannonPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setPriority(OverlayPriority.MED); this.client = client; - this.config = config; this.plugin = plugin; } @@ -91,9 +91,9 @@ class CannonOverlay extends Overlay textComponent.render(graphics); } - if (config.showDoubleHitSpot()) + if (plugin.isShowDoubleHitSpot()) { - Color color = config.highlightDoubleHitColor(); + Color color = plugin.getHighlightDoubleHitColor(); drawDoubleHitSpots(graphics, cannonPoint, color); } } 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 6b82e45aca..dd229ef8c6 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 @@ -33,6 +33,7 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.inject.Inject; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.AnimationID; import net.runelite.api.ChatMessageType; @@ -80,19 +81,19 @@ public class CannonPlugin extends Plugin private CannonCounter counter; private boolean skipProjectileCheckThisTick; - @Getter + @Getter(AccessLevel.PACKAGE) private int cballsLeft; - @Getter + @Getter(AccessLevel.PACKAGE) private boolean cannonPlaced; - @Getter + @Getter(AccessLevel.PACKAGE) private WorldPoint cannonPosition; - @Getter + @Getter(AccessLevel.PACKAGE) private GameObject cannon; - @Getter + @Getter(AccessLevel.PACKAGE) private List spotPoints = new ArrayList<>(); @Inject @@ -124,6 +125,17 @@ public class CannonPlugin extends Plugin private boolean lock; + private boolean showEmptyCannonNotification; + private boolean showInfobox; + @Getter(AccessLevel.PACKAGE) + private boolean showDoubleHitSpot; + @Getter(AccessLevel.PACKAGE) + private Color highlightDoubleHitColor; + @Getter(AccessLevel.PACKAGE) + private boolean showCannonSpots; + private int ammoAmount; + private boolean notifyAmmoLeft; + @Provides CannonConfig provideConfig(ConfigManager configManager) { @@ -133,6 +145,8 @@ public class CannonPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(cannonOverlay); overlayManager.add(cannonSpotOverlay); lock = false; @@ -169,7 +183,9 @@ public class CannonPlugin extends Plugin { if (event.getGroup().equals("cannon")) { - if (!config.showInfobox()) + updateConfig(); + + if (!this.showInfobox) { removeCounter(); } @@ -190,7 +206,7 @@ public class CannonPlugin extends Plugin ) public void checkSpots() { - if (!config.showCannonSpots()) + if (!this.showCannonSpots) { return; } @@ -318,7 +334,7 @@ public class CannonPlugin extends Plugin // extra check is a good idea. cballsLeft = 0; - if (config.showEmptyCannonNotification()) + if (this.showEmptyCannonNotification) { notifier.notify("Your cannon is out of ammo!"); } @@ -350,11 +366,11 @@ public class CannonPlugin extends Plugin { return Color.orange; } - else if (cballsLeft <= config.ammoAmount()) + else if (cballsLeft <= this.ammoAmount) { - if (config.notifyAmmoLeft() && !lock) + if (this.notifyAmmoLeft && !lock) { - notifier.notify("Your cannon has " + config.ammoAmount() + " balls left!"); + notifier.notify("Your cannon has " + this.ammoAmount + " balls left!"); lock = true; } } @@ -364,7 +380,7 @@ public class CannonPlugin extends Plugin private void addCounter() { - if (!config.showInfobox() || counter != null) + if (!this.showInfobox || counter != null) { return; } @@ -385,4 +401,15 @@ public class CannonPlugin extends Plugin infoBoxManager.removeInfoBox(counter); counter = null; } + + private void updateConfig() + { + this.showEmptyCannonNotification = config.showEmptyCannonNotification(); + this.showInfobox = config.showInfobox(); + this.showDoubleHitSpot = config.showDoubleHitSpot(); + this.highlightDoubleHitColor = config.highlightDoubleHitColor(); + this.showCannonSpots = config.showCannonSpots(); + this.ammoAmount = config.ammoAmount(); + this.notifyAmmoLeft = config.notifyAmmoLeft(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonSpotOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonSpotOverlay.java index 01c3eff871..3bf377f2b0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonSpotOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cannon/CannonSpotOverlay.java @@ -30,6 +30,7 @@ import java.awt.Graphics2D; import java.awt.Polygon; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Setter; import net.runelite.api.Client; @@ -43,13 +44,13 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton public class CannonSpotOverlay extends Overlay { private static final int MAX_DISTANCE = 2350; private final Client client; private final CannonPlugin plugin; - private final CannonConfig config; @Inject private ItemManager itemManager; @@ -58,18 +59,17 @@ public class CannonSpotOverlay extends Overlay private boolean hidden; @Inject - CannonSpotOverlay(Client client, CannonPlugin plugin, CannonConfig config) + CannonSpotOverlay(final Client client, final CannonPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); this.client = client; this.plugin = plugin; - this.config = config; } @Override public Dimension render(Graphics2D graphics) { - if (hidden || !config.showCannonSpots() || plugin.isCannonPlaced()) + if (hidden || !plugin.isShowCannonSpots() || plugin.isCannonPlaced()) { return null; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cerberus/CerberusGhost.java b/runelite-client/src/main/java/net/runelite/client/plugins/cerberus/CerberusGhost.java index 354dd0edf4..28adddc615 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cerberus/CerberusGhost.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cerberus/CerberusGhost.java @@ -27,13 +27,14 @@ package net.runelite.client.plugins.cerberus; import com.google.common.collect.ImmutableMap; import java.util.Map; import java.util.Optional; +import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; import net.runelite.api.NPC; import net.runelite.api.NpcID; import net.runelite.api.Skill; -@Getter +@Getter(AccessLevel.PACKAGE) @RequiredArgsConstructor public enum CerberusGhost { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatboxperformance/ChatboxPerformancePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatboxperformance/ChatboxPerformancePlugin.java index 4cc810847f..3f51018632 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatboxperformance/ChatboxPerformancePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatboxperformance/ChatboxPerformancePlugin.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.chatboxperformance; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.events.WidgetPositioned; import net.runelite.api.widgets.Widget; @@ -40,6 +41,7 @@ import net.runelite.client.plugins.PluginDescriptor; name = "Chatbox performance", hidden = true ) +@Singleton public class ChatboxPerformancePlugin extends Plugin { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java index 079f1cdba6..fcac5d54b1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java @@ -25,6 +25,7 @@ */ package net.runelite.client.plugins.chatcommands; +import javax.inject.Singleton; import net.runelite.api.vars.AccountType; import com.google.inject.Provides; import java.io.IOException; @@ -81,6 +82,7 @@ import org.apache.commons.text.WordUtils; description = "Enable chat commands", tags = {"grand", "exchange", "level", "prices"} ) +@Singleton @Slf4j public class ChatCommandsPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatfilter/ChatFilterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatfilter/ChatFilterPlugin.java index 8413b0e67a..a00c7391b2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatfilter/ChatFilterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatfilter/ChatFilterPlugin.java @@ -34,6 +34,9 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Setter; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.MessageNode; @@ -53,6 +56,7 @@ import org.apache.commons.lang3.StringUtils; description = "Censor user configurable words or patterns from chat", enabledByDefault = false ) +@Singleton public class ChatFilterPlugin extends Plugin { private static final Splitter NEWLINE_SPLITTER = Splitter @@ -71,6 +75,17 @@ public class ChatFilterPlugin extends Plugin @Inject private ChatFilterConfig config; + @Setter(AccessLevel.PACKAGE) + private ChatFilterType filterType; + @Setter(AccessLevel.PACKAGE) + private String filteredWords; + @Setter(AccessLevel.PACKAGE) + private String filteredRegex; + @Setter(AccessLevel.PACKAGE) + private boolean filterFriends; + @Setter(AccessLevel.PACKAGE) + private boolean filterClan; + @Provides ChatFilterConfig provideConfig(ConfigManager configManager) { @@ -80,6 +95,7 @@ public class ChatFilterPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); updateFilteredPatterns(); } @@ -122,8 +138,8 @@ public class ChatFilterPlugin extends Plugin MessageNode messageNode = (MessageNode) client.getMessages().get(messageId); if (client.getLocalPlayer().getName().equals(messageNode.getName()) || - !config.filterFriends() && messageNode.isFromFriend() || - !config.filterClan() && messageNode.isFromClanMate()) + !this.filterFriends && messageNode.isFromFriend() || + !this.filterClan && messageNode.isFromClanMate()) { return; } @@ -168,8 +184,8 @@ public class ChatFilterPlugin extends Plugin { boolean isMessageFromSelf = playerName.equals(client.getLocalPlayer().getName()); return !isMessageFromSelf && - (config.filterFriends() || !client.isFriended(playerName, false)) && - (config.filterClan() || !client.isClanMember(playerName)); + (this.filterFriends || !client.isFriended(playerName, false)) && + (this.filterClan || !client.isClanMember(playerName)); } String censorMessage(final String message) @@ -185,7 +201,7 @@ public class ChatFilterPlugin extends Plugin while (m.find()) { - switch (config.filterType()) + switch (this.filterType) { case CENSOR_WORDS: m.appendReplacement(sb, StringUtils.repeat("*", m.group(0).length())); @@ -209,11 +225,11 @@ public class ChatFilterPlugin extends Plugin { filteredPatterns.clear(); - Text.fromCSV(config.filteredWords()).stream() + Text.fromCSV(this.filteredWords).stream() .map(s -> Pattern.compile(Pattern.quote(s), Pattern.CASE_INSENSITIVE)) .forEach(filteredPatterns::add); - NEWLINE_SPLITTER.splitToList(config.filteredRegex()).stream() + NEWLINE_SPLITTER.splitToList(this.filteredRegex).stream() .map(s -> { try @@ -237,6 +253,16 @@ public class ChatFilterPlugin extends Plugin return; } + updateConfig(); updateFilteredPatterns(); } + + private void updateConfig() + { + this.filterType = config.filterType(); + this.filteredWords = config.filteredWords(); + this.filteredRegex = config.filteredRegex(); + this.filterFriends = config.filterFriends(); + this.filterClan = config.filterClan(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java index d6ed9d888d..86586dedf5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chathistory/ChatHistoryPlugin.java @@ -32,12 +32,14 @@ import java.util.Deque; import java.util.Iterator; import java.util.Queue; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.ScriptID; import net.runelite.api.VarClientInt; import net.runelite.api.VarClientStr; import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.MenuOptionClicked; import net.runelite.api.vars.InputType; import net.runelite.client.callback.ClientThread; @@ -56,6 +58,7 @@ import net.runelite.client.util.Text; description = "Retain your chat history when logging in/out or world hopping", tags = {"chat", "history", "retain", "cycle", "pm"} ) +@Singleton public class ChatHistoryPlugin extends Plugin implements KeyListener { private static final String WELCOME_MESSAGE = "Welcome to Old School RuneScape."; @@ -82,6 +85,9 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener @Inject private ChatMessageManager chatMessageManager; + private boolean retainChatHistory; + private boolean pmTargetCycling; + @Provides ChatHistoryConfig getConfig(ConfigManager configManager) { @@ -91,6 +97,8 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener @Override protected void startUp() { + updateConfig(); + messageQueue = EvictingQueue.create(100); friends = new ArrayDeque<>(FRIENDS_MAX_SIZE + 1); keyManager.registerKeyListener(this); @@ -113,7 +121,7 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener // of information that chat history was reset if (chatMessage.getMessage().equals(WELCOME_MESSAGE)) { - if (!config.retainChatHistory()) + if (!this.retainChatHistory) { return; } @@ -204,7 +212,7 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener @Override public void keyPressed(KeyEvent e) { - if (e.getKeyCode() != CYCLE_HOTKEY || !config.pmTargetCycling()) + if (e.getKeyCode() != CYCLE_HOTKEY || !this.pmTargetCycling) { return; } @@ -260,4 +268,21 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener return friends.getLast(); } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!"chathistory".equals(event.getGroup())) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.retainChatHistory = config.retainChatHistory(); + this.pmTargetCycling = config.pmTargetCycling(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java index 0f9f000b28..0f8c5f1847 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatnotifications/ChatNotificationsPlugin.java @@ -36,6 +36,7 @@ import java.util.regex.Pattern; import static java.util.regex.Pattern.quote; import java.util.stream.Collectors; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.MessageNode; import net.runelite.api.events.ChatMessage; @@ -57,6 +58,7 @@ import net.runelite.client.util.Text; tags = {"duel", "messages", "notifications", "trade", "username"}, enabledByDefault = false ) +@Singleton public class ChatNotificationsPlugin extends Plugin { @Inject @@ -82,6 +84,14 @@ public class ChatNotificationsPlugin extends Plugin // Private message cache used to avoid duplicate notifications from ChatHistory. private Set privateMessageHashes = new HashSet<>(); + private boolean highlightOwnName; + private String highlightWordsString; + private boolean notifyOnOwnName; + private boolean notifyOnHighlight; + private boolean notifyOnTrade; + private boolean notifyOnDuel; + private boolean notifyOnPm; + @Provides ChatNotificationsConfig provideConfig(ConfigManager configManager) { @@ -91,6 +101,7 @@ public class ChatNotificationsPlugin extends Plugin @Override public void startUp() { + updateConfig(); updateHighlights(); } @@ -117,6 +128,7 @@ public class ChatNotificationsPlugin extends Plugin { if (event.getGroup().equals("chatnotification")) { + updateConfig(); updateHighlights(); } } @@ -125,9 +137,9 @@ public class ChatNotificationsPlugin extends Plugin { highlightMatcher = null; - if (!config.highlightWordsString().trim().equals("")) + if (!this.highlightWordsString.trim().equals("")) { - List items = Text.fromCSV(config.highlightWordsString()); + List items = Text.fromCSV(this.highlightWordsString); String joined = items.stream() .map(Text::escapeJagex) // we compare these strings to the raw Jagex ones .map(Pattern::quote) @@ -147,13 +159,13 @@ public class ChatNotificationsPlugin extends Plugin switch (chatMessage.getType()) { case TRADEREQ: - if (chatMessage.getMessage().contains("wishes to trade with you.") && config.notifyOnTrade()) + if (chatMessage.getMessage().contains("wishes to trade with you.") && this.notifyOnTrade) { notifier.notify(chatMessage.getMessage()); } break; case CHALREQ_TRADE: - if (chatMessage.getMessage().contains("wishes to duel with you.") && config.notifyOnDuel()) + if (chatMessage.getMessage().contains("wishes to duel with you.") && this.notifyOnDuel) { notifier.notify(chatMessage.getMessage()); } @@ -167,7 +179,7 @@ public class ChatNotificationsPlugin extends Plugin break; case PRIVATECHAT: case MODPRIVATECHAT: - if (config.notifyOnPm()) + if (this.notifyOnPm) { int messageHash = this.buildMessageHash(chatMessage); if (this.privateMessageHashes.contains(messageHash)) @@ -187,7 +199,7 @@ public class ChatNotificationsPlugin extends Plugin usernameReplacer = "" + username + ""; } - if (config.highlightOwnName() && usernameMatcher != null) + if (this.highlightOwnName && usernameMatcher != null) { Matcher matcher = usernameMatcher.matcher(messageNode.getValue()); if (matcher.find()) @@ -195,7 +207,7 @@ public class ChatNotificationsPlugin extends Plugin messageNode.setValue(matcher.replaceAll(usernameReplacer)); update = true; - if (config.notifyOnOwnName()) + if (this.notifyOnOwnName) { sendNotification(chatMessage); } @@ -222,7 +234,7 @@ public class ChatNotificationsPlugin extends Plugin matcher.appendTail(stringBuffer); messageNode.setValue(stringBuffer.toString()); - if (config.notifyOnHighlight()) + if (this.notifyOnHighlight) { sendNotification(chatMessage); } @@ -261,4 +273,15 @@ public class ChatNotificationsPlugin extends Plugin String notification = stringBuilder.toString(); notifier.notify(notification); } + + private void updateConfig() + { + this.highlightOwnName = config.highlightOwnName(); + this.highlightWordsString = config.highlightWordsString(); + this.notifyOnOwnName = config.notifyOnOwnName(); + this.notifyOnHighlight = config.notifyOnHighlight(); + this.notifyOnTrade = config.notifyOnTrade(); + this.notifyOnDuel = config.notifyOnDuel(); + this.notifyOnPm = config.notifyOnPm(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chattranslation/ChatTranslationPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chattranslation/ChatTranslationPlugin.java index 034dfa2647..3760f5b036 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/chattranslation/ChatTranslationPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/chattranslation/ChatTranslationPlugin.java @@ -3,6 +3,7 @@ package net.runelite.client.plugins.chattranslation; import com.google.common.collect.ImmutableList; import com.google.common.collect.ObjectArrays; import com.google.inject.Provides; +import javax.inject.Singleton; import net.runelite.api.*; import net.runelite.api.events.ChatMessage; import net.runelite.api.events.ConfigChanged; @@ -34,6 +35,7 @@ import java.util.ArrayList; tags = {"translate", "language", "english", "spanish", "dutch", "french"}, type = PluginType.UTILITY ) +@Singleton public class ChatTranslationPlugin extends Plugin implements KeyListener { @@ -64,6 +66,13 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener @Inject private ChatTranslationConfig config; + private boolean translateOptionVisable; + private boolean publicChat; + private String getPlayerNames; + private Languages publicTargetLanguage; + private boolean playerChat; + private Languages playerTargetLanguage; + @Provides ChatTranslationConfig provideConfig(ConfigManager configManager) { @@ -73,9 +82,11 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener @Override protected void startUp() throws Exception { + updateConfig(); + if (client != null) { - if (config.translateOptionVisable()) + if (this.translateOptionVisable) { menuManager.get().addPlayerMenuItem(TRANSLATE); } @@ -90,7 +101,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener { if (client != null) { - if (config.translateOptionVisable()) + if (this.translateOptionVisable) { menuManager.get().removePlayerMenuItem(TRANSLATE); } @@ -105,9 +116,10 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener { if (event.getGroup().equals("chattranslation")) { + updateConfig(); if (event.getKey().equals("playerNames")) { - for (String names : Text.fromCSV(config.getPlayerNames())) + for (String names : Text.fromCSV(this.getPlayerNames)) { if (!playerNames.contains(Text.toJagexName(names))) { @@ -121,7 +133,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener @Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { - if (!config.translateOptionVisable()) + if (!this.translateOptionVisable) { return; } @@ -181,7 +193,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener case PUBLICCHAT: case MODCHAT: case FRIENDSCHAT: - if (!config.publicChat()) + if (!this.publicChat) { return; } @@ -201,7 +213,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener try { //Automatically check language of message and translate to selected language. - String translation = translator.translate("auto", config.publicTargetLanguage().toString(), message); + String translation = translator.translate("auto", this.publicTargetLanguage.toString(), message); if (translation != null) { final MessageNode messageNode = chatMessage.getMessageNode(); @@ -227,7 +239,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener return; } - if (!config.playerChat()) + if (!this.playerChat) { return; } @@ -259,7 +271,7 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener try { //Automatically check language of message and translate to selected language. - String translation = translator.translate("auto", config.playerTargetLanguage().toString(), message); + String translation = translator.translate("auto", this.playerTargetLanguage.toString(), message); if (translation != null) { client.setVar(VarClientStr.CHATBOX_TYPED_TEXT, translation); @@ -291,4 +303,13 @@ public class ChatTranslationPlugin extends Plugin implements KeyListener // Nothing. } + private void updateConfig() + { + this.publicChat = config.publicChat(); + this.getPlayerNames = config.getPlayerNames(); + this.translateOptionVisable = config.translateOptionVisable(); + this.publicTargetLanguage = config.publicTargetLanguage(); + this.playerChat = config.playerChat(); + this.playerTargetLanguage = config.playerTargetLanguage(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/ClanChatIndicator.java b/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/ClanChatIndicator.java index e8f7542d7d..38c86929dd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/ClanChatIndicator.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/clanchat/ClanChatIndicator.java @@ -26,13 +26,15 @@ package net.runelite.client.plugins.clanchat; import java.awt.Color; import java.awt.image.BufferedImage; +import javax.inject.Singleton; import net.runelite.client.ui.overlay.infobox.Counter; +@Singleton class ClanChatIndicator extends Counter { private final ClanChatPlugin plugin; - ClanChatIndicator(BufferedImage image, ClanChatPlugin plugin) + ClanChatIndicator(final BufferedImage image, final ClanChatPlugin plugin) { super(image, plugin, plugin.getClanAmount()); this.plugin = plugin; 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 8e053922dd..cab4bb4b45 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 @@ -40,6 +40,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.ChatLineBuffer; import net.runelite.api.ChatMessageType; import net.runelite.api.ClanMember; @@ -68,7 +69,6 @@ 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.chat.ChatMessageManager; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.game.ClanManager; @@ -87,6 +87,7 @@ import net.runelite.client.util.Text; description = "Add rank icons to users talking in clan chat", tags = {"icons", "rank", "recent"} ) +@Singleton public class ClanChatPlugin extends Plugin { private static final int MAX_CHATS = 20; @@ -112,9 +113,6 @@ public class ClanChatPlugin extends Plugin @Inject private ClientThread clientThread; - - @Inject - private ChatMessageManager chatMessageManager; private List chats = new ArrayList<>(); @@ -132,6 +130,17 @@ public class ClanChatPlugin extends Plugin private Map activityBuffer = new HashMap<>(); private int clanJoinedTick; + private boolean clanChatIcons; + private boolean recentChats; + private boolean showClanCounter; + private String chatsData; + private boolean showJoinLeave; + private ClanMemberRank joinLeaveRank; + private boolean privateMessageIcons; + private boolean publicChatIcons; + private boolean clanTabChat; + private String clanname; + @Provides ClanChatConfig getConfig(ConfigManager configManager) { @@ -141,6 +150,7 @@ public class ClanChatPlugin extends Plugin @Override public void startUp() { + updateConfig(); chats = new ArrayList<>(Text.fromCSV(config.chatsData())); } @@ -157,12 +167,14 @@ public class ClanChatPlugin extends Plugin { if (configChanged.getGroup().equals("clanchat")) { - if (!config.recentChats()) + updateConfig(); + + if (!this.recentChats) { resetClanChats(); } - if (config.showClanCounter()) + if (this.showClanCounter) { clientThread.invoke(this::addClanCounter); } @@ -200,8 +212,8 @@ public class ClanChatPlugin extends Plugin return; } - if (!config.showJoinLeave() || - member.getRank().getValue() < config.joinLeaveRank().getValue()) + if (!this.showJoinLeave || + member.getRank().getValue() < this.joinLeaveRank.getValue()) { return; } @@ -245,8 +257,8 @@ public class ClanChatPlugin extends Plugin } } - if (!config.showJoinLeave() || - member.getRank().getValue() < config.joinLeaveRank().getValue()) + if (!this.showJoinLeave || + member.getRank().getValue() < this.joinLeaveRank.getValue()) { return; } @@ -271,7 +283,7 @@ public class ClanChatPlugin extends Plugin return; } - client.setVar(VarClientStr.RECENT_CLAN_CHAT, config.clanname()); + client.setVar(VarClientStr.RECENT_CLAN_CHAT, this.clanname); Widget clanChatTitleWidget = client.getWidget(WidgetInfo.CLAN_CHAT_TITLE); if (clanChatTitleWidget != null) @@ -282,7 +294,7 @@ public class ClanChatPlugin extends Plugin { clanChatTitleWidget.setText(CLAN_CHAT_TITLE + " (" + client.getClanChatCount() + "/100)"); } - else if (config.recentChats() && clanChatList.getChildren() == null && !Strings.isNullOrEmpty(owner.getText())) + else if (this.recentChats && clanChatList.getChildren() == null && !Strings.isNullOrEmpty(owner.getText())) { clanChatTitleWidget.setText(RECENT_TITLE); @@ -290,7 +302,7 @@ public class ClanChatPlugin extends Plugin } } - if (!config.showJoinLeave()) + if (!this.showJoinLeave) { return; } @@ -373,7 +385,7 @@ public class ClanChatPlugin extends Plugin channelColor = CHAT_CLAN_NAME_TRANSPARENT_BACKGROUND; } - if (config.clanChatIcons() && rank != null && rank != ClanMemberRank.UNRANKED) + if (this.clanChatIcons && rank != null && rank != ClanMemberRank.UNRANKED) { rankIcon = clanManager.getIconNumber(rank); } @@ -405,7 +417,7 @@ public class ClanChatPlugin extends Plugin @Subscribe public void onVarClientStrChanged(VarClientStrChanged strChanged) { - if (strChanged.getIndex() == VarClientStr.RECENT_CLAN_CHAT.getIndex() && config.recentChats()) + if (strChanged.getIndex() == VarClientStr.RECENT_CLAN_CHAT.getIndex() && this.recentChats) { updateRecentChat(client.getVar(VarClientStr.RECENT_CLAN_CHAT)); } @@ -428,20 +440,20 @@ public class ClanChatPlugin extends Plugin { case PRIVATECHAT: case MODPRIVATECHAT: - if (!config.privateMessageIcons()) + if (!this.privateMessageIcons) { return; } break; case PUBLICCHAT: case MODCHAT: - if (!config.publicChatIcons()) + if (!this.publicChatIcons) { return; } break; case FRIENDSCHAT: - if (!config.clanChatIcons()) + if (!this.clanChatIcons) { return; } @@ -515,7 +527,7 @@ public class ClanChatPlugin extends Plugin final int[] intStack = client.getIntStack(); final int size = client.getIntStackSize(); - intStack[size - 1] = config.clanTabChat() ? 1 : 0; + intStack[size - 1] = this.clanTabChat ? 1 : 0; } int getClanAmount() @@ -617,7 +629,10 @@ public class ClanChatPlugin extends Plugin chats.remove(0); } - config.chatsData(Text.toCSV(chats)); + String csvText = Text.toCSV(chats); + + config.chatsData(csvText); + this.chatsData = csvText; } private void removeClanCounter() @@ -628,7 +643,7 @@ public class ClanChatPlugin extends Plugin private void addClanCounter() { - if (!config.showClanCounter() || clanMemberCounter != null || clanMembers.isEmpty()) + if (!this.showClanCounter || clanMemberCounter != null || clanMembers.isEmpty()) { return; } @@ -637,4 +652,18 @@ public class ClanChatPlugin extends Plugin clanMemberCounter = new ClanChatIndicator(image, this); infoBoxManager.addInfoBox(clanMemberCounter); } + + private void updateConfig() + { + this.clanChatIcons = config.clanChatIcons(); + this.recentChats = config.recentChats(); + this.showClanCounter = config.showClanCounter(); + this.chatsData = config.chatsData(); + this.showJoinLeave = config.showJoinLeave(); + this.joinLeaveRank = config.joinLeaveRank(); + this.privateMessageIcons = config.privateMessageIcons(); + this.publicChatIcons = config.publicChatIcons(); + this.clanTabChat = config.clanTabChat(); + this.clanname = config.clanname(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModeMinimapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModeMinimapOverlay.java index be94ee06f3..d0b8e79c9c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModeMinimapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModeMinimapOverlay.java @@ -19,7 +19,7 @@ public class ClanManModeMinimapOverlay extends Overlay private final ClanManModeConfig config; @Inject - private ClanManModeMinimapOverlay(ClanManModeConfig config, ClanManModeService ClanManModeService) + private ClanManModeMinimapOverlay(final ClanManModeConfig config, final ClanManModeService ClanManModeService) { this.config = config; this.ClanManModeService = ClanManModeService; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModeOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModeOverlay.java index 4cfc1cd6ad..e616ad7486 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModeOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModeOverlay.java @@ -20,7 +20,7 @@ public class ClanManModeOverlay extends Overlay private final ClanManModeConfig config; @Inject - private ClanManModeOverlay(ClanManModeConfig config, ClanManModeService ClanManModeService) + private ClanManModeOverlay(final ClanManModeConfig config, final ClanManModeService ClanManModeService) { this.config = config; this.ClanManModeService = ClanManModeService; 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 65f6bbe8a2..dbee4e7291 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 @@ -5,6 +5,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.Player; @@ -27,7 +28,7 @@ import net.runelite.client.ui.overlay.OverlayManager; type = PluginType.PVP, enabledByDefault = false ) - +@Singleton public class ClanManModePlugin extends Plugin { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModeService.java b/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModeService.java index c84072e94e..ca32c5892d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModeService.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModeService.java @@ -20,7 +20,7 @@ public class ClanManModeService private final ClanManModePlugin plugin; @Inject - private ClanManModeService(Client client, ClanManModeConfig config, ClanManModePlugin plugin) + private ClanManModeService(final Client client, final ClanManModeConfig config, final ClanManModePlugin plugin) { this.config = config; this.client = client; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModeTileOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModeTileOverlay.java index 5aea2e108f..8a70eef7c6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModeTileOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/clanmanmode/ClanManModeTileOverlay.java @@ -4,19 +4,21 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Polygon; import javax.inject.Inject; +import javax.inject.Singleton; 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 ClanManModeTileOverlay extends Overlay { private final ClanManModeService ClanManModeService; private final ClanManModeConfig config; @Inject - private ClanManModeTileOverlay(ClanManModeConfig config, ClanManModeService ClanManModeService) + private ClanManModeTileOverlay(final ClanManModeConfig config, final ClanManModeService ClanManModeService) { this.config = config; this.ClanManModeService = ClanManModeService; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollEmoteOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollEmoteOverlay.java index ecaa85b8ba..bf6c3d85d5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollEmoteOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollEmoteOverlay.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.cluescrolls; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetInfo; @@ -36,6 +37,7 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; +@Singleton class ClueScrollEmoteOverlay extends Overlay { private final ClueScrollPlugin plugin; @@ -44,7 +46,7 @@ class ClueScrollEmoteOverlay extends Overlay private boolean hasScrolled; @Inject - private ClueScrollEmoteOverlay(ClueScrollPlugin plugin, Client client) + private ClueScrollEmoteOverlay(final ClueScrollPlugin plugin, final Client client) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollMusicOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollMusicOverlay.java index 2b44290fb5..19e0b5b01e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollMusicOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollMusicOverlay.java @@ -28,6 +28,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Rectangle; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetInfo; @@ -37,6 +38,7 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; +@Singleton class ClueScrollMusicOverlay extends Overlay { private static final Rectangle PADDING = new Rectangle(2, 1, 0, 1); @@ -47,7 +49,7 @@ class ClueScrollMusicOverlay extends Overlay private boolean hasScrolled; @Inject - private ClueScrollMusicOverlay(ClueScrollPlugin plugin, Client client) + private ClueScrollMusicOverlay(final ClueScrollPlugin plugin, final Client client) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollOverlay.java index 0f95a3c940..9347f28de5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollOverlay.java @@ -30,6 +30,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import static net.runelite.api.ItemID.SPADE; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.client.plugins.cluescrolls.clues.ClueScroll; @@ -43,6 +44,7 @@ import net.runelite.client.ui.overlay.components.ComponentConstants; import net.runelite.client.ui.overlay.components.LineComponent; import net.runelite.client.ui.overlay.components.PanelComponent; +@Singleton public class ClueScrollOverlay extends Overlay { private static final ItemRequirement HAS_SPADE = new SingleItemRequirement(SPADE); @@ -53,7 +55,7 @@ public class ClueScrollOverlay extends Overlay private final PanelComponent panelComponent = new PanelComponent(); @Inject - private ClueScrollOverlay(ClueScrollPlugin plugin) + private ClueScrollOverlay(final ClueScrollPlugin plugin) { super(plugin); this.plugin = plugin; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java index 742decdd0d..98498a40fb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollPlugin.java @@ -41,6 +41,7 @@ import java.util.List; import java.util.Objects; import java.util.stream.Stream; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; @@ -108,6 +109,7 @@ import net.runelite.client.util.Text; tags = {"arrow", "hints", "world", "map", "coordinates", "emotes"} ) @Slf4j +@Singleton public class ClueScrollPlugin extends Plugin { private static final Color HIGHLIGHT_BORDER_COLOR = Color.ORANGE; @@ -164,6 +166,8 @@ public class ClueScrollPlugin extends Plugin private final TextComponent textComponent = new TextComponent(); + private boolean displayHintArrows; + @Provides ClueScrollConfig getConfig(ConfigManager configManager) { @@ -179,6 +183,7 @@ public class ClueScrollPlugin extends Plugin @Override protected void startUp() throws Exception { + this.displayHintArrows = config.displayHintArrows(); overlayManager.add(clueScrollOverlay); overlayManager.add(clueScrollEmoteOverlay); overlayManager.add(clueScrollWorldOverlay); @@ -274,7 +279,7 @@ public class ClueScrollPlugin extends Plugin worldMapPointsSet = false; npcsToMark.clear(); - if (config.displayHintArrows()) + if (this.displayHintArrows) { client.clearHintArrow(); } @@ -313,9 +318,13 @@ public class ClueScrollPlugin extends Plugin @Subscribe public void onConfigChanged(ConfigChanged event) { - if (event.getGroup().equals("cluescroll") && !config.displayHintArrows()) + if (event.getGroup().equals("cluescroll")) { - client.clearHintArrow(); + this.displayHintArrows = config.displayHintArrows(); + if (!this.displayHintArrows) + { + client.clearHintArrow(); + } } } @@ -366,7 +375,7 @@ public class ClueScrollPlugin extends Plugin if (location != null) { // Only set the location hint arrow if we do not already have more accurate location - if (config.displayHintArrows() + if (this.displayHintArrows && (client.getHintArrowNpc() == null || !npcsToMark.contains(client.getHintArrowNpc()))) { @@ -455,7 +464,7 @@ public class ClueScrollPlugin extends Plugin worldMapPointsSet = false; npcsToMark.clear(); - if (config.displayHintArrows()) + if (this.displayHintArrows) { client.clearHintArrow(); } @@ -698,7 +707,7 @@ public class ClueScrollPlugin extends Plugin } } - if (!npcsToMark.isEmpty() && config.displayHintArrows()) + if (!npcsToMark.isEmpty() && this.displayHintArrows) { // Always set hint arrow to first seen NPC client.setHintArrow(npcsToMark.get(0)); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollServiceImpl.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollServiceImpl.java index 3dd2d55a33..53887d80c6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollServiceImpl.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollServiceImpl.java @@ -35,7 +35,7 @@ class ClueScrollServiceImpl implements ClueScrollService private final ClueScrollPlugin plugin; @Inject - private ClueScrollServiceImpl(ClueScrollPlugin plugin) + private ClueScrollServiceImpl(final ClueScrollPlugin plugin) { this.plugin = plugin; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldMapPoint.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldMapPoint.java index 45fa1f874c..0ee530285c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldMapPoint.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldMapPoint.java @@ -36,7 +36,7 @@ class ClueScrollWorldMapPoint extends WorldMapPoint private final BufferedImage clueScrollWorldImage; private final Point clueScrollWorldImagePoint; - ClueScrollWorldMapPoint(final WorldPoint worldPoint, ClueScrollPlugin plugin) + ClueScrollWorldMapPoint(final WorldPoint worldPoint, final ClueScrollPlugin plugin) { super(worldPoint, null); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldOverlay.java index d68f06a691..0c4598043b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cluescrolls/ClueScrollWorldOverlay.java @@ -28,11 +28,13 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.client.plugins.cluescrolls.clues.ClueScroll; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; +@Singleton public class ClueScrollWorldOverlay extends Overlay { public static final int IMAGE_Z_OFFSET = 30; @@ -44,7 +46,7 @@ public class ClueScrollWorldOverlay extends Overlay private final ClueScrollPlugin plugin; @Inject - private ClueScrollWorldOverlay(ClueScrollPlugin plugin) + private ClueScrollWorldOverlay(final ClueScrollPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/combatcounter/CombatCounter.java b/runelite-client/src/main/java/net/runelite/client/plugins/combatcounter/CombatCounter.java index 24b14895c9..162aeca40a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/combatcounter/CombatCounter.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/combatcounter/CombatCounter.java @@ -25,6 +25,9 @@ package net.runelite.client.plugins.combatcounter; import com.google.inject.Provides; +import java.awt.Color; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import net.runelite.api.Actor; @@ -35,6 +38,7 @@ import net.runelite.api.NPCDefinition; import net.runelite.api.Player; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.AnimationChanged; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.HitsplatApplied; import net.runelite.api.kit.KitType; @@ -59,7 +63,7 @@ import java.util.Map; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton public class CombatCounter extends Plugin { @@ -79,16 +83,30 @@ public class CombatCounter extends Plugin private CombatCounterConfig config; private boolean instanced = false; - private boolean prevInstance = false; - @Setter - @Getter - private Map counter = new HashMap(); - private long BLOWPIPE_ID = 5061; + @Setter(AccessLevel.PACKAGE) + @Getter(AccessLevel.PACKAGE) + private Map counter = new HashMap<>(); private Map blowpipe = new HashMap<>(); - public Map npcDamageMap = new HashMap(); - public Map playerDamage = new HashMap(); + private Map npcDamageMap = new HashMap<>(); + Map playerDamage = new HashMap<>(); + + @Getter(AccessLevel.PACKAGE) + private boolean showTickCounter; + @Getter(AccessLevel.PACKAGE) + private boolean showDamageCounter; + private boolean resetOnNewInstance; + @Getter(AccessLevel.PACKAGE) + private Color selfColor; + @Getter(AccessLevel.PACKAGE) + private Color totalColor; + @Getter(AccessLevel.PACKAGE) + private Color otherColor; + @Getter(AccessLevel.PACKAGE) + private Color bgColor; + @Getter(AccessLevel.PACKAGE) + private Color titleColor; @Provides CombatCounterConfig provideConfig(ConfigManager configManager) @@ -96,8 +114,6 @@ public class CombatCounter extends Plugin return configManager.getConfig(CombatCounterConfig.class); } - - private Map variables = new HashMap() { { @@ -157,7 +173,7 @@ public class CombatCounter extends Plugin } }; - public List MELEE_ANIMATIONS = new ArrayList() + private List MELEE_ANIMATIONS = new ArrayList() { { this.add(422); // Unarmed Punch, Block @@ -201,7 +217,7 @@ public class CombatCounter extends Plugin } }; - public List RANGE_ANIMATIONS = new ArrayList() + private List RANGE_ANIMATIONS = new ArrayList() { { this.add(7552); // Armadyl Crossbow Accurate, Rapid, Longrange, Special @@ -214,7 +230,7 @@ public class CombatCounter extends Plugin } }; - public List MAGE_ANIMATIONS = new ArrayList() + private List MAGE_ANIMATIONS = new ArrayList() { { this.add(1167); // Trident Accurate, Accurate, Longrange @@ -226,6 +242,8 @@ public class CombatCounter extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(tickOverlay); overlayManager.add(damageOverlay); @@ -252,7 +270,7 @@ public class CombatCounter extends Plugin { Actor actor = event.getActor(); - if (actor != null && actor instanceof Player) + if (actor instanceof Player) { Player p = (Player) actor; String name = actor.getName(); @@ -276,6 +294,7 @@ public class CombatCounter extends Plugin counter.put(name, ticks); counter = sortByValue(counter); + long BLOWPIPE_ID = 5061; if (animation == BLOWPIPE_ID) { this.blowpipe.put(name, -4L); @@ -285,11 +304,11 @@ public class CombatCounter extends Plugin * This part handles the Damage Counter. */ Actor interacting = actor.getInteracting(); - if (interacting != null && interacting instanceof NPC) + if (interacting instanceof NPC) { NPC npc = (NPC) interacting; - List actives = new ArrayList(); + List actives = new ArrayList<>(); actives.add(npc); if (animation == 1979 || animation == 7618) @@ -340,7 +359,7 @@ public class CombatCounter extends Plugin if (delay != -1) { - List ticksToAdd = new ArrayList(); + List ticksToAdd = new ArrayList<>(); ticksToAdd.add(delay); if (canFarcast && delay > 2) @@ -348,7 +367,7 @@ public class CombatCounter extends Plugin ticksToAdd.add(delay - 1); } - /** + /* * Dragon Claw Specials are 2 ticks long. */ if (animation == 7514) @@ -364,7 +383,7 @@ public class CombatCounter extends Plugin for (Integer tick : ticksToAdd) { - List attackers = new ArrayList(); + List attackers = new ArrayList<>(); if (dc.attackers.containsKey(tick)) attackers = dc.attackers.get(tick); @@ -389,9 +408,9 @@ public class CombatCounter extends Plugin @Subscribe public void onGameTick(GameTick event) { - if (config.resetOnNewInstance()) + if (this.resetOnNewInstance) { - prevInstance = instanced; + boolean prevInstance = instanced; instanced = client.isInInstancedRegion(); if (!prevInstance && instanced) { @@ -402,19 +421,19 @@ public class CombatCounter extends Plugin } } - Map visible = new HashMap(); + Map visible = new HashMap<>(); for (Player p : this.client.getPlayers()) { if (p.getName() != null) visible.put(p.getName(), p); } - for (NPC npc : new ArrayList(this.npcDamageMap.keySet())) + for (NPC npc : new ArrayList<>(this.npcDamageMap.keySet())) { NPCDamageCounter counter = this.npcDamageMap.get(npc); Map> attackers = counter.attackers; - for (Integer i : new ArrayList(attackers.keySet())) + for (Integer i : new ArrayList<>(attackers.keySet())) { List p = attackers.get(i); attackers.put(i - 1, p); @@ -455,7 +474,7 @@ public class CombatCounter extends Plugin // this.playerDamage.put(name, count); // } - for (Integer i : new ArrayList(attackers.keySet())) + for (Integer i : new ArrayList<>(attackers.keySet())) if (i <= -1) attackers.remove(i); @@ -465,7 +484,7 @@ public class CombatCounter extends Plugin this.playerDamage = sortByValue(this.playerDamage); - for (String user : new ArrayList(blowpipe.keySet())) + for (String user : new ArrayList<>(blowpipe.keySet())) { if (visible.containsKey(user)) { @@ -481,7 +500,7 @@ public class CombatCounter extends Plugin Player p = visible.get(user); Actor interacting = p.getInteracting(); - if (interacting != null && interacting instanceof NPC) + if (interacting instanceof NPC) { NPC npc = (NPC) interacting; @@ -493,14 +512,14 @@ public class CombatCounter extends Plugin int delay = this.calculateBPDelay(distance); - List counts = new ArrayList(); + List counts = new ArrayList<>(); counts.add(delay); if (delay > 2) counts.add(delay - 1); for (int tick : counts) { - List attackers = new ArrayList(); + List attackers = new ArrayList<>(); if (dc.attackers.containsKey(tick)) attackers = dc.attackers.get(tick); @@ -553,7 +572,7 @@ public class CombatCounter extends Plugin return result; } - public int calculateDistance(Player p, NPC npc) + private int calculateDistance(Player p, NPC npc) { int size = 1; NPCDefinition comp = npc.getTransformedDefinition(); @@ -582,23 +601,44 @@ public class CombatCounter extends Plugin return distance; } - public int calculateBPDelay(double distance) + private int calculateBPDelay(double distance) { return 2 + (int) Math.floor(distance / 6d); } - public int calculateChinDelay(double distance) + private int calculateChinDelay(double distance) { return 2 + (int) Math.floor(distance / 6d); } - public int calculateMageDelay(double distance) + private int calculateMageDelay(double distance) { return 2 + (int) Math.floor((1d + distance) / 3d); } - public int calculateRangedDelay(double distance) + private int calculateRangedDelay(double distance) { return 2 + (int) Math.floor((3d + distance) / 6d); } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("combatcounter")) + { + updateConfig(); + } + } + + private void updateConfig() + { + this.showTickCounter = config.showTickCounter(); + this.showDamageCounter = config.showDamageCounter(); + this.resetOnNewInstance = config.resetOnNewInstance(); + this.selfColor = config.selfColor(); + this.totalColor = config.totalColor(); + this.otherColor = config.otherColor(); + this.bgColor = config.bgColor(); + this.titleColor = config.titleColor(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/combatcounter/CombatOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/combatcounter/CombatOverlay.java index 7f97d6ab42..dd0a2cc25c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/combatcounter/CombatOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/combatcounter/CombatOverlay.java @@ -26,9 +26,9 @@ package net.runelite.client.plugins.combatcounter; import java.awt.Dimension; import java.awt.Graphics2D; -import java.util.HashMap; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.api.Player; @@ -42,17 +42,16 @@ import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; import net.runelite.client.util.ColorUtil; +@Singleton class CombatOverlay extends Overlay { private final Client client; private final CombatCounter plugin; private final PanelComponent panelComponent = new PanelComponent(); - private final CombatCounterConfig config; - private HashMap ticks = new HashMap<>(); @Inject - public CombatOverlay(Client client, CombatCounter plugin, CombatCounterConfig config) + public CombatOverlay(final Client client, final CombatCounter plugin) { super(plugin); @@ -60,7 +59,6 @@ class CombatOverlay extends Overlay setPosition(OverlayPosition.DETACHED); setPosition(OverlayPosition.BOTTOM_RIGHT); - this.config = config; this.client = client; this.plugin = plugin; @@ -70,7 +68,7 @@ class CombatOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (config.showTickCounter()) + if (plugin.isShowTickCounter()) { panelComponent.getChildren().clear(); @@ -79,8 +77,8 @@ class CombatOverlay extends Overlay { return null; } - panelComponent.setBackgroundColor(config.bgColor()); - panelComponent.getChildren().add(TitleComponent.builder().text("Tick Counter").color(config.titleColor()).build()); + panelComponent.setBackgroundColor(plugin.getBgColor()); + panelComponent.getChildren().add(TitleComponent.builder().text("Tick Counter").color(plugin.getTitleColor()).build()); int total = 0; TableComponent tableComponent = new TableComponent(); @@ -102,22 +100,22 @@ class CombatOverlay extends Overlay { if (client.getLocalPlayer().getName().contains(name)) { - tableComponent.addRow(ColorUtil.prependColorTag(name, config.selfColor()), ColorUtil.prependColorTag(Long.toString(map.get(name)), config.selfColor())); + tableComponent.addRow(ColorUtil.prependColorTag(name, plugin.getSelfColor()), ColorUtil.prependColorTag(Long.toString(map.get(name)), plugin.getSelfColor())); } else { - tableComponent.addRow(ColorUtil.prependColorTag(name, config.otherColor()), ColorUtil.prependColorTag(Long.toString(map.get(name)), config.otherColor())); + tableComponent.addRow(ColorUtil.prependColorTag(name, plugin.getOtherColor()), ColorUtil.prependColorTag(Long.toString(map.get(name)), plugin.getOtherColor())); } total += map.get(name); } if (!map.containsKey(local.getName())) { - tableComponent.addRow(ColorUtil.prependColorTag(local.getName(), config.selfColor()), ColorUtil.prependColorTag("0", config.selfColor())); + tableComponent.addRow(ColorUtil.prependColorTag(local.getName(), plugin.getSelfColor()), ColorUtil.prependColorTag("0", plugin.getSelfColor())); } } - tableComponent.addRow(ColorUtil.prependColorTag("Total:", config.totalColor()), ColorUtil.prependColorTag(String.valueOf(total), config.totalColor())); + tableComponent.addRow(ColorUtil.prependColorTag("Total:", plugin.getTotalColor()), ColorUtil.prependColorTag(String.valueOf(total), plugin.getTotalColor())); if (!tableComponent.isEmpty()) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/combatcounter/DamageOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/combatcounter/DamageOverlay.java index 998246ccf2..0e2cd5109e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/combatcounter/DamageOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/combatcounter/DamageOverlay.java @@ -28,6 +28,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.api.Player; @@ -41,6 +42,7 @@ import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; import net.runelite.client.util.ColorUtil; +@Singleton class DamageOverlay extends Overlay { @@ -48,12 +50,10 @@ class DamageOverlay extends Overlay private final CombatCounter plugin; - private final CombatCounterConfig config; - private final PanelComponent panelComponent = new PanelComponent(); @Inject - public DamageOverlay(Client client, CombatCounter plugin, CombatCounterConfig config) + public DamageOverlay(final Client client, final CombatCounter plugin) { super(plugin); @@ -61,7 +61,6 @@ class DamageOverlay extends Overlay setPosition(OverlayPosition.DETACHED); setPosition(OverlayPosition.BOTTOM_RIGHT); - this.config = config; this.client = client; this.plugin = plugin; @@ -71,7 +70,7 @@ class DamageOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (config.showDamageCounter()) + if (plugin.isShowDamageCounter()) { panelComponent.getChildren().clear(); @@ -80,8 +79,8 @@ class DamageOverlay extends Overlay { return null; } - panelComponent.setBackgroundColor(config.bgColor()); - panelComponent.getChildren().add(TitleComponent.builder().text("Damage Counter").color(config.titleColor()).build()); + panelComponent.setBackgroundColor(plugin.getBgColor()); + panelComponent.getChildren().add(TitleComponent.builder().text("Damage Counter").color(plugin.getTitleColor()).build()); TableComponent tableComponent = new TableComponent(); tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT); @@ -103,17 +102,17 @@ class DamageOverlay extends Overlay String val = String.format("%.1f", map.get(name)); if (client.getLocalPlayer().getName().contains(name)) { - tableComponent.addRow(ColorUtil.prependColorTag(name, config.selfColor()), ColorUtil.prependColorTag(val, config.selfColor())); + tableComponent.addRow(ColorUtil.prependColorTag(name, plugin.getSelfColor()), ColorUtil.prependColorTag(val, plugin.getSelfColor())); } else { - tableComponent.addRow(ColorUtil.prependColorTag(name, config.otherColor()), ColorUtil.prependColorTag(val, config.otherColor())); + tableComponent.addRow(ColorUtil.prependColorTag(name, plugin.getOtherColor()), ColorUtil.prependColorTag(val, plugin.getOtherColor())); } } if (!map.containsKey(local.getName())) { - tableComponent.addRow(ColorUtil.prependColorTag(local.getName(), config.selfColor()), ColorUtil.prependColorTag("0", config.selfColor())); + tableComponent.addRow(ColorUtil.prependColorTag(local.getName(), plugin.getSelfColor()), ColorUtil.prependColorTag("0", plugin.getSelfColor())); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/combatcounter/NPCDamageCounter.java b/runelite-client/src/main/java/net/runelite/client/plugins/combatcounter/NPCDamageCounter.java index ef55777b59..2c5a848c89 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/combatcounter/NPCDamageCounter.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/combatcounter/NPCDamageCounter.java @@ -4,17 +4,19 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.TreeMap; +import javax.inject.Singleton; -public class NPCDamageCounter +@Singleton +class NPCDamageCounter { - public Map> attackers; + Map> attackers; - public List damage; + List damage; - public NPCDamageCounter() + NPCDamageCounter() { - this.attackers = new TreeMap>(); - this.damage = new ArrayList(); + this.attackers = new TreeMap<>(); + this.damage = new ArrayList<>(); } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/combatlevel/CombatLevelOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/combatlevel/CombatLevelOverlay.java index 3083e02cac..92c567aab9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/combatlevel/CombatLevelOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/combatlevel/CombatLevelOverlay.java @@ -29,6 +29,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Rectangle; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Experience; import net.runelite.api.Skill; @@ -39,19 +40,20 @@ import net.runelite.client.ui.overlay.tooltip.Tooltip; import net.runelite.client.ui.overlay.tooltip.TooltipManager; import net.runelite.client.util.ColorUtil; +@Singleton class CombatLevelOverlay extends Overlay { private static final Color COMBAT_LEVEL_COLOUR = new Color(0xff981f); private final Client client; - private final CombatLevelConfig config; + private final CombatLevelPlugin plugin; private final TooltipManager tooltipManager; @Inject - private CombatLevelOverlay(Client client, CombatLevelConfig config, TooltipManager tooltipManager) + private CombatLevelOverlay(final Client client, final CombatLevelPlugin plugin, final TooltipManager tooltipManager) { this.client = client; - this.config = config; + this.plugin = plugin; this.tooltipManager = tooltipManager; } @@ -59,7 +61,7 @@ class CombatLevelOverlay extends Overlay public Dimension render(Graphics2D graphics) { Widget combatLevelWidget = client.getWidget(WidgetInfo.COMBAT_LEVEL); - if (!config.showLevelsUntil() + if (!plugin.isShowLevelsUntil() || client.getLocalPlayer().getCombatLevel() == Experience.MAX_COMBAT_LEVEL || combatLevelWidget == null || combatLevelWidget.isHidden()) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/combatlevel/CombatLevelPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/combatlevel/CombatLevelPlugin.java index e466e939f4..a2db038077 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/combatlevel/CombatLevelPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/combatlevel/CombatLevelPlugin.java @@ -30,6 +30,9 @@ import java.text.DecimalFormat; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.Experience; import net.runelite.api.GameState; @@ -52,6 +55,7 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Show a more accurate combat level in Combat Options panel and other combat level functions", tags = {"wilderness", "attack", "range"} ) +@Singleton public class CombatLevelPlugin extends Plugin { private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.###"); @@ -80,6 +84,10 @@ public class CombatLevelPlugin extends Plugin @Inject private OverlayManager overlayManager; + @Getter(AccessLevel.PACKAGE) + private boolean showLevelsUntil; + private boolean wildernessAttackLevelRange; + @Provides CombatLevelConfig provideConfig(ConfigManager configManager) { @@ -89,9 +97,11 @@ public class CombatLevelPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(overlay); - if (config.wildernessAttackLevelRange()) + if (this.wildernessAttackLevelRange) { appendAttackLevelRangeText(); } @@ -151,7 +161,9 @@ public class CombatLevelPlugin extends Plugin return; } - if (config.wildernessAttackLevelRange()) + updateConfig(); + + if (this.wildernessAttackLevelRange) { appendAttackLevelRangeText(); } @@ -164,7 +176,7 @@ public class CombatLevelPlugin extends Plugin @Subscribe public void onScriptCallbackEvent(ScriptCallbackEvent event) { - if (config.wildernessAttackLevelRange() + if (this.wildernessAttackLevelRange && "wildernessWidgetTextSet".equals(event.getEventName())) { appendAttackLevelRangeText(); @@ -241,4 +253,10 @@ public class CombatLevelPlugin extends Plugin { return Math.max(MIN_COMBAT_LEVEL, combatLevel - wildernessLevel) + "-" + Math.min(Experience.MAX_COMBAT_LEVEL, combatLevel + wildernessLevel); } + + private void updateConfig() + { + this.showLevelsUntil = config.showLevelsUntil(); + this.wildernessAttackLevelRange = config.showLevelsUntil(); + } } 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 b80d912bc4..4d569f827c 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 @@ -50,6 +50,7 @@ import java.util.Comparator; import java.util.List; import java.util.concurrent.ScheduledExecutorService; import java.util.stream.Collectors; +import javax.inject.Singleton; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JButton; @@ -113,6 +114,7 @@ import net.runelite.client.util.Text; import org.apache.commons.lang3.StringUtils; @Slf4j +@Singleton public class ConfigPanel extends PluginPanel { private static final int SPINNER_FIELD_WIDTH = 6; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPlugin.java index 2004675a05..a4520ebbd1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/ConfigPlugin.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.config; import java.awt.image.BufferedImage; import java.util.concurrent.ScheduledExecutorService; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.SwingUtilities; import net.runelite.api.MenuAction; import net.runelite.client.config.ChatColorConfig; @@ -39,7 +40,6 @@ import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginManager; import net.runelite.client.ui.ClientToolbar; -import net.runelite.client.ui.ClientUI; import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayMenuEntry; @@ -50,10 +50,9 @@ import net.runelite.client.util.ImageUtil; loadWhenOutdated = true, hidden = true // prevent users from disabling ) +@Singleton public class ConfigPlugin extends Plugin { - @Inject - private ClientUI clientUI; @Inject private ClientToolbar clientToolbar; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/config/HotkeyButton.java b/runelite-client/src/main/java/net/runelite/client/plugins/config/HotkeyButton.java index 585ade5ea6..98fc840a7c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/config/HotkeyButton.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/config/HotkeyButton.java @@ -26,17 +26,20 @@ package net.runelite.client.plugins.config; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; +import javax.inject.Singleton; import javax.swing.JButton; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.client.config.Keybind; import net.runelite.client.config.ModifierlessKeybind; +@Singleton public class HotkeyButton extends JButton { - @Getter + @Getter(AccessLevel.PACKAGE) private Keybind value; - public HotkeyButton(Keybind value, boolean modifierless) + HotkeyButton(Keybind value, boolean modifierless) { setValue(value); addActionListener(e -> 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 3cd10af230..22065fc7df 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 @@ -32,6 +32,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.annotation.Nullable; +import javax.inject.Singleton; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; @@ -47,6 +48,7 @@ import net.runelite.client.ui.components.IconButton; import net.runelite.client.util.ImageUtil; import org.apache.commons.text.similarity.JaroWinklerDistance; +@Singleton public class PluginListItem extends JPanel { private static final JaroWinklerDistance DISTANCE = new JaroWinklerDistance(); @@ -74,10 +76,10 @@ public class PluginListItem extends JPanel @Getter(AccessLevel.PACKAGE) public final ConfigDescriptor configDescriptor; - @Getter + @Getter(AccessLevel.PUBLIC) private final String name; - @Getter + @Getter(AccessLevel.PUBLIC) private final String description; private final List keywords = new ArrayList<>(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cooking/CookingOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/cooking/CookingOverlay.java index a7bad8d813..7b71bfad11 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cooking/CookingOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cooking/CookingOverlay.java @@ -32,6 +32,7 @@ import java.text.DecimalFormat; import java.time.Instant; import java.time.Duration; import javax.inject.Inject; +import javax.inject.Singleton; import static net.runelite.api.AnimationID.COOKING_FIRE; import static net.runelite.api.AnimationID.COOKING_RANGE; import net.runelite.api.Client; @@ -47,6 +48,7 @@ import net.runelite.client.ui.overlay.components.TitleComponent; import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; +@Singleton class CookingOverlay extends Overlay { private static final int COOK_TIMEOUT = 3; @@ -58,7 +60,7 @@ class CookingOverlay extends Overlay private final PanelComponent panelComponent = new PanelComponent(); @Inject - private CookingOverlay(Client client, CookingPlugin plugin, XpTrackerService xpTrackerService) + private CookingOverlay(final Client client, final CookingPlugin plugin, final XpTrackerService xpTrackerService) { super(plugin); setPosition(OverlayPosition.TOP_LEFT); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cooking/CookingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/cooking/CookingPlugin.java index 976d81c4a0..96be647e3f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cooking/CookingPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cooking/CookingPlugin.java @@ -30,14 +30,17 @@ import java.time.Duration; import java.time.Instant; import java.util.Optional; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; +import lombok.Setter; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.GraphicID; import net.runelite.api.ItemID; import net.runelite.api.Player; import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.SpotAnimationChanged; import net.runelite.client.config.ConfigManager; @@ -55,6 +58,7 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager; description = "Show cooking statistics", tags = {"overlay", "skilling", "cook"} ) +@Singleton @PluginDependency(XpTrackerPlugin.class) public class CookingPlugin extends Plugin { @@ -79,6 +83,10 @@ public class CookingPlugin extends Plugin @Getter(AccessLevel.PACKAGE) private CookingSession session; + private int statTimeout; + @Setter(AccessLevel.PACKAGE) + private boolean fermentTimer; + @Provides CookingConfig getConfig(ConfigManager configManager) { @@ -88,6 +96,7 @@ public class CookingPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); session = null; overlayManager.add(overlay); } @@ -103,12 +112,12 @@ public class CookingPlugin extends Plugin @Subscribe public void onGameTick(GameTick gameTick) { - if (session == null || config.statTimeout() == 0) + if (session == null || this.statTimeout == 0) { return; } - Duration statTimeout = Duration.ofMinutes(config.statTimeout()); + Duration statTimeout = Duration.ofMinutes(this.statTimeout); Duration sinceCut = Duration.between(session.getLastCookingAction(), Instant.now()); if (sinceCut.compareTo(statTimeout) >= 0) @@ -127,7 +136,7 @@ public class CookingPlugin extends Plugin return; } - if (player.getSpotAnimation() == GraphicID.WINE_MAKE && config.fermentTimer()) + if (player.getSpotAnimation() == GraphicID.WINE_MAKE && this.fermentTimer) { Optional fermentTimerOpt = infoBoxManager.getInfoBoxes().stream() .filter(FermentTimer.class::isInstance) @@ -184,4 +193,19 @@ public class CookingPlugin extends Plugin session.increaseBurnAmount(); } } + + @Subscribe + public void onConfigChanged(ConfigChanged configChanged) + { + if (configChanged.getGroup().equals("cooking")) + { + updateConfig(); + } + } + + private void updateConfig() + { + this.statTimeout = config.statTimeout(); + this.fermentTimer = config.fermentTimer(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cooking/CookingSession.java b/runelite-client/src/main/java/net/runelite/client/plugins/cooking/CookingSession.java index 292e4a3584..14ad6a2722 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cooking/CookingSession.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cooking/CookingSession.java @@ -26,9 +26,11 @@ package net.runelite.client.plugins.cooking; import java.time.Instant; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; +@Singleton class CookingSession { @Getter(AccessLevel.PACKAGE) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/cooking/FermentTimer.java b/runelite-client/src/main/java/net/runelite/client/plugins/cooking/FermentTimer.java index 5312414ad1..36ef995fa8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/cooking/FermentTimer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/cooking/FermentTimer.java @@ -28,9 +28,11 @@ import java.awt.Color; import java.awt.Image; import java.time.Duration; import java.time.Instant; +import javax.inject.Singleton; import net.runelite.client.plugins.Plugin; import net.runelite.client.ui.overlay.infobox.InfoBox; +@Singleton final class FermentTimer extends InfoBox { private static final Duration FERMENT_TIME = Duration.ofMillis(13_800); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/corp/CoreOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/corp/CoreOverlay.java index 29c7dff16a..51eb6a8d88 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/corp/CoreOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/corp/CoreOverlay.java @@ -29,24 +29,23 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Polygon; import javax.inject.Inject; -import net.runelite.api.Client; +import javax.inject.Singleton; import net.runelite.api.NPC; 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; +@Singleton class CoreOverlay extends Overlay { - private final Client client; private final CorpPlugin corpPlugin; @Inject - private CoreOverlay(Client client, CorpPlugin corpPlugin) + private CoreOverlay(final CorpPlugin corpPlugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); - this.client = client; this.corpPlugin = corpPlugin; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpDamageOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpDamageOverlay.java index f76feec525..132075580a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpDamageOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpDamageOverlay.java @@ -29,6 +29,7 @@ import java.awt.Dimension; import java.awt.FontMetrics; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.api.NPC; @@ -48,16 +49,16 @@ import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; import net.runelite.client.util.ColorUtil; +@Singleton class CorpDamageOverlay extends Overlay { private final Client client; private final CorpPlugin corpPlugin; - private final CorpConfig config; private final PanelComponent panelComponent = new PanelComponent(); @Inject - private CorpDamageOverlay(Client client, CorpPlugin corpPlugin, CorpConfig config) + private CorpDamageOverlay(final Client client, final CorpPlugin corpPlugin) { super(corpPlugin); setPosition(OverlayPosition.TOP_LEFT); @@ -65,7 +66,6 @@ class CorpDamageOverlay extends Overlay setPriority(OverlayPriority.LOW); this.client = client; this.corpPlugin = corpPlugin; - this.config = config; getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Corp overlay")); } @@ -122,7 +122,7 @@ class CorpDamageOverlay extends Overlay } } - if (config.showDamage()) + if (corpPlugin.isShowDamage()) { tableComponent.addRow("Your damage", ColorUtil.prependColorTag(Integer.toString(myDamage), damageForKill > 0 && myDamage >= damageForKill ? Color.GREEN : Color.RED)); tableComponent.addRow("Total damage:", Integer.toString(totalDamage)); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpPlugin.java index 627c9091e8..d4c815f7eb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/corp/CorpPlugin.java @@ -41,6 +41,7 @@ import net.runelite.api.MenuEntry; import net.runelite.api.NPC; import net.runelite.api.NpcID; import net.runelite.api.Varbits; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.HitsplatApplied; import net.runelite.api.events.InteractingChanged; @@ -101,6 +102,10 @@ public class CorpPlugin extends Plugin @Inject private CorpConfig config; + private boolean leftClickCore; + @Getter(AccessLevel.PACKAGE) + private boolean showDamage; + @Provides CorpConfig getConfig(ConfigManager configManager) { @@ -110,6 +115,8 @@ public class CorpPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(corpOverlay); overlayManager.add(coreOverlay); } @@ -229,7 +236,7 @@ public class CorpPlugin extends Plugin public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) { if (menuEntryAdded.getType() != NPC_SECTION_ACTION - || !config.leftClickCore() || !menuEntryAdded.getOption().equals(ATTACK)) + || !this.leftClickCore || !menuEntryAdded.getOption().equals(ATTACK)) { return; } @@ -248,4 +255,19 @@ public class CorpPlugin extends Plugin menuEntry.setType(NPC_SECTION_ACTION + MENU_ACTION_DEPRIORITIZE_OFFSET); client.setMenuEntries(menuEntries); } + + @Subscribe + public void onConfigChanged(ConfigChanged configChanged) + { + if (configChanged.getGroup().equals("corp")) + { + updateConfig(); + } + } + + private void updateConfig() + { + this.leftClickCore = config.leftClickCore(); + this.showDamage = config.showDamage(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxInfoBox.java b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxInfoBox.java index 55edc43f39..e69be13521 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxInfoBox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxInfoBox.java @@ -32,6 +32,7 @@ import java.awt.Image; import java.awt.Rectangle; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.NpcID; import net.runelite.api.SpriteID; @@ -47,21 +48,20 @@ import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; import net.runelite.client.util.ColorUtil; +@Singleton public class CoxInfoBox extends Overlay { private static final Color NOT_ACTIVATED_BACKGROUND_COLOR = new Color(150, 0, 0, 150); private final CoxPlugin plugin; - private final CoxConfig config; private final Client client; private final SpriteManager spriteManager; private final PanelComponent prayAgainstPanel = new PanelComponent(); private final PanelComponent panelComponent = new PanelComponent(); @Inject - CoxInfoBox(CoxPlugin plugin, CoxConfig config, Client client, SpriteManager spriteManager) + CoxInfoBox(CoxPlugin plugin, Client client, SpriteManager spriteManager) { this.plugin = plugin; - this.config = config; this.client = client; this.spriteManager = spriteManager; setPosition(OverlayPosition.BOTTOM_RIGHT); @@ -79,7 +79,7 @@ public class CoxInfoBox extends Overlay final PrayAgainst prayAgainst = plugin.getPrayAgainstOlm(); - if (plugin.getPrayAgainstOlm() == null && !config.prayAgainstOlm()) + if (plugin.getPrayAgainstOlm() == null && !plugin.isConfigPrayAgainstOlm()) { return null; } @@ -105,7 +105,7 @@ public class CoxInfoBox extends Overlay plugin.setPrayAgainstOlm(null); } - if (config.vangHealth() && plugin.getVanguards() > 0) + if (plugin.isVangHealth() && plugin.getVanguards() > 0) { panelComponent.getChildren().add(TitleComponent.builder() .text("Vanguards") diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxOverlay.java index 4218f092c6..00d60e94ee 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxOverlay.java @@ -31,9 +31,9 @@ import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Polygon; -import java.util.Iterator; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Actor; import net.runelite.api.Client; import net.runelite.api.NPC; @@ -50,18 +50,17 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton public class CoxOverlay extends Overlay { private final Client client; private final CoxPlugin plugin; - private final CoxConfig config; @Inject - private CoxOverlay(Client client, CoxPlugin plugin, CoxConfig config) + private CoxOverlay(final Client client, final CoxPlugin plugin) { this.client = client; this.plugin = plugin; - this.config = config; setPosition(OverlayPosition.DYNAMIC); setPriority(OverlayPriority.HIGH); setLayer(OverlayLayer.ABOVE_SCENE); @@ -72,13 +71,13 @@ public class CoxOverlay extends Overlay { for (WorldPoint point : plugin.getOlm_Heal()) { - drawTile(graphics, point, config.tpColor(), 2, 150, 50); + drawTile(graphics, point, plugin.getTpColor(), 2, 150, 50); } for (WorldPoint point : plugin.getOlm_TP()) { client.setHintArrow(point); - drawTile(graphics, point, config.tpColor(), 2, 150, 50); + drawTile(graphics, point, plugin.getTpColor(), 2, 150, 50); } if (plugin.inRaid()) @@ -96,14 +95,14 @@ public class CoxOverlay extends Overlay case NpcID.TEKTON_7545: case NpcID.TEKTON_ENRAGED: case NpcID.TEKTON_ENRAGED_7544: - if (config.tekton()) + if (plugin.isTekton()) { hitSquares = getHitSquares(npcs.getNpc().getWorldLocation(), npcs.getNpcSize(), 1, false); for (WorldPoint p : hitSquares) { - drawTile(graphics, p, config.tektonColor(), 0, 0, 50); + drawTile(graphics, p, plugin.getTektonColor(), 0, 0, 50); } - if (config.tektonTickCounter()) + if (plugin.isTektonTickCounter()) { ticksLeft = npcs.getTicksUntilAttack(); int attackTicksleft = plugin.getTektonAttackTicks(); @@ -119,10 +118,10 @@ public class CoxOverlay extends Overlay } final String ticksLeftStr = String.valueOf(ticksLeft); Point canvasPoint = npcs.getNpc().getCanvasTextLocation(graphics, ticksLeftStr, 0); - renderTextLocation(graphics, ticksLeftStr, config.textSize(), config.fontStyle().getFont(), color, canvasPoint); + renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), color, canvasPoint); } } - if (config.tektonTickCounter()) + if (plugin.isTektonTickCounter()) { final int attackTicksleft = plugin.getTektonAttackTicks(); String attacksLeftStr; @@ -143,7 +142,7 @@ public class CoxOverlay extends Overlay if (npcs.getNpc() != null) { Point canvasPoint = npcs.getNpc().getCanvasTextLocation(graphics, attacksLeftStr, 0); - renderTextLocationAbove(graphics, attacksLeftStr, config.textSize(), config.fontStyle().getFont(), attackcolor, canvasPoint); + renderTextLocationAbove(graphics, attacksLeftStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), attackcolor, canvasPoint); } } } @@ -152,12 +151,12 @@ public class CoxOverlay extends Overlay case NpcID.MUTTADILE: case NpcID.MUTTADILE_7562: case NpcID.MUTTADILE_7563: - if (config.muttadile()) + if (plugin.isMuttadile()) { hitSquares = getHitSquares(npcs.getNpc().getWorldLocation(), npcs.getNpcSize(), 1, false); for (WorldPoint p : hitSquares) { - drawTile(graphics, p, config.muttaColor(), 0, 0, 50); + drawTile(graphics, p, plugin.getMuttaColor(), 0, 0, 50); } } break; @@ -165,15 +164,15 @@ public class CoxOverlay extends Overlay case NpcID.GUARDIAN_7570: case NpcID.GUARDIAN_7571: case NpcID.GUARDIAN_7572: - if (config.guardians()) + if (plugin.isGuardians()) { hitSquares = getHitSquares(npcs.getNpc().getWorldLocation(), npcs.getNpcSize(), 2, true); for (WorldPoint p : hitSquares) { - drawTile(graphics, p, config.guardColor(), 0, 0, 50); + drawTile(graphics, p, plugin.getGuardColor(), 0, 0, 50); } } - if (config.guardinTickCounter()) + if (plugin.isGuardinTickCounter()) { ticksLeft = npcs.getTicksUntilAttack(); if (ticksLeft > 0) @@ -188,7 +187,7 @@ public class CoxOverlay extends Overlay } final String ticksLeftStr = String.valueOf(ticksLeft); Point canvasPoint = npcs.getNpc().getCanvasTextLocation(graphics, ticksLeftStr, 0); - renderTextLocation(graphics, ticksLeftStr, config.textSize(), config.fontStyle().getFont(), color, canvasPoint); + renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), color, canvasPoint); } } break; @@ -196,7 +195,7 @@ public class CoxOverlay extends Overlay case NpcID.VANGUARD_7527: case NpcID.VANGUARD_7528: case NpcID.VANGUARD_7529: - if (config.vangHighlight()) + if (plugin.isVangHighlight()) { OverlayUtil.renderPolygon(graphics, npcs.getNpc().getConvexHull(), npcs.getAttackStyle().getColor()); } @@ -210,10 +209,10 @@ public class CoxOverlay extends Overlay NPC olmHand = plugin.getHand(); final String tickStr = String.valueOf(tick); Point canvasPoint = olmHand.getCanvasTextLocation(graphics, tickStr, 50); - renderTextLocation(graphics, tickStr, config.textSize(), config.fontStyle().getFont(), Color.GRAY, canvasPoint); + renderTextLocation(graphics, tickStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.GRAY, canvasPoint); } - if (config.timers()) + if (plugin.isTimers()) { if (plugin.getBurnTarget().size() > 0) { @@ -221,7 +220,7 @@ public class CoxOverlay extends Overlay { final int ticksLeft = plugin.getBurnTicks(); String ticksLeftStr = String.valueOf(ticksLeft); - Color tickcolor = new Color(255, 255, 255, 255); + Color tickcolor; if (ticksLeft >= 0) { if (ticksLeft == 34 || @@ -243,7 +242,7 @@ public class CoxOverlay extends Overlay tickcolor = new Color(255, 255, 255, 255); } Point canvasPoint = actor.getCanvasTextLocation(graphics, ticksLeftStr, 0); - renderTextLocation(graphics, ticksLeftStr, config.textSize(), config.fontStyle().getFont(), tickcolor, canvasPoint); + renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), tickcolor, canvasPoint); } } } @@ -251,9 +250,9 @@ public class CoxOverlay extends Overlay if (plugin.getAcidTarget() != null) { Actor actor = plugin.getAcidTarget(); - renderActorOverlay(graphics, actor, config.acidColor(), 2, 100, 10); + renderActorOverlay(graphics, actor, plugin.getAcidColor(), 2, 100, 10); final int ticksLeft = plugin.getAcidTicks(); - Color tickcolor = new Color(255, 255, 255, 255); + Color tickcolor; if (ticksLeft > 0) { if (ticksLeft > 1) @@ -266,12 +265,12 @@ public class CoxOverlay extends Overlay } final String ticksLeftStr = String.valueOf(ticksLeft); Point canvasPoint = actor.getCanvasTextLocation(graphics, ticksLeftStr, 0); - renderTextLocation(graphics, ticksLeftStr, config.textSize(), config.fontStyle().getFont(), tickcolor, canvasPoint); + renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), tickcolor, canvasPoint); } } } - if (config.tpOverlay()) + if (plugin.isTpOverlay()) { if (plugin.getTeleportTarget() != null) { @@ -283,7 +282,7 @@ public class CoxOverlay extends Overlay { NPC boss = plugin.getOlm_NPC(); - if (config.olmTick()) + if (plugin.isOlmTick()) { if (boss != null) { @@ -329,7 +328,7 @@ public class CoxOverlay extends Overlay } final String combinedStr = cycleStr + ":" + tickStr; Point canvasPoint = boss.getCanvasTextLocation(graphics, combinedStr, 130); - renderTextLocation(graphics, combinedStr, config.textSize(), config.fontStyle().getFont(), Color.WHITE, canvasPoint); + renderTextLocation(graphics, combinedStr, plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.WHITE, canvasPoint); } } } @@ -412,7 +411,7 @@ public class CoxOverlay extends Overlay final Point canvasCenterPoint_shadow = new Point( canvasPoint.getX() + 1, canvasPoint.getY() + 1); - if (config.shadows()) + if (plugin.isShadows()) { OverlayUtil.renderTextLocation(graphics, canvasCenterPoint_shadow, txtString, Color.BLACK); } @@ -431,7 +430,7 @@ public class CoxOverlay extends Overlay final Point canvasCenterPoint_shadow = new Point( canvasPoint.getX() + 1, canvasPoint.getY() + 21); - if (config.shadows()) + if (plugin.isShadows()) { OverlayUtil.renderTextLocation(graphics, canvasCenterPoint_shadow, txtString, Color.BLACK); } @@ -445,14 +444,7 @@ public class CoxOverlay extends Overlay 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)) - { - it.remove(); - } - } + big.removeIf(little::contains); } return big; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxPlugin.java index f5f08b1199..9dc12d080f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxPlugin.java @@ -28,6 +28,7 @@ package net.runelite.client.plugins.coxhelper; import com.google.inject.Provides; +import java.awt.Color; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -54,6 +55,7 @@ import net.runelite.api.ProjectileID; import net.runelite.api.Varbits; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcSpawned; @@ -154,6 +156,47 @@ public class CoxPlugin extends Plugin @Getter(AccessLevel.PACKAGE) private Map npcContainer = new HashMap<>(); + @Getter(AccessLevel.PACKAGE) + private boolean muttadile; + @Getter(AccessLevel.PACKAGE) + private boolean tekton; + @Getter(AccessLevel.PACKAGE) + private boolean tektonTickCounter; + @Getter(AccessLevel.PACKAGE) + private boolean guardians; + @Getter(AccessLevel.PACKAGE) + private boolean guardinTickCounter; + @Getter(AccessLevel.PACKAGE) + private boolean vangHighlight; + @Getter(AccessLevel.PACKAGE) + private boolean vangHealth; + @Getter(AccessLevel.PACKAGE) + private boolean configPrayAgainstOlm; + @Getter(AccessLevel.PACKAGE) + private boolean timers; + @Getter(AccessLevel.PACKAGE) + private boolean tpOverlay; + @Getter(AccessLevel.PACKAGE) + private boolean olmTick; + @Getter(AccessLevel.PACKAGE) + private Color muttaColor; + @Getter(AccessLevel.PACKAGE) + private Color guardColor; + @Getter(AccessLevel.PACKAGE) + private Color tektonColor; + @Getter(AccessLevel.PACKAGE) + private Color burnColor; + @Getter(AccessLevel.PACKAGE) + private Color acidColor; + @Getter(AccessLevel.PACKAGE) + private Color tpColor; + @Getter(AccessLevel.PACKAGE) + private CoxConfig.FontStyle fontStyle; + @Getter(AccessLevel.PACKAGE) + private int textSize; + @Getter(AccessLevel.PACKAGE) + private boolean shadows; + @Provides CoxConfig getConfig(ConfigManager configManager) { @@ -163,6 +206,8 @@ public class CoxPlugin extends Plugin @Override protected void startUp() { + updateConfig(); + overlayManager.add(coxOverlay); overlayManager.add(coxInfoBox); HandCripple = false; @@ -650,4 +695,37 @@ public class CoxPlugin extends Plugin { return client.getVar(Varbits.IN_RAID) == 1; } + + @Subscribe + public void onConfigChanged(ConfigChanged configChanged) + { + if (configChanged.getGroup().equals("Cox")) + { + updateConfig(); + } + } + + private void updateConfig() + { + this.muttadile = config.muttadile(); + this.tekton = config.tekton(); + this.tektonTickCounter = config.tektonTickCounter(); + this.guardians = config.guardians(); + this.guardinTickCounter = config.guardinTickCounter(); + this.vangHighlight = config.vangHighlight(); + this.vangHealth = config.vangHealth(); + this.configPrayAgainstOlm = config.prayAgainstOlm(); + this.timers = config.timers(); + this.tpOverlay = config.tpOverlay(); + this.olmTick = config.olmTick(); + this.muttaColor = config.muttaColor(); + this.guardColor = config.guardColor(); + this.tektonColor = config.tektonColor(); + this.burnColor = config.burnColor(); + this.acidColor = config.acidColor(); + this.tpColor = config.tpColor(); + this.fontStyle = config.fontStyle(); + this.textSize = config.textSize(); + this.shadows = config.shadows(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/NPCContainer.java b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/NPCContainer.java index de33254a5d..6265025058 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/NPCContainer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/NPCContainer.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.coxhelper; import java.awt.Color; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; @@ -36,40 +37,40 @@ import net.runelite.api.NPCDefinition; class NPCContainer { - @Getter + @Getter(AccessLevel.PACKAGE) private NPC npc; - @Getter + @Getter(AccessLevel.PACKAGE) private int npcIndex; - @Getter + @Getter(AccessLevel.PACKAGE) private String npcName; - @Getter + @Getter(AccessLevel.PACKAGE) private int npcSize; - @Setter - @Getter + @Setter(AccessLevel.PACKAGE) + @Getter(AccessLevel.PACKAGE) private int ticksUntilAttack; - @Setter - @Getter + @Setter(AccessLevel.PACKAGE) + @Getter(AccessLevel.PACKAGE) private int intermissionPeriod; - @Setter - @Getter + @Setter(AccessLevel.PACKAGE) + @Getter(AccessLevel.PACKAGE) private int npcSpeed; - @Setter - @Getter + @Setter(AccessLevel.PACKAGE) + @Getter(AccessLevel.PACKAGE) private Actor npcInteracting; - @Setter - @Getter + @Setter(AccessLevel.PACKAGE) + @Getter(AccessLevel.PACKAGE) private Specials specials; - @Setter - @Getter + @Setter(AccessLevel.PACKAGE) + @Getter(AccessLevel.PACKAGE) private Attackstyle attackStyle; @@ -93,7 +94,7 @@ class NPCContainer } @AllArgsConstructor - @Getter + @Getter(AccessLevel.PACKAGE) public enum Specials { PORTALS("Portals"), @@ -106,7 +107,7 @@ class NPCContainer } @AllArgsConstructor - @Getter + @Getter(AccessLevel.PACKAGE) public enum Attackstyle { MAGE("Mage", Color.CYAN), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/PrayAgainst.java b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/PrayAgainst.java index 2b61b5010e..30942bb461 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/PrayAgainst.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/PrayAgainst.java @@ -24,12 +24,13 @@ */ package net.runelite.client.plugins.coxhelper; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.Prayer; @AllArgsConstructor -@Getter +@Getter(AccessLevel.PACKAGE) public enum PrayAgainst { MELEE(Prayer.PROTECT_FROM_MELEE), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/crystalmathlabs/CrystalMathLabs.java b/runelite-client/src/main/java/net/runelite/client/plugins/crystalmathlabs/CrystalMathLabs.java index 155b3bfcc6..77a9ec68b2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/crystalmathlabs/CrystalMathLabs.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/crystalmathlabs/CrystalMathLabs.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.crystalmathlabs; import java.io.IOException; import java.util.Objects; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.GameState; @@ -52,6 +53,7 @@ import okhttp3.Response; enabledByDefault = false ) @Slf4j +@Singleton public class CrystalMathLabs extends Plugin { /** diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/customcursor/CustomCursor.java b/runelite-client/src/main/java/net/runelite/client/plugins/customcursor/CustomCursor.java index 11a65bccaf..ec89729654 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/customcursor/CustomCursor.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/customcursor/CustomCursor.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.customcursor; import java.awt.image.BufferedImage; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.client.util.ImageUtil; @@ -42,10 +43,10 @@ public enum CustomCursor ZAMORAK_GODSWORD("Zamorak Godsword", "cursor-zamorak-godsword.png"); private final String name; - @Getter + @Getter(AccessLevel.PUBLIC) private final BufferedImage cursorImage; - CustomCursor(String name, String icon) + CustomCursor(final String name, final String icon) { this.name = name; this.cursorImage = ImageUtil.getResourceStreamFromClass(CustomCursorPlugin.class, icon); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/customcursor/CustomCursorPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/customcursor/CustomCursorPlugin.java index 7e0fc4c18e..feb8729740 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/customcursor/CustomCursorPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/customcursor/CustomCursorPlugin.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.customcursor; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.events.ConfigChanged; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; @@ -38,6 +39,7 @@ import net.runelite.client.ui.ClientUI; description = "Replaces your mouse cursor image", enabledByDefault = false ) +@Singleton public class CustomCursorPlugin extends Plugin { @Inject 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 4e9c86df1d..764b93a308 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 @@ -26,6 +26,8 @@ package net.runelite.client.plugins.dailytaskindicators; +import javax.inject.Singleton; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.vars.AccountType; import com.google.inject.Provides; import javax.inject.Inject; @@ -50,6 +52,7 @@ import net.runelite.client.plugins.PluginDescriptor; name = "Daily Task Indicator", description = "Show chat notifications for daily tasks upon login" ) +@Singleton public class DailyTasksPlugin extends Plugin { private static final int ONE_DAY = 86400000; @@ -80,6 +83,16 @@ public class DailyTasksPlugin extends Plugin private long lastReset; private boolean loggingIn; + private boolean showHerbBoxes; + private boolean showStaves; + private boolean showEssence; + private boolean showRunes; + private boolean showSand; + private boolean showFlax; + private boolean showBonemeal; + private boolean showArrows; + private boolean showDynamite; + @Provides DailyTasksConfig provideConfig(ConfigManager configManager) { @@ -89,6 +102,8 @@ public class DailyTasksPlugin extends Plugin @Override public void startUp() { + updateConfig(); + loggingIn = true; } @@ -120,47 +135,47 @@ public class DailyTasksPlugin extends Plugin lastReset = (long) Math.floor(currentTime / ONE_DAY) * ONE_DAY; loggingIn = false; - if (config.showHerbBoxes()) + if (this.showHerbBoxes) { checkHerbBoxes(dailyReset); } - if (config.showStaves()) + if (this.showStaves) { checkStaves(dailyReset); } - if (config.showEssence()) + if (this.showEssence) { checkEssence(dailyReset); } - if (config.showRunes()) + if (this.showRunes) { checkRunes(dailyReset); } - if (config.showSand()) + if (this.showSand) { checkSand(dailyReset); } - if (config.showFlax()) + if (this.showFlax) { checkFlax(dailyReset); } - if (config.showBonemeal()) + if (this.showBonemeal) { checkBonemeal(dailyReset); } - if (config.showArrows()) + if (this.showArrows) { checkArrows(dailyReset); } - if (config.showDynamite()) + if (this.showDynamite) { checkDynamite(dailyReset); } @@ -281,4 +296,26 @@ public class DailyTasksPlugin extends Plugin .runeLiteFormattedMessage(message) .build()); } + + @Subscribe + public void onConfigChanged(ConfigChanged configChanged) + { + if (configChanged.getGroup().equals("dailytaskindicators")) + { + updateConfig(); + } + } + + private void updateConfig() + { + this.showHerbBoxes = config.showHerbBoxes(); + this.showStaves = config.showStaves(); + this.showEssence = config.showEssence(); + this.showRunes = config.showRunes(); + this.showSand = config.showSand(); + this.showFlax = config.showFlax(); + this.showBonemeal = config.showBonemeal(); + this.showArrows = config.showArrows(); + this.showDynamite = config.showDynamite(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/deathindicator/DeathIndicatorPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/deathindicator/DeathIndicatorPlugin.java index 34bb399c2f..049e6192b9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/deathindicator/DeathIndicatorPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/deathindicator/DeathIndicatorPlugin.java @@ -32,6 +32,7 @@ import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.GameState; @@ -56,6 +57,7 @@ import net.runelite.client.util.ImageUtil; description = "Show where you last died, and on what world", tags = {"arrow", "hints", "world", "map", "overlay"} ) +@Singleton @Slf4j public class DeathIndicatorPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/defaultworld/DefaultWorldPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/defaultworld/DefaultWorldPlugin.java index 96d5dfa246..f8a56ffbc6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/defaultworld/DefaultWorldPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/defaultworld/DefaultWorldPlugin.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.defaultworld; import com.google.inject.Provides; import java.io.IOException; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.GameState; @@ -47,6 +48,7 @@ import net.runelite.http.api.worlds.WorldResult; tags = {"home"} ) @Slf4j +@Singleton public class DefaultWorldPlugin extends Plugin { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/DemonicGorillaOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/DemonicGorillaOverlay.java index bf1154fecc..eaaf010435 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/DemonicGorillaOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/DemonicGorillaOverlay.java @@ -33,6 +33,7 @@ import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.Point; @@ -43,6 +44,7 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; +@Singleton public class DemonicGorillaOverlay extends Overlay { private static final Color COLOR_ICON_BACKGROUND = new Color(0, 0, 0, 128); @@ -58,7 +60,7 @@ public class DemonicGorillaOverlay extends Overlay private SkillIconManager iconManager; @Inject - public DemonicGorillaOverlay(Client client, DemonicGorillaPlugin plugin) + public DemonicGorillaOverlay(final Client client, final DemonicGorillaPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); @@ -106,7 +108,10 @@ public class DemonicGorillaOverlay extends Overlay { BufferedImage icon = getIcon(attackStyle); icons.add(icon); - totalWidth += icon.getWidth(); + if (icon != null) + { + totalWidth += icon.getWidth(); + } } int bgPadding = 4; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/DemonicGorillaPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/DemonicGorillaPlugin.java index 0df801bda5..d031b501b5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/DemonicGorillaPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/DemonicGorillaPlugin.java @@ -32,6 +32,8 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.AnimationID; import net.runelite.api.Client; @@ -64,6 +66,7 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Count demonic gorilla attacks and display their next possible attack styles", tags = {"combat", "overlay", "pve", "pvm"} ) +@Singleton public class DemonicGorillaPlugin extends Plugin { @Inject @@ -78,7 +81,7 @@ public class DemonicGorillaPlugin extends Plugin @Inject private ClientThread clientThread; - @Getter + @Getter(AccessLevel.PACKAGE) private Map gorillas; private List recentBoulders; @@ -145,7 +148,7 @@ public class DemonicGorillaPlugin extends Plugin } } - public static boolean isNpcGorilla(int npcId) + private static boolean isNpcGorilla(int npcId) { return npcId == NpcID.DEMONIC_GORILLA || npcId == NpcID.DEMONIC_GORILLA_7145 || @@ -321,8 +324,11 @@ public class DemonicGorillaPlugin extends Plugin .stream() .filter(x -> x != DemonicGorilla.AttackStyle.MELEE) .collect(Collectors.toList())); - checkGorillaAttackStyleSwitch(gorilla, DemonicGorilla.AttackStyle.MELEE, - getProtectedStyle(interacting)); + if (interacting != null) + { + checkGorillaAttackStyleSwitch(gorilla, DemonicGorilla.AttackStyle.MELEE, + getProtectedStyle(interacting)); + } } } else if (animationId != gorilla.getLastTickAnimation()) @@ -373,8 +379,7 @@ public class DemonicGorillaPlugin extends Plugin else if (mp != null) { WorldArea lastPlayerArea = mp.getLastWorldArea(); - if (lastPlayerArea != null && - interacting != null && recentBoulders.stream() + if (lastPlayerArea != null && recentBoulders.stream() .anyMatch(x -> x.distanceTo(lastPlayerArea) == 0)) { // A boulder started falling on the gorillas target, @@ -425,23 +430,21 @@ public class DemonicGorillaPlugin extends Plugin // Gorillas can't normally walk through other gorillas // or other players final WorldArea area1 = new WorldArea(x, 1, 1); - return area1 != null && - gorillas.values().stream().noneMatch(y -> + return gorillas.values().stream().noneMatch(y -> + { + if (y == gorilla) { - if (y == gorilla) - { - return false; - } - final WorldArea area2 = - y.getNpc().getIndex() < gorilla.getNpc().getIndex() ? - y.getNpc().getWorldArea() : y.getLastWorldArea(); - return area2 != null && area1.intersectsWith(area2); - }) && - memorizedPlayers.values().stream().noneMatch(y -> - { - final WorldArea area2 = y.getLastWorldArea(); - return area2 != null && area1.intersectsWith(area2); - }); + return false; + } + final WorldArea area2 = + y.getNpc().getIndex() < gorilla.getNpc().getIndex() ? + y.getNpc().getWorldArea() : y.getLastWorldArea(); + return area2 != null && area1.intersectsWith(area2); + }) && memorizedPlayers.values().stream().noneMatch(y -> + { + final WorldArea area2 = y.getLastWorldArea(); + return area2 != null && area1.intersectsWith(area2); + }); // There is a special case where if a player walked through // a gorilla, or a player walked through another player, @@ -453,9 +456,7 @@ public class DemonicGorillaPlugin extends Plugin { int distance = gorilla.getNpc().getWorldArea().distanceTo(mp.getLastWorldArea()); WorldPoint predictedMovement = predictedNewArea.toWorldPoint(); - if (distance <= DemonicGorilla.MAX_ATTACK_RANGE && - mp != null && - mp.getLastWorldArea().hasLineOfSightTo(client, gorilla.getLastWorldArea())) + if (distance <= DemonicGorilla.MAX_ATTACK_RANGE && mp.getLastWorldArea().hasLineOfSightTo(client, gorilla.getLastWorldArea())) { if (predictedMovement.distanceTo(gorilla.getLastWorldArea().toWorldPoint()) != 0) { @@ -549,8 +550,7 @@ public class DemonicGorillaPlugin extends Plugin { recentBoulders.add(WorldPoint.fromLocal(client, event.getPosition())); } - else if (projectileId == ProjectileID.DEMONIC_GORILLA_MAGIC || - projectileId == ProjectileID.DEMONIC_GORILLA_RANGED) + else { WorldPoint projectileSourcePosition = WorldPoint.fromLocal( client, projectile.getX1(), projectile.getY1(), client.getPlane()); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/MemorizedPlayer.java b/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/MemorizedPlayer.java index 7dd0058cd6..262042b7e1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/MemorizedPlayer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/MemorizedPlayer.java @@ -26,25 +26,26 @@ package net.runelite.client.plugins.demonicgorilla; import java.util.ArrayList; import java.util.List; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import net.runelite.api.Hitsplat; import net.runelite.api.Player; import net.runelite.api.coords.WorldArea; -public class MemorizedPlayer +class MemorizedPlayer { - @Getter + @Getter(AccessLevel.PACKAGE) private Player player; - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private WorldArea lastWorldArea; - @Getter + @Getter(AccessLevel.PACKAGE) private List recentHitsplats; - public MemorizedPlayer(Player player) + MemorizedPlayer(final Player player) { this.player = player; this.recentHitsplats = new ArrayList<>(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/PendingGorillaAttack.java b/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/PendingGorillaAttack.java index 6f3faff8d2..405f889469 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/PendingGorillaAttack.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/demonicgorilla/PendingGorillaAttack.java @@ -24,25 +24,25 @@ */ package net.runelite.client.plugins.demonicgorilla; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Player; -public class PendingGorillaAttack +class PendingGorillaAttack { - @Getter + @Getter(AccessLevel.PACKAGE) private DemonicGorilla attacker; - @Getter + @Getter(AccessLevel.PACKAGE) private DemonicGorilla.AttackStyle attackStyle; - @Getter + @Getter(AccessLevel.PACKAGE) private Player target; - @Getter + @Getter(AccessLevel.PACKAGE) private int finishesOnTick; - public PendingGorillaAttack(DemonicGorilla attacker, DemonicGorilla.AttackStyle attackStyle, - Player target, int finishesOnTick) + PendingGorillaAttack(final DemonicGorilla attacker, final DemonicGorilla.AttackStyle attackStyle, final Player target, final int finishesOnTick) { this.attacker = attacker; this.attackStyle = attackStyle; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordGameEventType.java b/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordGameEventType.java index 29bce7dc98..ac5487f6a8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordGameEventType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordGameEventType.java @@ -29,6 +29,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import java.util.List; import java.util.Map; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.Client; @@ -36,7 +37,7 @@ import net.runelite.api.Skill; import net.runelite.api.Varbits; @AllArgsConstructor -@Getter +@Getter(AccessLevel.PACKAGE) enum DiscordGameEventType { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordPlugin.java index 9d698b2085..68a10c2567 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordPlugin.java @@ -28,6 +28,7 @@ package net.runelite.client.plugins.discord; import com.google.common.base.Strings; import com.google.inject.Inject; import com.google.inject.Provides; +import com.google.inject.Singleton; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; @@ -37,6 +38,8 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; import javax.imageio.ImageIO; +import lombok.AccessLevel; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.GameState; @@ -80,9 +83,10 @@ import okhttp3.Response; tags = {"action", "activity", "external", "integration", "status"} ) @Slf4j +@Singleton public class DiscordPlugin extends Plugin { - public static boolean discordEnabled = false; + private static boolean discordEnabled = false; @Inject private Client client; @@ -112,6 +116,19 @@ public class DiscordPlugin extends Plugin private NavigationButton discordButton; private boolean loginFlag; + @Getter(AccessLevel.PACKAGE) + private int actionTimeout; + @Getter(AccessLevel.PACKAGE) + private boolean hideElapsedTime; + @Getter(AccessLevel.PACKAGE) + private boolean alwaysShowParty; + private boolean showSkillingActivity; + private boolean showBossActivity; + private boolean showCityActivity; + private boolean showDungeonActivity; + private boolean showMinigameActivity; + private boolean showRaidingActivity; + @Provides private DiscordConfig provideConfig(ConfigManager configManager) { @@ -121,6 +138,8 @@ public class DiscordPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "discord.png"); discordButton = NavigationButton.builder() @@ -182,6 +201,8 @@ public class DiscordPlugin extends Plugin { if (event.getGroup().equalsIgnoreCase("discord")) { + updateConfig(); + checkForGameStateUpdate(); checkForAreaUpdate(); updatePresence(); @@ -201,7 +222,7 @@ public class DiscordPlugin extends Plugin final DiscordGameEventType discordGameEventType = DiscordGameEventType.fromSkill(event.getSkill()); - if (discordGameEventType != null && config.showSkillingActivity()) + if (discordGameEventType != null && this.showSkillingActivity) { discordState.triggerEvent(discordGameEventType); } @@ -210,7 +231,7 @@ public class DiscordPlugin extends Plugin @Subscribe public void onVarbitChanged(VarbitChanged event) { - if (!config.showRaidingActivity()) + if (!this.showRaidingActivity) { return; } @@ -419,15 +440,28 @@ public class DiscordPlugin extends Plugin switch (event.getDiscordAreaType()) { case BOSSES: - return config.showBossActivity(); + return this.showBossActivity; case CITIES: - return config.showCityActivity(); + return this.showCityActivity; case DUNGEONS: - return config.showDungeonActivity(); + return this.showDungeonActivity; case MINIGAMES: - return config.showMinigameActivity(); + return this.showMinigameActivity; } return false; } + + public void updateConfig() + { + this.actionTimeout = config.actionTimeout(); + this.hideElapsedTime = config.hideElapsedTime(); + this.alwaysShowParty = config.alwaysShowParty(); + this.showSkillingActivity = config.showSkillingActivity(); + this.showBossActivity = config.showBossActivity(); + this.showCityActivity = config.showCityActivity(); + this.showDungeonActivity = config.showDungeonActivity(); + this.showMinigameActivity = config.showMinigameActivity(); + this.showRaidingActivity = config.showRaidingActivity(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordState.java b/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordState.java index c110194187..ddb554fd75 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordState.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/discord/DiscordState.java @@ -56,16 +56,16 @@ class DiscordState private final UUID partyId = UUID.randomUUID(); private final List events = new ArrayList<>(); private final DiscordService discordService; - private final DiscordConfig config; + private final DiscordPlugin plugin; private PartyService party; private final RuneLiteProperties properties; private DiscordPresence lastPresence; @Inject - private DiscordState(final DiscordService discordService, final DiscordConfig config, final PartyService party, final RuneLiteProperties properties) + private DiscordState(final DiscordService discordService, final DiscordPlugin plugin, final PartyService party, final RuneLiteProperties properties) { this.discordService = discordService; - this.config = config; + this.plugin = plugin; this.party = party; this.properties = properties; } @@ -97,7 +97,7 @@ class DiscordState .startTimestamp(lastPresence.getStartTimestamp()) .smallImageKey(lastPresence.getSmallImageKey()) .partyMax(lastPresence.getPartyMax()) - .partySize(Math.max(config.alwaysShowParty() ? 1 : 0, party.getMembers().size())); + .partySize(Math.max(plugin.isAlwaysShowParty() ? 1 : 0, party.getMembers().size())); if (party.isOwner()) { @@ -126,7 +126,7 @@ class DiscordState { // If we aren't showing the elapsed time within Discord then // We null out the event start property - event = new EventWithTime(eventType, config.hideElapsedTime() ? null : Instant.now()); + event = new EventWithTime(eventType, plugin.isHideElapsedTime() ? null : Instant.now()); events.add(event); } @@ -205,7 +205,7 @@ class DiscordState */ void checkForTimeout() { - final Duration actionTimeout = Duration.ofMinutes(config.actionTimeout()); + final Duration actionTimeout = Duration.ofMinutes(plugin.getActionTimeout()); final Instant now = Instant.now(); events.removeIf(event -> event.getType().isShouldTimeout() && now.isAfter(event.getUpdated().plus(actionTimeout))); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/emojis/EmojiPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/emojis/EmojiPlugin.java index 21eb1eab10..dff53b98c1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/emojis/EmojiPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/emojis/EmojiPlugin.java @@ -30,6 +30,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.annotation.Nullable; import javax.inject.Inject; +import javax.inject.Singleton; import joptsimple.internal.Strings; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; @@ -52,6 +53,7 @@ import net.runelite.client.util.ImageUtil; enabledByDefault = false ) @Slf4j +@Singleton public class EmojiPlugin extends Plugin { private static final Pattern TAG_REGEXP = Pattern.compile("<[^>]*>"); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/entityhider/EntityHiderPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/entityhider/EntityHiderPlugin.java index 73069862cd..72a13d5fe9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/entityhider/EntityHiderPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/entityhider/EntityHiderPlugin.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.entityhider; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.Player; @@ -44,6 +45,7 @@ import net.runelite.client.plugins.PluginDescriptor; tags = {"npcs", "players", "projectiles"}, enabledByDefault = false ) +@Singleton public class EntityHiderPlugin extends Plugin { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/EquipmentInspectorConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/EquipmentInspectorConfig.java index a43592e5d7..91c7a4b065 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/EquipmentInspectorConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/EquipmentInspectorConfig.java @@ -29,7 +29,7 @@ import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; import net.runelite.client.config.Range; -@ConfigGroup("grounditems") +@ConfigGroup("equipmentinspector") public interface EquipmentInspectorConfig extends Config { @ConfigItem( 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 d85f8127ac..10680e620b 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 @@ -37,12 +37,14 @@ import java.util.Optional; import java.util.concurrent.ScheduledExecutorService; import javax.annotation.Nullable; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.SwingUtilities; import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.ItemDefinition; import net.runelite.api.Player; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.PlayerMenuOptionClicked; import net.runelite.api.kit.KitType; import net.runelite.client.chat.ChatColorType; @@ -66,7 +68,7 @@ import net.runelite.client.util.Text; type = PluginType.PVP, enabledByDefault = false ) - +@Singleton @Slf4j public class EquipmentInspectorPlugin extends Plugin { @@ -100,6 +102,10 @@ public class EquipmentInspectorPlugin extends Plugin private int Prot3 = 0; private int Prot4 = 0; + private boolean ShowValue; + private int protecteditems; + private boolean ExactValue; + @Provides EquipmentInspectorConfig provideConfig(ConfigManager configManager) { @@ -109,6 +115,7 @@ public class EquipmentInspectorPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); equipmentInspectorPanel = injector.getInstance(EquipmentInspectorPanel.class); if (client != null) @@ -166,10 +173,18 @@ public class EquipmentInspectorPlugin extends Plugin // 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', ' '); - List players = client.getPlayers(); - Optional targetPlayer = players.stream() - .filter(Objects::nonNull) - .filter(p -> p.getName().equals(finalPlayerName)).findFirst(); + List players = null; + if (client != null) + { + players = client.getPlayers(); + } + Optional targetPlayer = Optional.empty(); + if (players != null) + { + targetPlayer = players.stream() + .filter(Objects::nonNull) + .filter(p -> p.getName().equals(finalPlayerName)).findFirst(); + } if (targetPlayer.isPresent()) { @@ -224,13 +239,13 @@ public class EquipmentInspectorPlugin extends Plugin } } } - int IgnoredItems = config.protecteditems(); + int IgnoredItems = this.protecteditems; if (IgnoredItems != 0 && IgnoredItems != 1 && IgnoredItems != 2 && IgnoredItems != 3) { IgnoredItems = 4; } - if (config.ShowValue()) + if (this.ShowValue) { switch (IgnoredItems) { @@ -255,13 +270,13 @@ public class EquipmentInspectorPlugin extends Plugin break; } String StringPrice = ""; - if (!config.ExactValue()) + if (!this.ExactValue) { TotalPrice = TotalPrice / 1000; StringPrice = NumberFormat.getIntegerInstance().format(TotalPrice); StringPrice = StringPrice + 'K'; } - if (config.ExactValue()) + if (this.ExactValue) { StringPrice = NumberFormat.getIntegerInstance().format(TotalPrice); } @@ -281,4 +296,20 @@ public class EquipmentInspectorPlugin extends Plugin }); } } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equalsIgnoreCase("equipmentinspector")) + { + updateConfig(); + } + } + + public void updateConfig() + { + this.ShowValue = config.ShowValue(); + this.protecteditems = config.protecteditems(); + this.ExactValue = config.ExactValue(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/normal.png b/runelite-client/src/main/java/net/runelite/client/plugins/equipmentinspector/normal.png deleted file mode 100644 index 613f95e46d5235a49ec0843faaa35384e9b0896b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 624 zcmV-$0+0QPP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0tHD#K~z{r?Uuhw z!$1_rUmcyLn~P8fmrQ~BGyq5#M;t!sDe|AI9PCT z5L;*0n(yTB<#Ji>Y`9Ti3&7jKIc7LRzA=EB!@v>HuhtrJNg@rXeB>M9M-je0Kgy>A zylh?sDMIn)l}ej(`+H8v(E%7b5cc-@C3nN&w2Fwp-R+IopcXQj3?*h0Vy~0lOgpUz zIPDlH0yrEs;AVPiQm$;Ucia462~d@01* diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/examine/CacheKey.java b/runelite-client/src/main/java/net/runelite/client/plugins/examine/CacheKey.java index 8cd0340b69..623aa869e7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/examine/CacheKey.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/examine/CacheKey.java @@ -31,7 +31,7 @@ class CacheKey private final ExamineType type; private final int id; - public CacheKey(ExamineType type, int id) + CacheKey(final ExamineType type, final int id) { this.type = type; this.id = id; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java index ddc21c724b..414c75a4c7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/examine/ExaminePlugin.java @@ -33,6 +33,7 @@ import java.util.Deque; import java.util.concurrent.ScheduledExecutorService; import java.util.regex.Pattern; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; @@ -69,6 +70,7 @@ import net.runelite.http.api.osbuddy.OSBGrandExchangeResult; tags = {"npcs", "items", "inventory", "objects"} ) @Slf4j +@Singleton public class ExaminePlugin extends Plugin { private static final Pattern X_PATTERN = Pattern.compile("^\\d+ x "); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropOverlay.java index cfdd113ef6..ee6ee0f26e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/experiencedrop/XpDropOverlay.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.experiencedrop; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Actor; import net.runelite.api.Point; import net.runelite.client.ui.overlay.Overlay; @@ -34,16 +35,15 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton class XpDropOverlay extends Overlay { private final XpDropPlugin plugin; - private final XpDropConfig config; @Inject - private XpDropOverlay(XpDropPlugin plugin, XpDropConfig config) + private XpDropOverlay(final XpDropPlugin plugin) { this.plugin = plugin; - this.config = config; setPosition(OverlayPosition.DYNAMIC); setPriority(OverlayPriority.MED); } @@ -57,12 +57,12 @@ class XpDropOverlay extends Overlay if (opponent != null) { int offset = opponent.getLogicalHeight() + 50; - String damageStr = String.valueOf(this.plugin.getDamage()); + String damageStr = String.valueOf(plugin.getDamage()); Point textLocation = opponent.getCanvasTextLocation(graphics, damageStr, offset); - if (textLocation != null && this.plugin.getDamage() != 0) + if (textLocation != null && plugin.getDamage() != 0) { - OverlayUtil.renderTextLocation(graphics, textLocation, damageStr, config.getDamageColor()); + OverlayUtil.renderTextLocation(graphics, textLocation, damageStr, plugin.getDamageColor()); } } } 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 e6e4aa3811..a94da44953 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 @@ -27,11 +27,13 @@ package net.runelite.client.plugins.experiencedrop; import com.google.inject.Provides; +import java.awt.Color; import java.util.Arrays; import java.util.EnumMap; import java.util.Map; import java.util.stream.IntStream; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Actor; @@ -65,6 +67,7 @@ import net.runelite.client.util.ColorUtil; description = "Enable customization of the way XP drops are displayed", tags = {"experience", "levels", "tick"} ) +@Singleton public class XpDropPlugin extends Plugin { private static final int XPDROP_PADDING = 2; // space between xp drop icons @@ -104,6 +107,15 @@ public class XpDropPlugin extends Plugin private PrayerType currentTickPrayer; private XpDropConfig.DamageMode damageMode; + private boolean hideSkillIcons; + private Color getMeleePrayerColor; + private Color getRangePrayerColor; + private Color getMagePrayerColor; + private int fakeXpDropDelay; + private XpDropConfig.DamageMode showdamagedrops; + @Getter(AccessLevel.PACKAGE) + private Color damageColor; + @Provides XpDropConfig provideConfig(ConfigManager configManager) { @@ -113,6 +125,8 @@ public class XpDropPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + damageMode = config.showdamagedrops(); if (damageMode == XpDropConfig.DamageMode.ABOVE_OPPONENT) @@ -135,10 +149,11 @@ public class XpDropPlugin extends Plugin return; } + updateConfig(); if (damageMode != XpDropConfig.DamageMode.ABOVE_OPPONENT) { - damageMode = config.showdamagedrops(); + damageMode = this.showdamagedrops; if (damageMode == XpDropConfig.DamageMode.ABOVE_OPPONENT) { @@ -147,7 +162,7 @@ public class XpDropPlugin extends Plugin } else { - damageMode = config.showdamagedrops(); + damageMode = this.showdamagedrops; if (damageMode != XpDropConfig.DamageMode.ABOVE_OPPONENT) { @@ -180,7 +195,7 @@ public class XpDropPlugin extends Plugin return; } - if (config.hideSkillIcons()) + if (this.hideSkillIcons) { if (widget.getSpriteId() > 0) { @@ -245,21 +260,21 @@ public class XpDropPlugin extends Plugin id == SpriteID.SKILL_ATTACK || id == SpriteID.SKILL_STRENGTH || id == SpriteID.SKILL_DEFENCE || correctPrayer)) { - color = config.getMeleePrayerColor().getRGB(); + color = this.getMeleePrayerColor.getRGB(); correctPrayer = true; } break; case RANGE: if (spriteIDs.anyMatch(id -> id == SpriteID.SKILL_RANGED || correctPrayer)) { - color = config.getRangePrayerColor().getRGB(); + color = this.getRangePrayerColor.getRGB(); correctPrayer = true; } break; case MAGIC: if (spriteIDs.anyMatch(id -> id == SpriteID.SKILL_MAGIC || correctPrayer)) { - color = config.getMagePrayerColor().getRGB(); + color = this.getMagePrayerColor.getRGB(); correctPrayer = true; } break; @@ -301,7 +316,7 @@ public class XpDropPlugin extends Plugin currentTickPrayer = getActivePrayerType(); correctPrayer = false; - final int fakeTickDelay = config.fakeXpDropDelay(); + final int fakeTickDelay = this.fakeXpDropDelay; if (fakeTickDelay == 0 || lastSkill == null) { @@ -343,7 +358,7 @@ public class XpDropPlugin extends Plugin @Subscribe public void onScriptCallbackEvent(ScriptCallbackEvent e) { - if (config.showdamagedrops() == XpDropConfig.DamageMode.NONE) + if (this.showdamagedrops == XpDropConfig.DamageMode.NONE) { return; } @@ -388,7 +403,7 @@ public class XpDropPlugin extends Plugin StringBuilder builder = new StringBuilder() .append(stringStack[stringStackSize - 1]) - .append(ColorUtil.colorTag(config.getDamageColor())) + .append(ColorUtil.colorTag(this.damageColor)) .append(" (").append(damage).append(")"); stringStack[stringStackSize - 1] = builder.toString(); @@ -430,4 +445,15 @@ public class XpDropPlugin extends Plugin damage = (int) Math.rint(damageDealt / npcManager.getXpModifier(target.getId())); tickShow = 3; } + + private void updateConfig() + { + this.hideSkillIcons = config.hideSkillIcons(); + this.getMeleePrayerColor = config.getMeleePrayerColor(); + this.getRangePrayerColor = config.getRangePrayerColor(); + this.getMagePrayerColor = config.getMagePrayerColor(); + this.fakeXpDropDelay = config.fakeXpDropDelay(); + this.showdamagedrops = config.showdamagedrops(); + this.damageColor = config.getDamageColor(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fairyring/FairyRingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/fairyring/FairyRingPlugin.java index b32f7f6c10..53f6b3d575 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fairyring/FairyRingPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fairyring/FairyRingPlugin.java @@ -35,6 +35,7 @@ import java.util.Map; import java.util.TreeMap; import javax.annotation.Nullable; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.Data; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; @@ -43,6 +44,7 @@ import net.runelite.api.ScriptID; import net.runelite.api.SoundEffectID; import net.runelite.api.SpriteID; import net.runelite.api.Varbits; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.VarbitChanged; import net.runelite.api.events.WidgetLoaded; @@ -66,6 +68,7 @@ import net.runelite.client.util.Text; description = "Show the location of the fairy ring teleport", tags = {"teleportation"} ) +@Singleton public class FairyRingPlugin extends Plugin { private static final String[] leftDial = new String[]{"A", "D", "C", "B"}; @@ -93,6 +96,8 @@ public class FairyRingPlugin extends Plugin private Widget searchBtn; private Collection codes = null; + private boolean autoOpen; + @Data private static class CodeWidgets { @@ -106,6 +111,23 @@ public class FairyRingPlugin extends Plugin private Widget description; } + @Override + protected void startUp() throws Exception + { + this.autoOpen = config.autoOpen(); + } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("fairyrings")) + { + return; + } + + this.autoOpen = config.autoOpen(); + } + @Provides FairyRingConfig getConfig(ConfigManager configManager) { @@ -142,7 +164,7 @@ public class FairyRingPlugin extends Plugin codes = null; - if (config.autoOpen()) + if (this.autoOpen) { openSearch(); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPanel.java index b6eb858b72..622ef7d273 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPanel.java @@ -41,6 +41,7 @@ import java.time.Instant; import java.util.Comparator; import java.util.function.Supplier; import javax.imageio.ImageIO; +import javax.inject.Singleton; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.ImageIcon; @@ -66,6 +67,7 @@ import okhttp3.Response; import okhttp3.ResponseBody; @Slf4j +@Singleton class FeedPanel extends PluginPanel { private static final ImageIcon RUNELITE_ICON; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPlugin.java index 8a34a73cf1..0366361345 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/feed/FeedPlugin.java @@ -33,6 +33,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.function.Supplier; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.events.ConfigChanged; import net.runelite.client.config.ConfigManager; @@ -53,6 +54,7 @@ import net.runelite.http.api.feed.FeedResult; loadWhenOutdated = true ) @Slf4j +@Singleton public class FeedPlugin extends Plugin { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/FightCaveContainer.java b/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/FightCaveContainer.java index cc0f1a523c..3bc482bf51 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/FightCaveContainer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/FightCaveContainer.java @@ -40,7 +40,7 @@ import net.runelite.api.NPCDefinition; import net.runelite.api.NpcID; import net.runelite.api.Prayer; -@Getter +@Getter(AccessLevel.PACKAGE) class FightCaveContainer { private NPC npc; @@ -50,11 +50,11 @@ class FightCaveContainer private int attackSpeed; private int priority; private ImmutableSet animations; - @Setter + @Setter(AccessLevel.PACKAGE) private int ticksUntilAttack; - @Setter + @Setter(AccessLevel.PACKAGE) private Actor npcInteracting; - @Setter + @Setter(AccessLevel.PACKAGE) private AttackStyle attackStyle; FightCaveContainer(NPC npc, int attackSpeed) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/FightCaveOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/FightCaveOverlay.java index 68569157d5..4f9c675825 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/FightCaveOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/FightCaveOverlay.java @@ -32,6 +32,7 @@ import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Point; import net.runelite.api.Prayer; @@ -44,19 +45,18 @@ import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.util.ImageUtil; +@Singleton public class FightCaveOverlay extends Overlay { private FightCavePlugin plugin; - private FightCaveConfig config; private Client client; private SpriteManager spriteManager; @Inject - FightCaveOverlay(Client client, FightCavePlugin plugin, FightCaveConfig config, SpriteManager spriteManager) + FightCaveOverlay(final Client client, final FightCavePlugin plugin, final SpriteManager spriteManager) { this.client = client; this.plugin = plugin; - this.config = config; this.spriteManager = spriteManager; setPosition(OverlayPosition.DYNAMIC); setPriority(OverlayPriority.HIGHEST); @@ -82,8 +82,8 @@ public class FightCaveOverlay extends Overlay } final String ticksLeftStr = String.valueOf(ticksLeft); - final int font = config.fontStyle().getFont(); - final boolean shadows = config.shadows(); + final int font = plugin.getFontStyle().getFont(); + final boolean shadows = plugin.isShadows(); Color color = (ticksLeft <= 1 ? Color.WHITE : attackStyle.getColor()); final Point canvasPoint = npc.getNpc().getCanvasTextLocation(graphics, Integer.toString(ticksLeft), 0); @@ -101,10 +101,10 @@ public class FightCaveOverlay extends Overlay renderImageLocation(graphics, npc.getNpc().getCanvasImageLocation(ImageUtil.resizeImage(pray, 36, 36), 0), pray, 12, 30); } - OverlayUtil.renderTextLocation(graphics, ticksLeftStr, config.textSize(), font, color, canvasPoint, shadows, 0); + OverlayUtil.renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), font, color, canvasPoint, shadows, 0); } - if (config.tickTimersWidget()) + if (plugin.isTickTimersWidget()) { if (!plugin.getMageTicks().isEmpty()) @@ -113,7 +113,7 @@ public class FightCaveOverlay extends Overlay Prayer.PROTECT_FROM_MAGIC, plugin.getMageTicks().get(0) == 1 ? Color.WHITE : Color.CYAN, Integer.toString(plugin.getMageTicks().get(0)), - config.shadows() + plugin.isShadows() ); } if (!plugin.getRangedTicks().isEmpty()) @@ -122,7 +122,7 @@ public class FightCaveOverlay extends Overlay Prayer.PROTECT_FROM_MISSILES, plugin.getRangedTicks().get(0) == 1 ? Color.WHITE : Color.GREEN, Integer.toString(plugin.getRangedTicks().get(0)), - config.shadows() + plugin.isShadows() ); } if (!plugin.getMeleeTicks().isEmpty()) @@ -131,7 +131,7 @@ public class FightCaveOverlay extends Overlay Prayer.PROTECT_FROM_MELEE, plugin.getMeleeTicks().get(0) == 1 ? Color.WHITE : Color.RED, Integer.toString(plugin.getMeleeTicks().get(0)), - config.shadows() + plugin.isShadows() ); } } @@ -146,7 +146,7 @@ public class FightCaveOverlay extends Overlay if (bounds != null) { - renderTextLocation(graphics, ticks, 16, config.fontStyle().getFont(), color, centerPoint(bounds), shadows); + renderTextLocation(graphics, ticks, 16, plugin.getFontStyle().getFont(), color, centerPoint(bounds), shadows); } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/FightCavePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/FightCavePlugin.java index c694aae2f2..a31197e700 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/FightCavePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/FightCavePlugin.java @@ -35,6 +35,7 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -45,6 +46,7 @@ import net.runelite.api.GameState; import net.runelite.api.NPC; import net.runelite.api.NpcID; import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.NpcDespawned; @@ -65,7 +67,7 @@ import org.apache.commons.lang3.ArrayUtils; type = PluginType.PVM, enabledByDefault = false ) - +@Singleton @Slf4j public class FightCavePlugin extends Plugin { @@ -146,6 +148,18 @@ public class FightCavePlugin extends Plugin return String.format("%dx %s", quantity, monster); } + + @Getter(AccessLevel.PACKAGE) + private WaveDisplayMode waveDisplay; + @Getter(AccessLevel.PACKAGE) + private boolean tickTimersWidget; + @Getter(AccessLevel.PACKAGE) + private FightCaveConfig.FontStyle fontStyle; + @Getter(AccessLevel.PACKAGE) + private int textSize; + @Getter(AccessLevel.PACKAGE) + private boolean shadows; + @Provides FightCaveConfig provideConfig(ConfigManager configManager) { @@ -155,6 +169,8 @@ public class FightCavePlugin extends Plugin @Override public void startUp() { + updateConfig(); + if (client.getGameState() == GameState.LOGGED_IN) { if (regionCheck()) @@ -174,6 +190,17 @@ public class FightCavePlugin extends Plugin currentWave = -1; } + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("fightcave")) + { + return; + } + + updateConfig(); + } + @Subscribe public void onChatMessage(ChatMessage event) { @@ -346,4 +373,13 @@ public class FightCavePlugin extends Plugin { return ArrayUtils.contains(client.getMapRegions(), FIGHT_CAVE_REGION); } + + private void updateConfig() + { + this.waveDisplay = config.waveDisplay(); + this.tickTimersWidget = config.tickTimersWidget(); + this.fontStyle = config.fontStyle(); + this.textSize = config.textSize(); + this.shadows = config.shadows(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/WaveOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/WaveOverlay.java index f1d81816f6..12beb81be2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/WaveOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fightcave/WaveOverlay.java @@ -32,6 +32,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; @@ -40,6 +41,7 @@ import net.runelite.client.ui.overlay.components.TitleComponent; import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; +@Singleton class WaveOverlay extends Overlay { private static final Color HEADER_COLOR = ColorScheme.BRAND_ORANGE; @@ -49,7 +51,7 @@ class WaveOverlay extends Overlay private final PanelComponent panelComponent = new PanelComponent(); @Inject - private WaveOverlay(FightCaveConfig config, FightCavePlugin plugin) + private WaveOverlay(final FightCaveConfig config, final FightCavePlugin plugin) { this.config = config; this.plugin = plugin; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingOverlay.java index 78082d052a..24f15c5e42 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingOverlay.java @@ -28,6 +28,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.api.Skill; @@ -41,25 +42,24 @@ import net.runelite.client.ui.overlay.components.TitleComponent; import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; +@Singleton class FishingOverlay extends Overlay { private static final String FISHING_SPOT = "Fishing spot"; private final Client client; private final FishingPlugin plugin; - private final FishingConfig config; private final XpTrackerService xpTrackerService; private final PanelComponent panelComponent = new PanelComponent(); @Inject - public FishingOverlay(Client client, FishingPlugin plugin, FishingConfig config, XpTrackerService xpTrackerService) + public FishingOverlay(final Client client, final FishingPlugin plugin, final 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, "Fishing overlay")); } @@ -67,7 +67,7 @@ class FishingOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!config.showFishingStats() || plugin.getSession().getLastFishCaught() == null) + if (!plugin.isShowFishingStats() || plugin.getSession().getLastFishCaught() == null) { return null; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingPlugin.java index aa4db54c50..074a4d4858 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingPlugin.java @@ -50,6 +50,7 @@ import net.runelite.api.NPC; import net.runelite.api.Varbits; import net.runelite.api.coords.LocalPoint; import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.InteractingChanged; @@ -138,9 +139,27 @@ public class FishingPlugin extends Plugin return configManager.getConfig(FishingConfig.class); } + @Getter(AccessLevel.PACKAGE) + private boolean onlyCurrentSpot; + @Getter(AccessLevel.PACKAGE) + private boolean showSpotTiles; + @Getter(AccessLevel.PACKAGE) + private boolean showSpotIcons; + @Getter(AccessLevel.PACKAGE) + private boolean showSpotNames; + private int statTimeout; + @Getter(AccessLevel.PACKAGE) + private boolean showFishingStats; + @Getter(AccessLevel.PACKAGE) + private boolean showMinnowOverlay; + private boolean trawlerNotification; + private boolean trawlerTimer; + @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(overlay); overlayManager.add(spotOverlay); overlayManager.add(fishingSpotMinimapOverlay); @@ -161,6 +180,17 @@ public class FishingPlugin extends Plugin trawlerStartTime = null; } + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("fishing")) + { + return; + } + + updateConfig(); + } + @Subscribe public void onGameStateChanged(GameStateChanged gameStateChanged) { @@ -253,7 +283,7 @@ public class FishingPlugin extends Plugin // Reset fishing session if (session.getLastFishCaught() != null) { - final Duration statTimeout = Duration.ofMinutes(config.statTimeout()); + final Duration statTimeout = Duration.ofMinutes(this.statTimeout); final Duration sinceCaught = Duration.between(session.getLastFishCaught(), Instant.now()); if (sinceCaught.compareTo(statTimeout) >= 0) @@ -267,7 +297,7 @@ public class FishingPlugin extends Plugin for (NPC npc : fishingSpots) { - if (FishingSpot.getSPOTS().get(npc.getId()) == FishingSpot.MINNOW && config.showMinnowOverlay()) + if (FishingSpot.getSPOTS().get(npc.getId()) == FishingSpot.MINNOW && this.showMinnowOverlay) { final int id = npc.getIndex(); final MinnowSpot minnowSpot = minnowSpots.get(id); @@ -282,7 +312,7 @@ public class FishingPlugin extends Plugin } } - if (config.trawlerTimer()) + if (this.trawlerTimer) { updateTrawlerTimer(); } @@ -319,7 +349,7 @@ public class FishingPlugin extends Plugin @Subscribe public void onVarbitChanged(VarbitChanged event) { - if (!config.trawlerNotification() || client.getGameState() != GameState.LOGGED_IN) + if (!this.trawlerNotification || client.getGameState() != GameState.LOGGED_IN) { return; } @@ -411,4 +441,17 @@ public class FishingPlugin extends Plugin final LocalPoint cameraPoint = new LocalPoint(client.getCameraX(), client.getCameraY()); fishingSpots.sort(Comparator.comparing(npc -> -1 * npc.getLocalLocation().distanceTo(cameraPoint))); } + + private void updateConfig() + { + this.onlyCurrentSpot = config.onlyCurrentSpot(); + this.showSpotTiles = config.showSpotTiles(); + this.showSpotIcons = config.showSpotIcons(); + this.showSpotNames = config.showSpotNames(); + this.statTimeout = config.statTimeout(); + this.showFishingStats = config.showFishingStats(); + this.showMinnowOverlay = config.showMinnowOverlay(); + this.trawlerNotification = config.trawlerNotification(); + this.trawlerTimer = config.trawlerTimer(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSession.java b/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSession.java index ae1f387747..f5daf21ce6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSession.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSession.java @@ -25,12 +25,13 @@ package net.runelite.client.plugins.fishing; import java.time.Instant; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; class FishingSession { - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private Instant lastFishCaught; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSpotMinimapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSpotMinimapOverlay.java index c241cd695f..c04ae8426b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSpotMinimapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSpotMinimapOverlay.java @@ -28,6 +28,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Setter; import net.runelite.api.GraphicID; @@ -37,21 +38,20 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton class FishingSpotMinimapOverlay extends Overlay { private final FishingPlugin plugin; - private final FishingConfig config; @Setter(AccessLevel.PACKAGE) private boolean hidden; @Inject - public FishingSpotMinimapOverlay(FishingPlugin plugin, FishingConfig config) + public FishingSpotMinimapOverlay(final FishingPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); this.plugin = plugin; - this.config = config; } @Override @@ -71,7 +71,7 @@ class FishingSpotMinimapOverlay extends Overlay continue; } - if (config.onlyCurrentSpot() && plugin.getCurrentSpot() != null && plugin.getCurrentSpot() != spot) + if (plugin.isOnlyCurrentSpot() && plugin.getCurrentSpot() != null && plugin.getCurrentSpot() != spot) { continue; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSpotOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSpotOverlay.java index 1b9c27eda0..7f7f058438 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSpotOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fishing/FishingSpotOverlay.java @@ -32,6 +32,7 @@ import java.awt.image.BufferedImage; import java.time.Duration; import java.time.Instant; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Setter; import net.runelite.api.Client; @@ -48,6 +49,7 @@ import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.ui.overlay.components.ProgressPieComponent; import net.runelite.client.util.ImageUtil; +@Singleton class FishingSpotOverlay extends Overlay { private static final Duration MINNOW_MOVE = Duration.ofSeconds(15); @@ -55,7 +57,6 @@ class FishingSpotOverlay extends Overlay private static final int ONE_TICK_AERIAL_FISHING = 3; private final FishingPlugin plugin; - private final FishingConfig config; private final Client client; private final ItemManager itemManager; @@ -63,12 +64,11 @@ class FishingSpotOverlay extends Overlay private boolean hidden; @Inject - private FishingSpotOverlay(FishingPlugin plugin, FishingConfig config, Client client, ItemManager itemManager) + private FishingSpotOverlay(final FishingPlugin plugin, final Client client, final ItemManager itemManager) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); this.plugin = plugin; - this.config = config; this.client = client; this.itemManager = itemManager; } @@ -90,14 +90,14 @@ class FishingSpotOverlay extends Overlay continue; } - if (config.onlyCurrentSpot() && plugin.getCurrentSpot() != null && plugin.getCurrentSpot() != spot) + if (plugin.isOnlyCurrentSpot() && plugin.getCurrentSpot() != null && plugin.getCurrentSpot() != spot) { continue; } Color color = npc.getSpotAnimation() == GraphicID.FLYING_FISH ? Color.RED : Color.CYAN; - if (spot == FishingSpot.MINNOW && config.showMinnowOverlay()) + if (spot == FishingSpot.MINNOW && plugin.isShowMinnowOverlay()) { MinnowSpot minnowSpot = plugin.getMinnowSpots().get(npc.getIndex()); if (minnowSpot != null) @@ -123,7 +123,7 @@ class FishingSpotOverlay extends Overlay } } - if (config.showSpotTiles()) + if (plugin.isShowSpotTiles()) { Polygon poly = npc.getCanvasTilePoly(); @@ -139,7 +139,7 @@ class FishingSpotOverlay extends Overlay } } - if (config.showSpotIcons()) + if (plugin.isShowSpotIcons()) { BufferedImage fishImage = itemManager.getImage(spot.getFishSpriteId()); @@ -159,7 +159,7 @@ class FishingSpotOverlay extends Overlay } } - if (config.showSpotNames()) + if (plugin.isShowSpotNames()) { String text = spot.getName(); Point textLocation = npc.getCanvasTextLocation(graphics, text, npc.getLogicalHeight() + 40); 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 index 4c145ae303..811eca25bb 100644 --- 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 @@ -35,38 +35,37 @@ import java.awt.Rectangle; import java.awt.geom.Line2D; import java.util.ArrayList; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; +@Singleton public class FlexoOverlay extends Overlay { - private static Rectangle clickArea; - - ArrayList clickAreas = new ArrayList<>(); - ArrayList clickPoints = new ArrayList<>(); + @Inject + private FlexoPlugin plugin; @Inject - private FlexoConfig config; - - @Inject - public FlexoOverlay(FlexoConfig config) + public FlexoOverlay(final FlexoPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); - this.config = config; + this.plugin = plugin; } @Override public Dimension render(Graphics2D graphics) { - if (config.getDebugNPCs() || config.getDebugGroundItems() || config.getDebugPlayers()) + if (!plugin.isOverlayEnabled()) { - if (clickArea != null) - { - graphics.draw(clickArea); - } + return null; + } + + if (plugin.isDebugNPCs() || plugin.isDebugGroundItems() || plugin.isDebugPlayers()) + { + ArrayList clickAreas = plugin.getClickAreas(); if (clickAreas != null) { for (Rectangle clickArea : clickAreas) @@ -77,6 +76,8 @@ public class FlexoOverlay extends Overlay } } } + + ArrayList clickPoints = plugin.getClickPoints(); if (clickPoints != null) { for (Point p : clickPoints) 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 index ed49c53b91..e6587510ae 100644 --- 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 @@ -36,10 +36,13 @@ import com.github.joonasvali.naturalmouse.support.SinusoidalDeviationProvider; import com.github.joonasvali.naturalmouse.util.FlowTemplates; import com.google.inject.Provides; import java.awt.AWTException; +import java.awt.Point; import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; +import lombok.AccessLevel; +import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.NPC; import net.runelite.api.Perspective; @@ -97,26 +100,52 @@ public class FlexoPlugin extends Plugin @Inject private FlexoOverlay overlay; + @Inject + private FlexoConfig config; + @Provides FlexoConfig getConfig(ConfigManager configManager) { return configManager.getConfig(FlexoConfig.class); } + @Getter(AccessLevel.PACKAGE) + private boolean overlayEnabled; + @Getter(AccessLevel.PACKAGE) + private boolean debugNPCs; + @Getter(AccessLevel.PACKAGE) + private boolean debugPlayers; + @Getter(AccessLevel.PACKAGE) + private boolean debugGroundItems; + private int minDelayAmt; + private int getReactionTimeVariation; + private int getMouseDragSpeed; + private int getOvershoots; + private boolean getVariatingFlow; + private boolean getSlowStartupFlow; + private boolean getSlowStartup2Flow; + private boolean getJaggedFlow; + private boolean getInterruptedFlow; + private boolean getInterruptedFlow2; + private boolean getStoppingFlow; + private int getDeviationSlope; + private String getNoisinessDivider; + private int scalingFactor; + + @Getter(AccessLevel.PACKAGE) + private ArrayList clickAreas = new ArrayList<>(); + @Getter(AccessLevel.PACKAGE) + private ArrayList clickPoints = new ArrayList<>(); + @Subscribe private void onConfigChanged(ConfigChanged event) { - if (event.getKey().compareTo("overlayEnabled") == 0) + if (!event.getGroup().equals("flexo") || (!event.getGroup().equals("stretchedmode")) ) { - if (getConfig(configManager).overlayEnabled()) - { - overlayManager.add(overlay); - } - else - { - overlayManager.remove(overlay); - } + return; } + + updateConfig(); updateMouseMotionFactory(); } @@ -132,12 +161,12 @@ public class FlexoPlugin extends Plugin { Flexo.clientUI = clientUI; } - overlay.clickAreas = new ArrayList<>(); - overlay.clickPoints = new ArrayList<>(); - if (getConfig(configManager).getDebugNPCs()) + this.clickAreas = new ArrayList<>(); + this.clickPoints = new ArrayList<>(); + if (this.debugNPCs) { Flexo.isStretched = client.isStretchedEnabled(); - Flexo.scale = configManager.getConfig(StretchedModeConfig.class).scalingFactor(); + Flexo.scale = this.scalingFactor; if (flexo != null) { for (NPC npc : client.getNpcs()) @@ -147,19 +176,19 @@ public class FlexoPlugin extends Plugin if (npc.getConvexHull() != null) { Rectangle r = FlexoMouse.getClickArea(npc.getConvexHull().getBounds()); - overlay.clickAreas.add(r); + this.clickAreas.add(r); java.awt.Point p = FlexoMouse.getClickPoint(r); - overlay.clickPoints.add(p); + this.clickPoints.add(p); } } } } } - if (getConfig(configManager).getDebugPlayers()) + if (this.debugPlayers) { Flexo.isStretched = client.isStretchedEnabled(); - Flexo.scale = configManager.getConfig(StretchedModeConfig.class).scalingFactor(); + Flexo.scale = this.scalingFactor; if (flexo != null) { for (Player player : client.getPlayers()) @@ -169,9 +198,9 @@ public class FlexoPlugin extends Plugin if (player.getConvexHull() != null) { Rectangle r = FlexoMouse.getClickArea(player.getConvexHull().getBounds()); - overlay.clickAreas.add(r); + this.clickAreas.add(r); java.awt.Point p = FlexoMouse.getClickPoint(r); - overlay.clickPoints.add(p); + this.clickPoints.add(p); } } } @@ -179,10 +208,10 @@ public class FlexoPlugin extends Plugin } // Could still use some improvement - if (getConfig(configManager).getDebugGroundItems()) + if (this.debugGroundItems) { Flexo.isStretched = client.isStretchedEnabled(); - Flexo.scale = configManager.getConfig(StretchedModeConfig.class).scalingFactor(); + Flexo.scale = this.scalingFactor; if (flexo != null) { @@ -200,9 +229,9 @@ public class FlexoPlugin extends Plugin Rectangle r1 = FlexoMouse.getClickArea(Perspective.getCanvasTilePoly(client, lp).getBounds()); Rectangle r2 = FlexoMouse.getClickArea(r1); Rectangle r3 = FlexoMouse.getClickArea(r2); - overlay.clickAreas.add(r3); + this.clickAreas.add(r3); java.awt.Point p = FlexoMouse.getClickPoint(r3); - overlay.clickPoints.add(p); + this.clickPoints.add(p); } } } @@ -214,7 +243,7 @@ public class FlexoPlugin extends Plugin private void updateMouseMotionFactory() { - Flexo.minDelay = getConfig(configManager).minDelayAmt(); + Flexo.minDelay = this.minDelayAmt; MouseMotionFactory factory = new MouseMotionFactory(); // TODO:Add Options for various flows to allow more personalization List flows = new ArrayList<>(); @@ -222,50 +251,50 @@ public class FlexoPlugin extends Plugin // Always add random flows.add(new Flow(FlowTemplates.random())); - if (getConfig(configManager).getVariatingFlow()) + if (this.getVariatingFlow) { flows.add(new Flow(FlowTemplates.variatingFlow())); } - if (getConfig(configManager).getSlowStartupFlow()) + if (this.getSlowStartupFlow) { flows.add(new Flow(FlowTemplates.slowStartupFlow())); } - if (getConfig(configManager).getSlowStartup2Flow()) + if (this.getSlowStartup2Flow) { flows.add(new Flow(FlowTemplates.slowStartup2Flow())); } - if (getConfig(configManager).getJaggedFlow()) + if (this.getJaggedFlow) { flows.add(new Flow(FlowTemplates.jaggedFlow())); } - if (getConfig(configManager).getInterruptedFlow()) + if (this.getInterruptedFlow) { flows.add(new Flow(FlowTemplates.interruptedFlow())); } - if (getConfig(configManager).getInterruptedFlow2()) + if (this.getInterruptedFlow2) { flows.add(new Flow(FlowTemplates.interruptedFlow2())); } - if (getConfig(configManager).getStoppingFlow()) + if (this.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()); + factory.setDeviationProvider(new SinusoidalDeviationProvider(this.getDeviationSlope)); + factory.setNoiseProvider(new DefaultNoiseProvider(Double.valueOf(this.getNoisinessDivider))); + factory.getNature().setReactionTimeVariationMs(this.getReactionTimeVariation); + manager.setMouseMovementBaseTimeMs(this.getMouseDragSpeed); DefaultOvershootManager overshootManager = (DefaultOvershootManager) factory.getOvershootManager(); - overshootManager.setOvershoots(getConfig(configManager).getOvershoots()); + overshootManager.setOvershoots(this.getOvershoots); factory.setSpeedManager(manager); Flexo.currentMouseMotionFactory = factory; @@ -274,6 +303,8 @@ public class FlexoPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + Flexo.isStretched = client.isStretchedEnabled(); overlayManager.add(overlay); updateMouseMotionFactory(); @@ -284,4 +315,26 @@ public class FlexoPlugin extends Plugin { overlayManager.remove(overlay); } + + private void updateConfig() + { + this.overlayEnabled = config.overlayEnabled(); + this.debugNPCs = config.getDebugNPCs(); + this.debugPlayers = config.getDebugPlayers(); + this.debugGroundItems = config.getDebugGroundItems(); + this.minDelayAmt = config.minDelayAmt(); + this.getReactionTimeVariation = config.getReactionTimeVariation(); + this.getMouseDragSpeed = config.getMouseDragSpeed(); + this.getOvershoots = config.getOvershoots(); + this.getVariatingFlow = config.getVariatingFlow(); + this.getSlowStartupFlow = config.getSlowStartupFlow(); + this.getSlowStartup2Flow = config.getSlowStartup2Flow(); + this.getJaggedFlow = config.getJaggedFlow(); + this.getInterruptedFlow = config.getInterruptedFlow(); + this.getInterruptedFlow2 = config.getInterruptedFlow2(); + this.getStoppingFlow = config.getStoppingFlow(); + this.getDeviationSlope = config.getDeviationSlope(); + this.getNoisinessDivider = config.getNoisinessDivider(); + this.scalingFactor = configManager.getConfig(StretchedModeConfig.class).scalingFactor(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingOverlay.java index 1dfbc0bda0..a46289ad80 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingOverlay.java @@ -30,6 +30,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.Point; @@ -40,12 +41,11 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.components.ProgressPieComponent; - +@Singleton public class FlinchingOverlay extends Overlay { private final Client client; private final FlinchingPlugin plugin; - private final FlinchingConfig config; private Color color; private Color borderColor; @@ -53,15 +53,14 @@ public class FlinchingOverlay extends Overlay private int overlaySize; @Inject - FlinchingOverlay(Client client, FlinchingPlugin plugin, FlinchingConfig config) + FlinchingOverlay(Client client, FlinchingPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); this.plugin = plugin; - this.config = config; this.client = client; - overlaySize = this.config.getFlinchOverlaySize(); + overlaySize = this.plugin.getFlinchOverlaySize(); } @Override @@ -73,10 +72,10 @@ public class FlinchingOverlay extends Overlay public void updateConfig() { - borderColor = config.getFlinchOverlayColor(); + borderColor = plugin.getFlinchOverlayColor(); color = new Color(borderColor.getRed(), borderColor.getGreen(), borderColor.getBlue(), 100); - overlaySize = config.getFlinchOverlaySize(); + overlaySize = plugin.getFlinchOverlaySize(); } private void drawOverlays(Graphics2D graphics) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingPlugin.java index bbe125e4f7..0ed62ecd06 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingPlugin.java @@ -25,10 +25,14 @@ package net.runelite.client.plugins.flinching; import com.google.inject.Provides; +import java.awt.Color; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Actor; import net.runelite.api.Client; @@ -49,6 +53,7 @@ import net.runelite.client.ui.overlay.OverlayManager; @Slf4j +@Singleton @PluginDescriptor( name = "Flinching Timer", description = "Time your attacks while flinching", @@ -79,6 +84,15 @@ public class FlinchingPlugin extends Plugin private boolean resetOnHit = true; private boolean resetOnHitReceived = true; + private int getFlinchAttackedDelay; + private int getFlinchDelay; + @Getter(AccessLevel.PACKAGE) + private int flinchOverlaySize; + @Getter(AccessLevel.PACKAGE) + private Color flinchOverlayColor; + private boolean getFlinchResetOnHit; + private boolean getFlinchResetOnHitReceived; + @Provides FlinchingConfig provideConfig(ConfigManager configManager) { @@ -88,11 +102,13 @@ public class FlinchingPlugin extends Plugin @Override protected void startUp() { + updateConfig(); + overlayManager.add(overlay); overlay.updateConfig(); - resetOnHit = config.getFlinchResetOnHit(); - resetOnHitReceived = config.getFlinchResetOnHitReceived(); + resetOnHit = this.getFlinchResetOnHit; + resetOnHitReceived = this.getFlinchResetOnHitReceived; ClearTargets(); } @@ -108,16 +124,18 @@ public class FlinchingPlugin extends Plugin { if (event.getGroup().equals("flinching")) { + updateConfig(); + overlay.updateConfig(); - resetOnHit = config.getFlinchResetOnHit(); - resetOnHitReceived = config.getFlinchResetOnHitReceived(); + resetOnHit = this.getFlinchResetOnHit; + resetOnHitReceived = this.getFlinchResetOnHitReceived; for (Map.Entry integerFlinchingTargetEntry : flinchingTargets.entrySet()) { FlinchingTarget target = integerFlinchingTargetEntry.getValue(); if (target != null) { - target.SetDelayTime(config.getFlinchDelay(), config.getFlinchAttackedDelay()); + target.SetDelayTime(this.getFlinchDelay, this.getFlinchAttackedDelay); } } } @@ -279,4 +297,14 @@ public class FlinchingPlugin extends Plugin { return (flinchingTargets); } + + private void updateConfig() + { + this.getFlinchAttackedDelay = config.getFlinchAttackedDelay(); + this.getFlinchDelay = config.getFlinchDelay(); + this.flinchOverlaySize = config.getFlinchOverlaySize(); + this.flinchOverlayColor = config.getFlinchOverlayColor(); + this.getFlinchResetOnHit = config.getFlinchResetOnHit(); + this.getFlinchResetOnHitReceived = config.getFlinchResetOnHitReceived(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingTarget.java b/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingTarget.java index 24c0aad399..58d90cb247 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingTarget.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/flinching/FlinchingTarget.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.flinching; import java.time.Duration; import java.time.Instant; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.NPC; import net.runelite.api.coords.WorldPoint; @@ -42,11 +43,11 @@ public class FlinchingTarget public boolean isActive; - @Getter + @Getter(AccessLevel.PACKAGE) private int objectId; private NPC targetObject; - @Getter + @Getter(AccessLevel.PACKAGE) public WorldPoint worldLocation; FlinchingTarget(NPC target) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsDrawListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsDrawListener.java index 671098a333..3fdd3f6925 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsDrawListener.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsDrawListener.java @@ -59,7 +59,7 @@ public class FpsDrawListener implements Runnable private long sleepDelay = 0; @Inject - private FpsDrawListener(FpsConfig config, FpsPlugin plugin) + private FpsDrawListener(final FpsConfig config, final FpsPlugin plugin) { this.config = config; this.plugin = plugin; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java index 110a447966..17afae61b6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java @@ -29,6 +29,7 @@ import java.awt.Dimension; import java.awt.FontMetrics; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Point; import net.runelite.api.Varbits; @@ -47,6 +48,7 @@ import net.runelite.client.ui.overlay.OverlayUtil; * This locks "FPS:" into one position (the far top right corner of the canvas), * along with a locked position for the FPS value. */ +@Singleton public class FpsOverlay extends Overlay { // Local dependencies @@ -57,7 +59,7 @@ public class FpsOverlay extends Overlay private boolean isFocused = true; @Inject - private FpsOverlay(FpsPlugin plugin, Client client) + private FpsOverlay(final FpsPlugin plugin, final Client client) { this.client = client; this.plugin = plugin; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsPlugin.java index 2ef788fab8..686b09c152 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsPlugin.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.fps; import com.google.inject.Inject; import com.google.inject.Provides; +import com.google.inject.Singleton; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -64,6 +65,7 @@ import net.runelite.client.util.ping.Ping; tags = {"frames", "framerate", "limit", "overlay", "ping"}, enabledByDefault = false ) +@Singleton public class FpsPlugin extends Plugin { static final String CONFIG_GROUP_KEY = "fpscontrol"; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FontStyle.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FontStyle.java index 47cbd82c69..c9921af410 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FontStyle.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FontStyle.java @@ -24,10 +24,11 @@ package net.runelite.client.plugins.freezetimers; import java.awt.Font; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; -@Getter +@Getter(AccessLevel.PACKAGE) @AllArgsConstructor public enum FontStyle { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeInfo.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeInfo.java index 233c6710c0..2a5409cd4d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeInfo.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/FreezeInfo.java @@ -1,5 +1,6 @@ package net.runelite.client.plugins.freezetimers; +import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; import net.runelite.api.Actor; @@ -8,8 +9,8 @@ import net.runelite.api.coords.LocalPoint; @Builder class FreezeInfo { - @Getter + @Getter(AccessLevel.PACKAGE) private final Actor actor; - @Getter + @Getter(AccessLevel.PACKAGE) private final LocalPoint freezePoint; } \ No newline at end of file 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 6842cd111d..fe43baae47 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 @@ -34,6 +34,7 @@ import java.awt.Graphics2D; import java.awt.Polygon; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Actor; import net.runelite.api.Client; import net.runelite.api.GraphicID; @@ -45,24 +46,22 @@ 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.ImageUtil; - +@Singleton public class FreezeTimersOverlay extends Overlay { - private final FreezeTimersConfig config; + private final FreezeTimersPlugin plugin; private final Client client; private final Font timerFont = FontManager.getRunescapeBoldFont().deriveFont(14.0f); private final BufferedImage FREEZE_IMAGE = ImageUtil.getResourceStreamFromClass(getClass(), "freeze.png"); private final BufferedImage TB_IMAGE = ImageUtil.getResourceStreamFromClass(getClass(), "teleblock.png"); private final BufferedImage VENG_IMAGE = ImageUtil.getResourceStreamFromClass(getClass(), "veng.png"); private Timers timers; - private boolean lock; - private long finishedAtTest; @Inject - public FreezeTimersOverlay(FreezeTimersConfig config, Client client, Timers timers) + public FreezeTimersOverlay(final FreezeTimersPlugin plugin, final Client client, final Timers timers) { - this.config = config; + this.plugin = plugin; this.client = client; this.timers = timers; setPriority(OverlayPriority.HIGHEST); @@ -73,11 +72,11 @@ public class FreezeTimersOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (config.showPlayers()) + if (plugin.isShowPlayers()) { client.getPlayers().forEach((p) -> renderOverlayFor(graphics, p)); } - if (config.showNpcs()) + if (plugin.isShowNpcs()) { client.getNpcs().forEach((npc) -> renderOverlayFor(graphics, npc)); } @@ -93,15 +92,15 @@ public class FreezeTimersOverlay extends Overlay int overlaysDrawn = 0; - if (drawFreezeOverlay(g, actor, overlaysDrawn) && config.FreezeTimers()) + if (drawFreezeOverlay(g, actor, overlaysDrawn) && plugin.isFreezeTimers()) { overlaysDrawn++; } - if (drawTBOverlay(g, actor, overlaysDrawn) && config.TB()) + if (drawTBOverlay(g, actor, overlaysDrawn) && plugin.isTB()) { overlaysDrawn++; } - if (drawVengOverlay(g, actor, overlaysDrawn) && config.Veng()) + if (drawVengOverlay(g, actor, overlaysDrawn) && plugin.isVeng()) { overlaysDrawn++; } @@ -127,15 +126,15 @@ public class FreezeTimersOverlay extends Overlay Point FixedPoint = new Point(poi.getX(), poi.getY()); - if (config.noImage()) + if (plugin.isNoImage()) { if (test > 3) { - OverlayUtil.renderTextLocation(g, text, config.textSize(), config.fontStyle().getFont(), Color.WHITE, FixedPoint, false, 0); + OverlayUtil.renderTextLocation(g, text, plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.WHITE, FixedPoint, false, 0); } else { - OverlayUtil.renderTextLocation(g, text, config.textSize(), config.fontStyle().getFont(), Color.YELLOW, FixedPoint, false, 0); + OverlayUtil.renderTextLocation(g, text, plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.YELLOW, FixedPoint, false, 0); } } else @@ -148,7 +147,7 @@ public class FreezeTimersOverlay extends Overlay private boolean drawTBOverlay(Graphics2D g, Actor actor, int overlaysDrawn) { long currentTick = System.currentTimeMillis(); - if (!config.TB()) + if (!plugin.isTB()) { return false; } @@ -167,19 +166,19 @@ public class FreezeTimersOverlay extends Overlay } Point FixedPoint = new Point(poi.getX() + 20, poi.getY()); - if (config.noImage()) + if (plugin.isNoImage()) { if (timers.getTimerEnd(actor, TimerType.FREEZE) <= currentTick) { - OverlayUtil.renderTextLocation(g, text, config.textSize(), config.fontStyle().getFont(), Color.CYAN, poi, false, 0); + OverlayUtil.renderTextLocation(g, text, plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.CYAN, poi, false, 0); } if (timers.getTimerEnd(actor, TimerType.FREEZE) >= currentTick) { - OverlayUtil.renderTextLocation(g, " | " + text, config.textSize(), config.fontStyle().getFont(), Color.CYAN, FixedPoint, false, 0); + OverlayUtil.renderTextLocation(g, " | " + text, plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.CYAN, FixedPoint, false, 0); } if (timers.getTimerEnd(actor, TimerType.VENG) >= currentTick) { - OverlayUtil.renderTextLocation(g, " | " + text, config.textSize(), config.fontStyle().getFont(), Color.CYAN, FixedPoint, false, 0); + OverlayUtil.renderTextLocation(g, " | " + text, plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.CYAN, FixedPoint, false, 0); } } else @@ -192,7 +191,7 @@ public class FreezeTimersOverlay extends Overlay private boolean drawVengOverlay(Graphics2D g, Actor actor, int overlaysDrawn) { long currentTick = System.currentTimeMillis(); - if (!config.Veng()) + if (!plugin.isVeng()) { return false; } @@ -211,19 +210,19 @@ public class FreezeTimersOverlay extends Overlay } Point FixedPoint = new Point(poi.getX() - 20, poi.getY()); - if (config.noImage()) + if (plugin.isNoImage()) { if (timers.getTimerEnd(actor, TimerType.FREEZE) <= currentTick) { - OverlayUtil.renderTextLocation(g, text, config.textSize(), config.fontStyle().getFont(), Color.RED, poi, false, 0); + OverlayUtil.renderTextLocation(g, text, plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.RED, poi, false, 0); } if (timers.getTimerEnd(actor, TimerType.FREEZE) >= currentTick) { - OverlayUtil.renderTextLocation(g, text + " | ", config.textSize(), config.fontStyle().getFont(), Color.RED, FixedPoint, false, 0); + OverlayUtil.renderTextLocation(g, text + " | ", plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.RED, FixedPoint, false, 0); } if (timers.getTimerEnd(actor, TimerType.TELEBLOCK) >= currentTick) { - OverlayUtil.renderTextLocation(g, text + " | ", config.textSize(), config.fontStyle().getFont(), Color.RED, FixedPoint, false, 0); + OverlayUtil.renderTextLocation(g, text + " | ", plugin.getTextSize(), plugin.getFontStyle().getFont(), Color.RED, FixedPoint, false, 0); } } else @@ -253,7 +252,7 @@ public class FreezeTimersOverlay extends Overlay int yOffset = (overlaysDrawn * 18); g.setFont(timerFont); g.setColor(WHITE); - int xOffset = config.offset(); + int xOffset = plugin.getOffset(); renderActorTextAndImage(g, actor, text, Color.WHITE, image, yOffset, xOffset); } 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 e66279aa4d..5769c33df1 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 @@ -28,9 +28,13 @@ import com.google.inject.Provides; import java.util.HashMap; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; import net.runelite.api.Actor; import net.runelite.api.Client; import net.runelite.api.Player; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.SpotAnimationChanged; import net.runelite.api.events.PlayerDespawned; @@ -48,11 +52,10 @@ import net.runelite.client.ui.overlay.OverlayManager; type = PluginType.PVP, enabledByDefault = false ) - +@Singleton public class FreezeTimersPlugin extends Plugin { private final Map freezes = new HashMap<>(); - private Actor player; @Inject private Client client; @@ -69,8 +72,31 @@ public class FreezeTimersPlugin extends Plugin @Inject private FreezeTimersOverlay overlay; + @Inject + private FreezeTimersConfig config; + + @Getter(AccessLevel.PACKAGE) + private boolean showPlayers; + @Getter(AccessLevel.PACKAGE) + private boolean showNpcs; + @Getter(AccessLevel.PACKAGE) + private boolean FreezeTimers; + @Getter(AccessLevel.PACKAGE) + private boolean TB; + @Getter(AccessLevel.PACKAGE) + private boolean Veng; + @Getter(AccessLevel.PACKAGE) + private int offset; + @Getter(AccessLevel.PACKAGE) + private boolean noImage; + @Getter(AccessLevel.PACKAGE) + private FontStyle fontStyle; + @Getter(AccessLevel.PACKAGE) + private int textSize; + public void startUp() { + updateConfig(); overlayManager.add(overlay); } @@ -141,4 +167,26 @@ public class FreezeTimersPlugin extends Plugin freezes.remove(actor.getName()); } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("freezetimers")) + { + updateConfig(); + } + } + + private void updateConfig() + { + this.showPlayers = config.showPlayers(); + this.showNpcs = config.showNpcs(); + this.FreezeTimers = config.FreezeTimers(); + this.TB = config.TB(); + this.Veng = config.Veng(); + this.offset = config.offset(); + this.noImage = config.noImage(); + this.fontStyle = config.fontStyle(); + this.textSize = config.textSize(); + } } 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 7c8fbf80ce..bc95d19900 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 @@ -24,6 +24,7 @@ */ package net.runelite.client.plugins.freezetimers; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @@ -42,20 +43,20 @@ public enum PlayerSpellEffect VENG_OTHER("Vengeance Other", 725, 30000, false, 9, TimerType.VENG), NONE("Nothing", -69, 420, true, 9999, TimerType.THIS_SHIT_BROKE); - @Getter + @Getter(AccessLevel.PACKAGE) private final String name; - @Getter + @Getter(AccessLevel.PACKAGE) private final int spotAnimId; - @Getter + @Getter(AccessLevel.PACKAGE) private final int timerLengthTicks; - @Getter + @Getter(AccessLevel.PACKAGE) private boolean halvable; - @Getter + @Getter(AccessLevel.PACKAGE) private final int spriteIdx; - @Getter + @Getter(AccessLevel.PACKAGE) private final TimerType type; - public static PlayerSpellEffect getFromSpotAnim(int spotAnim) + static PlayerSpellEffect getFromSpotAnim(int spotAnim) { for (PlayerSpellEffect effect : values()) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/PrayerTracker.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/PrayerTracker.java index 475cff14ad..05806a1c24 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/PrayerTracker.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/PrayerTracker.java @@ -71,12 +71,12 @@ public class PrayerTracker newTick.get(actor).put("SpotAnim", actor.getSpotAnimation()); } - public int getPrayerIconLastTick(Actor p) + int getPrayerIconLastTick(Actor p) { return lastTick.getOrDefault(p, new HashMap<>()).getOrDefault("PrayerIcon", -1337); } - public int getSpotanimLastTick(Actor p) + int getSpotanimLastTick(Actor p) { return lastTick.getOrDefault(p, new HashMap<>()).getOrDefault("SpotAnim", -1337); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Timers.java b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Timers.java index c74ab74c3d..0d58af3127 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Timers.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/freezetimers/Timers.java @@ -24,28 +24,22 @@ package net.runelite.client.plugins.freezetimers; import java.util.HashMap; -import javax.inject.Inject; import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Actor; -import net.runelite.api.Client; @Slf4j @Singleton public class Timers { - - @Inject - private Client client; - private HashMap> timerMap = new HashMap<>(); - public void gameTick() + void gameTick() { } - public void setTimerEnd(Actor actor, TimerType type, long n) + void setTimerEnd(Actor actor, TimerType type, long n) { if (!timerMap.containsKey(actor)) { @@ -54,7 +48,7 @@ public class Timers timerMap.get(actor).put(type, n); } - public long getTimerEnd(Actor actor, TimerType type) + long getTimerEnd(Actor actor, TimerType type) { if (!timerMap.containsKey(actor)) { @@ -63,7 +57,7 @@ public class Timers return timerMap.get(actor).getOrDefault(type, (long) 0); } - public boolean areAllTimersZero(Actor actor) + boolean areAllTimersZero(Actor actor) { for (TimerType type : TimerType.values()) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/friendlist/FriendListPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/friendlist/FriendListPlugin.java index 355d9db46a..b98b68d7eb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/friendlist/FriendListPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/friendlist/FriendListPlugin.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.friendlist; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.VarPlayer; import net.runelite.api.events.GameTick; @@ -39,6 +40,7 @@ import net.runelite.client.plugins.PluginDescriptor; name = "Friend List", description = "Add extra information to the friend and ignore lists" ) +@Singleton public class FriendListPlugin extends Plugin { private static final int MAX_FRIENDS_P2P = 400; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/friendnotes/FriendNoteOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/friendnotes/FriendNoteOverlay.java index 554a823573..acac979de6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/friendnotes/FriendNoteOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/friendnotes/FriendNoteOverlay.java @@ -30,11 +30,13 @@ package net.runelite.client.plugins.friendnotes; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.tooltip.Tooltip; import net.runelite.client.ui.overlay.tooltip.TooltipManager; +@Singleton class FriendNoteOverlay extends Overlay { private final Client client; @@ -42,7 +44,7 @@ class FriendNoteOverlay extends Overlay private final TooltipManager tooltipManager; @Inject - private FriendNoteOverlay(Client client, FriendNotesPlugin plugin, TooltipManager tooltipManager) + private FriendNoteOverlay(final Client client, final FriendNotesPlugin plugin, final TooltipManager tooltipManager) { this.client = client; this.plugin = plugin; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/friendnotes/FriendNotesPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/friendnotes/FriendNotesPlugin.java index fe27938a7e..75561cb114 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/friendnotes/FriendNotesPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/friendnotes/FriendNotesPlugin.java @@ -32,6 +32,7 @@ import com.google.common.collect.ObjectArrays; import java.awt.Color; import javax.annotation.Nullable; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; @@ -58,6 +59,7 @@ import net.runelite.client.util.Text; name = "Friend Notes", description = "Store notes about your friends" ) +@Singleton public class FriendNotesPlugin extends Plugin { private static final String CONFIG_GROUP = "friendNotes"; 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 index 99434bcffe..c4c088aab3 100644 --- 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 @@ -18,6 +18,7 @@ import java.util.HashSet; import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; @@ -52,7 +53,7 @@ import org.apache.commons.lang3.ArrayUtils; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton public class FriendTaggingPlugin extends Plugin { public static final ConcurrentHashMap taggedFriends = new ConcurrentHashMap<>(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GLUtil.java b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GLUtil.java index 2629e81e4b..8c4bf270fc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GLUtil.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GLUtil.java @@ -37,33 +37,33 @@ class GLUtil private static final int[] buf = new int[1]; private static final float[] fbuf = new float[1]; - static int glGetInteger(GL4 gl, int pname) + static int glGetInteger(GL4 gl) { - gl.glGetIntegerv(pname, buf, 0); + gl.glGetIntegerv(com.jogamp.opengl.GL.GL_MAX_SAMPLES, buf, 0); return buf[0]; } - static float glGetFloat(GL4 gl, int pname) + static float glGetFloat(GL4 gl) { - gl.glGetFloatv(pname, fbuf, 0); + gl.glGetFloatv(com.jogamp.opengl.GL.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, fbuf, 0); return fbuf[0]; } - static int glGetShader(GL4 gl, int shader, int pname) + private static int glGetShader(GL4 gl, int shader) { - gl.glGetShaderiv(shader, pname, buf, 0); + gl.glGetShaderiv(shader, com.jogamp.opengl.GL2ES2.GL_COMPILE_STATUS, buf, 0); assert buf[0] > -1; return buf[0]; } - static int glGetProgram(GL4 gl, int program, int pname) + private static int glGetProgram(GL4 gl, int program, int pname) { gl.glGetProgramiv(program, pname, buf, 0); assert buf[0] > -1; return buf[0]; } - static String glGetShaderInfoLog(GL4 gl, int shader) + private static String glGetShaderInfoLog(GL4 gl, int shader) { byte[] err = new byte[ERR_LEN]; gl.glGetShaderInfoLog(shader, ERR_LEN, buf, 0, err, 0); @@ -192,7 +192,7 @@ class GLUtil gl.glShaderSource(shader, 1, new String[]{source}, null); gl.glCompileShader(shader); - if (glGetShader(gl, shader, gl.GL_COMPILE_STATUS) == gl.GL_TRUE) + if (glGetShader(gl, shader) == gl.GL_TRUE) { gl.glAttachShader(program, shader); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuFloatBuffer.java b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuFloatBuffer.java index a90d85a16d..a5901d65b2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuFloatBuffer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuFloatBuffer.java @@ -32,9 +32,9 @@ class GpuFloatBuffer { private FloatBuffer buffer = allocateDirect(65536); - void put(float texture, float u, float v, float pad) + void put(float texture, float u, float v) { - buffer.put(texture).put(u).put(v).put(pad); + buffer.put(texture).put(u).put(v).put((float) 0.0); } void flip() diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuIntBuffer.java b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuIntBuffer.java index 15ea5461ad..bc85a230b0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuIntBuffer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuIntBuffer.java @@ -32,11 +32,6 @@ class GpuIntBuffer { private IntBuffer buffer = allocateDirect(65536); - void put(int x, int y, int z) - { - buffer.put(x).put(y).put(z); - } - void put(int x, int y, int z, int c) { buffer.put(x).put(y).put(z).put(c); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java index e437d3cbe9..272ff27c39 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/GpuPlugin.java @@ -48,6 +48,7 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.util.function.Function; import javax.inject.Inject; +import javax.inject.Singleton; import jogamp.nativewindow.SurfaceScaleUtils; import jogamp.nativewindow.jawt.x11.X11JAWTWindow; import jogamp.newt.awt.NewtFactoryAWT; @@ -65,6 +66,7 @@ import net.runelite.api.SceneTileModel; import net.runelite.api.SceneTilePaint; import net.runelite.api.Texture; import net.runelite.api.TextureProvider; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.hooks.DrawCallbacks; import net.runelite.client.callback.ClientThread; @@ -88,6 +90,7 @@ import net.runelite.client.util.OSType; tags = {"fog", "draw distance"} ) @Slf4j +@Singleton public class GpuPlugin extends Plugin implements DrawCallbacks { // This is the maximum number of triangles the compute shaders support @@ -227,9 +230,38 @@ public class GpuPlugin extends Plugin implements DrawCallbacks private int uniBlockMain; private int uniSmoothBanding; + private int drawDistance; + private boolean smoothBanding; + private AntiAliasingMode antiAliasingMode; + private AnisotropicFilteringMode anisotropicFilteringMode; + private int fogDepth; + private int fogCircularity; + private int fogDensity; + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("gpu")) + { + updateConfig(); + } + } + + private void updateConfig() + { + this.drawDistance = config.drawDistance(); + this.smoothBanding = config.smoothBanding(); + this.antiAliasingMode = config.antiAliasingMode(); + this.anisotropicFilteringMode = config.anisotropicFilteringMode(); + this.fogDepth = config.fogDepth(); + this.fogCircularity = config.fogCircularity(); + this.fogDensity = config.fogDensity(); + } + @Override protected void startUp() { + updateConfig(); clientThread.invoke(() -> { try @@ -704,7 +736,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks centerY = client.getCenterY(); final Scene scene = client.getScene(); - final int drawDistance = Math.max(0, Math.min(MAX_DISTANCE, config.drawDistance())); + final int drawDistance = Math.max(0, Math.min(MAX_DISTANCE, this.drawDistance)); scene.setDrawDistance(drawDistance); } @@ -794,7 +826,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks } // Setup anti-aliasing - final AntiAliasingMode antiAliasingMode = config.antiAliasingMode(); + final AntiAliasingMode antiAliasingMode = this.antiAliasingMode; final boolean aaEnabled = antiAliasingMode != AntiAliasingMode.DISABLED; if (aaEnabled) @@ -813,7 +845,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks { shutdownSceneFbo(); - final int maxSamples = glGetInteger(gl, gl.GL_MAX_SAMPLES); + final int maxSamples = glGetInteger(gl); final int samples = Math.min(antiAliasingMode.getSamples(), maxSamples); initSceneFbo(stretchedCanvasWidth, stretchedCanvasHeight, samples); @@ -977,8 +1009,8 @@ public class GpuPlugin extends Plugin implements DrawCallbacks int renderViewportWidth = viewportWidth; // Setup anisotropic filtering - final AnisotropicFilteringMode anisotropicFilteringMode = config.anisotropicFilteringMode(); - final boolean afEnabled = anisotropicFilteringMode != anisotropicFilteringMode.DISABLED; + final AnisotropicFilteringMode anisotropicFilteringMode = this.anisotropicFilteringMode; + final boolean afEnabled = anisotropicFilteringMode != AnisotropicFilteringMode.DISABLED; if (lastAnisotropicFilteringMode != anisotropicFilteringMode) { @@ -993,7 +1025,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR_MIPMAP_LINEAR); break; default: - final float maxSamples = glGetFloat(gl, gl.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); + final float maxSamples = glGetFloat(gl); final float samples = Math.min(anisotropicFilteringMode.getSamples(), maxSamples); gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR_MIPMAP_LINEAR); gl.glTexParameterf(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MAX_ANISOTROPY_EXT, samples); @@ -1034,19 +1066,19 @@ public class GpuPlugin extends Plugin implements DrawCallbacks gl.glUseProgram(glProgram); - final int drawDistance = Math.max(0, Math.min(MAX_DISTANCE, config.drawDistance())); - final int fogDepth = config.fogDepth(); + final int drawDistance = Math.max(0, Math.min(MAX_DISTANCE, this.drawDistance)); + final int fogDepth = this.fogDepth; float effectiveDrawDistance = Perspective.LOCAL_TILE_SIZE * Math.min(Constants.SCENE_SIZE / 2, drawDistance); gl.glUniform1i(uniUseFog, fogDepth > 0 ? 1 : 0); gl.glUniform4f(uniFogColor, (sky >> 16 & 0xFF) / 255f, (sky >> 8 & 0xFF) / 255f, (sky & 0xFF) / 255f, 1f); - gl.glUniform1f(uniFogDepth, config.fogDepth() * 0.01f * effectiveDrawDistance); - gl.glUniform1f(uniFogCornerRadius, config.fogCircularity() * 0.01f * effectiveDrawDistance); - gl.glUniform1f(uniFogDensity, config.fogDensity() * 0.1f); + gl.glUniform1f(uniFogDepth, this.fogDepth * 0.01f * effectiveDrawDistance); + gl.glUniform1f(uniFogCornerRadius, this.fogCircularity * 0.01f * effectiveDrawDistance); + gl.glUniform1f(uniFogDensity, this.fogDensity * 0.1f); gl.glUniform1i(uniDrawDistance, drawDistance * Perspective.LOCAL_TILE_SIZE); // Brightness happens to also be stored in the texture provider, so we use that gl.glUniform1f(uniBrightness, (float) textureProvider.getBrightness()); - gl.glUniform1f(uniSmoothBanding, config.smoothBanding() ? 0f : 1f); + gl.glUniform1f(uniSmoothBanding, this.smoothBanding ? 0f : 1f); for (int id = 0; id < textures.length; ++id) { @@ -1303,7 +1335,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks /** * Check is a model is visible and should be drawn. */ - private boolean isVisible(Model model, int orientation, int pitchSin, int pitchCos, int yawSin, int yawCos, int _x, int _y, int _z, long hash) + private boolean isNotVisible(Model model, int orientation, int pitchSin, int pitchCos, int yawSin, int yawCos, int _x, int _y, int _z, long hash) { final int XYZMag = model.getXYZMag(); final int zoom = client.get3dZoom(); @@ -1334,12 +1366,12 @@ public class GpuPlugin extends Plugin implements DrawCallbacks { int var21 = (pitchCos * modelHeight >> 16) + var19; int var22 = (var18 - var21) * zoom; - return var22 / var14 < Rasterizer3D_clipMidY2; + return var22 / var14 >= Rasterizer3D_clipMidY2; } } } } - return false; + return true; } /** @@ -1367,7 +1399,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks model.calculateBoundsCylinder(); model.calculateExtreme(orientation); - if (!isVisible(model, orientation, pitchSin, pitchCos, yawSin, yawCos, x, y, z, hash)) + if (isNotVisible(model, orientation, pitchSin, pitchCos, yawSin, yawCos, x, y, z, hash)) { return; } @@ -1431,7 +1463,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks model.calculateBoundsCylinder(); model.calculateExtreme(orientation); - if (!isVisible(model, orientation, pitchSin, pitchCos, yawSin, yawCos, x, y, z, hash)) + if (isNotVisible(model, orientation, pitchSin, pitchCos, yawSin, yawCos, x, y, z, hash)) { return; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/SceneUploader.java b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/SceneUploader.java index cb7d283d69..056e32cc39 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/gpu/SceneUploader.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/gpu/SceneUploader.java @@ -292,48 +292,34 @@ class SceneUploader vertexBuffer.ensureCapacity(24); uvBuffer.ensureCapacity(24); - // 0,0 - int vertexDx = localX; - int vertexDy = localY; - int vertexDz = swHeight; - final int c1 = swColor; - // 1,0 int vertexCx = localX + Perspective.LOCAL_TILE_SIZE; - int vertexCy = localY; - int vertexCz = seHeight; - final int c2 = seColor; // 1,1 int vertexAx = localX + Perspective.LOCAL_TILE_SIZE; int vertexAy = localY + Perspective.LOCAL_TILE_SIZE; - int vertexAz = neHeight; - final int c3 = neColor; // 0,1 - int vertexBx = localX; int vertexBy = localY + Perspective.LOCAL_TILE_SIZE; - int vertexBz = nwHeight; - final int c4 = nwColor; - vertexBuffer.put(vertexAx, vertexAz, vertexAy, c3); - vertexBuffer.put(vertexBx, vertexBz, vertexBy, c4); - vertexBuffer.put(vertexCx, vertexCz, vertexCy, c2); + vertexBuffer.put(vertexAx, neHeight, vertexAy, neColor); + vertexBuffer.put(localX, nwHeight, vertexBy, nwColor); + vertexBuffer.put(vertexCx, seHeight, localY, seColor); - vertexBuffer.put(vertexDx, vertexDz, vertexDy, c1); - vertexBuffer.put(vertexCx, vertexCz, vertexCy, c2); - vertexBuffer.put(vertexBx, vertexBz, vertexBy, c4); + vertexBuffer.put(localX, swHeight, localY, swColor); + vertexBuffer.put(vertexCx, seHeight, localY, seColor); + vertexBuffer.put(localX, nwHeight, vertexBy, nwColor); if (tile.getTexture() != -1) { float tex = tile.getTexture() + 1f; - uvBuffer.put(tex, 1.0f, 1.0f, 0f); - uvBuffer.put(tex, 0.0f, 1.0f, 0f); - uvBuffer.put(tex, 1.0f, 0.0f, 0f); + uvBuffer.put(tex, 1.0f, 1.0f); + uvBuffer.put(tex, 0.0f, 1.0f); + uvBuffer.put(tex, 1.0f, 0.0f); - uvBuffer.put(tex, 0.0f, 0.0f, 0f); - uvBuffer.put(tex, 1.0f, 0.0f, 0f); - uvBuffer.put(tex, 0.0f, 1.0f, 0f); + uvBuffer.put(tex, 0.0f, 0.0f); + uvBuffer.put(tex, 1.0f, 0.0f); + uvBuffer.put(tex, 0.0f, 1.0f); } return 6; @@ -399,15 +385,15 @@ class SceneUploader if (triangleTextures[i] != -1) { float tex = triangleTextures[i] + 1f; - uvBuffer.put(tex, vertexXA / 128f, vertexZA / 128f, 0f); - uvBuffer.put(tex, vertexXB / 128f, vertexZB / 128f, 0f); - uvBuffer.put(tex, vertexXC / 128f, vertexZC / 128f, 0f); + uvBuffer.put(tex, vertexXA / 128f, vertexZA / 128f); + uvBuffer.put(tex, vertexXB / 128f, vertexZB / 128f); + uvBuffer.put(tex, vertexXC / 128f, vertexZC / 128f); } else { - uvBuffer.put(0, 0, 0, 0f); - uvBuffer.put(0, 0, 0, 0f); - uvBuffer.put(0, 0, 0, 0f); + uvBuffer.put(0, 0, 0); + uvBuffer.put(0, 0, 0); + uvBuffer.put(0, 0, 0); } } } @@ -537,9 +523,9 @@ class SceneUploader if (faceTextures != null) { - uvBuffer.put(0, 0, 0, 0f); - uvBuffer.put(0, 0, 0, 0f); - uvBuffer.put(0, 0, 0, 0f); + uvBuffer.put(0, 0, 0); + uvBuffer.put(0, 0, 0); + uvBuffer.put(0, 0, 0); } return 3; } @@ -572,15 +558,15 @@ class SceneUploader if (u != null && v != null && (uf = u[face]) != null && (vf = v[face]) != null) { float texture = faceTextures[face] + 1f; - uvBuffer.put(texture, uf[0], vf[0], 0f); - uvBuffer.put(texture, uf[1], vf[1], 0f); - uvBuffer.put(texture, uf[2], vf[2], 0f); + uvBuffer.put(texture, uf[0], vf[0]); + uvBuffer.put(texture, uf[1], vf[1]); + uvBuffer.put(texture, uf[2], vf[2]); } else { - uvBuffer.put(0f, 0f, 0f, 0f); - uvBuffer.put(0f, 0f, 0f, 0f); - uvBuffer.put(0f, 0f, 0f, 0f); + uvBuffer.put(0f, 0f, 0f); + uvBuffer.put(0f, 0f, 0f); + uvBuffer.put(0f, 0f, 0f); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeInputListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeInputListener.java index c2533d59e4..56cc228a6e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeInputListener.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeInputListener.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.grandexchange; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.SwingUtilities; import net.runelite.api.Client; import net.runelite.api.MenuEntry; @@ -35,13 +36,14 @@ import net.runelite.client.input.MouseAdapter; import static net.runelite.client.plugins.grandexchange.GrandExchangePlugin.SEARCH_GRAND_EXCHANGE; import net.runelite.client.util.Text; +@Singleton public class GrandExchangeInputListener extends MouseAdapter implements KeyListener { private final Client client; private final GrandExchangePlugin plugin; @Inject - private GrandExchangeInputListener(Client client, GrandExchangePlugin plugin) + private GrandExchangeInputListener(final Client client, final GrandExchangePlugin plugin) { this.client = client; this.plugin = plugin; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeItemPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeItemPanel.java index 9c93d47b0f..c60130e94c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeItemPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeItemPanel.java @@ -35,6 +35,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.List; +import javax.inject.Singleton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.CompoundBorder; @@ -48,6 +49,7 @@ import net.runelite.client.util.StackFormatter; * This panel displays an individual item result in the * Grand Exchange search plugin. */ +@Singleton class GrandExchangeItemPanel extends JPanel { private static final Dimension ICON_SIZE = new Dimension(32, 32); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeOfferSlot.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeOfferSlot.java index 0f2f75b0de..e311fdc9e1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeOfferSlot.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeOfferSlot.java @@ -37,6 +37,7 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.image.BufferedImage; import javax.annotation.Nullable; +import javax.inject.Singleton; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; @@ -54,7 +55,8 @@ import net.runelite.client.util.ColorUtil; import net.runelite.client.util.ImageUtil; import net.runelite.client.util.StackFormatter; -public class GrandExchangeOfferSlot extends JPanel +@Singleton +class GrandExchangeOfferSlot extends JPanel { private static final String FACE_CARD = "FACE_CARD"; private static final String DETAILS_CARD = "DETAILS_CARD"; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeOffersPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeOffersPanel.java index 0531651a56..b58e28cbac 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeOffersPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeOffersPanel.java @@ -30,6 +30,7 @@ import java.awt.CardLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.image.BufferedImage; +import javax.inject.Singleton; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; import net.runelite.api.GrandExchangeOffer; @@ -38,7 +39,8 @@ import net.runelite.api.ItemDefinition; import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.components.PluginErrorPanel; -public class GrandExchangeOffersPanel extends JPanel +@Singleton +class GrandExchangeOffersPanel extends JPanel { private static final String ERROR_PANEL = "ERROR_PANEL"; private static final String OFFERS_PANEL = "OFFERS_PANEL"; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePanel.java index 68e18cecc0..2544ad2c07 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePanel.java @@ -30,8 +30,10 @@ import java.awt.BorderLayout; import java.util.Map; import java.util.concurrent.ScheduledExecutorService; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.client.callback.ClientThread; import net.runelite.client.game.ItemManager; @@ -40,6 +42,7 @@ import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.components.materialtabs.MaterialTab; import net.runelite.client.ui.components.materialtabs.MaterialTabGroup; +@Singleton class GrandExchangePanel extends PluginPanel { @@ -49,9 +52,9 @@ class GrandExchangePanel extends PluginPanel private final MaterialTabGroup tabGroup = new MaterialTabGroup(display); private final MaterialTab searchTab; - @Getter + @Getter(AccessLevel.PACKAGE) private GrandExchangeSearchPanel searchPanel; - @Getter + @Getter(AccessLevel.PACKAGE) private GrandExchangeOffersPanel offersPanel; @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java index 1cec9f64f1..4ce28688b9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java @@ -37,6 +37,7 @@ import java.io.InputStreamReader; import java.util.Map; import java.util.concurrent.ScheduledExecutorService; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.SwingUtilities; import lombok.AccessLevel; import lombok.Getter; @@ -90,6 +91,7 @@ import net.runelite.http.api.osbuddy.OSBGrandExchangeResult; tags = {"external", "integration", "notifications", "panel", "prices", "trade"} ) @Slf4j +@Singleton public class GrandExchangePlugin extends Plugin { private static final int OFFER_CONTAINER_ITEM = 21; @@ -174,6 +176,11 @@ public class GrandExchangePlugin extends Plugin configManager.unsetConfiguration("geoffer." + client.getUsername().toLowerCase(), Integer.toString(slot)); } + private boolean quickLookup; + private boolean enableNotifications; + private boolean enableOsbPrices; + private boolean enableGELimits; + @Provides GrandExchangeConfig provideConfig(ConfigManager configManager) { @@ -183,6 +190,8 @@ public class GrandExchangePlugin extends Plugin @Override protected void startUp() { + updateConfig(); + itemGELimits = loadGELimits(); panel = injector.getInstance(GrandExchangePanel.class); panel.setGELimits(itemGELimits); @@ -198,7 +207,7 @@ public class GrandExchangePlugin extends Plugin clientToolbar.addNavigation(button); - if (config.quickLookup()) + if (this.quickLookup) { mouseManager.registerMouseListener(inputListener); keyManager.registerKeyListener(inputListener); @@ -237,6 +246,14 @@ public class GrandExchangePlugin extends Plugin } } + private void updateConfig() + { + this.quickLookup = config.quickLookup(); + this.enableNotifications = config.enableNotifications(); + this.enableOsbPrices = config.enableOsbPrices(); + this.enableGELimits = config.enableGELimits(); + } + @Subscribe public void onSessionClose(SessionClose sessionClose) { @@ -248,9 +265,10 @@ public class GrandExchangePlugin extends Plugin { if (event.getGroup().equals("grandexchange")) { + updateConfig(); if (event.getKey().equals("quickLookup")) { - if (config.quickLookup()) + if (this.quickLookup) { mouseManager.registerMouseListener(inputListener); keyManager.registerKeyListener(inputListener); @@ -345,7 +363,7 @@ public class GrandExchangePlugin extends Plugin @Subscribe public void onChatMessage(ChatMessage event) { - if (!this.config.enableNotifications() || event.getType() != ChatMessageType.GAMEMESSAGE) + if (!this.enableNotifications || event.getType() != ChatMessageType.GAMEMESSAGE) { return; } @@ -490,7 +508,7 @@ public class GrandExchangePlugin extends Plugin return; } - if (config.enableGELimits() && itemGELimits != null && !geTextString.contains(BUY_LIMIT_GE_TEXT)) + if (this.enableGELimits && itemGELimits != null && !geTextString.contains(BUY_LIMIT_GE_TEXT)) { final Integer itemLimit = itemGELimits.get(itemId); @@ -502,7 +520,7 @@ public class GrandExchangePlugin extends Plugin } } - if (!config.enableOsbPrices() || geTextString.contains(OSB_GE_TEXT)) + if (!this.enableOsbPrices || geTextString.contains(OSB_GE_TEXT)) { // OSB prices are disabled or price was already looked up, so no need to set it again return; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeSearchPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeSearchPanel.java index b5443be68d..d8d88e3933 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeSearchPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangeSearchPanel.java @@ -36,10 +36,12 @@ import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.ScheduledExecutorService; +import javax.inject.Singleton; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.SwingUtilities; import javax.swing.border.EmptyBorder; +import lombok.AccessLevel; import lombok.Setter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.ItemDefinition; @@ -56,6 +58,7 @@ import net.runelite.http.api.item.ItemPrice; * It should display a search bar and either item results or a error panel. */ @Slf4j +@Singleton class GrandExchangeSearchPanel extends JPanel { private static final String ERROR_PANEL = "ERROR_PANEL"; @@ -82,10 +85,10 @@ class GrandExchangeSearchPanel extends JPanel private final List itemsList = new ArrayList<>(); - @Setter + @Setter(AccessLevel.PACKAGE) private Map itemGELimits = Collections.emptyMap(); - GrandExchangeSearchPanel(ClientThread clientThread, ItemManager itemManager, ScheduledExecutorService executor) + GrandExchangeSearchPanel(final ClientThread clientThread, final ItemManager itemManager, final ScheduledExecutorService executor) { this.clientThread = clientThread; this.itemManager = itemManager; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grotesqueguardians/DuskAttack.java b/runelite-client/src/main/java/net/runelite/client/plugins/grotesqueguardians/DuskAttack.java index ece52fe62e..afe3107282 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grotesqueguardians/DuskAttack.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grotesqueguardians/DuskAttack.java @@ -34,7 +34,7 @@ public enum DuskAttack private final int animation; private final Prayer prayer; - DuskAttack(int animation, Prayer prayer) + DuskAttack(final int animation, final Prayer prayer) { this.animation = animation; this.prayer = prayer; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grotesqueguardians/GrotesqueGuardiansOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/grotesqueguardians/GrotesqueGuardiansOverlay.java index 0c02d79b92..ed8602718b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grotesqueguardians/GrotesqueGuardiansOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grotesqueguardians/GrotesqueGuardiansOverlay.java @@ -29,6 +29,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Polygon; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.GraphicsObject; import net.runelite.api.Perspective; @@ -40,6 +41,7 @@ import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.ui.overlay.components.TextComponent; +@Singleton class GrotesqueGuardiansOverlay extends Overlay { private static final int GROTESQUE_GUARDIANS_REGION_ID = 6727; @@ -51,7 +53,7 @@ class GrotesqueGuardiansOverlay extends Overlay private static final int GROTESQUE_GUARDIANS_STONE_ORB = 160; @Inject - private GrotesqueGuardiansOverlay(Client client, GrotesqueGuardiansPlugin plugin) + private GrotesqueGuardiansOverlay(final Client client, final GrotesqueGuardiansPlugin plugin) { this.client = client; this.plugin = plugin; 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 77332e3c93..1ef158830f 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 @@ -25,6 +25,7 @@ package net.runelite.client.plugins.grotesqueguardians; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginType; @@ -46,7 +47,7 @@ import static net.runelite.api.NpcID.DUSK_7888; type = PluginType.PVM, enabledByDefault = false ) - +@Singleton public class GrotesqueGuardiansPlugin extends Plugin { private static final int GARGOYLES_REGION = 6727; @@ -93,7 +94,7 @@ public class GrotesqueGuardiansPlugin extends Plugin @Subscribe public void onGameTick(final GameTick event) { - final ArrayList regions = new ArrayList(); + final ArrayList regions = new ArrayList<>(); for (final int intValue : client.getMapRegions()) { regions.add(intValue); @@ -126,14 +127,7 @@ public class GrotesqueGuardiansPlugin extends Plugin { prayAgainst = null; } - if (dusk.getAnimation() == 7802) - { - needingToRun = true; - } - else - { - needingToRun = false; - } + needingToRun = dusk.getAnimation() == 7802; } } else diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grotesqueguardians/GrotesqueGuardiansPrayerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/grotesqueguardians/GrotesqueGuardiansPrayerOverlay.java index c63c0845da..1de4b29640 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grotesqueguardians/GrotesqueGuardiansPrayerOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grotesqueguardians/GrotesqueGuardiansPrayerOverlay.java @@ -30,6 +30,7 @@ import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.NPC; import net.runelite.api.Perspective; @@ -43,6 +44,7 @@ import net.runelite.client.ui.overlay.components.ComponentConstants; import net.runelite.client.ui.overlay.components.ImageComponent; import net.runelite.client.ui.overlay.components.PanelComponent; +@Singleton public class GrotesqueGuardiansPrayerOverlay extends Overlay { private static final Color NOT_ACTIVATED_BACKGROUND_COLOR = new Color(150, 0, 0, 150); @@ -52,7 +54,7 @@ public class GrotesqueGuardiansPrayerOverlay extends Overlay private final PanelComponent imagePanelComponent = new PanelComponent(); @Inject - private GrotesqueGuardiansPrayerOverlay(Client client, GrotesqueGuardiansPlugin plugin, SpriteManager spriteManager) + private GrotesqueGuardiansPrayerOverlay(final Client client, final GrotesqueGuardiansPlugin plugin, final SpriteManager spriteManager) { setLayer(OverlayLayer.ABOVE_SCENE); setPriority(OverlayPriority.HIGH); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemInputListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemInputListener.java index da6c3a80c5..4badf41ef4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemInputListener.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemInputListener.java @@ -30,10 +30,12 @@ import java.awt.event.MouseEvent; import java.time.Duration; import java.time.Instant; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.SwingUtilities; import net.runelite.client.input.KeyListener; import net.runelite.client.input.MouseAdapter; +@Singleton public class GroundItemInputListener extends MouseAdapter implements KeyListener { private static final int HOTKEY = KeyEvent.VK_ALT; @@ -43,9 +45,6 @@ public class GroundItemInputListener extends MouseAdapter implements KeyListener @Inject private GroundItemsPlugin plugin; - @Inject - private GroundItemsConfig config; - @Override public void keyTyped(KeyEvent e) { @@ -63,7 +62,7 @@ public class GroundItemInputListener extends MouseAdapter implements KeyListener plugin.setHotKeyPressed(true); lastPress = null; } - else if (lastPress != null && !plugin.isHotKeyPressed() && config.doubleTapDelay() > 0 && Duration.between(lastPress, Instant.now()).compareTo(Duration.ofMillis(config.doubleTapDelay())) < 0) + else if (lastPress != null && !plugin.isHotKeyPressed() && plugin.getDoubleTapDelay() > 0 && Duration.between(lastPress, Instant.now()).compareTo(Duration.ofMillis(plugin.getDoubleTapDelay())) < 0) { plugin.setHideAll(true); lastPress = null; 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 f9ce93dad6..14ff283672 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 @@ -41,6 +41,7 @@ import java.util.Map; import java.util.List; import java.util.Comparator; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.Player; @@ -60,6 +61,7 @@ import net.runelite.client.ui.overlay.components.ProgressPieComponent; import net.runelite.client.ui.overlay.components.TextComponent; import net.runelite.client.util.StackFormatter; +@Singleton public class GroundItemsOverlay extends Overlay { private static final int MAX_DISTANCE = 2500; @@ -83,7 +85,6 @@ public class GroundItemsOverlay extends Overlay private final Client client; private final GroundItemsPlugin plugin; - private final GroundItemsConfig config; private final StringBuilder itemStringBuilder = new StringBuilder(); private final BackgroundComponent backgroundComponent = new BackgroundComponent(); private final TextComponent textComponent = new TextComponent(); @@ -91,21 +92,20 @@ public class GroundItemsOverlay extends Overlay private final Map offsetMap = new HashMap<>(); @Inject - private GroundItemsOverlay(Client client, GroundItemsPlugin plugin, GroundItemsConfig config) + private GroundItemsOverlay(final Client client, final GroundItemsPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); this.client = client; this.plugin = plugin; - this.config = config; } @Override public Dimension render(Graphics2D graphics) { - final boolean dontShowOverlay = (config.itemHighlightMode() == MENU || plugin.isHideAll()) && !plugin.isHotKeyPressed(); + final boolean dontShowOverlay = (plugin.getItemHighlightMode() == MENU || plugin.isHideAll()) && !plugin.isHotKeyPressed(); - if (dontShowOverlay && !config.highlightTiles()) + if (dontShowOverlay && !plugin.isHighlightTiles()) { return null; } @@ -177,13 +177,13 @@ public class GroundItemsOverlay extends Overlay plugin.setHiddenBoxBounds(null); plugin.setHighlightBoxBounds(null); - final boolean onlyShowLoot = config.onlyShowLoot(); + final boolean onlyShowLoot = plugin.isOnlyShowLoot(); List groundItemListAsList = new ArrayList<>(groundItemList); // make a copy so we can non-destructively modify the list Comparator compareByHaPrice = Comparator.comparingInt(GroundItem::getHaPrice); Comparator compareByGePrice = Comparator.comparingInt(GroundItem::getGePrice); - groundItemListAsList.sort(config.sortByGEPrice() ? compareByGePrice : compareByHaPrice); + groundItemListAsList.sort(plugin.isSortByGEPrice() ? compareByGePrice : compareByHaPrice); for (GroundItem item : groundItemListAsList) { @@ -207,7 +207,7 @@ public class GroundItemsOverlay extends Overlay } // Do not display non-highlighted items - if (config.showHighlightedOnly()) + if (plugin.isShowHighlightedOnly()) { continue; } @@ -215,7 +215,7 @@ public class GroundItemsOverlay extends Overlay final Color color = plugin.getItemColor(highlighted, hidden); - if (config.highlightTiles()) + if (plugin.isHighlightTiles()) { final Polygon poly = Perspective.getCanvasTilePoly(client, groundPoint); @@ -246,7 +246,7 @@ public class GroundItemsOverlay extends Overlay } } - if (config.priceDisplayMode() == PriceDisplayMode.BOTH) + if (plugin.getPriceDisplayMode() == PriceDisplayMode.BOTH) { if (item.getGePrice() > 0) { @@ -262,9 +262,9 @@ public class GroundItemsOverlay extends Overlay .append(" gp)"); } } - else if (config.priceDisplayMode() != PriceDisplayMode.OFF) + else if (plugin.getPriceDisplayMode() != PriceDisplayMode.OFF) { - final int price = config.priceDisplayMode() == PriceDisplayMode.GE + final int price = plugin.getPriceDisplayMode() == PriceDisplayMode.GE ? item.getGePrice() : item.getHaPrice(); @@ -277,7 +277,7 @@ public class GroundItemsOverlay extends Overlay } } - if (item.getTicks() > 0 && config.showTimer()) + if (item.getTicks() > 0 && plugin.isShowTimer()) { itemStringBuilder .append(" - ") @@ -368,15 +368,15 @@ public class GroundItemsOverlay extends Overlay drawRectangle(graphics, itemHighlightBox, topItem && mouseInHighlightBox ? Color.GREEN : color, highlighted != null, false); } - if (config.showGroundItemDuration() == TimerDisplayMode.ALWAYS - || (config.showGroundItemDuration() == TimerDisplayMode.HOTKEY_PRESSED && plugin.isHotKeyPressed())) + if (plugin.getShowGroundItemDuration() == TimerDisplayMode.ALWAYS + || (plugin.getShowGroundItemDuration() == TimerDisplayMode.HOTKEY_PRESSED && plugin.isHotKeyPressed())) { drawTimerOverlay(graphics, new java.awt.Point(textX, textY), item); } - if (config.toggleOutline()) + if (plugin.isToggleOutline()) { - final Color bordercolor = config.bordercolor(); + final Color bordercolor = plugin.getBordercolor(); graphics.setColor(bordercolor); graphics.drawString(itemString, textX + 1, textY + 1); graphics.drawString(itemString, textX - 1, textY - 1); 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 0754a4616f..f2e70b9fdc 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 @@ -46,6 +46,7 @@ import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; @@ -82,11 +83,14 @@ import net.runelite.client.input.KeyManager; import net.runelite.client.input.MouseManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.grounditems.config.ItemHighlightMode; import static net.runelite.client.plugins.grounditems.config.ItemHighlightMode.OVERLAY; import net.runelite.client.plugins.grounditems.config.MenuHighlightMode; import static net.runelite.client.plugins.grounditems.config.MenuHighlightMode.BOTH; import static net.runelite.client.plugins.grounditems.config.MenuHighlightMode.NAME; import static net.runelite.client.plugins.grounditems.config.MenuHighlightMode.OPTION; +import net.runelite.client.plugins.grounditems.config.PriceDisplayMode; +import net.runelite.client.plugins.grounditems.config.TimerDisplayMode; import net.runelite.client.plugins.grounditems.config.ValueCalculationMode; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.util.ColorUtil; @@ -98,6 +102,7 @@ import net.runelite.client.util.Text; description = "Highlight ground items and/or show price information", tags = {"grand", "exchange", "high", "alchemy", "prices", "highlight", "overlay"} ) +@Singleton public class GroundItemsPlugin extends Plugin { // ItemID for coins @@ -175,12 +180,63 @@ public class GroundItemsPlugin extends Plugin @Inject private Notifier notifier; - @Getter + @Getter(AccessLevel.PUBLIC) public static final Map collectedGroundItems = new LinkedHashMap<>(); private final Map priceChecks = new LinkedHashMap<>(); private LoadingCache highlightedItems; private LoadingCache hiddenItems; + private Color defaultColor; + private Color highlightedColor; + private Color hiddenColor; + private String getHighlightItems; + @Getter(AccessLevel.PACKAGE) + private boolean showHighlightedOnly; + private ValueCalculationMode valueCalculationMode; + private int getHighlightOverValue; + private boolean notifyHighlightedDrops; + private boolean dontHideUntradeables; + private String getHiddenItems; + private boolean recolorMenuHiddenItems; + private int getHideUnderValue; + private boolean removeIgnored; + private boolean rightClickHidden; + @Getter(AccessLevel.PACKAGE) + private boolean highlightTiles; + @Getter(AccessLevel.PACKAGE) + private ItemHighlightMode itemHighlightMode; + private MenuHighlightMode menuHighlightMode; + private Color lowValueColor; + private int lowValuePrice; + private boolean notifyLowValueDrops; + private Color mediumValueColor; + private int mediumValuePrice; + private boolean notifyMediumValueDrops; + private Color highValueColor; + private int highValuePrice; + private boolean notifyHighValueDrops; + private Color insaneValueColor; + private int insaneValuePrice; + private boolean notifyInsaneValueDrops; + @Getter(AccessLevel.PACKAGE) + private PriceDisplayMode priceDisplayMode; + @Getter(AccessLevel.PACKAGE) + private boolean sortByGEPrice; + private boolean showMenuItemQuantities; + private boolean collapseEntries; + @Getter(AccessLevel.PACKAGE) + private boolean onlyShowLoot; + @Getter(AccessLevel.PACKAGE) + private TimerDisplayMode showGroundItemDuration; + @Getter(AccessLevel.PACKAGE) + private int doubleTapDelay; + @Getter(AccessLevel.PACKAGE) + private boolean toggleOutline; + @Getter(AccessLevel.PACKAGE) + private boolean showTimer; + @Getter(AccessLevel.PACKAGE) + private Color bordercolor; + @Provides GroundItemsConfig provideConfig(ConfigManager configManager) { @@ -190,6 +246,7 @@ public class GroundItemsPlugin extends Plugin @Override protected void startUp() { + updateConfig(); overlayManager.add(overlay); reset(); mouseManager.registerMouseListener(inputListener); @@ -226,6 +283,7 @@ public class GroundItemsPlugin extends Plugin { if (event.getGroup().equals("grounditems")) { + updateConfig(); reset(); } } @@ -254,12 +312,12 @@ public class GroundItemsPlugin extends Plugin existing.setQuantity(existing.getQuantity() + groundItem.getQuantity()); } - boolean shouldNotify = !config.onlyShowLoot() && config.highlightedColor().equals(getHighlighted( + boolean shouldNotify = !this.onlyShowLoot && this.highlightedColor.equals(getHighlighted( groundItem.getName(), groundItem.getGePrice(), groundItem.getHaPrice())); - if (config.notifyHighlightedDrops() && shouldNotify) + if (this.notifyHighlightedDrops && shouldNotify) { notifyHighlightedItem(groundItem); } @@ -340,23 +398,23 @@ public class GroundItemsPlugin extends Plugin Color itemColor = getHighlighted(composition.getName(), itemManager.getItemPrice(is.getId()) * is.getQuantity(), itemManager.getAlchValue(is.getId()) * is.getQuantity()); if (itemColor != null) { - if (config.notifyHighlightedDrops() && itemColor.equals(config.highlightedColor())) + if (this.notifyHighlightedDrops && itemColor.equals(this.highlightedColor)) { sendLootNotification(composition.getName(), "highlighted"); } - else if (config.notifyLowValueDrops() && itemColor.equals(config.lowValueColor())) + else if (this.notifyLowValueDrops && itemColor.equals(this.lowValueColor)) { sendLootNotification(composition.getName(), "low value"); } - else if (config.notifyMediumValueDrops() && itemColor.equals(config.mediumValueColor())) + else if (this.notifyMediumValueDrops && itemColor.equals(this.mediumValueColor)) { sendLootNotification(composition.getName(), "medium value"); } - else if (config.notifyHighValueDrops() && itemColor.equals(config.highValueColor())) + else if (this.notifyHighValueDrops && itemColor.equals(this.highValueColor)) { sendLootNotification(composition.getName(), "high value"); } - else if (config.notifyInsaneValueDrops() && itemColor.equals(config.insaneValueColor())) + else if (this.notifyInsaneValueDrops && itemColor.equals(this.insaneValueColor)) { sendLootNotification(composition.getName(), "insane value"); } @@ -382,7 +440,7 @@ public class GroundItemsPlugin extends Plugin { MenuEntry menuEntry = menuEntries[i]; - if (config.collapseEntries()) + if (this.collapseEntries) { int menuType = menuEntry.getType(); if (menuType == FIRST_OPTION || menuType == SECOND_OPTION || menuType == THIRD_OPTION @@ -427,7 +485,7 @@ public class GroundItemsPlugin extends Plugin final int bQuantity = getCollapsedItemQuantity(bId, bEntry.getTarget()); // only put items below walk if the config is set for it - if (config.rightClickHidden()) + if (this.rightClickHidden) { if (aHidden && bMenuType == WALK) return -1; @@ -442,8 +500,8 @@ public class GroundItemsPlugin extends Plugin return 1; - // RS sorts by alch price by default, so no need to sort if config not set - if (config.sortByGEPrice()) + // RS sorts by alch price by private, so no need to sort if config not set + if (this.sortByGEPrice) return (getGePriceFromItemId(aId) * aQuantity) - (getGePriceFromItemId(bId) * bQuantity); } } @@ -455,7 +513,7 @@ public class GroundItemsPlugin extends Plugin { final MenuEntry entry = e.getEntry(); - if (config.collapseEntries()) + if (this.collapseEntries) { final int count = e.getCount(); if (count > 1) @@ -480,12 +538,12 @@ public class GroundItemsPlugin extends Plugin groundItem.setMine(true); groundItem.setTicks(200); - boolean shouldNotify = config.onlyShowLoot() && config.highlightedColor().equals(getHighlighted( + boolean shouldNotify = this.onlyShowLoot && this.highlightedColor.equals(getHighlighted( groundItem.getName(), groundItem.getGePrice(), groundItem.getHaPrice())); - if (config.notifyHighlightedDrops() && shouldNotify) + if (this.notifyHighlightedDrops && shouldNotify) { notifyHighlightedItem(groundItem); } @@ -555,10 +613,10 @@ public class GroundItemsPlugin extends Plugin private void reset() { // gets the hidden items from the text box in the config - hiddenItemList = Text.fromCSV(config.getHiddenItems()); + hiddenItemList = Text.fromCSV(this.getHiddenItems); // gets the highlighted items from the text box in the config - highlightedItemsList = Text.fromCSV(config.getHighlightItems()); + highlightedItemsList = Text.fromCSV(this.getHighlightItems); highlightedItems = CacheBuilder.newBuilder() .maximumSize(512L) @@ -573,36 +631,36 @@ public class GroundItemsPlugin extends Plugin // Cache colors priceChecks.clear(); - if (config.insaneValuePrice() > 0) + if (this.insaneValuePrice > 0) { - priceChecks.put(config.insaneValuePrice(), config.insaneValueColor()); + priceChecks.put(this.insaneValuePrice, this.insaneValueColor); } - if (config.highValuePrice() > 0) + if (this.highValuePrice > 0) { - priceChecks.put(config.highValuePrice(), config.highValueColor()); + priceChecks.put(this.highValuePrice, this.highValueColor); } - if (config.mediumValuePrice() > 0) + if (this.mediumValuePrice > 0) { - priceChecks.put(config.mediumValuePrice(), config.mediumValueColor()); + priceChecks.put(this.mediumValuePrice, this.mediumValueColor); } - if (config.lowValuePrice() > 0) + if (this.lowValuePrice > 0) { - priceChecks.put(config.lowValuePrice(), config.lowValueColor()); + priceChecks.put(this.lowValuePrice, this.lowValueColor); } - if (config.getHighlightOverValue() > 0) + if (this.getHighlightOverValue > 0) { - priceChecks.put(config.getHighlightOverValue(), config.highlightedColor()); + priceChecks.put(this.getHighlightOverValue, this.highlightedColor); } } @Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { - if (config.itemHighlightMode() != OVERLAY + if (this.itemHighlightMode != OVERLAY && event.getOption().equals("Take") && event.getIdentifier() == THIRD_OPTION) { @@ -641,11 +699,11 @@ public class GroundItemsPlugin extends Plugin final Color hidden = getHidden(itemComposition.getName(), gePrice, haPrice, itemComposition.isTradeable()); final Color highlighted = getHighlighted(itemComposition.getName(), gePrice, haPrice); final Color color = getItemColor(highlighted, hidden); - final boolean canBeRecolored = highlighted != null || (hidden != null && config.recolorMenuHiddenItems()); + final boolean canBeRecolored = highlighted != null || (hidden != null && this.recolorMenuHiddenItems); - if (color != null && canBeRecolored && !color.equals(config.defaultColor())) + if (color != null && canBeRecolored && !color.equals(this.defaultColor)) { - final MenuHighlightMode mode = config.menuHighlightMode(); + final MenuHighlightMode mode = this.menuHighlightMode; if (mode == BOTH || mode == OPTION) { @@ -659,12 +717,12 @@ public class GroundItemsPlugin extends Plugin } } - if (config.showMenuItemQuantities() && itemComposition.isStackable() && quantity > 1) + if (this.showMenuItemQuantities && itemComposition.isStackable() && quantity > 1) { lastEntry.setTarget(lastEntry.getTarget() + " (" + quantity + ")"); } - if (config.removeIgnored() && event.getOption().equals("Take") && hiddenItemList.contains(Text.removeTags(event.getTarget()))) + if (this.removeIgnored && event.getOption().equals("Take") && hiddenItemList.contains(Text.removeTags(event.getTarget()))) { menuEntries = removeOption(event.getOption(), event.getTarget()); } @@ -718,14 +776,16 @@ public class GroundItemsPlugin extends Plugin } config.setHiddenItems(Text.toCSV(hiddenItemSet)); + this.getHiddenItems = Text.toCSV(hiddenItemSet); config.setHighlightedItem(Text.toCSV(highlightedItemSet)); + this.getHighlightItems = Text.toCSV(highlightedItemSet); } Color getHighlighted(String item, int gePrice, int haPrice) { if (TRUE.equals(highlightedItems.getUnchecked(item))) { - return config.highlightedColor(); + return this.highlightedColor; } // Explicit hide takes priority over implicit highlight @@ -734,7 +794,7 @@ public class GroundItemsPlugin extends Plugin return null; } - ValueCalculationMode mode = config.valueCalculationMode(); + ValueCalculationMode mode = this.valueCalculationMode; for (Map.Entry entry : priceChecks.entrySet()) { switch (mode) @@ -767,13 +827,13 @@ public class GroundItemsPlugin extends Plugin { final boolean isExplicitHidden = TRUE.equals(hiddenItems.getUnchecked(item)); final boolean isExplicitHighlight = TRUE.equals(highlightedItems.getUnchecked(item)); - final boolean canBeHidden = gePrice > 0 || isTradeable || !config.dontHideUntradeables(); - final boolean underGe = gePrice < config.getHideUnderValue(); - final boolean underHa = haPrice < config.getHideUnderValue(); + final boolean canBeHidden = gePrice > 0 || isTradeable || !this.dontHideUntradeables; + final boolean underGe = gePrice < this.getHideUnderValue; + final boolean underHa = haPrice < this.getHideUnderValue; // Explicit highlight takes priority over implicit hide return isExplicitHidden || (!isExplicitHighlight && canBeHidden && underGe && underHa) - ? config.hiddenColor() + ? this.hiddenColor : null; } @@ -827,7 +887,7 @@ public class GroundItemsPlugin extends Plugin return hidden; } - return config.defaultColor(); + return this.defaultColor; } @Subscribe @@ -868,4 +928,47 @@ public class GroundItemsPlugin extends Plugin notificationStringBuilder.append("!"); notifier.notify(notificationStringBuilder.toString()); } + + private void updateConfig() + { + this.defaultColor = config.defaultColor(); + this.highlightedColor = config.highlightedColor(); + this.hiddenColor = config.hiddenColor(); + this.getHighlightItems = config.getHighlightItems(); + this.showHighlightedOnly = config.showHighlightedOnly(); + this.valueCalculationMode = config.valueCalculationMode(); + this.getHighlightOverValue = config.getHighlightOverValue(); + this.notifyHighlightedDrops = config.notifyHighlightedDrops(); + this.dontHideUntradeables = config.dontHideUntradeables(); + this.getHiddenItems = config.getHiddenItems(); + this.recolorMenuHiddenItems = config.recolorMenuHiddenItems(); + this.getHideUnderValue = config.getHideUnderValue(); + this.removeIgnored = config.removeIgnored(); + this.rightClickHidden = config.rightClickHidden(); + this.highlightTiles = config.highlightTiles(); + this.itemHighlightMode = config.itemHighlightMode(); + this.menuHighlightMode = config.menuHighlightMode(); + this.lowValueColor = config.lowValueColor(); + this.lowValuePrice = config.lowValuePrice(); + this.notifyLowValueDrops = config.notifyLowValueDrops(); + this.mediumValueColor = config.mediumValueColor(); + this.mediumValuePrice = config.mediumValuePrice(); + this.notifyMediumValueDrops = config.notifyMediumValueDrops(); + this.highValueColor = config.highValueColor(); + this.highValuePrice = config.highValuePrice(); + this.notifyHighValueDrops = config.notifyHighValueDrops(); + this.insaneValueColor = config.insaneValueColor(); + this.insaneValuePrice = config.insaneValuePrice(); + this.notifyInsaneValueDrops = config.notifyInsaneValueDrops(); + this.priceDisplayMode = config.priceDisplayMode(); + this.sortByGEPrice = config.sortByGEPrice(); + this.showMenuItemQuantities = config.showMenuItemQuantities(); + this.collapseEntries = config.collapseEntries(); + this.onlyShowLoot = config.onlyShowLoot(); + this.showGroundItemDuration = config.showGroundItemDuration(); + this.doubleTapDelay = config.doubleTapDelay(); + this.toggleOutline = config.toggleOutline(); + this.showTimer = config.showTimer(); + this.bordercolor = config.bordercolor(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/MenuEntryWithCount.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/MenuEntryWithCount.java index a8539921c0..172bbc94ee 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/MenuEntryWithCount.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/MenuEntryWithCount.java @@ -24,6 +24,7 @@ */ package net.runelite.client.plugins.grounditems; +import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; import net.runelite.api.MenuEntry; @@ -31,10 +32,10 @@ import net.runelite.api.MenuEntry; @RequiredArgsConstructor class MenuEntryWithCount { - @Getter + @Getter(AccessLevel.PACKAGE) private final MenuEntry entry; - @Getter + @Getter(AccessLevel.PACKAGE) private int count = 1; void increment() diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/WildcardMatchLoader.java b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/WildcardMatchLoader.java index 7b91067ba4..0aeea2e1dd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/WildcardMatchLoader.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/grounditems/WildcardMatchLoader.java @@ -34,7 +34,7 @@ class WildcardMatchLoader extends CacheLoader { private final List nameFilters; - WildcardMatchLoader(List nameFilters) + WildcardMatchLoader(final List nameFilters) { this.nameFilters = nameFilters; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerInputListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerInputListener.java index a097d47d29..6a92bb0e99 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerInputListener.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerInputListener.java @@ -27,8 +27,10 @@ package net.runelite.client.plugins.groundmarkers; import java.awt.event.KeyEvent; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.client.input.KeyListener; +@Singleton public class GroundMarkerInputListener implements KeyListener { private static final int HOTKEY = KeyEvent.VK_SHIFT; @@ -36,7 +38,7 @@ public class GroundMarkerInputListener implements KeyListener private final GroundMarkerPlugin plugin; @Inject - private GroundMarkerInputListener(GroundMarkerPlugin plugin) + private GroundMarkerInputListener(final GroundMarkerPlugin plugin) { this.plugin = plugin; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerMinimapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerMinimapOverlay.java index 4e53a7d966..b4c3b21d75 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerMinimapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerMinimapOverlay.java @@ -30,6 +30,7 @@ import java.awt.Graphics2D; import static java.lang.Math.floor; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.Point; @@ -41,6 +42,7 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton class GroundMarkerMinimapOverlay extends Overlay { private static final int MAX_DRAW_DISTANCE = 16; @@ -48,14 +50,12 @@ class GroundMarkerMinimapOverlay extends Overlay private static final int TILE_HEIGHT = 4; private final Client client; - private final GroundMarkerConfig config; private final GroundMarkerPlugin plugin; @Inject - private GroundMarkerMinimapOverlay(Client client, GroundMarkerConfig config, GroundMarkerPlugin plugin) + private GroundMarkerMinimapOverlay(final Client client, final GroundMarkerPlugin plugin) { this.client = client; - this.config = config; this.plugin = plugin; setPosition(OverlayPosition.DYNAMIC); setPriority(OverlayPriority.LOW); @@ -65,7 +65,7 @@ class GroundMarkerMinimapOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!config.showMinimap()) + if (!plugin.isShowMinimap()) { return null; } @@ -79,20 +79,20 @@ class GroundMarkerMinimapOverlay extends Overlay continue; } - Color color = config.markerColor(); + Color color = plugin.getMarkerColor(); switch (point.getGroundMarkerPoint().getGroup()) { case 2: - color = config.markerColor2(); + color = plugin.getMarkerColor2(); break; case 3: - color = config.markerColor3(); + color = plugin.getMarkerColor3(); break; case 4: - color = config.markerColor4(); + color = plugin.getMarkerColor4(); } - int opacity = (int) floor(config.minimapOverlayOpacity() * 2.55); + int opacity = (int) floor(plugin.getMinimapOverlayOpacity() * 2.55); Color tileColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), opacity); drawOnMinimap(graphics, worldPoint, tileColor); 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 0d11dbf4a9..cb9b3c2eba 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 @@ -31,6 +31,7 @@ import java.awt.Graphics2D; import java.awt.Polygon; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.coords.LocalPoint; @@ -41,17 +42,16 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton public class GroundMarkerOverlay extends Overlay { private final Client client; - private final GroundMarkerConfig config; private final GroundMarkerPlugin plugin; @Inject - private GroundMarkerOverlay(Client client, GroundMarkerConfig config, GroundMarkerPlugin plugin) + private GroundMarkerOverlay(final Client client, final GroundMarkerPlugin plugin) { this.client = client; - this.config = config; this.plugin = plugin; setPosition(OverlayPosition.DYNAMIC); setPriority(OverlayPriority.LOW); @@ -78,8 +78,6 @@ public class GroundMarkerOverlay extends Overlay return; } - WorldPoint playerLocation = client.getLocalPlayer().getWorldLocation(); - LocalPoint lp = LocalPoint.fromWorld(client, point); if (lp == null) { @@ -92,17 +90,17 @@ public class GroundMarkerOverlay extends Overlay return; } - Color color = config.markerColor(); + Color color = plugin.getMarkerColor(); switch (groundMarkerWorldPoint.getGroundMarkerPoint().getGroup()) { case 2: - color = config.markerColor2(); + color = plugin.getMarkerColor2(); break; case 3: - color = config.markerColor3(); + color = plugin.getMarkerColor3(); break; case 4: - color = config.markerColor4(); + color = plugin.getMarkerColor4(); } OverlayUtil.renderPolygon(graphics, poly, color); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerPlugin.java index 400b01bd52..2566142be8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerPlugin.java @@ -39,6 +39,7 @@ import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; @@ -51,6 +52,7 @@ import net.runelite.api.MenuEntry; import net.runelite.api.Tile; import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.WorldPoint; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.FocusChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.MenuEntryAdded; @@ -70,6 +72,7 @@ import net.runelite.client.util.Text; description = "Enable marking of tiles using the Shift key", tags = {"overlay", "tiles"} ) +@Singleton public class GroundMarkerPlugin extends Plugin { private static final String CONFIG_GROUP = "groundMarker"; @@ -138,6 +141,19 @@ public class GroundMarkerPlugin extends Plugin { } + @Getter(AccessLevel.PACKAGE) + private Color markerColor; + @Getter(AccessLevel.PACKAGE) + private Color markerColor2; + @Getter(AccessLevel.PACKAGE) + private Color markerColor3; + @Getter(AccessLevel.PACKAGE) + private Color markerColor4; + @Getter(AccessLevel.PACKAGE) + private boolean showMinimap; + @Getter(AccessLevel.PACKAGE) + private int minimapOverlayOpacity; + @Provides GroundMarkerConfig provideConfig(ConfigManager configManager) { @@ -348,13 +364,15 @@ public class GroundMarkerPlugin extends Plugin @Override protected void shutDown() { + updateConfig(); + overlayManager.remove(overlay); overlayManager.remove(minimapOverlay); keyManager.unregisterKeyListener(inputListener); points.clear(); } - protected void markTile(LocalPoint localPoint, int group) + private void markTile(LocalPoint localPoint, int group) { if (localPoint == null) { @@ -390,19 +408,38 @@ public class GroundMarkerPlugin extends Plugin private Color getColor(int group) { - Color color = config.markerColor(); + Color color = this.markerColor; switch (group) { case 2: - color = config.markerColor2(); + color = this.markerColor2; break; case 3: - color = config.markerColor3(); + color = this.markerColor3; break; case 4: - color = config.markerColor4(); + color = this.markerColor4; } return color; } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("groundMarker")) + { + updateConfig(); + } + } + + private void updateConfig() + { + this.markerColor = config.markerColor(); + this.markerColor2 = config.markerColor2(); + this.markerColor3 = config.markerColor3(); + this.markerColor4 = config.markerColor4(); + this.showMinimap = config.showMinimap(); + this.minimapOverlayOpacity = config.minimapOverlayOpacity(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerPoint.java b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerPoint.java index e287f44efe..1d4e987862 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerPoint.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerPoint.java @@ -26,31 +26,16 @@ package net.runelite.client.plugins.groundmarkers; +import lombok.EqualsAndHashCode; import lombok.Value; @Value -public class GroundMarkerPoint +@EqualsAndHashCode(exclude = { "group" }) +class GroundMarkerPoint { private int regionId; private int regionX; private int regionY; private int z; private int group; - - @Override - public String toString() - { - return "GroundMarkerPoint(regionId=" + regionId + ",regionX=" + regionX + ",=regionY" + regionY + ",z=" + z + ")"; - } - - @Override - public boolean equals(Object o) - { - if (!(o instanceof GroundMarkerPoint)) - { - return false; - } - - return o.toString().equals(this.toString()); - } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerWorldPoint.java b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerWorldPoint.java index 9ea9915459..57234eeca0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerWorldPoint.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerWorldPoint.java @@ -28,7 +28,7 @@ import lombok.Value; import net.runelite.api.coords.WorldPoint; @Value -public class GroundMarkerWorldPoint +class GroundMarkerWorldPoint { private GroundMarkerPoint groundMarkerPoint; private WorldPoint worldPoint; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/herbiboars/HerbiboarMinimapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/herbiboars/HerbiboarMinimapOverlay.java index fff22cbc39..8e05236ea3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/herbiboars/HerbiboarMinimapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/herbiboars/HerbiboarMinimapOverlay.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.herbiboars; import com.google.inject.Inject; +import com.google.inject.Singleton; import java.awt.Dimension; import java.awt.Graphics2D; import java.util.Set; @@ -34,25 +35,23 @@ 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; - +@Singleton public class HerbiboarMinimapOverlay extends Overlay { private final HerbiboarPlugin plugin; - private final HerbiboarConfig config; @Inject - public HerbiboarMinimapOverlay(HerbiboarPlugin plugin, HerbiboarConfig config) + public HerbiboarMinimapOverlay(final HerbiboarPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); this.plugin = plugin; - this.config = config; } @Override public Dimension render(Graphics2D graphics) { - if (config.isTrailShown() && plugin.isInHerbiboarArea()) + if (plugin.isTrailShown() && plugin.isInHerbiboarArea()) { HerbiboarTrail currentTrail = plugin.getCurrentTrail(); int finishId = plugin.getFinishId(); @@ -70,7 +69,7 @@ public class HerbiboarMinimapOverlay extends Overlay if (shownTrailIds.contains(id) && (finishId > 0 || (currentTrail != null && currentTrail.getTrailId() != id && currentTrail.getTrailId() + 1 != id))) { - OverlayUtil.renderMinimapLocation(graphics, minimapLocation, config.getTrailColor()); + OverlayUtil.renderMinimapLocation(graphics, minimapLocation, plugin.getGetTrailColor()); } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/herbiboars/HerbiboarOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/herbiboars/HerbiboarOverlay.java index 653228cdb3..ad79b5b9e2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/herbiboars/HerbiboarOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/herbiboars/HerbiboarOverlay.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.herbiboars; import com.google.inject.Inject; +import com.google.inject.Singleton; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; @@ -37,18 +38,17 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton class HerbiboarOverlay extends Overlay { private final HerbiboarPlugin plugin; - private final HerbiboarConfig config; @Inject - public HerbiboarOverlay(HerbiboarPlugin plugin, HerbiboarConfig config) + public HerbiboarOverlay(final HerbiboarPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); this.plugin = plugin; - this.config = config; } @Override @@ -64,16 +64,14 @@ class HerbiboarOverlay extends Overlay int finishId = plugin.getFinishId(); // Draw start objects - if (config.isStartShown() && (currentTrail == null && finishId == 0)) + if (plugin.isStartShown() && (currentTrail == null && finishId == 0)) { plugin.getStarts().values().forEach((obj) -> - { - OverlayUtil.renderTileOverlay(graphics, obj, "", config.getStartColor()); - }); + OverlayUtil.renderTileOverlay(graphics, obj, "", plugin.getGetStartColor())); } // Draw trails - if (config.isTrailShown()) + if (plugin.isTrailShown()) { Set shownTrailIds = plugin.getShownTrails(); plugin.getTrails().values().forEach((x) -> @@ -81,13 +79,13 @@ class HerbiboarOverlay extends Overlay int id = x.getId(); if (shownTrailIds.contains(id) && (finishId > 0 || (currentTrail != null && currentTrail.getTrailId() != id && currentTrail.getTrailId() + 1 != id))) { - OverlayUtil.renderTileOverlay(graphics, x, "", config.getTrailColor()); + OverlayUtil.renderTileOverlay(graphics, x, "", plugin.getGetTrailColor()); } }); } // Draw trail objects (mushrooms, mud, etc) - if (config.isObjectShown() && currentTrail != null) + if (plugin.isObjectShown() && currentTrail != null) { int currentPath = plugin.getCurrentPath(); WorldPoint[] trailLocs = currentTrail.getObjectLocs(currentPath); @@ -101,12 +99,12 @@ class HerbiboarOverlay extends Overlay TileObject object = plugin.getTrailObjects().get(trailLoc); if (object != null) { - if (config.showClickBoxes()) + if (plugin.isShowClickBoxes()) { Area clickbox = object.getClickbox(); if (clickbox != null) { - graphics.setColor(config.getObjectColor()); + graphics.setColor(plugin.getGetObjectColor()); graphics.draw(clickbox); graphics.setColor(new Color(255, 0, 255, 20)); graphics.fill(clickbox); @@ -114,25 +112,25 @@ class HerbiboarOverlay extends Overlay } else { - OverlayUtil.renderTileOverlay(graphics, object, "", config.getObjectColor()); + OverlayUtil.renderTileOverlay(graphics, object, "", plugin.getGetObjectColor()); } } } } // Draw finish tunnels - if (config.isTunnelShown() && finishId > 0) + if (plugin.isTunnelShown() && finishId > 0) { WorldPoint finishLoc = plugin.getEndLocations().get(finishId - 1); TileObject object = plugin.getTunnels().get(finishLoc); if (object != null) { - if (config.showClickBoxes()) + if (plugin.isShowClickBoxes()) { Area clickbox = object.getClickbox(); if (clickbox != null) { - Color col = config.getObjectColor(); + Color col = plugin.getGetObjectColor(); graphics.setColor(col); graphics.draw(clickbox); graphics.setColor(new Color(col.getRed(), col.getGreen(), col.getBlue(), 20)); @@ -141,7 +139,7 @@ class HerbiboarOverlay extends Overlay } else { - OverlayUtil.renderTileOverlay(graphics, object, "", config.getTunnelColor()); + OverlayUtil.renderTileOverlay(graphics, object, "", plugin.getGetTunnelColor()); } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/herbiboars/HerbiboarPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/herbiboars/HerbiboarPlugin.java index b921bb5495..cc6dc7258d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/herbiboars/HerbiboarPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/herbiboars/HerbiboarPlugin.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.herbiboars; import com.google.inject.Provides; +import java.awt.Color; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -32,6 +33,8 @@ import java.util.List; import java.util.Map; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import net.runelite.api.Client; @@ -44,6 +47,7 @@ import net.runelite.api.Tile; import net.runelite.api.TileObject; import net.runelite.api.Varbits; import net.runelite.api.coords.WorldPoint; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameObjectChanged; import net.runelite.api.events.GameObjectDespawned; import net.runelite.api.events.GameObjectSpawned; @@ -63,6 +67,7 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Highlight starting rocks, trails, and the objects to search at the end of each trail", tags = {"herblore", "hunter", "skilling", "overlay"} ) +@Singleton public class HerbiboarPlugin extends Plugin { private static final List END_LOCATIONS = Arrays.asList( @@ -104,37 +109,59 @@ public class HerbiboarPlugin extends Plugin @Inject private HerbiboarMinimapOverlay minimapOverlay; - @Getter + @Inject + private HerbiboarConfig config; + + @Getter(AccessLevel.PACKAGE) private boolean inHerbiboarArea; - @Getter + @Getter(AccessLevel.PACKAGE) private Map trails = new HashMap<>(); - @Getter + @Getter(AccessLevel.PACKAGE) private Map tunnels = new HashMap<>(); - @Getter + @Getter(AccessLevel.PACKAGE) private Map starts = new HashMap<>(); - @Getter + @Getter(AccessLevel.PACKAGE) private Map trailObjects = new HashMap<>(); - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private Set shownTrails = new HashSet<>(); - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private HerbiboarTrail currentTrail; - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private int currentPath; - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private int finishId; + @Getter(AccessLevel.PACKAGE) + private boolean isStartShown; + @Getter(AccessLevel.PACKAGE) + private boolean showClickBoxes; + @Getter(AccessLevel.PACKAGE) + private Color getStartColor; + @Getter(AccessLevel.PACKAGE) + private boolean isTunnelShown; + @Getter(AccessLevel.PACKAGE) + private Color getTunnelColor; + @Getter(AccessLevel.PACKAGE) + private boolean isObjectShown; + @Getter(AccessLevel.PACKAGE) + private Color getObjectColor; + @Getter(AccessLevel.PACKAGE) + private boolean isTrailShown; + @Getter(AccessLevel.PACKAGE) + private Color getTrailColor; + @Provides HerbiboarConfig getConfig(ConfigManager configManager) { @@ -144,6 +171,8 @@ public class HerbiboarPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(overlay); overlayManager.add(minimapOverlay); inHerbiboarArea = checkArea(); @@ -260,19 +289,19 @@ public class HerbiboarPlugin extends Plugin @Subscribe public void onGroundObjectSpawned(GroundObjectSpawned event) { - onGroundObject(event.getTile(), null, event.getGroundObject()); + onGroundObject( null, event.getGroundObject()); } @Subscribe public void onGroundObjectChanged(GroundObjectChanged event) { - onGroundObject(event.getTile(), event.getPrevious(), event.getGroundObject()); + onGroundObject(event.getPrevious(), event.getGroundObject()); } @Subscribe public void onGroundObjectDespawned(GroundObjectDespawned event) { - onGroundObject(event.getTile(), event.getGroundObject(), null); + onGroundObject(event.getGroundObject(), null); } // Store relevant GameObjects (starts, objects used to trigger next trails, and some tunnels) @@ -313,7 +342,7 @@ public class HerbiboarPlugin extends Plugin } // Store relevant GroundObjects (tracks on trails, and some tunnels) - private void onGroundObject(Tile tile, TileObject oldObject, TileObject newObject) + private void onGroundObject(TileObject oldObject, TileObject newObject) { if (oldObject != null) { @@ -348,8 +377,30 @@ public class HerbiboarPlugin extends Plugin .toArray().length > 0; } - public List getEndLocations() + List getEndLocations() { return END_LOCATIONS; } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("herbiboar")) + { + updateConfig(); + } + } + + private void updateConfig() + { + this.isStartShown = config.isStartShown(); + this.showClickBoxes = config.showClickBoxes(); + this.getStartColor = config.getStartColor(); + this.isTunnelShown = config.isTunnelShown(); + this.getTunnelColor = config.getTunnelColor(); + this.isObjectShown = config.isObjectShown(); + this.getObjectColor = config.getObjectColor(); + this.isTrailShown = config.isTrailShown(); + this.getTrailColor = config.getTrailColor(); + } } 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 15ae602352..0fb87507c7 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 @@ -33,6 +33,7 @@ import java.util.List; import java.util.Objects; import java.util.stream.Collectors; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.HashTable; @@ -50,7 +51,16 @@ import net.runelite.client.eventbus.Subscribe; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginType; +import net.runelite.client.plugins.hideprayers.util.Armadyl; +import net.runelite.client.plugins.hideprayers.util.Bandos; +import net.runelite.client.plugins.hideprayers.util.Barrows; +import net.runelite.client.plugins.hideprayers.util.Cerberus; +import net.runelite.client.plugins.hideprayers.util.PVPPrayers; import net.runelite.client.plugins.hideprayers.util.PrayerTabStates; +import net.runelite.client.plugins.hideprayers.util.Saradomin; +import net.runelite.client.plugins.hideprayers.util.Vorkath; +import net.runelite.client.plugins.hideprayers.util.Zamorak; +import net.runelite.client.plugins.hideprayers.util.Zulrah; @PluginDescriptor( name = "Show/Hide Prayers", @@ -58,7 +68,7 @@ import net.runelite.client.plugins.hideprayers.util.PrayerTabStates; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton public class HidePrayersPlugin extends Plugin { private static final List PRAYER_WIDGET_INFO_LIST = ImmutableList.of( @@ -99,6 +109,56 @@ public class HidePrayersPlugin extends Plugin @Inject private HidePrayersConfig config; + private boolean showindividualprayers; + private boolean ShowTHICK_SKIN; + private boolean ShowBURST_OF_STRENGTH; + private boolean ShowCLARITY_OF_THOUGHT; + private boolean ShowSHARP_EYE; + private boolean ShowMYSTIC_WILL; + private boolean ShowROCK_SKIN; + private boolean ShowSUPERHUMAN_STRENGTH; + private boolean ShowIMPROVED_REFLEXES; + private boolean ShowRapidRestore; + private boolean ShowRapidHeal; + private boolean ShowProtectItem; + private boolean ShowHAWK_EYE; + private boolean ShowMYSTIC_LORE; + private boolean ShowSteelSkin; + private boolean ShowUltimateStrength; + private boolean ShowIncredibleReflex; + private boolean ShowPTFMagic; + private boolean ShowPTFRange; + private boolean ShowPTFMelee; + private boolean ShowEagle; + private boolean ShowMystic; + private boolean ShowRETRIBUTION; + private boolean ShowRedemption; + private boolean ShowSmite; + private boolean ShowPreserve; + private boolean ShowChivalry; + private boolean ShowPiety; + private boolean ShowRigour; + private boolean ShowAugury; + private boolean getarmadylprayers; + private Armadyl armadyl; + private boolean getbarrowsprayers; + private Barrows barrows; + private boolean getbandosprayers; + private Bandos bandos; + private boolean getcerberusprayers; + private Cerberus cerberus; + private boolean getsaradominprayers; + private Saradomin saradomin; + private boolean getvorkathprayers; + private Vorkath vorkath; + private boolean getzamorakprayers; + private Zamorak zamorak; + private boolean getzulrahprayers; + private Zulrah zulrah; + private boolean getpvpprayers; + private PVPPrayers pvpprayers; + private boolean HideRapidHealRestore; + @Provides HidePrayersConfig provideConfig(ConfigManager configManager) { @@ -108,6 +168,7 @@ public class HidePrayersPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); hidePrayers(); } @@ -132,6 +193,7 @@ public class HidePrayersPlugin extends Plugin { if (event.getGroup().equals("hideprayers")) { + updateConfig(); hidePrayers(); } } @@ -233,16 +295,16 @@ public class HidePrayersPlugin extends Plugin return; } - if ( !config.showindividualprayers() - && !config.getarmadylprayers() - && !config.getbarrowsprayers() - && !config.getbandosprayers() - && !config.getcerberusprayers() - && !config.getsaradominprayers() - && !config.getvorkathprayers() - && !config.getzamorakprayers() - && !config.getzulrahprayers() - && !config.getpvpprayers()) + if ( !this.showindividualprayers + && !this.getarmadylprayers + && !this.getbarrowsprayers + && !this.getbandosprayers + && !this.getcerberusprayers + && !this.getsaradominprayers + && !this.getvorkathprayers + && !this.getzamorakprayers + && !this.getzulrahprayers + && !this.getpvpprayers) { restorePrayers(); return; @@ -250,42 +312,42 @@ public class HidePrayersPlugin extends Plugin reallyHidePrayers(); - if (config.showindividualprayers()) + if (this.showindividualprayers) { - prayerWidgets.get(0).setHidden(!config.ShowTHICK_SKIN()); // Thick Skin - prayerWidgets.get(1).setHidden(!config.ShowBURST_OF_STRENGTH()); // Burst of Strength - prayerWidgets.get(2).setHidden(!config.ShowCLARITY_OF_THOUGHT()); // Clarity of Thought - prayerWidgets.get(3).setHidden(!config.ShowSHARP_EYE()); // Sharp Eye - prayerWidgets.get(4).setHidden(!config.ShowMYSTIC_WILL()); // Mystic Will - prayerWidgets.get(5).setHidden(!config.ShowROCK_SKIN()); // Rock Skin - prayerWidgets.get(6).setHidden(!config.ShowSUPERHUMAN_STRENGTH()); // Super Human Strength - prayerWidgets.get(7).setHidden(!config.ShowIMPROVED_REFLEXES()); // Improved_Reflexes - prayerWidgets.get(8).setHidden(!config.ShowRapidRestore()); // Rapid Restore - prayerWidgets.get(9).setHidden(!config.ShowRapidHeal()); // Rapid Heal - prayerWidgets.get(10).setHidden(!config.ShowProtectItem()); // Protect Item - prayerWidgets.get(11).setHidden(!config.ShowHAWK_EYE()); // Hawk Eye - prayerWidgets.get(12).setHidden(!config.ShowMYSTIC_LORE()); // Mystic Lore - prayerWidgets.get(13).setHidden(!config.ShowSteelSkin()); // Steel Skin - prayerWidgets.get(14).setHidden(!config.ShowUltimateStrength()); // Ultimate Strength - prayerWidgets.get(15).setHidden(!config.ShowIncredibleReflex()); // Incredible Reflexes - prayerWidgets.get(16).setHidden(!config.ShowPTFMagic()); // Protect from Magic - prayerWidgets.get(17).setHidden(!config.ShowPTFRange()); // Protect from Range - prayerWidgets.get(18).setHidden(!config.ShowPTFMelee()); // Protect from Melee - prayerWidgets.get(19).setHidden(!config.ShowEagle()); // eagle eye - prayerWidgets.get(20).setHidden(!config.ShowMystic()); // Mystic Might - prayerWidgets.get(21).setHidden(!config.ShowRETRIBUTION()); // Retribution - prayerWidgets.get(22).setHidden(!config.ShowRedemption()); // Redemption - prayerWidgets.get(23).setHidden(!config.ShowSmite()); // Smite - prayerWidgets.get(24).setHidden(!config.ShowPreserve()); // Preserve - prayerWidgets.get(25).setHidden(!config.ShowChivalry()); // Chivalry - prayerWidgets.get(26).setHidden(!config.ShowPiety()); // Piety - prayerWidgets.get(27).setHidden(!config.ShowRigour()); // Rigour - prayerWidgets.get(28).setHidden(!config.ShowAugury()); // Augury + prayerWidgets.get(0).setHidden(!this.ShowTHICK_SKIN); // Thick Skin + prayerWidgets.get(1).setHidden(!this.ShowBURST_OF_STRENGTH); // Burst of Strength + prayerWidgets.get(2).setHidden(!this.ShowCLARITY_OF_THOUGHT); // Clarity of Thought + prayerWidgets.get(3).setHidden(!this.ShowSHARP_EYE); // Sharp Eye + prayerWidgets.get(4).setHidden(!this.ShowMYSTIC_WILL); // Mystic Will + prayerWidgets.get(5).setHidden(!this.ShowROCK_SKIN); // Rock Skin + prayerWidgets.get(6).setHidden(!this.ShowSUPERHUMAN_STRENGTH); // Super Human Strength + prayerWidgets.get(7).setHidden(!this.ShowIMPROVED_REFLEXES); // Improved_Reflexes + prayerWidgets.get(8).setHidden(!this.ShowRapidRestore); // Rapid Restore + prayerWidgets.get(9).setHidden(!this.ShowRapidHeal); // Rapid Heal + prayerWidgets.get(10).setHidden(!this.ShowProtectItem); // Protect Item + prayerWidgets.get(11).setHidden(!this.ShowHAWK_EYE); // Hawk Eye + prayerWidgets.get(12).setHidden(!this.ShowMYSTIC_LORE); // Mystic Lore + prayerWidgets.get(13).setHidden(!this.ShowSteelSkin); // Steel Skin + prayerWidgets.get(14).setHidden(!this.ShowUltimateStrength); // Ultimate Strength + prayerWidgets.get(15).setHidden(!this.ShowIncredibleReflex); // Incredible Reflexes + prayerWidgets.get(16).setHidden(!this.ShowPTFMagic); // Protect from Magic + prayerWidgets.get(17).setHidden(!this.ShowPTFRange); // Protect from Range + prayerWidgets.get(18).setHidden(!this.ShowPTFMelee); // Protect from Melee + prayerWidgets.get(19).setHidden(!this.ShowEagle); // eagle eye + prayerWidgets.get(20).setHidden(!this.ShowMystic); // Mystic Might + prayerWidgets.get(21).setHidden(!this.ShowRETRIBUTION); // Retribution + prayerWidgets.get(22).setHidden(!this.ShowRedemption); // Redemption + prayerWidgets.get(23).setHidden(!this.ShowSmite); // Smite + prayerWidgets.get(24).setHidden(!this.ShowPreserve); // Preserve + prayerWidgets.get(25).setHidden(!this.ShowChivalry); // Chivalry + prayerWidgets.get(26).setHidden(!this.ShowPiety); // Piety + prayerWidgets.get(27).setHidden(!this.ShowRigour); // Rigour + prayerWidgets.get(28).setHidden(!this.ShowAugury); // Augury } - else if (config.getarmadylprayers()) + else if (this.getarmadylprayers) { - switch (config.armadyl()) + switch (this.armadyl) { case DISABLED: break; @@ -306,9 +368,9 @@ public class HidePrayersPlugin extends Plugin } } - else if (config.getbandosprayers()) + else if (this.getbandosprayers) { - switch (config.bandos()) + switch (this.bandos) { case DISABLED: break; @@ -329,9 +391,9 @@ public class HidePrayersPlugin extends Plugin } } - else if (config.getbarrowsprayers()) + else if (this.getbarrowsprayers) { - switch (config.barrows()) + switch (this.barrows) { case DISABLED: break; @@ -356,9 +418,9 @@ public class HidePrayersPlugin extends Plugin } } - else if (config.getcerberusprayers()) + else if (this.getcerberusprayers) { - switch (config.cerberus()) + switch (this.cerberus) { case DISABLED: break; @@ -399,9 +461,9 @@ public class HidePrayersPlugin extends Plugin } } - else if (config.getsaradominprayers()) + else if (this.getsaradominprayers) { - switch (config.saradomin()) + switch (this.saradomin) { case DISABLED: break; @@ -423,9 +485,9 @@ public class HidePrayersPlugin extends Plugin break; } } - else if (config.getvorkathprayers()) + else if (this.getvorkathprayers) { - switch (config.vorkath()) + switch (this.vorkath) { case DISABLED: break; @@ -446,9 +508,9 @@ public class HidePrayersPlugin extends Plugin } } - else if (config.getzamorakprayers()) + else if (this.getzamorakprayers) { - switch (config.zamorak()) + switch (this.zamorak) { case DISABLED: break; @@ -471,9 +533,9 @@ public class HidePrayersPlugin extends Plugin } } - else if (config.getzulrahprayers()) + else if (this.getzulrahprayers) { - switch (config.zulrah()) + switch (this.zulrah) { case DISABLED: break; @@ -496,9 +558,9 @@ public class HidePrayersPlugin extends Plugin } } - else if (config.getpvpprayers()) + else if (this.getpvpprayers) { - if (config.HideRapidHealRestore()) + if (this.HideRapidHealRestore) { prayerWidgets.get(8).setHidden(true); // Rapid Restore prayerWidgets.get(9).setHidden(true); // Rapid Heal @@ -518,7 +580,7 @@ public class HidePrayersPlugin extends Plugin prayerWidgets.get(10).setHidden(false); // Protect Item } - switch (config.pvpprayers()) + switch (this.pvpprayers) { case DISABLED: reallyHidePrayers(); @@ -651,4 +713,57 @@ public class HidePrayersPlugin extends Plugin } } } + + private void updateConfig() + { + this.showindividualprayers = config.showindividualprayers(); + this.ShowTHICK_SKIN = config.ShowTHICK_SKIN(); + this.ShowBURST_OF_STRENGTH = config.ShowBURST_OF_STRENGTH(); + this.ShowCLARITY_OF_THOUGHT = config.ShowCLARITY_OF_THOUGHT(); + this.ShowSHARP_EYE = config.ShowSHARP_EYE(); + this.ShowMYSTIC_WILL = config.ShowMYSTIC_WILL(); + this.ShowROCK_SKIN = config.ShowROCK_SKIN(); + this.ShowSUPERHUMAN_STRENGTH = config.ShowSUPERHUMAN_STRENGTH(); + this.ShowIMPROVED_REFLEXES = config.ShowIMPROVED_REFLEXES(); + this.ShowRapidRestore = config.ShowRapidRestore(); + this.ShowRapidHeal = config.ShowRapidHeal(); + this.ShowProtectItem = config.ShowProtectItem(); + this.ShowHAWK_EYE = config.ShowHAWK_EYE(); + this.ShowMYSTIC_LORE = config.ShowMYSTIC_LORE(); + this.ShowSteelSkin = config.ShowSteelSkin(); + this.ShowUltimateStrength = config.ShowUltimateStrength(); + this.ShowIncredibleReflex = config.ShowIncredibleReflex(); + this.ShowPTFMagic = config.ShowPTFMagic(); + this.ShowPTFRange = config.ShowPTFRange(); + this.ShowPTFMelee = config.ShowPTFMelee(); + this.ShowEagle = config.ShowEagle(); + this.ShowMystic = config.ShowMystic(); + this.ShowRETRIBUTION = config.ShowRETRIBUTION(); + this.ShowRedemption = config.ShowRedemption(); + this.ShowSmite = config.ShowSmite(); + this.ShowPreserve = config.ShowPreserve(); + this.ShowChivalry = config.ShowChivalry(); + this.ShowPiety = config.ShowPiety(); + this.ShowRigour = config.ShowRigour(); + this.ShowAugury = config.ShowAugury(); + this.getarmadylprayers = config.getarmadylprayers(); + this.armadyl = config.armadyl(); + this.getbarrowsprayers = config.getbarrowsprayers(); + this.barrows = config.barrows(); + this.getbandosprayers = config.getbandosprayers(); + this.bandos = config.bandos(); + this.getcerberusprayers = config.getcerberusprayers(); + this.cerberus = config.cerberus(); + this.getsaradominprayers = config.getsaradominprayers(); + this.saradomin = config.saradomin(); + this.getvorkathprayers = config.getvorkathprayers(); + this.vorkath = config.vorkath(); + this.getzamorakprayers = config.getzamorakprayers(); + this.zamorak = config.zamorak(); + this.getzulrahprayers = config.getzulrahprayers(); + this.zulrah = config.zulrah(); + this.getpvpprayers = config.getpvpprayers(); + this.pvpprayers = config.pvpprayers(); + this.HideRapidHealRestore = config.HideRapidHealRestore(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/highalchemy/HighAlchemyOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/highalchemy/HighAlchemyOverlay.java index 191b7c9cf9..d4de57b30e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/highalchemy/HighAlchemyOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/highalchemy/HighAlchemyOverlay.java @@ -33,6 +33,7 @@ import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.ItemDefinition; import net.runelite.api.ItemID; import net.runelite.api.widgets.Widget; @@ -41,19 +42,18 @@ import net.runelite.api.widgets.WidgetItem; import net.runelite.client.game.ItemManager; import net.runelite.client.ui.overlay.WidgetItemOverlay; +@Singleton public class HighAlchemyOverlay extends WidgetItemOverlay { private final ItemManager itemManager; - private final HighAlchemyConfig config; private final HighAlchemyPlugin plugin; private final int alchPrice; private final int alchPriceNoStaff; @Inject - public HighAlchemyOverlay(ItemManager itemManager, HighAlchemyPlugin plugin, HighAlchemyConfig config) + public HighAlchemyOverlay(final ItemManager itemManager, final HighAlchemyPlugin plugin) { this.itemManager = itemManager; - this.config = config; this.plugin = plugin; int natPrice = itemManager.getItemPrice(ItemID.NATURE_RUNE); @@ -78,13 +78,13 @@ public class HighAlchemyOverlay extends WidgetItemOverlay final int id = getNotedId(itemId); final int gePrice = getGEPrice(id); final int haPrice = getHAPrice(id); - final int materialCost = config.usingFireRunes() ? alchPriceNoStaff : alchPrice; - final int desiredProfit = config.minProfit(); + final int materialCost = plugin.isUsingFireRunes() ? alchPriceNoStaff : alchPrice; + final int desiredProfit = plugin.getMinProfit(); final int haProfit = getHAProfit(haPrice, gePrice, materialCost); if (gePrice > 0 && haPrice > 0 && haProfit >= desiredProfit) { - final Color color = config.getHighlightColor(); + final Color color = plugin.getGetHighlightColor(); if (color != null) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/highalchemy/HighAlchemyPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/highalchemy/HighAlchemyPlugin.java index ecfa486fed..79be6bbac4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/highalchemy/HighAlchemyPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/highalchemy/HighAlchemyPlugin.java @@ -28,10 +28,12 @@ package net.runelite.client.plugins.highalchemy; import com.google.inject.Provides; +import java.awt.Color; import java.util.Arrays; import java.util.HashSet; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.events.ConfigChanged; @@ -57,7 +59,7 @@ import net.runelite.client.ui.overlay.OverlayManager; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton public class HighAlchemyPlugin extends Plugin { private static final String CONFIG_GROUP = "highalchemy"; @@ -80,9 +82,19 @@ public class HighAlchemyPlugin extends Plugin return configManager.getConfig(HighAlchemyConfig.class); } + private boolean showBank; + private boolean showInventory; + @Getter(AccessLevel.PACKAGE) + private Color getHighlightColor; + @Getter(AccessLevel.PACKAGE) + private int minProfit; + @Getter(AccessLevel.PACKAGE) + private boolean usingFireRunes; + @Override protected void startUp() throws Exception { + updateConfig(); buildGroupList(); overlayManager.add(overlay); } @@ -98,6 +110,7 @@ public class HighAlchemyPlugin extends Plugin { if (event.getGroup().equals(CONFIG_GROUP)) { + updateConfig(); buildGroupList(); } } @@ -106,12 +119,12 @@ public class HighAlchemyPlugin extends Plugin { interfaceGroups.clear(); - if (config.showBank()) + if (this.showBank) { interfaceGroups.add(BANK_GROUP_ID); } - if (config.showInventory()) + if (this.showInventory) { Arrays.stream( new int[]{ @@ -126,4 +139,13 @@ public class HighAlchemyPlugin extends Plugin ).forEach(interfaceGroups::add); } } + + private void updateConfig() + { + this.showBank = config.showBank(); + this.showInventory = config.showInventory(); + this.getHighlightColor = config.getHighlightColor(); + this.minProfit = config.minProfit(); + this.usingFireRunes = config.usingFireRunes(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePanel.java index cf2de858e9..ec184a1a87 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePanel.java @@ -43,6 +43,7 @@ import java.util.List; import java.util.concurrent.ScheduledExecutorService; import javax.annotation.Nullable; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; @@ -95,6 +96,7 @@ import static net.runelite.http.api.hiscore.HiscoreSkill.WOODCUTTING; import net.runelite.http.api.hiscore.Skill; @Slf4j +@Singleton public class HiscorePanel extends PluginPanel { /* The maximum allowed username length in runescape accounts */ diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePlugin.java index a7f7dd9b4a..a90ca7b8ba 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/HiscorePlugin.java @@ -35,6 +35,7 @@ import java.util.regex.Pattern; import javax.annotation.Nullable; import javax.inject.Inject; import javax.inject.Provider; +import javax.inject.Singleton; import javax.swing.SwingUtilities; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; @@ -62,6 +63,7 @@ import org.apache.commons.lang3.ArrayUtils; tags = {"panel", "players"}, loadWhenOutdated = true ) +@Singleton public class HiscorePlugin extends Plugin { private static final String LOOKUP = "Lookup"; @@ -179,8 +181,6 @@ public class HiscorePlugin extends Plugin groupId == WidgetInfo.CHATBOX.getGroupId() && !KICK_OPTION.equals(option) || //prevent from adding for Kick option (interferes with the raiding party one) groupId == WidgetInfo.RAIDING_PARTY.getGroupId() || groupId == WidgetInfo.PRIVATE_CHAT_MESSAGE.getGroupId()) { - boolean after; - if (!AFTER_OPTIONS.contains(option)) { return; @@ -194,7 +194,10 @@ public class HiscorePlugin extends Plugin lookup.setParam1(event.getActionParam1()); lookup.setIdentifier(event.getIdentifier()); - insertMenuEntry(lookup, client.getMenuEntries()); + if (client != null) + { + insertMenuEntry(lookup, client.getMenuEntries()); + } } } @@ -228,7 +231,10 @@ public class HiscorePlugin extends Plugin MenuEntry[] newMenu = ObjectArrays.concat(entries, newEntry); int menuEntryCount = newMenu.length; ArrayUtils.swap(newMenu, menuEntryCount - 1, menuEntryCount - 2); - client.setMenuEntries(newMenu); + if (client != null) + { + client.setMenuEntries(newMenu); + } } private void lookupPlayer(String playerName) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/NameAutocompleter.java b/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/NameAutocompleter.java index 3fd3fbe26d..bf23f9190f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/NameAutocompleter.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/hiscore/NameAutocompleter.java @@ -68,7 +68,7 @@ class NameAutocompleter implements KeyListener private Pattern autocompleteNamePattern; @Inject - private NameAutocompleter(@Nullable Client client) + private NameAutocompleter(@Nullable final Client client) { this.client = client; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/hunter/HunterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/hunter/HunterPlugin.java index 2e307a4992..c287fc1160 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/hunter/HunterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/hunter/HunterPlugin.java @@ -25,11 +25,14 @@ package net.runelite.client.plugins.hunter; import com.google.inject.Provides; +import java.awt.Color; import java.time.Instant; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; @@ -56,6 +59,7 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Show the state of your traps", tags = {"overlay", "skilling", "timers"} ) +@Singleton public class HunterPlugin extends Plugin { @Inject @@ -73,14 +77,24 @@ public class HunterPlugin extends Plugin @Inject private HunterConfig config; - @Getter + @Getter(AccessLevel.PACKAGE) private final Map traps = new HashMap<>(); - @Getter + @Getter(AccessLevel.PACKAGE) private Instant lastActionTime = Instant.ofEpochMilli(0); private WorldPoint lastTickLocalPlayerLocation; + @Getter(AccessLevel.PACKAGE) + private Color getOpenTrapColor; + @Getter(AccessLevel.PACKAGE) + private Color getFullTrapColor; + @Getter(AccessLevel.PACKAGE) + private Color getEmptyTrapColor; + @Getter(AccessLevel.PACKAGE) + private Color getTransTrapColor; + private boolean maniacalMonkeyNotify; + @Provides HunterConfig provideConfig(ConfigManager configManager) { @@ -90,6 +104,8 @@ public class HunterPlugin extends Plugin @Override protected void startUp() { + updateConfig(); + overlayManager.add(overlay); overlay.updateConfig(); } @@ -210,7 +226,7 @@ public class HunterPlugin extends Plugin myTrap.resetTimer(); lastActionTime = Instant.now(); - if (config.maniacalMonkeyNotify() && myTrap.getObjectId() == ObjectID.MONKEY_TRAP) + if (this.maniacalMonkeyNotify && myTrap.getObjectId() == ObjectID.MONKEY_TRAP) { notifier.notify("You've caught part of a monkey's tail."); } @@ -384,7 +400,17 @@ public class HunterPlugin extends Plugin { if (event.getGroup().equals("hunterplugin")) { + updateConfig(); overlay.updateConfig(); } } + + private void updateConfig() + { + this.getOpenTrapColor = config.getOpenTrapColor(); + this.getFullTrapColor = config.getFullTrapColor(); + this.getEmptyTrapColor = config.getEmptyTrapColor(); + this.getTransTrapColor = config.getTransTrapColor(); + this.maniacalMonkeyNotify = config.maniacalMonkeyNotify(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/hunter/HunterTrap.java b/runelite-client/src/main/java/net/runelite/client/plugins/hunter/HunterTrap.java index 4a28288994..3312a5a4f7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/hunter/HunterTrap.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/hunter/HunterTrap.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.hunter; import java.time.Duration; import java.time.Instant; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import net.runelite.api.GameObject; @@ -44,23 +45,23 @@ class HunterTrap /** * The time in milliseconds when the trap was placed. */ - @Getter + @Getter(AccessLevel.PACKAGE) private Instant placedOn; /** * The state of the trap. */ - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private State state; /** * The ID of the game object this is representing */ - @Getter + @Getter(AccessLevel.PACKAGE) private int objectId; - @Getter + @Getter(AccessLevel.PACKAGE) private WorldPoint worldLocation; /** @@ -91,7 +92,7 @@ class HunterTrap * * @param gameObject The gameobject thats corresponds with this trap. */ - HunterTrap(GameObject gameObject) + HunterTrap(final GameObject gameObject) { this.state = State.OPEN; this.placedOn = Instant.now(); @@ -105,7 +106,7 @@ class HunterTrap * @return Value between 0 and 1. 0 means the trap was laid moments ago. * 1 is a trap that's about to collapse. */ - public double getTrapTimeRelative() + double getTrapTimeRelative() { Duration duration = Duration.between(placedOn, Instant.now()); return duration.compareTo(TRAP_TIME) < 0 ? (double) duration.toMillis() / TRAP_TIME.toMillis() : 1; @@ -114,7 +115,7 @@ class HunterTrap /** * Resets the time value when the trap was placed. */ - public void resetTimer() + void resetTimer() { placedOn = Instant.now(); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/hunter/TrapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/hunter/TrapOverlay.java index 6c41519726..cb774336d4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/hunter/TrapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/hunter/TrapOverlay.java @@ -29,6 +29,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.coords.LocalPoint; @@ -42,6 +43,7 @@ import net.runelite.client.ui.overlay.components.ProgressPieComponent; * Represents the overlay that shows timers on traps that are placed by the * player. */ +@Singleton public class TrapOverlay extends Overlay { /** @@ -51,7 +53,6 @@ public class TrapOverlay extends Overlay private final Client client; private final HunterPlugin plugin; - private final HunterConfig config; private Color colorOpen, colorOpenBorder; private Color colorEmpty, colorEmptyBorder; @@ -59,12 +60,11 @@ public class TrapOverlay extends Overlay private Color colorTrans, colorTransBorder; @Inject - TrapOverlay(Client client, HunterPlugin plugin, HunterConfig config) + TrapOverlay(final Client client, final HunterPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); this.plugin = plugin; - this.config = config; this.client = client; } @@ -80,13 +80,13 @@ public class TrapOverlay extends Overlay */ public void updateConfig() { - colorEmptyBorder = config.getEmptyTrapColor(); + colorEmptyBorder = plugin.getGetEmptyTrapColor(); colorEmpty = new Color(colorEmptyBorder.getRed(), colorEmptyBorder.getGreen(), colorEmptyBorder.getBlue(), 100); - colorFullBorder = config.getFullTrapColor(); + colorFullBorder = plugin.getGetFullTrapColor(); colorFull = new Color(colorFullBorder.getRed(), colorFullBorder.getGreen(), colorFullBorder.getBlue(), 100); - colorOpenBorder = config.getOpenTrapColor(); + colorOpenBorder = plugin.getGetOpenTrapColor(); colorOpen = new Color(colorOpenBorder.getRed(), colorOpenBorder.getGreen(), colorOpenBorder.getBlue(), 100); - colorTransBorder = config.getTransTrapColor(); + colorTransBorder = plugin.getGetTransTrapColor(); colorTrans = new Color(colorTransBorder.getRed(), colorTransBorder.getGreen(), colorTransBorder.getBlue(), 100); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/hydra/BabyHydraIndicatorOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/hydra/BabyHydraIndicatorOverlay.java index 67523eebe3..610352bd86 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/hydra/BabyHydraIndicatorOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/hydra/BabyHydraIndicatorOverlay.java @@ -27,12 +27,14 @@ package net.runelite.client.plugins.hydra; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; 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; +@Singleton public class BabyHydraIndicatorOverlay extends Overlay { private final BabyHydraPlugin plugin; @@ -40,7 +42,7 @@ public class BabyHydraIndicatorOverlay extends Overlay private final PanelComponent panelComponent = new PanelComponent(); @Inject - private BabyHydraIndicatorOverlay(BabyHydraPlugin plugin) + private BabyHydraIndicatorOverlay(final BabyHydraPlugin plugin) { this.plugin = plugin; setPosition(OverlayPosition.BOTTOM_RIGHT); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/hydra/BabyHydraOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/hydra/BabyHydraOverlay.java index 08ea0a13c9..58456a4ef3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/hydra/BabyHydraOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/hydra/BabyHydraOverlay.java @@ -28,6 +28,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.NPC; import net.runelite.api.Point; @@ -38,19 +39,17 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton public class BabyHydraOverlay extends Overlay { - private final BabyHydraConfig config; private final BabyHydraPlugin plugin; - @Inject private Client client; @Inject - private BabyHydraOverlay(BabyHydraConfig config, BabyHydraPlugin plugin) + private BabyHydraOverlay(final BabyHydraPlugin plugin) { - this.config = config; this.plugin = plugin; setLayer(OverlayLayer.ABOVE_SCENE); setPosition(OverlayPosition.DYNAMIC); @@ -73,7 +72,7 @@ public class BabyHydraOverlay extends Overlay int val = plugin.getHydras().get(hydra.getIndex()); if (val != 0) { - if (config.BoldText()) + if (plugin.isBoldText()) { graphics.setFont(FontManager.getRunescapeBoldFont()); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/hydra/BabyHydraPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/hydra/BabyHydraPlugin.java index dfd72f8ee1..c0c6e28536 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/hydra/BabyHydraPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/hydra/BabyHydraPlugin.java @@ -28,6 +28,8 @@ import com.google.inject.Provides; import java.util.HashMap; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Actor; import net.runelite.api.Client; @@ -50,7 +52,7 @@ import net.runelite.client.ui.overlay.OverlayManager; type = PluginType.PVM, enabledByDefault = false ) - +@Singleton public class BabyHydraPlugin extends Plugin { @Inject @@ -77,23 +79,30 @@ public class BabyHydraPlugin extends Plugin return configManager.getConfig(BabyHydraConfig.class); } - @Getter + @Getter(AccessLevel.PACKAGE) private Map hydras = new HashMap<>(); - @Getter + @Getter(AccessLevel.PACKAGE) private Map hydraattacks = new HashMap<>(); - @Getter + @Getter(AccessLevel.PACKAGE) private NPC hydra; + private boolean TextIndicator; + @Getter(AccessLevel.PACKAGE) + private boolean BoldText; + private boolean PrayerHelper; + @Override protected void startUp() throws Exception { - if (config.TextIndicator()) + updateConfig(); + + if (this.TextIndicator) { overlayManager.add(hydraOverlay); } - if (config.PrayerHelper()) + if (this.PrayerHelper) { overlayManager.add(hydraPrayOverlay); overlayManager.add(hydraIndicatorOverlay); @@ -118,6 +127,8 @@ public class BabyHydraPlugin extends Plugin return; } + updateConfig(); + if (event.getKey().equals("textindicators")) { if (Boolean.parseBoolean(event.getNewValue())) @@ -241,4 +252,11 @@ public class BabyHydraPlugin extends Plugin } } } + + private void updateConfig() + { + this.TextIndicator = config.TextIndicator(); + this.BoldText = config.BoldText(); + this.PrayerHelper = config.PrayerHelper(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/hydra/BabyHydraPrayOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/hydra/BabyHydraPrayOverlay.java index f11c6b172d..cf56196e21 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/hydra/BabyHydraPrayOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/hydra/BabyHydraPrayOverlay.java @@ -29,6 +29,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Prayer; import net.runelite.api.SpriteID; @@ -40,6 +41,7 @@ import net.runelite.client.ui.overlay.components.ComponentConstants; import net.runelite.client.ui.overlay.components.ImageComponent; import net.runelite.client.ui.overlay.components.PanelComponent; +@Singleton public class BabyHydraPrayOverlay extends Overlay { private final BabyHydraPlugin plugin; @@ -56,7 +58,7 @@ public class BabyHydraPrayOverlay extends Overlay private Client client; @Inject - private BabyHydraPrayOverlay(BabyHydraPlugin plugin, SpriteManager spriteManager) + private BabyHydraPrayOverlay(final BabyHydraPlugin plugin, final SpriteManager spriteManager) { this.plugin = plugin; this.spriteManager = spriteManager; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPlugin.java index e0d3925cb6..66310c8d41 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPlugin.java @@ -36,6 +36,10 @@ import java.util.List; import javax.inject.Inject; //import javax.sound.sampled.LineUnavailableException; //import javax.sound.sampled.UnsupportedAudioFileException; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Setter; +import net.runelite.api.events.ConfigChanged; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -151,6 +155,7 @@ import net.runelite.client.util.PvPUtil; description = "Send a notification when going idle, or when HP/Prayer reaches a threshold", tags = {"health", "hitpoints", "notifications", "prayer", "pvp", "pker"} ) +@Singleton public class IdleNotifierPlugin extends Plugin { private static final Logger logger = LoggerFactory.getLogger(IdleNotifierPlugin.class); @@ -195,6 +200,32 @@ public class IdleNotifierPlugin extends Plugin private SkullIcon lastTickSkull = null; private boolean isFirstTick = true; + @Setter(AccessLevel.PACKAGE) + private boolean animationIdle; + private boolean animationIdleSound; + @Setter(AccessLevel.PACKAGE) + private boolean interactionIdle; + private boolean interactionIdleSound; + @Setter(AccessLevel.PACKAGE) + private boolean logoutIdle; + private boolean outOfCombatSound; + private boolean showSkullNotification; + private boolean showUnskullNotification; + @Setter(AccessLevel.PACKAGE) + private int getIdleNotificationDelay; + @Setter(AccessLevel.PACKAGE) + private int getHitpointsThreshold; + private boolean getPlayHealthSound; + @Setter(AccessLevel.PACKAGE) + private int getPrayerThreshold; + private boolean getPlayPrayerSound; + private int getOxygenThreshold; + @Setter(AccessLevel.PACKAGE) + private int getSpecEnergyThreshold; + private boolean getSpecSound; + private boolean getOverSpecEnergy; + private boolean notifyPkers; + @Provides IdleNotifierConfig provideConfig(ConfigManager configManager) { @@ -331,7 +362,7 @@ public class IdleNotifierPlugin extends Plugin private void onPlayerSpawned(PlayerSpawned event) { final Player p = event.getPlayer(); - if (config.notifyPkers()) + if (this.notifyPkers) { if (p != null) { @@ -473,7 +504,7 @@ public class IdleNotifierPlugin extends Plugin skullNotifier(); final Player local = client.getLocalPlayer(); - final Duration waitDuration = Duration.ofMillis(config.getIdleNotificationDelay()); + final Duration waitDuration = Duration.ofMillis(this.getIdleNotificationDelay); lastCombatCountdown = Math.max(lastCombatCountdown - 1, 0); if (client.getGameState() != GameState.LOGGED_IN @@ -486,7 +517,7 @@ public class IdleNotifierPlugin extends Plugin return; } - if (config.logoutIdle() && checkIdleLogout()) + if (this.logoutIdle && checkIdleLogout()) { notifier.notify("[" + local.getName() + "] is about to log out from idling too long!"); } @@ -496,20 +527,20 @@ public class IdleNotifierPlugin extends Plugin notifier.notify("[" + local.getName() + "] is about to log out from being online for 6 hours!"); } - if (config.animationIdle() && checkAnimationIdle(waitDuration, local)) + if (this.animationIdle && checkAnimationIdle(waitDuration, local)) { notifier.notify("[" + local.getName() + "] is now idle!"); - if (config.animationIdleSound()) + if (this.animationIdleSound) { soundManager.playSound(Sound.IDLE); } } - if (config.interactionIdle() && checkInteractionIdle(waitDuration, local)) + if (this.interactionIdle && checkInteractionIdle(waitDuration, local)) { if (lastInteractWasCombat) { notifier.notify("[" + local.getName() + "] is now out of combat!"); - if (config.outOfCombatSound()) + if (this.outOfCombatSound) { soundManager.playSound(Sound.OUT_OF_COMBAT); } @@ -517,7 +548,7 @@ public class IdleNotifierPlugin extends Plugin else { notifier.notify("[" + local.getName() + "] is now idle!"); - if (config.interactionIdleSound()) + if (this.interactionIdleSound) { soundManager.playSound(Sound.IDLE); } @@ -527,7 +558,7 @@ public class IdleNotifierPlugin extends Plugin if (checkLowHitpoints()) { notifier.notify("[" + local.getName() + "] has low hitpoints!"); - if (config.getPlayHealthSound()) + if (this.getPlayHealthSound) { soundManager.playSound(Sound.LOW_HEATLH); } @@ -536,7 +567,7 @@ public class IdleNotifierPlugin extends Plugin if (checkLowPrayer()) { notifier.notify("[" + local.getName() + "] has low prayer!"); - if (config.getPlayPrayerSound()) + if (this.getPlayPrayerSound) { soundManager.playSound(Sound.LOW_PRAYER); } @@ -550,7 +581,7 @@ public class IdleNotifierPlugin extends Plugin if (checkFullSpecEnergy()) { notifier.notify("[" + local.getName() + "] has restored spec energy!"); - if (config.getSpecSound()) + if (this.getSpecSound) { soundManager.playSound(Sound.RESTORED_SPECIAL_ATTACK); } @@ -561,7 +592,7 @@ public class IdleNotifierPlugin extends Plugin { int currentSpecEnergy = client.getVar(VarPlayer.SPECIAL_ATTACK_PERCENT); - int threshold = config.getSpecEnergyThreshold() * 10; + int threshold = this.getSpecEnergyThreshold * 10; if (threshold == 0) { lastSpecEnergy = currentSpecEnergy; @@ -572,7 +603,7 @@ public class IdleNotifierPlugin extends Plugin // regen was small enough. boolean notify = lastSpecEnergy < threshold && currentSpecEnergy >= threshold && currentSpecEnergy - lastSpecEnergy <= 100; - notify = (notify) || ((config.getOverSpecEnergy()) && (currentSpecEnergy >= threshold) && (currentSpecEnergy != lastSpecEnergy) && (currentSpecEnergy - lastSpecEnergy <= 100)); + notify = (notify) || ((this.getOverSpecEnergy) && (currentSpecEnergy >= threshold) && (currentSpecEnergy != lastSpecEnergy) && (currentSpecEnergy - lastSpecEnergy <= 100)); lastSpecEnergy = currentSpecEnergy; return notify; @@ -580,11 +611,11 @@ public class IdleNotifierPlugin extends Plugin private boolean checkLowOxygen() { - if (config.getOxygenThreshold() == 0) + if (this.getOxygenThreshold == 0) { return false; } - if (config.getOxygenThreshold() >= client.getVar(Varbits.OXYGEN_LEVEL) * 0.1) + if (this.getOxygenThreshold >= client.getVar(Varbits.OXYGEN_LEVEL) * 0.1) { if (!notifyOxygen) { @@ -601,13 +632,13 @@ public class IdleNotifierPlugin extends Plugin private boolean checkLowHitpoints() { - if (config.getHitpointsThreshold() == 0) + if (this.getHitpointsThreshold == 0) { return false; } - if (client.getRealSkillLevel(Skill.HITPOINTS) > config.getHitpointsThreshold()) + if (client.getRealSkillLevel(Skill.HITPOINTS) > this.getHitpointsThreshold) { - if (client.getBoostedSkillLevel(Skill.HITPOINTS) + client.getVar(Varbits.NMZ_ABSORPTION) <= config.getHitpointsThreshold()) + if (client.getBoostedSkillLevel(Skill.HITPOINTS) + client.getVar(Varbits.NMZ_ABSORPTION) <= this.getHitpointsThreshold) { if (!notifyHitpoints) { @@ -626,13 +657,13 @@ public class IdleNotifierPlugin extends Plugin private boolean checkLowPrayer() { - if (config.getPrayerThreshold() == 0) + if (this.getPrayerThreshold == 0) { return false; } - if (client.getRealSkillLevel(Skill.PRAYER) > config.getPrayerThreshold()) + if (client.getRealSkillLevel(Skill.PRAYER) > this.getPrayerThreshold) { - if (client.getBoostedSkillLevel(Skill.PRAYER) <= config.getPrayerThreshold()) + if (client.getBoostedSkillLevel(Skill.PRAYER) <= this.getPrayerThreshold) { if (!notifyPrayer) { @@ -792,11 +823,11 @@ public class IdleNotifierPlugin extends Plugin { if (!isFirstTick) { - if (config.showSkullNotification() && lastTickSkull == null && currentTickSkull == SkullIcon.SKULL) + if (this.showSkullNotification && lastTickSkull == null && currentTickSkull == SkullIcon.SKULL) { notifier.notify("[" + local.getName() + "] is now skulled!"); } - else if (config.showUnskullNotification() && lastTickSkull == SkullIcon.SKULL && currentTickSkull == null) + else if (this.showUnskullNotification && lastTickSkull == SkullIcon.SKULL && currentTickSkull == null) { notifier.notify("[" + local.getName() + "] is now unskulled!"); } @@ -809,4 +840,43 @@ public class IdleNotifierPlugin extends Plugin lastTickSkull = currentTickSkull; } } + + @Override + protected void startUp() throws Exception + { + updateConfig(); + } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("idlenotifier")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.animationIdle = config.animationIdle(); + this.animationIdleSound = config.animationIdleSound(); + this.interactionIdle = config.interactionIdle(); + this.interactionIdleSound = config.interactionIdleSound(); + this.logoutIdle = config.logoutIdle(); + this.outOfCombatSound = config.outOfCombatSound(); + this.showSkullNotification = config.showSkullNotification(); + this.showUnskullNotification = config.showUnskullNotification(); + this.getIdleNotificationDelay = config.getIdleNotificationDelay(); + this.getHitpointsThreshold = config.getHitpointsThreshold(); + this.getPlayHealthSound = config.getPlayHealthSound(); + this.getPrayerThreshold = config.getPrayerThreshold(); + this.getPlayPrayerSound = config.getPlayPrayerSound(); + this.getOxygenThreshold = config.getOxygenThreshold(); + this.getSpecEnergyThreshold = config.getSpecEnergyThreshold(); + this.getSpecSound = config.getSpecSound(); + this.getOverSpecEnergy = config.getOverSpecEnergy(); + this.notifyPkers = config.notifyPkers(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingCounterOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingCounterOverlay.java index c88d433254..a66ee4e270 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingCounterOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingCounterOverlay.java @@ -4,26 +4,23 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.util.Map; import javax.inject.Inject; -import net.runelite.api.Client; +import javax.inject.Singleton; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; import net.runelite.client.ui.overlay.components.PanelComponent; +@Singleton public class ImplingCounterOverlay extends Overlay { - private final Client client; private final ImplingsPlugin plugin; - private final ImplingsConfig config; private final PanelComponent panelComponent = new PanelComponent(); @Inject - public ImplingCounterOverlay(Client client, ImplingsConfig config, ImplingsPlugin plugin) + public ImplingCounterOverlay(final ImplingsPlugin plugin) { - this.client = client; - this.config = config; this.plugin = plugin; setPosition(OverlayPosition.TOP_LEFT); } @@ -31,7 +28,7 @@ public class ImplingCounterOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!config.showCounter() || plugin.getImplings().isEmpty()) + if (!plugin.isShowSpawn() || plugin.getImplings().isEmpty()) return null; panelComponent.getChildren().clear(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingMinimapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingMinimapOverlay.java index ab35f9f945..cb78082865 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingMinimapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingMinimapOverlay.java @@ -29,6 +29,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.NPC; import net.runelite.api.Point; import net.runelite.client.ui.overlay.Overlay; @@ -36,18 +37,17 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton public class ImplingMinimapOverlay extends Overlay { private final ImplingsPlugin plugin; - private final ImplingsConfig config; @Inject - private ImplingMinimapOverlay(ImplingsPlugin plugin, ImplingsConfig config) + private ImplingMinimapOverlay(final ImplingsPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); this.plugin = plugin; - this.config = config; } @Override @@ -63,14 +63,14 @@ public class ImplingMinimapOverlay extends Overlay { Point impLocation = imp.getMinimapLocation(); Color color = plugin.npcToColor(imp); - if (!plugin.showNpc(imp) || impLocation == null || color == null) + if (plugin.showNpc(imp) || impLocation == null || color == null) { continue; } OverlayUtil.renderMinimapLocation(graphics, impLocation, color); - if (config.showName()) + if (plugin.isShowName()) { Point textLocation = new Point(impLocation.getX() + 1, impLocation.getY()); OverlayUtil.renderTextLocation(graphics, textLocation, imp.getName(), color); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingSpawn.java b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingSpawn.java index d624c02682..122c0b5583 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingSpawn.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingSpawn.java @@ -24,6 +24,7 @@ */ package net.runelite.client.plugins.implings; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.coords.WorldPoint; @@ -32,7 +33,7 @@ import net.runelite.api.coords.WorldPoint; * @author Juzzed */ @AllArgsConstructor -@Getter +@Getter(AccessLevel.PACKAGE) enum ImplingSpawn { //Baby spawns diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingType.java b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingType.java index cacac2f167..787adcc46a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingType.java @@ -24,11 +24,12 @@ */ package net.runelite.client.plugins.implings; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @AllArgsConstructor -@Getter +@Getter(AccessLevel.PACKAGE) enum ImplingType { BABY("Baby"), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsConfig.java index d55be9f962..386284a874 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsConfig.java @@ -320,15 +320,4 @@ public interface ImplingsConfig extends Config { return Color.WHITE; } - - @ConfigItem( - position = 26, - keyName = "showCounter", - name = "Show impling counter overlay", - description = "Shows how many of each impling there is nearby" - ) - default boolean showCounter() - { - return false; - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsOverlay.java index 8b4e404bd3..47a1e42271 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsOverlay.java @@ -31,6 +31,7 @@ import java.awt.Polygon; import java.util.List; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Actor; import net.runelite.api.Client; import net.runelite.api.NPC; @@ -47,18 +48,17 @@ import net.runelite.client.ui.overlay.OverlayUtil; /** * @author robin */ +@Singleton public class ImplingsOverlay extends Overlay { private final Client client; - private final ImplingsConfig config; private final ImplingsPlugin plugin; @Inject - private ImplingsOverlay(Client client, ImplingsConfig config, ImplingsPlugin plugin) + private ImplingsOverlay(final Client client, final ImplingsPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); - this.config = config; this.client = client; this.plugin = plugin; } @@ -76,7 +76,7 @@ public class ImplingsOverlay extends Overlay for (NPC imp : implings) { Color color = plugin.npcToColor(imp); - if (!plugin.showNpc(imp) || color == null) + if (plugin.showNpc(imp) || color == null) { continue; } @@ -85,7 +85,7 @@ public class ImplingsOverlay extends Overlay } //Draw static spawns - if (config.showSpawn()) + if (plugin.isShowSpawn()) { for (ImplingSpawn spawn : ImplingSpawn.values()) { @@ -95,14 +95,14 @@ public class ImplingsOverlay extends Overlay } String impName = spawn.getType().getName(); - drawSpawn(graphics, spawn.getSpawnLocation(), impName, config.getSpawnColor()); + drawSpawn(graphics, spawn.getSpawnLocation(), impName, plugin.getGetSpawnColor()); } //Draw dynamic spawns Map dynamicSpawns = plugin.getDynamicSpawns(); for (Map.Entry dynamicSpawn : dynamicSpawns.entrySet()) { - drawDynamicSpawn(graphics, dynamicSpawn.getKey(), dynamicSpawn.getValue(), config.getDynamicSpawnColor()); + drawDynamicSpawn(graphics, dynamicSpawn.getKey(), dynamicSpawn.getValue(), plugin.getGetDynamicSpawnColor()); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java index 5ec61041da..8458b45735 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/implings/ImplingsPlugin.java @@ -31,10 +31,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.GameState; import net.runelite.api.NPC; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.NpcDespawned; @@ -53,13 +55,14 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Highlight nearby implings on the minimap and on-screen", tags = {"hunter", "minimap", "overlay"} ) +@Singleton public class ImplingsPlugin extends Plugin { private static final int DYNAMIC_SPAWN_NATURE_DRAGON = 1618; private static final int DYNAMIC_SPAWN_ECLECTIC = 1633; private static final int DYNAMIC_SPAWN_BABY_ESSENCE = 1634; - @Getter + @Getter(AccessLevel.PACKAGE) private Map implingCounterMap = new HashMap<>(); @Getter(AccessLevel.PACKAGE) @@ -84,6 +87,37 @@ public class ImplingsPlugin extends Plugin @Inject private ImplingsConfig config; + private boolean showBaby; + private Color getBabyColor; + private boolean showYoung; + private Color getYoungColor; + private boolean showGourmet; + private Color getGourmetColor; + private boolean showEarth; + private Color getEarthColor; + private boolean showEssence; + private Color getEssenceColor; + private boolean showEclectic; + private Color getEclecticColor; + private boolean showNature; + private Color getNatureColor; + private boolean showMagpie; + private Color getMagpieColor; + private boolean showNinja; + private Color getNinjaColor; + private boolean showDragon; + private Color getDragonColor; + private boolean showLucky; + private Color getLuckyColor; + @Getter(AccessLevel.PACKAGE) + private boolean showSpawn; + @Getter(AccessLevel.PACKAGE) + private Color getSpawnColor; + @Getter(AccessLevel.PACKAGE) + private boolean showName; + @Getter(AccessLevel.PACKAGE) + private Color getDynamicSpawnColor; + @Provides ImplingsConfig getConfig(ConfigManager configManager) { @@ -93,6 +127,8 @@ public class ImplingsPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + dynamicSpawns.put(DYNAMIC_SPAWN_NATURE_DRAGON, "T3 Nature-Lucky Dynamic"); dynamicSpawns.put(DYNAMIC_SPAWN_ECLECTIC, "T2 Eclectic Dynamic"); dynamicSpawns.put(DYNAMIC_SPAWN_BABY_ESSENCE, "T1 Baby-Essence Dynamic"); @@ -175,10 +211,10 @@ public class ImplingsPlugin extends Plugin Impling impling = Impling.findImpling(npc.getId()); if (impling == null) { - return false; + return true; } - return showImplingType(impling.getImplingType()); + return !showImplingType(impling.getImplingType()); } boolean showImplingType(ImplingType implingType) @@ -186,27 +222,27 @@ public class ImplingsPlugin extends Plugin switch (implingType) { case BABY: - return config.showBaby(); + return this.showBaby; case YOUNG: - return config.showYoung(); + return this.showYoung; case GOURMET: - return config.showGourmet(); + return this.showGourmet; case EARTH: - return config.showEarth(); + return this.showEarth; case ESSENCE: - return config.showEssence(); + return this.showEssence; case ECLECTIC: - return config.showEclectic(); + return this.showEclectic; case NATURE: - return config.showNature(); + return this.showNature; case MAGPIE: - return config.showMagpie(); + return this.showMagpie; case NINJA: - return config.showNinja(); + return this.showNinja; case DRAGON: - return config.showDragon(); + return this.showDragon; case LUCKY: - return config.showLucky(); + return this.showLucky; default: return false; } @@ -223,35 +259,76 @@ public class ImplingsPlugin extends Plugin return typeToColor(impling.getImplingType()); } - Color typeToColor(ImplingType type) + private Color typeToColor(ImplingType type) { switch (type) { case BABY: - return config.getBabyColor(); + return this.getBabyColor; case YOUNG: - return config.getYoungColor(); + return this.getYoungColor; case GOURMET: - return config.getGourmetColor(); + return this.getGourmetColor; case EARTH: - return config.getEarthColor(); + return this.getEarthColor; case ESSENCE: - return config.getEssenceColor(); + return this.getEssenceColor; case ECLECTIC: - return config.getEclecticColor(); + return this.getEclecticColor; case NATURE: - return config.getNatureColor(); + return this.getNatureColor; case MAGPIE: - return config.getMagpieColor(); + return this.getMagpieColor; case NINJA: - return config.getNinjaColor(); + return this.getNinjaColor; case DRAGON: - return config.getDragonColor(); + return this.getDragonColor; case LUCKY: - return config.getLuckyColor(); + return this.getLuckyColor; default: return null; } } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("implings")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.showBaby = config.showBaby(); + this.getBabyColor = config.getBabyColor(); + this.showYoung = config.showYoung(); + this.getYoungColor = config.getYoungColor(); + this.showGourmet = config.showGourmet(); + this.getGourmetColor = config.getGourmetColor(); + this.showEarth = config.showEarth(); + this.getEarthColor = config.getEarthColor(); + this.showEssence = config.showEssence(); + this.getEssenceColor = config.getEssenceColor(); + this.showEclectic = config.showEclectic(); + this.getEclecticColor = config.getEclecticColor(); + this.showNature = config.showNature(); + this.getNatureColor = config.getNatureColor(); + this.showMagpie = config.showMagpie(); + this.getMagpieColor = config.getMagpieColor(); + this.showNinja = config.showNinja(); + this.getNinjaColor = config.getNinjaColor(); + this.showDragon = config.showDragon(); + this.getDragonColor = config.getDragonColor(); + this.showLucky = config.showLucky(); + this.getLuckyColor = config.getLuckyColor(); + this.showSpawn = config.showSpawn(); + this.getSpawnColor = config.getSpawnColor(); + this.showName = config.showName(); + this.getDynamicSpawnColor = config.getDynamicSpawnColor(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoConfig.java index bd7c2b045e..7e6f0ece3a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoConfig.java @@ -24,66 +24,66 @@ */ package net.runelite.client.plugins.inferno; +import java.awt.Color; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; -import java.awt.Color; @ConfigGroup("inferno") public interface InfernoConfig extends Config - { +{ @ConfigItem( - position = 0, - keyName = "Nibbler Overlay", - name = "Nibbler Overlay", - description = "Shows if there are any Nibblers left" + position = 0, + keyName = "Nibbler Overlay", + name = "Nibbler Overlay", + description = "Shows if there are any Nibblers left" ) default boolean displayNibblerOverlay() - { - return false; - } + { + return false; + } @ConfigItem( - position = 1, - keyName = "Prayer Helper", - name = "Prayer Helper", - description = "Tells you what to flick in how many ticks" + position = 1, + keyName = "Prayer Helper", + name = "Prayer Helper", + description = "Tells you what to flick in how many ticks" ) default boolean showPrayerHelp() - { - return false; - } + { + return false; + } @ConfigItem( - position = 2, - keyName = "waveDisplay", - name = "Wave display", - description = "Shows monsters that will spawn on the selected wave(s)." + position = 2, + keyName = "waveDisplay", + name = "Wave display", + description = "Shows monsters that will spawn on the selected wave(s)." ) default InfernoWaveDisplayMode waveDisplay() - { - return InfernoWaveDisplayMode.BOTH; - } + { + return InfernoWaveDisplayMode.BOTH; + } @ConfigItem( - position = 3, - keyName = "getWaveOverlayHeaderColor", - name = "Wave Header", - description = "Color for Wave Header" + position = 3, + keyName = "getWaveOverlayHeaderColor", + name = "Wave Header", + description = "Color for Wave Header" ) default Color getWaveOverlayHeaderColor() - { - return Color.ORANGE; - } + { + return Color.ORANGE; + } @ConfigItem( - position = 4, - keyName = "getWaveTextColor", - name = "Wave Text Color", - description = "Color for Wave Texts" + position = 4, + keyName = "getWaveTextColor", + name = "Wave Text Color", + description = "Color for Wave Texts" ) default Color getWaveTextColor() - { - return Color.WHITE; - } - } \ No newline at end of file + { + return Color.WHITE; + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoInfobox.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoInfobox.java index 12b4571b09..9e1af9a978 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoInfobox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoInfobox.java @@ -27,26 +27,26 @@ package net.runelite.client.plugins.inferno; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; 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.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; -import net.runelite.client.ui.overlay.components.PanelComponent; +@Singleton public class InfernoInfobox extends Overlay { private final Client client; private final InfernoPlugin plugin; - private final InfernoConfig config; private final PanelComponent panelComponent = new PanelComponent(); @Inject - public InfernoInfobox(Client client, InfernoConfig config, InfernoPlugin plugin) + public InfernoInfobox(final Client client, final InfernoPlugin plugin) { this.client = client; - this.config = config; this.plugin = plugin; setPosition(OverlayPosition.TOP_LEFT); } @@ -54,7 +54,10 @@ public class InfernoInfobox extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!config.showPrayerHelp() || client.getMapRegions()[0] != 9043) return null; + if (!plugin.isShowPrayerHelp() || client.getMapRegions()[0] != 9043) + { + return null; + } panelComponent.getChildren().clear(); TableComponent tableComponent = new TableComponent(); @@ -68,7 +71,7 @@ public class InfernoInfobox extends Overlay } else { - tableComponent.addRow(plugin.getPriorityNPC()[i - 1].getName(), plugin.getPriorityNPC()[i - 1 ].getAttackstyle().getName()); + tableComponent.addRow(plugin.getPriorityNPC()[i - 1].getName(), plugin.getPriorityNPC()[i - 1].getAttackstyle().getName()); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoJadAttack.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoJadAttack.java index 28ae29c1cd..1451a96216 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoJadAttack.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoJadAttack.java @@ -28,26 +28,26 @@ import net.runelite.api.AnimationID; import net.runelite.api.Prayer; public enum InfernoJadAttack - { - MAGIC(AnimationID.JALTOK_JAD_MAGE_ATTACK, Prayer.PROTECT_FROM_MAGIC), - RANGE(AnimationID.JALTOK_JAD_RANGE_ATTACK, Prayer.PROTECT_FROM_MISSILES); +{ + MAGIC(AnimationID.JALTOK_JAD_MAGE_ATTACK, Prayer.PROTECT_FROM_MAGIC), + RANGE(AnimationID.JALTOK_JAD_RANGE_ATTACK, Prayer.PROTECT_FROM_MISSILES); private final int animation; private final Prayer prayer; - InfernoJadAttack(int animation, Prayer prayer) - { - this.animation = animation; - this.prayer = prayer; - } + InfernoJadAttack(final int animation, final Prayer prayer) + { + this.animation = animation; + this.prayer = prayer; + } public int getAnimation() - { - return animation; - } + { + return animation; + } public Prayer getPrayer() - { - return prayer; - } + { + return prayer; } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoJadOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoJadOverlay.java index 43252b4c95..50af2fb664 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoJadOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoJadOverlay.java @@ -29,7 +29,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.inject.Inject; - +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.SpriteID; import net.runelite.client.game.SpriteManager; @@ -40,8 +40,9 @@ import net.runelite.client.ui.overlay.components.ComponentConstants; import net.runelite.client.ui.overlay.components.ImageComponent; import net.runelite.client.ui.overlay.components.PanelComponent; +@Singleton public class InfernoJadOverlay extends Overlay - { +{ private static final Color NOT_ACTIVATED_BACKGROUND_COLOR = new Color(150, 0, 0, 150); private final Client client; private final InfernoPlugin plugin; @@ -49,39 +50,39 @@ public class InfernoJadOverlay extends Overlay private final PanelComponent imagePanelComponent = new PanelComponent(); @Inject - private InfernoJadOverlay(Client client, InfernoPlugin plugin, SpriteManager spriteManager) - { - setPosition(OverlayPosition.BOTTOM_RIGHT); - setPriority(OverlayPriority.HIGH); - this.client = client; - this.plugin = plugin; - this.spriteManager = spriteManager; - } + private InfernoJadOverlay(final Client client, final InfernoPlugin plugin, final SpriteManager spriteManager) + { + setPosition(OverlayPosition.BOTTOM_RIGHT); + setPriority(OverlayPriority.HIGH); + this.client = client; + this.plugin = plugin; + this.spriteManager = spriteManager; + } @Override public Dimension render(Graphics2D graphics) + { + final InfernoJadAttack attack = plugin.getAttack(); + + if (attack == null) { - final InfernoJadAttack attack = plugin.getAttack(); - - if (attack == null) - { - return null; - } - - final BufferedImage prayerImage = getPrayerImage(attack); - - imagePanelComponent.getChildren().clear(); - imagePanelComponent.getChildren().add(new ImageComponent(prayerImage)); - imagePanelComponent.setBackgroundColor(client.isPrayerActive(attack.getPrayer()) - ? ComponentConstants.STANDARD_BACKGROUND_COLOR - : NOT_ACTIVATED_BACKGROUND_COLOR); - - return imagePanelComponent.render(graphics); + return null; } + final BufferedImage prayerImage = getPrayerImage(attack); + + imagePanelComponent.getChildren().clear(); + imagePanelComponent.getChildren().add(new ImageComponent(prayerImage)); + imagePanelComponent.setBackgroundColor(client.isPrayerActive(attack.getPrayer()) + ? ComponentConstants.STANDARD_BACKGROUND_COLOR + : NOT_ACTIVATED_BACKGROUND_COLOR); + + return imagePanelComponent.render(graphics); + } + private BufferedImage getPrayerImage(InfernoJadAttack attack) - { - final int prayerSpriteID = attack == InfernoJadAttack.MAGIC ? SpriteID.PRAYER_PROTECT_FROM_MAGIC : SpriteID.PRAYER_PROTECT_FROM_MISSILES; - return spriteManager.getSprite(prayerSpriteID, 0); - } + { + final int prayerSpriteID = attack == InfernoJadAttack.MAGIC ? SpriteID.PRAYER_PROTECT_FROM_MAGIC : SpriteID.PRAYER_PROTECT_FROM_MISSILES; + return spriteManager.getSprite(prayerSpriteID, 0); } +} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNPC.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNPC.java index 392ec4bad6..3208dba7df 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNPC.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNPC.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.inferno; import java.awt.Color; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import net.runelite.api.NPC; @@ -39,10 +40,10 @@ public class InfernoNPC MELEE("Melee", Color.WHITE), RANDOM("Random", Color.ORANGE); - @Getter + @Getter(AccessLevel.PACKAGE) private String name = ""; - @Getter + @Getter(AccessLevel.PACKAGE) private Color color; Attackstyle(String s, Color c) @@ -52,44 +53,44 @@ public class InfernoNPC } } - @Getter + @Getter(AccessLevel.PACKAGE) private NPC npc; - @Getter + @Getter(AccessLevel.PACKAGE) private String name; - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private Attackstyle attackstyle; - @Getter + @Getter(AccessLevel.PACKAGE) private int attackTicks; - @Getter + @Getter(AccessLevel.PACKAGE) private int priority; - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private int ticksTillAttack = -1; - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private boolean attacking = false; - @Getter + @Getter(AccessLevel.PACKAGE) private int attackAnimation; - @Getter + @Getter(AccessLevel.PACKAGE) private boolean isMidAttack = false; - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private int distanceToPlayer = 0; - @Getter + @Getter(AccessLevel.PACKAGE) int textLocHeight; - public InfernoNPC(NPC npc) + InfernoNPC(NPC npc) { this.npc = npc; textLocHeight = npc.getLogicalHeight() + 40; @@ -177,7 +178,7 @@ public class InfernoNPC return info; } - public void attacked() + void attacked() { ticksTillAttack = attackTicks; attacking = true; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNibblerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNibblerOverlay.java index 12d88ef2af..a55b0f9f2e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNibblerOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoNibblerOverlay.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.inferno; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; @@ -34,29 +35,29 @@ import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; +@Singleton public class InfernoNibblerOverlay extends Overlay { private final Client client; private final InfernoPlugin plugin; - private final InfernoConfig config; private final PanelComponent panelComponent = new PanelComponent(); @Inject - public InfernoNibblerOverlay(Client client, InfernoConfig config, InfernoPlugin plugin) + public InfernoNibblerOverlay(final Client client, final InfernoPlugin plugin) { this.client = client; - this.config = config; this.plugin = plugin; setPosition(OverlayPosition.TOP_LEFT); } - @Override public Dimension render(Graphics2D graphics) { - if (!config.displayNibblerOverlay() || plugin.getNibblers().size() == 0 || client.getMapRegions()[0] != 9043) - return null; + if (!plugin.isDisplayNibblerOverlay() || plugin.getNibblers().size() == 0 || client.getMapRegions()[0] != 9043) + { + return null; + } panelComponent.getChildren().clear(); TableComponent tableComponent = new TableComponent(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoOverlay.java index 0175e1f751..0d374137f7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoOverlay.java @@ -30,6 +30,7 @@ import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.NPC; import net.runelite.api.Perspective; @@ -38,29 +39,29 @@ 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.components.PanelComponent; +@Singleton public class InfernoOverlay extends Overlay { private final Client client; private final InfernoPlugin plugin; - private final InfernoConfig config; - private final PanelComponent panelComponent = new PanelComponent(); @Inject - public InfernoOverlay(Client client, InfernoConfig config, InfernoPlugin plugin) + public InfernoOverlay(final Client client, final InfernoPlugin plugin) { 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() || client.getMapRegions()[0] != 9043) return null; + if (!client.isInInstancedRegion() || client.getMapRegions()[0] != 9043) + { + return null; + } for (InfernoNPC monster : plugin.getMonsters().values()) { @@ -96,13 +97,16 @@ public class InfernoOverlay extends Overlay return; } - int x = textLocation.getX(); - int y = textLocation.getY(); + if (textLocation != null) + { + int x = textLocation.getX(); + int y = textLocation.getY(); - graphics.setColor(Color.BLACK); - graphics.drawString(text, x + 1, y + 1); + graphics.setColor(Color.BLACK); + graphics.drawString(text, x + 1, y + 1); - graphics.setColor(color); - graphics.drawString(text, x, y); + graphics.setColor(color); + graphics.drawString(text, x, y); + } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java index 8a8549c4d5..4b0112a94f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoPlugin.java @@ -25,13 +25,14 @@ package net.runelite.client.plugins.inferno; import com.google.inject.Provides; - +import java.awt.Color; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Nullable; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -58,12 +59,13 @@ import net.runelite.client.ui.overlay.OverlayManager; import org.apache.commons.lang3.ArrayUtils; @PluginDescriptor( - name = "Inferno", - description = "Inferno helper", - tags = {"combat", "overlay", "pve", "pvm"}, - type = PluginType.PVM + name = "Inferno", + description = "Inferno helper", + tags = {"combat", "overlay", "pve", "pvm"}, + type = PluginType.PVM ) @Slf4j +@Singleton public class InfernoPlugin extends Plugin { private static final int INFERNO_REGION = 9043; @@ -92,22 +94,21 @@ public class InfernoPlugin extends Plugin @Inject private InfernoConfig config; - @Getter + @Getter(AccessLevel.PACKAGE) private int currentWave = -1; - @Getter + @Getter(AccessLevel.PACKAGE) private Map monsters; - @Getter + @Getter(AccessLevel.PACKAGE) private Map> monsterCurrentAttackMap; - @Getter + @Getter(AccessLevel.PACKAGE) private List nibblers; - @Getter + @Getter(AccessLevel.PACKAGE) private InfernoNPC[] priorityNPC; - @Getter(AccessLevel.PACKAGE) @Nullable private InfernoJadAttack attack; @@ -120,20 +121,29 @@ public class InfernoPlugin extends Plugin private List waveMonsters; public InfernoPlugin() - { - waveMonsters = new ArrayList<>(); - } + { + waveMonsters = new ArrayList<>(); + } + + @Getter(AccessLevel.PACKAGE) + private boolean displayNibblerOverlay; + @Getter(AccessLevel.PACKAGE) + private boolean showPrayerHelp; + private InfernoWaveDisplayMode waveDisplay; + private Color getWaveOverlayHeaderColor; + private Color getWaveTextColor; @Provides InfernoConfig provideConfig(ConfigManager configManager) - { - return configManager.getConfig(InfernoConfig.class); - } + { + return configManager.getConfig(InfernoConfig.class); + } @Override protected void startUp() throws Exception { - waveOverlay.setDisplayMode(config.waveDisplay()); + updateConfig(); + waveOverlay.setDisplayMode(this.waveDisplay); if (isInInferno()) { @@ -141,7 +151,7 @@ public class InfernoPlugin extends Plugin overlayManager.add(infernoInfobox); overlayManager.add(nibblerOverlay); - if (config.waveDisplay() != InfernoWaveDisplayMode.NONE) + if (this.waveDisplay != InfernoWaveDisplayMode.NONE) { overlayManager.add(waveOverlay); } @@ -149,8 +159,8 @@ public class InfernoPlugin extends Plugin overlayManager.add(jadOverlay); } - waveOverlay.setWaveHeaderColor(config.getWaveOverlayHeaderColor()); - waveOverlay.setWaveTextColor(config.getWaveTextColor()); + waveOverlay.setWaveHeaderColor(this.getWaveOverlayHeaderColor); + waveOverlay.setWaveTextColor(this.getWaveTextColor); monsters = new HashMap<>(); monsterCurrentAttackMap = new HashMap<>(6); @@ -177,6 +187,7 @@ public class InfernoPlugin extends Plugin monsters = null; currentWaveNumber = -1; } + @Subscribe private void onConfigChanged(ConfigChanged event) { @@ -185,18 +196,20 @@ public class InfernoPlugin extends Plugin return; } + updateConfig(); + if (event.getKey().endsWith("color")) { - waveOverlay.setWaveHeaderColor(config.getWaveOverlayHeaderColor()); - waveOverlay.setWaveTextColor(config.getWaveTextColor()); + waveOverlay.setWaveHeaderColor(this.getWaveOverlayHeaderColor); + waveOverlay.setWaveTextColor(this.getWaveTextColor); } else if ("waveDisplay".equals(event.getKey())) { overlayManager.remove(waveOverlay); - waveOverlay.setDisplayMode(config.waveDisplay()); + waveOverlay.setDisplayMode(this.waveDisplay); - if (isInInferno() && config.waveDisplay() != InfernoWaveDisplayMode.NONE) + if (isInInferno() && this.waveDisplay != InfernoWaveDisplayMode.NONE) { overlayManager.add(waveOverlay); } @@ -205,40 +218,46 @@ public class InfernoPlugin extends Plugin @Subscribe public void onNpcSpawned(NpcSpawned event) + { + if (client.getMapRegions()[0] != 9043) { - if (client.getMapRegions()[0] != 9043) return; - - NPC npc = event.getNpc(); - if (isValidInfernoMob(npc)) - { - monsters.put(npc, new InfernoNPC(npc)); - log.debug(String.valueOf(monsters.size())); - } - - if (npc.getId() == NpcID.JALNIB) - { - nibblers.add(npc); - } - - final int id = event.getNpc().getId(); - - if (id == NpcID.JALTOKJAD || id == NpcID.JALTOKJAD_7704) - { - jad = event.getNpc(); - } - - final Actor actor = event.getActor(); - - if (actor != null) - { - waveMonsters.add(actor); - } + return; } + NPC npc = event.getNpc(); + if (isValidInfernoMob(npc)) + { + monsters.put(npc, new InfernoNPC(npc)); + log.debug(String.valueOf(monsters.size())); + } + + if (npc.getId() == NpcID.JALNIB) + { + nibblers.add(npc); + } + + final int id = event.getNpc().getId(); + + if (id == NpcID.JALTOKJAD || id == NpcID.JALTOKJAD_7704) + { + jad = event.getNpc(); + } + + final Actor actor = event.getActor(); + + if (actor != null) + { + waveMonsters.add(actor); + } + } + @Subscribe public void onNpcDespawned(NpcDespawned event) { - if (client.getMapRegions()[0] != 9043) return; + if (client.getMapRegions()[0] != 9043) + { + return; + } NPC npc = event.getNpc(); if (monsters.containsKey(npc)) @@ -288,7 +307,7 @@ public class InfernoPlugin extends Plugin overlayManager.add(infernoInfobox); overlayManager.add(nibblerOverlay); - if (config.waveDisplay() != InfernoWaveDisplayMode.NONE) + if (this.waveDisplay != InfernoWaveDisplayMode.NONE) { overlayManager.add(waveOverlay); } @@ -317,7 +336,10 @@ public class InfernoPlugin extends Plugin @Subscribe public void onGameTick(GameTick event) { - if (client.getMapRegions()[0] != 9043) return; + if (client.getMapRegions()[0] != 9043) + { + return; + } clearMapAndPriority(); @@ -405,7 +427,10 @@ public class InfernoPlugin extends Plugin { ArrayList monsters = monsterCurrentAttackMap.get(i + 1); - if (monsters.size() == 0) continue; + if (monsters.size() == 0) + { + continue; + } int priority = monsters.get(0).getPriority(); @@ -474,4 +499,13 @@ public class InfernoPlugin extends Plugin { return currentWaveNumber == -1 || currentWaveNumber == 69 ? -1 : currentWaveNumber + 1; } + + private void updateConfig() + { + this.displayNibblerOverlay = config.displayNibblerOverlay(); + this.showPrayerHelp = config.showPrayerHelp(); + this.waveDisplay = config.waveDisplay(); + this.getWaveOverlayHeaderColor = config.getWaveOverlayHeaderColor(); + this.getWaveTextColor = config.getWaveTextColor(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoWaveMappings.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoWaveMappings.java index 0e87b0c13b..eb079846cf 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoWaveMappings.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoWaveMappings.java @@ -28,16 +28,17 @@ package net.runelite.client.plugins.inferno; import com.google.common.collect.ImmutableMap; import java.awt.Color; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.TitleComponent; class InfernoWaveMappings { - @Getter + @Getter(AccessLevel.PACKAGE) private static final ImmutableMap waveMapping; - @Getter + @Getter(AccessLevel.PACKAGE) private static final ImmutableMap npcNameMapping; static @@ -88,7 +89,7 @@ class InfernoWaveMappings waveMapBuilder.put(42, new int[]{32, 32, 32, 240, 490}); waveMapBuilder.put(43, new int[]{32, 32, 32, 85, 240, 490}); waveMapBuilder.put(44, new int[]{32, 32, 32, 85, 85, 240, 490}); - waveMapBuilder.put(45, new int[]{32, 32, 32, 165, 240, 490 }); + waveMapBuilder.put(45, new int[]{32, 32, 32, 165, 240, 490}); waveMapBuilder.put(46, new int[]{32, 32, 32, 85, 165, 240, 490}); waveMapBuilder.put(47, new int[]{32, 32, 32, 85, 85, 165, 240, 490}); waveMapBuilder.put(48, new int[]{32, 32, 32, 165, 165, 240, 490}); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoWaveOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoWaveOverlay.java index 88e3e32766..03d86509c0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoWaveOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inferno/InfernoWaveOverlay.java @@ -1,28 +1,31 @@ package net.runelite.client.plugins.inferno; -import java.awt.Color; import com.google.inject.Inject; +import com.google.inject.Singleton; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import lombok.AccessLevel; import lombok.Setter; import static net.runelite.client.plugins.inferno.InfernoWaveMappings.addWaveComponent; -import java.awt.Graphics2D; -import net.runelite.client.ui.overlay.OverlayPriority; -import net.runelite.client.ui.overlay.OverlayPosition; -import java.awt.Dimension; -import net.runelite.client.ui.overlay.components.PanelComponent; 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.PanelComponent; +@Singleton public class InfernoWaveOverlay extends Overlay - { +{ private final InfernoPlugin plugin; private final PanelComponent panelComponent; - @Setter + @Setter(AccessLevel.PACKAGE) private Color waveHeaderColor; - @Setter + @Setter(AccessLevel.PACKAGE) private Color waveTextColor; - @Setter + @Setter(AccessLevel.PACKAGE) private InfernoWaveDisplayMode displayMode; @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPlugin.java index 4311fd23e8..1578ee408b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/info/InfoPlugin.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.info; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.ClientToolbar; @@ -37,6 +38,7 @@ import net.runelite.client.util.ImageUtil; description = "Enable the Info panel", loadWhenOutdated = true ) +@Singleton public class InfoPlugin extends Plugin { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/info/JRichTextPane.java b/runelite-client/src/main/java/net/runelite/client/plugins/info/JRichTextPane.java index f24df49e17..b3e88b6a60 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/info/JRichTextPane.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/info/JRichTextPane.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.info; import java.awt.Desktop; import java.io.IOException; import java.net.URISyntaxException; +import javax.inject.Singleton; import javax.swing.BorderFactory; import javax.swing.JEditorPane; import javax.swing.event.HyperlinkEvent; @@ -35,6 +36,7 @@ import javax.swing.text.html.HTMLEditorKit; import lombok.extern.slf4j.Slf4j; @Slf4j +@Singleton public class JRichTextPane extends JEditorPane { private HyperlinkListener linkHandler; @@ -58,7 +60,7 @@ public class JRichTextPane extends JEditorPane setText(text); } - public void enableAutoLinkHandler(boolean enable) + void enableAutoLinkHandler(boolean enable) { if (enable == (linkHandler == null)) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/instancemap/InstanceMapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/instancemap/InstanceMapOverlay.java index 87d164b78f..2ef28d51b1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/instancemap/InstanceMapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/instancemap/InstanceMapOverlay.java @@ -31,6 +31,7 @@ import java.awt.Rectangle; import java.awt.image.BufferedImage; import javax.inject.Inject; import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import net.runelite.api.Client; @@ -56,7 +57,7 @@ class InstanceMapOverlay extends Overlay * this value to be 4. Changing this will break the method for rendering * complex tiles */ - static final int TILE_SIZE = 4; + private static final int TILE_SIZE = 4; /** * The size of the player's position marker on the map @@ -85,9 +86,9 @@ class InstanceMapOverlay extends Overlay private volatile boolean showMap = false; private final BackgroundComponent backgroundComponent = new BackgroundComponent(); - @Setter + @Setter(AccessLevel.PACKAGE) private boolean isCloseButtonHovered; - @Getter + @Getter(AccessLevel.PACKAGE) private Rectangle closeButtonBounds; private BufferedImage closeButtonImage; private BufferedImage closeButtonHoveredImage; @@ -103,7 +104,7 @@ class InstanceMapOverlay extends Overlay backgroundComponent.setFill(false); } - public boolean isMapShown() + boolean isMapShown() { return showMap; } @@ -114,7 +115,7 @@ class InstanceMapOverlay extends Overlay * * @param show Whether or not the map should be shown. */ - public synchronized void setShowMap(boolean show) + synchronized void setShowMap(boolean show) { showMap = show; if (showMap) @@ -128,7 +129,7 @@ class InstanceMapOverlay extends Overlay /** * Increases the viewed plane. The maximum viewedPlane is 3 */ - public synchronized void onAscend() + synchronized void onAscend() { if (viewedPlane >= MAX_PLANE) { @@ -142,7 +143,7 @@ class InstanceMapOverlay extends Overlay /** * Decreases the viewed plane. The minimum viewedPlane is 0 */ - public synchronized void onDescend() + synchronized void onDescend() { if (viewedPlane <= MIN_PLANE) { @@ -235,7 +236,7 @@ class InstanceMapOverlay extends Overlay * * @param event The game state change event */ - public void onGameStateChange(GameStateChanged event) + void onGameStateChange(GameStateChanged event) { mapImage = null; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/instancemap/InstanceMapPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/instancemap/InstanceMapPlugin.java index 38803e3c1b..d6f4cb3e17 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/instancemap/InstanceMapPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/instancemap/InstanceMapPlugin.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.instancemap; import com.google.inject.Binder; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.WidgetMenuOptionClicked; import net.runelite.api.widgets.WidgetInfo; @@ -43,6 +44,7 @@ import net.runelite.client.ui.overlay.OverlayManager; name = "Instance Map", description = "Add an instanced map, accessible by right-clicking the map button" ) +@Singleton public class InstanceMapPlugin extends Plugin { private final WidgetMenuOption openMapOption = new WidgetMenuOption("Show", "Instance Map", WidgetInfo.WORLD_MAP_OPTION); @@ -134,24 +136,24 @@ public class InstanceMapPlugin extends Plugin } } - public void showMap() + private void showMap() { overlay.setShowMap(true); openMapOption.setMenuOption("Hide"); } - public void closeMap() + void closeMap() { overlay.setShowMap(false); openMapOption.setMenuOption("Show"); } - public void ascendMap() + void ascendMap() { overlay.onAscend(); } - public void descendMap() + void descendMap() { overlay.onDescend(); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/HealthbarOverride.java b/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/HealthbarOverride.java index c0e844939a..500661a8ff 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/HealthbarOverride.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/HealthbarOverride.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.interfacestyles; import com.google.common.collect.ImmutableMap; import java.util.Map; +import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; import static net.runelite.api.SpriteID.*; @@ -52,12 +53,12 @@ enum HealthbarOverride implements SpriteOverride FRONT_140PX(HEALTHBAR_DEFAULT_FRONT_140PX, "front_90px.png"), FRONT_160PX(HEALTHBAR_DEFAULT_FRONT_160PX, "front_90px.png"); - @Getter + @Getter(AccessLevel.PUBLIC) private final int spriteId; private final String fileName; - @Getter + @Getter(AccessLevel.PACKAGE) private int padding = 1; private static final Map MAP; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/InterfaceStylesPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/InterfaceStylesPlugin.java index 6944a982d7..9758434681 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/InterfaceStylesPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/InterfaceStylesPlugin.java @@ -29,6 +29,7 @@ package net.runelite.client.plugins.interfacestyles; import com.google.inject.Provides; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.GameState; @@ -57,6 +58,7 @@ import net.runelite.client.util.ImageUtil; tags = {"2005", "2010", "skin", "theme", "ui"}, enabledByDefault = false ) +@Singleton public class InterfaceStylesPlugin extends Plugin { @Inject @@ -73,6 +75,11 @@ public class InterfaceStylesPlugin extends Plugin private Sprite[] defaultCrossSprites; + private Skin skin; + private boolean hdHealthBars; + private boolean hdMenu; + private boolean rsCrossSprites; + @Provides InterfaceStylesConfig provideConfig(ConfigManager configManager) { @@ -82,6 +89,7 @@ public class InterfaceStylesPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); clientThread.invoke(this::updateAllOverrides); } @@ -102,6 +110,7 @@ public class InterfaceStylesPlugin extends Plugin { if (config.getGroup().equals("interfaceStyles")) { + updateConfig(); clientThread.invoke(this::updateAllOverrides); } } @@ -115,7 +124,7 @@ public class InterfaceStylesPlugin extends Plugin @Subscribe public void onPostHealthBar(PostHealthBar postHealthBar) { - if (!config.hdHealthBars()) + if (!this.hdHealthBars) { return; } @@ -161,7 +170,7 @@ public class InterfaceStylesPlugin extends Plugin @Subscribe public void onBeforeMenuRender(BeforeMenuRender event) { - if (config.hdMenu()) + if (this.hdMenu) { client.draw2010Menu(); event.consume(); @@ -174,9 +183,9 @@ public class InterfaceStylesPlugin extends Plugin { for (Skin skin : spriteOverride.getSkin()) { - if (skin == config.skin()) + if (skin == this.skin) { - String file = config.skin().toString() + "/" + spriteOverride.getSpriteID() + ".png"; + String file = this.skin.toString() + "/" + spriteOverride.getSpriteID() + ".png"; Sprite spritePixels = getFileSpritePixels(file); if (spriteOverride.getSpriteID() == SpriteID.COMPASS_TEXTURE) @@ -206,9 +215,9 @@ public class InterfaceStylesPlugin extends Plugin { for (WidgetOverride widgetOverride : WidgetOverride.values()) { - if (widgetOverride.getSkin() == config.skin()) + if (widgetOverride.getSkin() == this.skin) { - String file = config.skin().toString() + "/widget/" + widgetOverride.getName() + ".png"; + String file = this.skin.toString() + "/widget/" + widgetOverride.getName() + ".png"; Sprite spritePixels = getFileSpritePixels(file); if (spritePixels != null) @@ -253,7 +262,7 @@ public class InterfaceStylesPlugin extends Plugin { for (WidgetOffset widgetOffset : WidgetOffset.values()) { - if (widgetOffset.getSkin() != config.skin()) + if (widgetOffset.getSkin() != this.skin) { continue; } @@ -287,7 +296,7 @@ public class InterfaceStylesPlugin extends Plugin private void overrideHealthBars() { - if (config.hdHealthBars()) + if (this.hdHealthBars) { spriteManager.addSpriteOverrides(HealthbarOverride.values()); // Reset health bar caches to apply the override @@ -307,7 +316,7 @@ public class InterfaceStylesPlugin extends Plugin private void overrideCrossSprites() { - if (config.rsCrossSprites()) + if (this.rsCrossSprites) { // If we've already replaced them, // we don't need to replace them again @@ -387,4 +396,12 @@ public class InterfaceStylesPlugin extends Plugin client.setCompass(compass); } } + + private void updateConfig() + { + this.skin = config.skin(); + this.hdHealthBars = config.hdHealthBars(); + this.hdMenu = config.hdMenu(); + this.rsCrossSprites = config.rsCrossSprites(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/Skin.java b/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/Skin.java index c041ffedc2..3e9aad9be9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/Skin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/Skin.java @@ -26,10 +26,11 @@ */ package net.runelite.client.plugins.interfacestyles; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; -@Getter +@Getter(AccessLevel.PACKAGE) @AllArgsConstructor public enum Skin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/SpriteOverride.java b/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/SpriteOverride.java index b5db7bb69c..f46a3bd50c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/SpriteOverride.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/SpriteOverride.java @@ -26,12 +26,13 @@ */ package net.runelite.client.plugins.interfacestyles; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.SpriteID; import static net.runelite.client.plugins.interfacestyles.Skin.AROUND_2005; import static net.runelite.client.plugins.interfacestyles.Skin.AROUND_2010; -@Getter +@Getter(AccessLevel.PACKAGE) enum SpriteOverride { TAB_COMBAT(SpriteID.TAB_COMBAT, AROUND_2005, AROUND_2010), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/WidgetOffset.java b/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/WidgetOffset.java index 9edf17165e..920aa0a818 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/WidgetOffset.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/WidgetOffset.java @@ -26,10 +26,11 @@ */ package net.runelite.client.plugins.interfacestyles; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.widgets.WidgetInfo; -@Getter +@Getter(AccessLevel.PACKAGE) enum WidgetOffset { RESIZABLE_2010_COMBAT_HIGHLIGHT(Skin.AROUND_2010, WidgetInfo.RESIZABLE_VIEWPORT_COMBAT_TAB, -4, 1, null, null), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/WidgetOverride.java b/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/WidgetOverride.java index 1998fb3808..0a83eb372d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/WidgetOverride.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/WidgetOverride.java @@ -26,10 +26,11 @@ */ package net.runelite.client.plugins.interfacestyles; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.widgets.WidgetInfo; -@Getter +@Getter(AccessLevel.PACKAGE) enum WidgetOverride { FIXED_CORNER_TOP_LEFT_2005(Skin.AROUND_2005, "1026", WidgetInfo.FIXED_VIEWPORT_COMBAT_TAB), @@ -47,7 +48,7 @@ enum WidgetOverride private String name; private WidgetInfo[] widgetInfo; - WidgetOverride(Skin skin, String name, WidgetInfo... widgetInfo) + WidgetOverride(final Skin skin, final String name, final WidgetInfo... widgetInfo) { this.skin = skin; this.name = name; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridOverlay.java index f9f66e10b8..4e86d634ff 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridOverlay.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.inventorygrid; import com.google.inject.Inject; +import com.google.inject.Singleton; import java.awt.AlphaComposite; import java.awt.Dimension; import java.awt.Graphics2D; @@ -42,20 +43,21 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; +@Singleton class InventoryGridOverlay extends Overlay { private static final int INVENTORY_SIZE = 28; - private final InventoryGridConfig config; + private final InventoryGridPlugin plugin; private final Client client; private final ItemManager itemManager; @Inject - private InventoryGridOverlay(InventoryGridConfig config, Client client, ItemManager itemManager) + private InventoryGridOverlay(final InventoryGridPlugin plugin, final Client client, final ItemManager itemManager) { this.itemManager = itemManager; this.client = client; - this.config = config; + this.plugin = plugin; setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); @@ -68,7 +70,7 @@ class InventoryGridOverlay extends Overlay final Widget inventoryWidget = client.getWidget(WidgetInfo.INVENTORY); if (if1DraggingWidget == null || if1DraggingWidget != inventoryWidget - || client.getItemPressedDuration() < config.dragDelay() / Constants.CLIENT_TICK_LENGTH) + || client.getItemPressedDuration() < plugin.getDragDelay() / Constants.CLIENT_TICK_LENGTH) { return null; } @@ -83,7 +85,7 @@ class InventoryGridOverlay extends Overlay final Rectangle bounds = widgetItem.getCanvasBounds(); boolean inBounds = bounds.contains(mousePoint); - if (config.showItem() && inBounds) + if (plugin.isShowItem() && inBounds) { final WidgetItem draggedItem = inventoryWidget.getWidgetItem(client.getIf1DraggedItemIndex()); final BufferedImage draggedItemImage = itemManager.getImage(draggedItem.getId()); @@ -95,14 +97,14 @@ class InventoryGridOverlay extends Overlay graphics.setComposite(AlphaComposite.SrcOver); } - if (config.showHighlight() && inBounds) + if (plugin.isShowHighlight() && inBounds) { - graphics.setColor(config.highlightColor()); + graphics.setColor(plugin.getHighlightColor()); graphics.fill(bounds); } - else if (config.showGrid()) + else if (plugin.isShowGrid()) { - graphics.setColor(config.gridColor()); + graphics.setColor(plugin.getGridColor()); graphics.fill(bounds); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridPlugin.java index dc6b0ae372..0ab7d78067 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorygrid/InventoryGridPlugin.java @@ -27,7 +27,13 @@ package net.runelite.client.plugins.inventorygrid; import com.google.inject.Inject; import com.google.inject.Provides; +import com.google.inject.Singleton; +import java.awt.Color; +import lombok.AccessLevel; +import lombok.Getter; +import net.runelite.api.events.ConfigChanged; 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; @@ -38,6 +44,7 @@ import net.runelite.client.ui.overlay.OverlayManager; tags = {"items", "overlay"}, enabledByDefault = false ) +@Singleton public class InventoryGridPlugin extends Plugin { @Inject @@ -46,9 +53,26 @@ public class InventoryGridPlugin extends Plugin @Inject private OverlayManager overlayManager; + @Inject + private InventoryGridConfig config; + + @Getter(AccessLevel.PACKAGE) + private boolean showItem; + @Getter(AccessLevel.PACKAGE) + boolean showGrid; + @Getter(AccessLevel.PACKAGE) + private boolean showHighlight; + @Getter(AccessLevel.PACKAGE) + private int dragDelay; + @Getter(AccessLevel.PACKAGE) + private Color gridColor; + @Getter(AccessLevel.PACKAGE) + private Color highlightColor; + @Override public void startUp() { + updateConfig(); overlayManager.add(overlay); } @@ -63,4 +87,23 @@ public class InventoryGridPlugin extends Plugin { return configManager.getConfig(InventoryGridConfig.class); } + + @Subscribe + public void onConfigChanged(ConfigChanged config) + { + if (config.getGroup().equals("inventorygrid")) + { + updateConfig(); + } + } + + private void updateConfig() + { + this.showItem = config.showItem(); + this.showGrid = config.showGrid(); + this.showHighlight = config.showHighlight(); + this.dragDelay = config.dragDelay(); + this.gridColor = config.gridColor(); + this.highlightColor = config.highlightColor(); + } } 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 index 1b0be390fb..95d4276a52 100644 --- 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 @@ -42,21 +42,19 @@ public class InventorySetupBankOverlay extends WidgetItemOverlay { private final ItemManager itemManager; private final InventorySetupPlugin plugin; - private final InventorySetupConfig config; @Inject - public InventorySetupBankOverlay(ItemManager itemManager, InventorySetupPlugin plugin, InventorySetupConfig config) + public InventorySetupBankOverlay(ItemManager itemManager, InventorySetupPlugin plugin) { this.itemManager = itemManager; this.plugin = plugin; - this.config = config; showOnBank(); } @Override public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget) { - if (config.getBankHighlight()) + if (plugin.isGetBankHighlight()) { int[] ids = plugin.getCurrentInventorySetupIds(); if (ids == null) @@ -70,7 +68,7 @@ public class InventorySetupBankOverlay extends WidgetItemOverlay } - final Color color = config.getBankHighlightColor(); + final Color color = plugin.getGetBankHighlightColor(); if (color != null) { 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 index fa35f2718e..a9c0b01929 100644 --- 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 @@ -28,6 +28,7 @@ package net.runelite.client.plugins.inventorysetups; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.inject.Provides; +import java.awt.Color; import java.awt.image.BufferedImage; import java.lang.reflect.Type; import java.util.ArrayList; @@ -35,8 +36,11 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; +import lombok.AccessLevel; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.GameState; @@ -70,6 +74,7 @@ import net.runelite.client.util.ImageUtil; ) @Slf4j +@Singleton public class InventorySetupPlugin extends Plugin { private static final String CONFIG_GROUP = "inventorysetups"; @@ -109,9 +114,23 @@ public class InventorySetupPlugin extends Plugin private boolean highlightDifference; + private boolean getHighlightDifferences; + @Getter(AccessLevel.PUBLIC) + private Color getHighlightColor; + @Getter(AccessLevel.PUBLIC) + private boolean getStackDifference; + @Getter(AccessLevel.PUBLIC) + private boolean getVariationDifference; + @Getter(AccessLevel.PACKAGE) + private boolean getBankHighlight; + @Getter(AccessLevel.PACKAGE) + private Color getBankHighlightColor; + @Override public void startUp() { + updateConfigOptions(); + overlayManager.add(overlay); panel = new InventorySetupPluginPanel(this, itemManager); @@ -242,8 +261,9 @@ public class InventorySetupPlugin extends Plugin { if (event.getGroup().equals(CONFIG_GROUP)) { + updateConfigOptions(); // only allow highlighting if the config is enabled and the player is logged in - highlightDifference = config.getHighlightDifferences() && client.getGameState() == GameState.LOGGED_IN; + highlightDifference = this.getHighlightDifferences && client.getGameState() == GameState.LOGGED_IN; final String setupName = panel.getSelectedInventorySetup(); if (highlightDifference && !setupName.isEmpty()) { @@ -338,7 +358,7 @@ public class InventorySetupPlugin extends Plugin // set highlighting case LOGGED_IN: - highlightDifference = config.getHighlightDifferences(); + highlightDifference = this.getHighlightDifferences; break; default: @@ -433,4 +453,14 @@ public class InventorySetupPlugin extends Plugin .filter(id -> id != -1) .toArray(); } + + private void updateConfigOptions() + { + this.getHighlightDifferences = config.getHighlightDifferences(); + this.getHighlightColor = config.getHighlightColor(); + this.getStackDifference = config.getHighlightDifferences(); + this.getVariationDifference = config.getVariationDifference(); + this.getBankHighlight = config.getBankHighlight(); + this.getBankHighlightColor = config.getBankHighlightColor(); + } } \ 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 index 0d5cb02f4d..6e0b8b99ba 100644 --- 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 @@ -28,16 +28,17 @@ package net.runelite.client.plugins.inventorysetups.ui; import java.awt.BorderLayout; import java.awt.Color; import java.util.ArrayList; +import javax.inject.Singleton; import javax.swing.JLabel; import javax.swing.JPanel; 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; +@Singleton public abstract class InventorySetupContainerPanel extends JPanel { protected ItemManager itemManager; @@ -99,10 +100,9 @@ public abstract class InventorySetupContainerPanel extends JPanel // 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(); + final Color highlightColor = plugin.getGetHighlightColor(); - if (config.getStackDifference() && currItem.getQuantity() != savedItem.getQuantity()) + if (plugin.isGetStackDifference() && currItem.getQuantity() != savedItem.getQuantity()) { containerSlot.setBackground(highlightColor); return; @@ -111,7 +111,7 @@ public abstract class InventorySetupContainerPanel extends JPanel int currId = currItem.getId(); int checkId = savedItem.getId(); - if (!config.getVariationDifference()) + if (!plugin.isGetVariationDifference()) { currId = ItemVariationMapping.map(currId); checkId = ItemVariationMapping.map(checkId); 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 index b964a205eb..2ca6687660 100644 --- 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 @@ -28,6 +28,7 @@ package net.runelite.client.plugins.inventorysetups.ui; import java.awt.GridLayout; import java.util.ArrayList; import java.util.HashMap; +import javax.inject.Singleton; import javax.swing.JPanel; import net.runelite.api.EquipmentInventorySlot; import net.runelite.client.game.ItemManager; @@ -36,6 +37,7 @@ import net.runelite.client.plugins.inventorysetups.InventorySetupItem; import net.runelite.client.plugins.inventorysetups.InventorySetupPlugin; import net.runelite.client.ui.ColorScheme; +@Singleton public class InventorySetupEquipmentPanel extends InventorySetupContainerPanel { private HashMap equipmentSlots; 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 index 689773b517..3310b2f25c 100644 --- 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 @@ -27,13 +27,14 @@ package net.runelite.client.plugins.inventorysetups.ui; import java.awt.GridLayout; import java.util.ArrayList; +import javax.inject.Singleton; import javax.swing.JPanel; 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; - +@Singleton public class InventorySetupInventoryPanel extends InventorySetupContainerPanel { private static final int ITEMS_PER_ROW = 4; 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 index 73f0033819..339ba435a3 100644 --- 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 @@ -34,6 +34,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.util.ArrayList; +import javax.inject.Singleton; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.ImageIcon; @@ -51,6 +52,7 @@ import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.components.PluginErrorPanel; import net.runelite.client.util.ImageUtil; +@Singleton public class InventorySetupPluginPanel extends PluginPanel { private static ImageIcon ADD_ICON; 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 index 0af6a142cb..bf05e88178 100644 --- 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 @@ -27,16 +27,18 @@ package net.runelite.client.plugins.inventorysetups.ui; import java.awt.Color; import java.awt.Dimension; +import javax.inject.Singleton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; import net.runelite.client.game.AsyncBufferedImage; -public class InventorySetupSlot extends JPanel +@Singleton +class InventorySetupSlot extends JPanel { private final JLabel imageLabel; - public InventorySetupSlot(Color color) + InventorySetupSlot(Color color) { imageLabel = new JLabel(); imageLabel.setVerticalAlignment(SwingConstants.CENTER); @@ -46,7 +48,7 @@ public class InventorySetupSlot extends JPanel } - public void setImageLabel(String toolTip, AsyncBufferedImage itemImage) + void setImageLabel(String toolTip, AsyncBufferedImage itemImage) { if (itemImage == null || toolTip == null) { 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 de7d786eb6..85560e0133 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 @@ -29,17 +29,19 @@ import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.widgets.WidgetItem; import net.runelite.client.game.ItemManager; import net.runelite.client.ui.overlay.WidgetItemOverlay; +@Singleton public class InventoryTagsOverlay extends WidgetItemOverlay { private final ItemManager itemManager; private final InventoryTagsPlugin plugin; @Inject - private InventoryTagsOverlay(ItemManager itemManager, InventoryTagsPlugin plugin) + private InventoryTagsOverlay(final ItemManager itemManager, final InventoryTagsPlugin plugin) { this.itemManager = itemManager; this.plugin = plugin; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsPlugin.java index 23e518e1f5..4438f22e34 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/inventorytags/InventoryTagsPlugin.java @@ -30,9 +30,11 @@ import com.google.inject.Provides; import java.awt.Color; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.MenuAction; import net.runelite.api.MenuEntry; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.MenuOpened; import net.runelite.api.events.MenuOptionClicked; import net.runelite.api.events.WidgetMenuOptionClicked; @@ -53,6 +55,7 @@ import net.runelite.client.util.Text; tags = {"highlight", "items", "overlay", "tagging"}, enabledByDefault = false ) +@Singleton public class InventoryTagsPlugin extends Plugin { private static final String ITEM_KEY_PREFIX = "item_"; @@ -103,6 +106,11 @@ public class InventoryTagsPlugin extends Plugin private boolean editorMode; + private Color group1Color; + private Color group2Color; + private Color group3Color; + private Color group4Color; + @Provides InventoryTagsConfig provideConfig(ConfigManager configManager) { @@ -133,6 +141,7 @@ public class InventoryTagsPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); refreshInventoryMenuOptions(); overlayManager.add(overlay); } @@ -227,13 +236,13 @@ public class InventoryTagsPlugin extends Plugin switch (name) { case SETNAME_GROUP_1: - return config.getGroup1Color(); + return this.group1Color; case SETNAME_GROUP_2: - return config.getGroup2Color(); + return this.group2Color; case SETNAME_GROUP_3: - return config.getGroup3Color(); + return this.group3Color; case SETNAME_GROUP_4: - return config.getGroup4Color(); + return this.group4Color; } return null; @@ -265,4 +274,21 @@ public class InventoryTagsPlugin extends Plugin menuManager.addManagedCustomMenu(RESIZABLE_BOTTOM_LINE_INVENTORY_TAB_CONFIGURE); } } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("inventorytags")) + { + updateConfig(); + } + } + + private void updateConfig() + { + this.group1Color = config.getGroup1Color(); + this.group2Color = config.getGroup2Color(); + this.group3Color = config.getGroup3Color(); + this.group4Color = config.getGroup4Color(); + } } 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 index 18405155ee..c6707f8701 100644 --- 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 @@ -24,10 +24,11 @@ */ package net.runelite.client.plugins.inventoryviewer; +import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; -@Getter +@Getter(AccessLevel.PACKAGE) @RequiredArgsConstructor public enum InventoryViewerMode { 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 efe6df33a0..c4d82e5a90 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 @@ -33,6 +33,7 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Constants; import net.runelite.api.InventoryID; @@ -50,6 +51,7 @@ import net.runelite.client.ui.overlay.components.ImageComponent; import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.TitleComponent; +@Singleton class InventoryViewerOverlay extends Overlay { private static final int INVENTORY_SIZE = 28; @@ -58,14 +60,14 @@ class InventoryViewerOverlay extends Overlay private final Client client; private final ItemManager itemManager; - private final InventoryViewerConfig config; + private final InventoryViewerPlugin plugin; private final PanelComponent wrapperComponent = new PanelComponent(); private final PanelComponent inventoryComponent = new PanelComponent(); private final TitleComponent freeSlotsComponent = TitleComponent.builder().build(); @Inject - private InventoryViewerOverlay(Client client, ItemManager itemManager, InventoryViewerConfig config) + private InventoryViewerOverlay(final Client client, final ItemManager itemManager, final InventoryViewerPlugin plugin) { setPosition(OverlayPosition.BOTTOM_RIGHT); @@ -89,13 +91,13 @@ class InventoryViewerOverlay extends Overlay this.itemManager = itemManager; this.client = client; - this.config = config; + this.plugin = plugin; } @Override public Dimension render(Graphics2D graphics) { - if (config.hideWhenInvOpen() + if (plugin.isHideWhenInvOpen() && client.getVar(VarClientInt.PLAYER_INVENTORY_OPENED) == 3) { return null; @@ -113,7 +115,7 @@ class InventoryViewerOverlay extends Overlay final Item[] items = itemContainer.getItems(); - if (config.viewerMode() == InventoryViewerMode.GROUPED) + if (plugin.getViewerMode() == InventoryViewerMode.GROUPED) { Multiset totals = HashMultiset.create(); for (Item item : items) @@ -140,7 +142,7 @@ class InventoryViewerOverlay extends Overlay } wrapperComponent.getChildren().add(inventoryComponent); - if (config.showFreeSlots()) + if (plugin.isShowFreeSlots()) { freeSlotsComponent.setText(remaining + " free"); wrapperComponent.setPreferredSize(new Dimension(Math.min(totals.elementSet().size(), 4) * (PLACEHOLDER_WIDTH + 6) + ComponentConstants.STANDARD_BORDER * 2, 0)); @@ -175,7 +177,7 @@ class InventoryViewerOverlay extends Overlay wrapperComponent.getChildren().add(inventoryComponent); - if (config.showFreeSlots()) + if (plugin.isShowFreeSlots()) { freeSlotsComponent.setText(remaining + " free"); wrapperComponent.setPreferredSize(new Dimension(4 * (PLACEHOLDER_WIDTH + 6) + ComponentConstants.STANDARD_BORDER * 2, 0)); 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 71032a10c7..114809287e 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 @@ -26,7 +26,12 @@ package net.runelite.client.plugins.inventoryviewer; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; +import net.runelite.api.events.ConfigChanged; 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; @@ -37,6 +42,7 @@ import net.runelite.client.ui.overlay.OverlayManager; tags = {"alternate", "items", "overlay", "second"}, enabledByDefault = false ) +@Singleton public class InventoryViewerPlugin extends Plugin { static final String CONFIG_GROUP_KEY = "inventoryviewer"; @@ -47,6 +53,16 @@ public class InventoryViewerPlugin extends Plugin @Inject private OverlayManager overlayManager; + @Inject + private InventoryViewerConfig config; + + @Getter(AccessLevel.PACKAGE) + private InventoryViewerMode viewerMode; + @Getter(AccessLevel.PACKAGE) + private boolean showFreeSlots; + @Getter(AccessLevel.PACKAGE) + private boolean hideWhenInvOpen; + @Provides InventoryViewerConfig provideConfig(ConfigManager configManager) { @@ -56,12 +72,29 @@ public class InventoryViewerPlugin extends Plugin @Override public void startUp() { + updateConfig(); overlayManager.add(overlay); } + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals(CONFIG_GROUP_KEY)) + { + updateConfig(); + } + } + @Override public void shutDown() { overlayManager.remove(overlay); } + + private void updateConfig() + { + this.viewerMode = config.viewerMode(); + this.showFreeSlots = config.showFreeSlots(); + this.hideWhenInvOpen = config.hideWhenInvOpen(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeConfig.java index 18b9d6386b..a866064623 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeConfig.java @@ -284,8 +284,8 @@ public interface ItemChargeConfig extends Config { return false; } - - + + @ConfigItem( keyName = "showSlayerBracelets", name = "Show Slayer Bracelets Charges", @@ -298,12 +298,11 @@ public interface ItemChargeConfig extends Config } - @ConfigItem( - keyName = "expeditious", - name = "", - description = "", - hidden = true + keyName = "expeditious", + name = "", + description = "", + hidden = true ) default int expeditious() { @@ -311,9 +310,9 @@ public interface ItemChargeConfig extends Config } @ConfigItem( - keyName = "expeditious", - name = "", - description = "" + keyName = "expeditious", + name = "", + description = "" ) void expeditious(int expeditious); @@ -337,10 +336,10 @@ public interface ItemChargeConfig extends Config @ConfigItem( - keyName = "xericTalisman", - name = "", - description = "", - hidden = true + keyName = "xericTalisman", + name = "", + description = "", + hidden = true ) default int xericTalisman() { @@ -348,17 +347,17 @@ public interface ItemChargeConfig extends Config } @ConfigItem( - keyName = "xericTalisman", - name = "", - description = "" + keyName = "xericTalisman", + name = "", + description = "" ) void xericTalisman(int xericTalisman); @ConfigItem( - keyName = "showSoulBearerCharges", - name = "Show Soul Bearer Charges", - description = "Configures if Soul Bearer item charge is shown", - position = 19 + keyName = "showSoulBearerCharges", + name = "Show Soul Bearer Charges", + description = "Configures if Soul Bearer item charge is shown", + position = 19 ) default boolean showSoulBearerCharges() { @@ -366,10 +365,10 @@ public interface ItemChargeConfig extends Config } @ConfigItem( - keyName = "soulBearer", - name = "", - description = "", - hidden = true + keyName = "soulBearer", + name = "", + description = "", + hidden = true ) default int soulBearer() { @@ -377,17 +376,17 @@ public interface ItemChargeConfig extends Config } @ConfigItem( - keyName = "soulBearer", - name = "", - description = "" + keyName = "soulBearer", + name = "", + description = "" ) void soulBearer(int soulBearer); @ConfigItem( - keyName = "showChronicleCharges", - name = "Show Chronicle Charges", - description = "Configures if Chronicle item charge is shown", - position = 20 + keyName = "showChronicleCharges", + name = "Show Chronicle Charges", + description = "Configures if Chronicle item charge is shown", + position = 20 ) default boolean showChronicleCharges() { @@ -395,23 +394,21 @@ public interface ItemChargeConfig extends Config } @ConfigItem( - keyName = "showXericTalismanCharges", - name = "Show Xeric's Talisman Charges", - description = "Configures if Xeric's Talisman item charge is shown", - position = 21 + keyName = "showXericTalismanCharges", + name = "Show Xeric's Talisman Charges", + description = "Configures if Xeric's Talisman item charge is shown", + position = 21 ) default boolean showXericTalismanCharges() { return false; } - - @ConfigItem( - keyName = "showrecoil", - name = "Show If Recoil is activated", - description = "Configures if Recoil is activated", - position = 22 + keyName = "showrecoil", + name = "Show If Recoil is activated", + description = "Configures if Recoil is activated", + position = 22 ) default boolean showrecoil() { @@ -419,10 +416,10 @@ public interface ItemChargeConfig extends Config } @ConfigItem( - keyName = "chronicle", - name = "", - description = "", - hidden = true + keyName = "chronicle", + name = "", + description = "", + hidden = true ) default int chronicle() { @@ -430,9 +427,9 @@ public interface ItemChargeConfig extends Config } @ConfigItem( - keyName = "chronicle", - name = "", - description = "" + keyName = "chronicle", + name = "", + description = "" ) void chronicle(int chronicle); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeInfobox.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeInfobox.java index 7ee70d44b5..82bd2e411a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeInfobox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargeInfobox.java @@ -26,11 +26,12 @@ package net.runelite.client.plugins.itemcharges; import java.awt.Color; import java.awt.image.BufferedImage; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.EquipmentInventorySlot; import net.runelite.client.ui.overlay.infobox.Counter; -@Getter +@Getter(AccessLevel.PACKAGE) class ItemChargeInfobox extends Counter { private final ItemChargePlugin plugin; @@ -38,12 +39,12 @@ class ItemChargeInfobox extends Counter private final EquipmentInventorySlot slot; ItemChargeInfobox( - ItemChargePlugin plugin, - BufferedImage image, - String name, - int charges, - ItemWithSlot item, - EquipmentInventorySlot slot) + final ItemChargePlugin plugin, + final BufferedImage image, + final String name, + final int charges, + final ItemWithSlot item, + final EquipmentInventorySlot slot) { super(image, plugin, charges); setTooltip(name); 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 31db7daad1..6253985981 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 @@ -29,6 +29,7 @@ import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.ItemID; import net.runelite.api.widgets.WidgetItem; import static net.runelite.client.plugins.itemcharges.ItemChargeType.ABYSSAL_BRACELET; @@ -42,16 +43,15 @@ import net.runelite.client.ui.FontManager; import net.runelite.client.ui.overlay.WidgetItemOverlay; import net.runelite.client.ui.overlay.components.TextComponent; +@Singleton class ItemChargeOverlay extends WidgetItemOverlay { - private final ItemChargePlugin itemChargePlugin; - private final ItemChargeConfig config; + private final ItemChargePlugin plugin; @Inject - ItemChargeOverlay(ItemChargePlugin itemChargePlugin, ItemChargeConfig config) + ItemChargeOverlay(final ItemChargePlugin itemChargePlugin) { - this.itemChargePlugin = itemChargePlugin; - this.config = config; + this.plugin = itemChargePlugin; showOnInventory(); showOnEquipment(); } @@ -69,72 +69,72 @@ class ItemChargeOverlay extends WidgetItemOverlay int charges; if (itemId == ItemID.DODGY_NECKLACE) { - if (!config.showDodgyCount()) + if (!plugin.isShowDodgyCount()) { return; } - charges = config.dodgyNecklace(); + charges = plugin.getDodgyNecklace(); } else if (itemId == ItemID.BRACELET_OF_SLAUGHTER) { - if (!config.showSlayerBracelets()) + if (!plugin.isShowSlayerBracelets()) { return; } - charges = config.slaughter(); + charges = plugin.getSlaughter(); } else if (itemId == ItemID.EXPEDITIOUS_BRACELET) { - if (!config.showSlayerBracelets()) + if (!plugin.isShowSlayerBracelets()) { return; } - charges = config.expeditious(); + charges = plugin.getExpeditious(); } else if (itemId == ItemID.BINDING_NECKLACE) { - if (!config.showBindingNecklaceCharges()) + if (!plugin.isShowBindingNecklaceCharges()) { return; } - charges = config.bindingNecklace(); + charges = plugin.getBindingNecklace(); } else if (itemId == ItemID.XERICS_TALISMAN) { - if (!config.showXericTalismanCharges()) + if (!plugin.isShowXericTalismanCharges()) { return; } - charges = config.xericTalisman(); + charges = plugin.getXericTalisman(); } else if (itemId == ItemID.SOUL_BEARER) { - if (!config.showSoulBearerCharges()) + if (!plugin.isShowSoulBearerCharges()) { return; } - charges = config.soulBearer(); + charges = plugin.getSoulBearer(); } else if (itemId == ItemID.CHRONICLE) { - if (!config.showChronicleCharges()) + if (!plugin.isShowChronicleCharges()) { return; } - charges = config.chronicle(); + charges = plugin.getChronicle(); } else if (itemId >= ItemID.EXPLORERS_RING_1 && itemId <= ItemID.EXPLORERS_RING_4) { - if (!config.showExplorerRingCharges()) + if (!plugin.isShowExplorerRingCharges()) { return; } - charges = config.explorerRing(); + charges = plugin.getExplorerRing(); } else @@ -146,13 +146,13 @@ class ItemChargeOverlay extends WidgetItemOverlay } ItemChargeType type = chargeItem.getType(); - if ((type == TELEPORT && !config.showTeleportCharges()) - || (type == FUNGICIDE_SPRAY && !config.showFungicideCharges()) - || (type == IMPBOX && !config.showImpCharges()) - || (type == WATERCAN && !config.showWateringCanCharges()) - || (type == WATERSKIN && !config.showWaterskinCharges()) - || (type == BELLOWS && !config.showBellowCharges()) - || (type == ABYSSAL_BRACELET && !config.showAbyssalBraceletCharges())) + if ((type == TELEPORT && !plugin.isShowTeleportCharges()) + || (type == FUNGICIDE_SPRAY && !plugin.isShowFungicideCharges()) + || (type == IMPBOX && !plugin.isShowImpCharges()) + || (type == WATERCAN && !plugin.isShowWateringCanCharges()) + || (type == WATERSKIN && !plugin.isShowWaterskinCharges()) + || (type == BELLOWS && !plugin.isShowBellowCharges()) + || (type == ABYSSAL_BRACELET && !plugin.isShowAbyssalBraceletCharges())) { return; } @@ -164,14 +164,14 @@ class ItemChargeOverlay extends WidgetItemOverlay final TextComponent textComponent = new TextComponent(); textComponent.setPosition(new Point(bounds.x, bounds.y + 1 + graphics.getFontMetrics().getMaxAscent() - graphics.getFontMetrics().getMaxDescent())); textComponent.setText(charges < 0 ? "?" : String.valueOf(charges)); - textComponent.setColor(itemChargePlugin.getColor(charges)); + textComponent.setColor(plugin.getColor(charges)); textComponent.render(graphics); } private boolean displayOverlay() { - return config.showTeleportCharges() || config.showDodgyCount() || config.showFungicideCharges() - || config.showImpCharges() || config.showWateringCanCharges() || config.showWaterskinCharges() - || config.showBellowCharges() || config.showAbyssalBraceletCharges() || config.showExplorerRingCharges(); + return plugin.isShowTeleportCharges() || plugin.isShowDodgyCount() || plugin.isShowFungicideCharges() + || plugin.isShowImpCharges() || plugin.isShowWateringCanCharges() || plugin.isShowWaterskinCharges() + || plugin.isShowBellowCharges() || plugin.isShowAbyssalBraceletCharges() || plugin.isShowExplorerRingCharges(); } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargePlugin.java index 5267d8c0f4..16f7184da9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemChargePlugin.java @@ -32,6 +32,7 @@ import java.awt.image.BufferedImage; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.ChatMessageType; @@ -69,6 +70,7 @@ import static net.runelite.api.ItemID.RING_OF_RECOIL; description = "Show number of item charges remaining", tags = {"inventory", "notifications", "overlay"} ) +@Singleton public class ItemChargePlugin extends Plugin { private static final Pattern DODGY_CHECK_PATTERN = Pattern.compile( @@ -126,8 +128,6 @@ public class ItemChargePlugin extends Plugin private static final int MAX_BINDING_CHARGES = 16; private static final int MAX_EXPLORER_RING_CHARGES = 30; - private int lastExplorerRingCharge = -1; - @Getter(AccessLevel.PACKAGE) private boolean ringOfRecoilAvailable = false; @@ -164,6 +164,65 @@ public class ItemChargePlugin extends Plugin // Limits destroy callback to once per tick private int lastCheckTick; + private Color veryLowWarningColor; + private Color lowWarningolor; + private int veryLowWarning; + private int lowWarning; + @Getter(AccessLevel.PACKAGE) + private boolean showTeleportCharges; + @Getter(AccessLevel.PACKAGE) + private boolean showDodgyCount; + private boolean dodgyNotification; + @Getter(AccessLevel.PACKAGE) + private int dodgyNecklace; + @Getter(AccessLevel.PACKAGE) + private boolean showImpCharges; + @Getter(AccessLevel.PACKAGE) + private boolean showFungicideCharges; + @Getter(AccessLevel.PACKAGE) + private boolean showWateringCanCharges; + @Getter(AccessLevel.PACKAGE) + private boolean showWaterskinCharges; + @Getter(AccessLevel.PACKAGE) + private boolean showBellowCharges; + @Getter(AccessLevel.PACKAGE) + private boolean showBasketCharges; + @Getter(AccessLevel.PACKAGE) + private boolean showSackCharges; + @Getter(AccessLevel.PACKAGE) + private boolean showAbyssalBraceletCharges; + private boolean recoilNotification; + @Getter(AccessLevel.PACKAGE) + private boolean showBindingNecklaceCharges; + @Getter(AccessLevel.PACKAGE) + private int bindingNecklace; + private boolean bindingNotification; + @Getter(AccessLevel.PACKAGE) + private boolean showExplorerRingCharges; + @Getter(AccessLevel.PACKAGE) + private int explorerRing; + private boolean showInfoboxes; + @Getter(AccessLevel.PACKAGE) + private boolean showSlayerBracelets; + @Getter(AccessLevel.PACKAGE) + private int expeditious; + @Getter(AccessLevel.PACKAGE) + private int slaughter; + @Getter(AccessLevel.PACKAGE) + private int xericTalisman; + @Getter(AccessLevel.PACKAGE) + private boolean showSoulBearerCharges; + @Getter(AccessLevel.PACKAGE) + private int soulBearer; + @Getter(AccessLevel.PACKAGE) + private boolean showChronicleCharges; + @Getter(AccessLevel.PACKAGE) + private boolean showXericTalismanCharges; + @Getter(AccessLevel.PACKAGE) + private boolean showrecoil; + @Getter(AccessLevel.PACKAGE) + private int chronicle; + @Provides ItemChargeConfig getConfig(ConfigManager configManager) { @@ -173,6 +232,8 @@ public class ItemChargePlugin extends Plugin @Override protected void startUp() { + updateConfig(); + overlayManager.add(overlay); overlayManager.add(recoilOverlay); recoilRingImage = itemManager.getImage(RING_OF_RECOIL); @@ -195,39 +256,41 @@ public class ItemChargePlugin extends Plugin return; } - if (!config.showInfoboxes()) + updateConfig(); + + if (!this.showInfoboxes) { infoBoxManager.removeIf(ItemChargeInfobox.class::isInstance); return; } - if (!config.showTeleportCharges()) + if (!this.showTeleportCharges) { removeInfobox(ItemWithSlot.TELEPORT); } - if (!config.showAbyssalBraceletCharges()) + if (!this.showAbyssalBraceletCharges) { removeInfobox(ItemWithSlot.ABYSSAL_BRACELET); } - if (!config.showDodgyCount()) + if (!this.showDodgyCount) { removeInfobox(ItemWithSlot.DODGY_NECKLACE); } - if (!config.showSlayerBracelets()) + if (!this.showSlayerBracelets) { removeInfobox(ItemWithSlot.BRACELET_OF_SLAUGHTER); removeInfobox(ItemWithSlot.EXPEDITIOUS_BRACELET); } - if (!config.showBindingNecklaceCharges()) + if (!this.showBindingNecklaceCharges) { removeInfobox(ItemWithSlot.BINDING_NECKLACE); } - if (!config.showExplorerRingCharges()) + if (!this.showExplorerRingCharges) { removeInfobox(ItemWithSlot.EXPLORER_RING); } @@ -256,7 +319,7 @@ public class ItemChargePlugin extends Plugin if (event.getType() == ChatMessageType.GAMEMESSAGE || event.getType() == ChatMessageType.SPAM) { - if (config.recoilNotification() && message.contains(RING_OF_RECOIL_BREAK_MESSAGE)) + if (this.recoilNotification && message.contains(RING_OF_RECOIL_BREAK_MESSAGE)) { notifier.notify("Your Ring of Recoil has shattered"); } @@ -286,7 +349,7 @@ public class ItemChargePlugin extends Plugin } else if (dodgyBreakMatcher.find()) { - if (config.dodgyNotification()) + if (this.dodgyNotification) { notifier.notify("Your dodgy necklace has crumbled to dust."); } @@ -295,7 +358,7 @@ public class ItemChargePlugin extends Plugin } else if (message.contains(BINDING_BREAK_TEXT)) { - if (config.bindingNotification()) + if (this.bindingNotification) { notifier.notify(BINDING_BREAK_TEXT); } @@ -305,7 +368,7 @@ public class ItemChargePlugin extends Plugin } else if (bindingNecklaceUsedMatcher.find()) { - updateBindingNecklaceCharges(config.bindingNecklace() - 1); + updateBindingNecklaceCharges(this.bindingNecklace - 1); } else if (bindingNecklaceCheckMatcher.find()) { @@ -360,40 +423,40 @@ public class ItemChargePlugin extends Plugin @Subscribe public void onItemContainerChanged(ItemContainerChanged event) { - if (event.getItemContainer() != client.getItemContainer(InventoryID.EQUIPMENT) || !config.showInfoboxes()) + if (event.getItemContainer() != client.getItemContainer(InventoryID.EQUIPMENT) || !this.showInfoboxes) { return; } final Item[] items = event.getItemContainer().getItems(); - if (config.showTeleportCharges()) + if (this.showTeleportCharges) { updateJewelleryInfobox(ItemWithSlot.TELEPORT, items); } - if (config.showDodgyCount()) + if (this.showDodgyCount) { updateJewelleryInfobox(ItemWithSlot.DODGY_NECKLACE, items); } - if (config.showAbyssalBraceletCharges()) + if (this.showAbyssalBraceletCharges) { updateJewelleryInfobox(ItemWithSlot.ABYSSAL_BRACELET, items); } - if (config.showSlayerBracelets()) + if (this.showSlayerBracelets) { updateJewelleryInfobox(ItemWithSlot.BRACELET_OF_SLAUGHTER, items); updateJewelleryInfobox(ItemWithSlot.EXPEDITIOUS_BRACELET, items); } - if (config.showBindingNecklaceCharges()) + if (this.showBindingNecklaceCharges) { updateJewelleryInfobox(ItemWithSlot.BINDING_NECKLACE, items); } - if (config.showExplorerRingCharges()) + if (this.showExplorerRingCharges) { updateJewelleryInfobox(ItemWithSlot.EXPLORER_RING, items); } @@ -410,10 +473,12 @@ public class ItemChargePlugin extends Plugin if (braceletText.contains("bracelet of slaughter")) { config.slaughter(MAX_SLAUGHTER_CHARGES); + this.slaughter = MAX_SLAUGHTER_CHARGES; } else if (braceletText.contains("expeditious bracelet")) { config.expeditious(MAX_EXPEDITIOUS_CHARGES); + this.expeditious = MAX_EXPEDITIOUS_CHARGES; } } @@ -506,7 +571,7 @@ public class ItemChargePlugin extends Plugin { if (client.getLocalPlayer().getSpotAnimation() == GraphicID.XERIC_TELEPORT) { - final int xericCharges = Math.max(config.xericTalisman() - 1, 0); + final int xericCharges = Math.max(this.xericTalisman - 1, 0); updateXericCharges(xericCharges); } } @@ -531,6 +596,7 @@ public class ItemChargePlugin extends Plugin private void onVarbitChanged(VarbitChanged event) { int explorerRingCharge = client.getVar(Varbits.EXPLORER_RING_ALCHS); + int lastExplorerRingCharge = -1; if (lastExplorerRingCharge != explorerRingCharge) { updateExplorerRingCharges(explorerRingCharge); @@ -540,8 +606,9 @@ public class ItemChargePlugin extends Plugin private void updateDodgyNecklaceCharges(final int value) { config.dodgyNecklace(value); + this.dodgyNecklace = value; - if (config.showInfoboxes() && config.showDodgyCount()) + if (this.showInfoboxes && this.showDodgyCount) { final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); @@ -557,8 +624,9 @@ public class ItemChargePlugin extends Plugin private void updateBraceletOfSlaughterCharges(final int value) { config.slaughter(value); + this.slaughter = value; - if (config.showInfoboxes() && config.showSlayerBracelets()) + if (this.showInfoboxes && this.showSlayerBracelets) { final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); @@ -574,8 +642,9 @@ public class ItemChargePlugin extends Plugin private void updateExpeditiousCharges(final int value) { config.expeditious(value); + this.expeditious = value; - if (config.showInfoboxes() && config.showSlayerBracelets()) + if (this.showInfoboxes && this.showSlayerBracelets) { final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); @@ -591,8 +660,9 @@ public class ItemChargePlugin extends Plugin private void updateBindingNecklaceCharges(final int value) { config.bindingNecklace(value); + this.bindingNecklace = value; - if (config.showInfoboxes() && config.showBindingNecklaceCharges()) + if (this.showInfoboxes && this.showBindingNecklaceCharges) { final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); @@ -608,24 +678,28 @@ public class ItemChargePlugin extends Plugin private void updateXericCharges(int xericCharges) { config.xericTalisman(xericCharges); + this.xericTalisman = xericCharges; } private void updateSoulBearerCharges(int soulBearerCharges) { config.soulBearer(soulBearerCharges); + this.soulBearer = soulBearerCharges; } private void updateChronicleCharges(int chronicleCharges) { config.chronicle(chronicleCharges); + this.chronicle = chronicleCharges; } private void updateExplorerRingCharges(final int value) { // Note: Varbit counts upwards. We count down from the maximum charges. config.explorerRing(MAX_EXPLORER_RING_CHARGES - value); + this.explorerRing = MAX_EXPLORER_RING_CHARGES - value; - if (config.showInfoboxes() && config.showExplorerRingCharges()) + if (this.showInfoboxes && this.showExplorerRingCharges) { final ItemContainer itemContainer = client.getItemContainer(InventoryID.EQUIPMENT); @@ -694,23 +768,23 @@ public class ItemChargePlugin extends Plugin { if (id == ItemID.DODGY_NECKLACE && type == ItemWithSlot.DODGY_NECKLACE) { - charges = config.dodgyNecklace(); + charges = this.dodgyNecklace; } else if (id == ItemID.BRACELET_OF_SLAUGHTER && type == ItemWithSlot.BRACELET_OF_SLAUGHTER) { - charges = config.slaughter(); + charges = this.slaughter; } else if (id == ItemID.EXPEDITIOUS_BRACELET && type == ItemWithSlot.EXPEDITIOUS_BRACELET) { - charges = config.expeditious(); + charges = this.expeditious; } else if (id == ItemID.BINDING_NECKLACE && type == ItemWithSlot.BINDING_NECKLACE) { - charges = config.bindingNecklace(); + charges = this.bindingNecklace; } else if ((id >= ItemID.EXPLORERS_RING_1 && id <= ItemID.EXPLORERS_RING_4) && type == ItemWithSlot.EXPLORER_RING) { - charges = config.explorerRing(); + charges = this.explorerRing; } } else if (itemWithCharge.getType() == type.getType()) @@ -751,14 +825,49 @@ public class ItemChargePlugin extends Plugin Color getColor(int charges) { Color color = Color.WHITE; - if (charges <= config.veryLowWarning()) + if (charges <= this.veryLowWarning) { - color = config.veryLowWarningColor(); + color = this.veryLowWarningColor; } - else if (charges <= config.lowWarning()) + else if (charges <= this.lowWarning) { - color = config.lowWarningolor(); + color = this.lowWarningolor; } return color; } + + private void updateConfig() + { + this.veryLowWarningColor = config.veryLowWarningColor(); + this.lowWarningolor = config.lowWarningolor(); + this.veryLowWarning = config.veryLowWarning(); + this.lowWarning = config.lowWarning(); + this.showTeleportCharges = config.showTeleportCharges(); + this.showDodgyCount = config.showDodgyCount(); + this.dodgyNotification = config.dodgyNotification(); + this.dodgyNecklace = config.dodgyNecklace(); + this.showImpCharges = config.showImpCharges(); + this.showFungicideCharges = config.showFungicideCharges(); + this.showWateringCanCharges = config.showWateringCanCharges(); + this.showWaterskinCharges = config.showWaterskinCharges(); + this.showBellowCharges = config.showBellowCharges(); + this.showAbyssalBraceletCharges = config.showAbyssalBraceletCharges(); + this.recoilNotification = config.recoilNotification(); + this.showBindingNecklaceCharges = config.showBindingNecklaceCharges(); + this.bindingNecklace = config.bindingNecklace(); + this.bindingNotification = config.bindingNotification(); + this.showExplorerRingCharges = config.showExplorerRingCharges(); + this.explorerRing = config.explorerRing(); + this.showInfoboxes = config.showInfoboxes(); + this.showSlayerBracelets = config.showSlayerBracelets(); + this.expeditious = config.expeditious(); + this.slaughter = config.slaughter(); + this.xericTalisman = config.xericTalisman(); + this.showSoulBearerCharges = config.showSoulBearerCharges(); + this.soulBearer = config.soulBearer(); + this.showChronicleCharges = config.showChronicleCharges(); + this.showXericTalismanCharges = config.showXericTalismanCharges(); + this.showrecoil = config.showrecoil(); + this.chronicle = config.chronicle(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemRecoilOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemRecoilOverlay.java index af55d54fe7..57e00c2f64 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemRecoilOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemRecoilOverlay.java @@ -30,7 +30,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.inject.Inject; -import net.runelite.api.Client; +import javax.inject.Singleton; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.components.ImageComponent; @@ -38,20 +38,19 @@ import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; +@Singleton class ItemRecoilOverlay extends Overlay { private static final Color NOT_ACTIVATED_BACKGROUND_COLOR = new Color(150, 0, 0, 150); private static final Color ACTIVATED_BACKGROUND_COLOR = new Color(0, 150, 0, 150); private final ItemChargePlugin plugin; - private final ItemChargeConfig config; private final PanelComponent imagePanelComponent = new PanelComponent(); @Inject - public ItemRecoilOverlay(Client client, ItemChargePlugin plugin, ItemChargeConfig config) + public ItemRecoilOverlay(final ItemChargePlugin plugin) { setPosition(OverlayPosition.TOP_LEFT); this.plugin = plugin; - this.config = config; } @Override @@ -61,7 +60,7 @@ class ItemRecoilOverlay extends Overlay tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT); this.imagePanelComponent.getChildren().clear(); - if (config.showrecoil()) + if (plugin.isShowrecoil()) { if (plugin.isRingOfRecoilAvailable()) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java index 2f2fe76469..6df317f5c6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithCharge.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.itemcharges; import com.google.common.collect.ImmutableMap; import java.util.Map; import javax.annotation.Nullable; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import static net.runelite.api.ItemID.ABYSSAL_BRACELET1; @@ -165,7 +166,7 @@ import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERCAN; import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERSKIN; @AllArgsConstructor -@Getter +@Getter(AccessLevel.PACKAGE) enum ItemWithCharge { ABRACE1(ABYSSAL_BRACELET, ABYSSAL_BRACELET1, 1), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithSlot.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithSlot.java index 4e7aec6b52..01d37630ae 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithSlot.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemcharges/ItemWithSlot.java @@ -27,10 +27,11 @@ package net.runelite.client.plugins.itemcharges; import com.google.common.collect.Sets; import java.util.Set; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.EquipmentInventorySlot; -@Getter +@Getter(AccessLevel.PACKAGE) enum ItemWithSlot { ABYSSAL_BRACELET(ItemChargeType.ABYSSAL_BRACELET, EquipmentInventorySlot.GLOVES), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentificationOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentificationOverlay.java index 588a51173d..416073704f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentificationOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentificationOverlay.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.itemidentification; import com.google.inject.Inject; +import com.google.inject.Singleton; import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; @@ -38,14 +39,15 @@ import net.runelite.client.ui.FontManager; import net.runelite.client.ui.overlay.WidgetItemOverlay; import net.runelite.client.ui.overlay.components.TextComponent; +@Singleton class ItemIdentificationOverlay extends WidgetItemOverlay { - private final ItemIdentificationConfig config; + private final ItemIdentificationPlugin plugin; @Inject - ItemIdentificationOverlay(ItemIdentificationConfig config) + ItemIdentificationOverlay(final ItemIdentificationPlugin plugin) { - this.config = config; + this.plugin = plugin; showOnInventory(); showOnBank(); showOnInterfaces(KEPT_ON_DEATH_GROUP_ID, GUIDE_PRICE_GROUP_ID, LOOTING_BAG_GROUP_ID, SEED_BOX_GROUP_ID, KINGDOM_GROUP_ID); @@ -63,19 +65,19 @@ class ItemIdentificationOverlay extends WidgetItemOverlay switch (iden.type) { case SEED: - if (!config.showSeeds()) + if (!plugin.isShowSeeds()) { return; } break; case HERB: - if (!config.showHerbs()) + if (!plugin.isShowHerbs()) { return; } break; case SAPLING: - if (!config.showSaplings()) + if (!plugin.isShowSaplings()) { return; } @@ -91,8 +93,8 @@ class ItemIdentificationOverlay extends WidgetItemOverlay { final TextComponent textComponent = new TextComponent(); textComponent.setPosition(new Point(bounds.x - 1, bounds.y + bounds.height - 1)); - textComponent.setColor(config.textColor()); - switch (config.identificationType()) + textComponent.setColor(plugin.getTextColor()); + switch (plugin.getIdentificationType()) { case SHORT: textComponent.setText(iden.shortName); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentificationPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentificationPlugin.java index 6e4f331765..1a8e9fa293 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentificationPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentificationPlugin.java @@ -25,8 +25,14 @@ package net.runelite.client.plugins.itemidentification; import com.google.inject.Provides; +import java.awt.Color; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; +import net.runelite.api.events.ConfigChanged; 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; @@ -36,6 +42,7 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Show identifying text over items with difficult to distinguish sprites", enabledByDefault = false ) +@Singleton public class ItemIdentificationPlugin extends Plugin { @Inject @@ -44,6 +51,20 @@ public class ItemIdentificationPlugin extends Plugin @Inject private ItemIdentificationOverlay overlay; + @Inject + private ItemIdentificationConfig config; + + @Getter(AccessLevel.PACKAGE) + private ItemIdentificationMode identificationType; + @Getter(AccessLevel.PACKAGE) + private Color textColor; + @Getter(AccessLevel.PACKAGE) + private boolean showSeeds; + @Getter(AccessLevel.PACKAGE) + private boolean showHerbs; + @Getter(AccessLevel.PACKAGE) + private boolean showSaplings; + @Provides ItemIdentificationConfig getConfig(ConfigManager configManager) { @@ -53,6 +74,7 @@ public class ItemIdentificationPlugin extends Plugin @Override protected void startUp() { + updateConfig(); overlayManager.add(overlay); } @@ -61,4 +83,24 @@ public class ItemIdentificationPlugin extends Plugin { overlayManager.remove(overlay); } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("itemidentification")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.identificationType = config.identificationType(); + this.textColor = config.textColor(); + this.showSeeds = config.showSeeds(); + this.showHerbs = config.showHerbs(); + this.showSaplings = config.showSaplings(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesOverlay.java index c252bc054c..cd28fbfda6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesOverlay.java @@ -28,6 +28,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Constants; import net.runelite.api.InventoryID; @@ -47,6 +48,7 @@ import net.runelite.client.ui.overlay.tooltip.TooltipManager; import net.runelite.client.util.ColorUtil; import net.runelite.client.util.StackFormatter; +@Singleton class ItemPricesOverlay extends Overlay { private static final int INVENTORY_ITEM_WIDGETID = WidgetInfo.INVENTORY.getPackedId(); @@ -54,7 +56,7 @@ class ItemPricesOverlay extends Overlay private static final int BANK_ITEM_WIDGETID = WidgetInfo.BANK_ITEM_CONTAINER.getPackedId(); private final Client client; - private final ItemPricesConfig config; + private final ItemPricesPlugin plugin; private final TooltipManager tooltipManager; private final StringBuilder itemStringBuilder = new StringBuilder(); @@ -62,11 +64,11 @@ class ItemPricesOverlay extends Overlay ItemManager itemManager; @Inject - ItemPricesOverlay(Client client, ItemPricesConfig config, TooltipManager tooltipManager) + ItemPricesOverlay(final Client client, final ItemPricesPlugin plugin, final TooltipManager tooltipManager) { setPosition(OverlayPosition.DYNAMIC); this.client = client; - this.config = config; + this.plugin = plugin; this.tooltipManager = tooltipManager; } @@ -95,7 +97,7 @@ class ItemPricesOverlay extends Overlay switch (action) { case ITEM_USE_ON_WIDGET: - if (!menuEntry.getTarget().contains("High Level Alchemy") || !config.showAlchProfit()) return null; + if (!menuEntry.getTarget().contains("High Level Alchemy") || !plugin.isShowAlchProfit()) return null; case WIDGET_DEFAULT: case ITEM_USE: case ITEM_FIRST_OPTION: @@ -107,7 +109,7 @@ class ItemPricesOverlay extends Overlay switch (groupId) { case WidgetID.INVENTORY_GROUP_ID: - if (config.hideInventory()) + if (plugin.isHideInventory()) { return null; } @@ -130,7 +132,7 @@ class ItemPricesOverlay extends Overlay private String makeValueTooltip(MenuEntry menuEntry) { // Disabling both disables all value tooltips - if (!config.showGEPrice() && !config.showHAValue()) + if (!plugin.isShowGEPrice() && !plugin.isShowHAValue()) { return null; } @@ -199,15 +201,15 @@ class ItemPricesOverlay extends Overlay int haProfit = 0; final int itemHaPrice = Math.round(itemDef.getPrice() * Constants.HIGH_ALCHEMY_MULTIPLIER); - if (config.showGEPrice()) + if (plugin.isShowGEPrice()) { gePrice = itemManager.getItemPrice(id); } - if (config.showHAValue()) + if (plugin.isShowHAValue()) { haPrice = itemManager.getAlchValue(id); } - if (gePrice > 0 && itemHaPrice > 0 && config.showAlchProfit()) + if (gePrice > 0 && itemHaPrice > 0 && plugin.isShowAlchProfit()) { haProfit = calculateHAProfit(itemHaPrice, gePrice); } @@ -227,7 +229,7 @@ class ItemPricesOverlay extends Overlay itemStringBuilder.append("EX: ") .append(StackFormatter.quantityToStackSize(gePrice * qty)) .append(" gp"); - if (config.showEA() && qty > 1) + if (plugin.isShowEA() && qty > 1) { itemStringBuilder.append(" (") .append(StackFormatter.quantityToStackSize(gePrice)) @@ -244,7 +246,7 @@ class ItemPricesOverlay extends Overlay itemStringBuilder.append("HA: ") .append(StackFormatter.quantityToStackSize(haValue * qty)) .append(" gp"); - if (config.showEA() && qty > 1) + if (plugin.isShowEA() && qty > 1) { itemStringBuilder.append(" (") .append(StackFormatter.quantityToStackSize(haValue)) @@ -260,7 +262,7 @@ class ItemPricesOverlay extends Overlay itemStringBuilder.append("HA Profit: ") .append(ColorUtil.wrapWithColorTag(String.valueOf(haProfit * qty), haColor)) .append(" gp"); - if (config.showEA() && qty > 1) + if (plugin.isShowEA() && qty > 1) { itemStringBuilder.append(" (") .append(ColorUtil.wrapWithColorTag(String.valueOf(haProfit), haColor)) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesPlugin.java index 2434faade3..302c9d8728 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemprices/ItemPricesPlugin.java @@ -26,7 +26,12 @@ package net.runelite.client.plugins.itemprices; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; +import net.runelite.api.events.ConfigChanged; 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; @@ -37,6 +42,7 @@ import net.runelite.client.ui.overlay.OverlayManager; tags = {"bank", "inventory", "overlay", "high", "alchemy", "grand", "exchange", "tooltips"}, enabledByDefault = false ) +@Singleton public class ItemPricesPlugin extends Plugin { @Inject @@ -45,6 +51,20 @@ public class ItemPricesPlugin extends Plugin @Inject private ItemPricesOverlay overlay; + @Inject + private ItemPricesConfig config; + + @Getter(AccessLevel.PACKAGE) + private boolean showGEPrice; + @Getter(AccessLevel.PACKAGE) + private boolean showHAValue; + @Getter(AccessLevel.PACKAGE) + private boolean showEA; + @Getter(AccessLevel.PACKAGE) + private boolean hideInventory; + @Getter(AccessLevel.PACKAGE) + private boolean showAlchProfit; + @Provides ItemPricesConfig getConfig(ConfigManager configManager) { @@ -54,6 +74,7 @@ public class ItemPricesPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); overlayManager.add(overlay); } @@ -62,4 +83,24 @@ public class ItemPricesPlugin extends Plugin { overlayManager.remove(overlay); } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("itemprices")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.showGEPrice = config.showGEPrice(); + this.showHAValue = config.showHAValue(); + this.showEA = config.showEA(); + this.hideInventory = config.hideInventory(); + this.showAlchProfit = config.showAlchProfit(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemskeptondeath/AlwaysLostItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemskeptondeath/AlwaysLostItem.java index 37066622bc..2e9ac325cc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemskeptondeath/AlwaysLostItem.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemskeptondeath/AlwaysLostItem.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.itemskeptondeath; import com.google.common.collect.ImmutableMap; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.ItemID; @@ -36,7 +37,7 @@ import net.runelite.api.ItemID; * The white outline will be added to these items when they are lost on death. */ @AllArgsConstructor -@Getter +@Getter(AccessLevel.PACKAGE) enum AlwaysLostItem { RUNE_POUCH(ItemID.RUNE_POUCH, true), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemskeptondeath/FixedPriceItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemskeptondeath/FixedPriceItem.java index a40851dc65..5afb14c931 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemskeptondeath/FixedPriceItem.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemskeptondeath/FixedPriceItem.java @@ -28,6 +28,7 @@ package net.runelite.client.plugins.itemskeptondeath; import com.google.common.collect.ImmutableMap; import java.util.Map; import javax.annotation.Nullable; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.ItemID; @@ -37,7 +38,7 @@ import net.runelite.api.ItemID; * These are typically imbued items, such as Berserker ring (i), to help it protect over the non-imbued variants. */ @AllArgsConstructor -@Getter +@Getter(AccessLevel.PACKAGE) enum FixedPriceItem { IMBUED_BLACK_MASK_I(ItemID.BLACK_MASK_I, 5000), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemskeptondeath/ItemsKeptOnDeathPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemskeptondeath/ItemsKeptOnDeathPlugin.java index ee761ad9a9..f6d817b54c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemskeptondeath/ItemsKeptOnDeathPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemskeptondeath/ItemsKeptOnDeathPlugin.java @@ -33,6 +33,7 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.Constants; @@ -64,6 +65,7 @@ import net.runelite.client.util.StackFormatter; enabledByDefault = false ) @Slf4j +@Singleton public class ItemsKeptOnDeathPlugin extends Plugin { private static final int DEEP_WILDY = 20; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatOverlay.java index 209e86aa41..28b3e555a2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatOverlay.java @@ -53,25 +53,26 @@ public class ItemStatOverlay extends Overlay .aspeed(6) .build()); - @Inject private Client client; - - @Inject private ItemManager itemManager; - - @Inject private TooltipManager tooltipManager; - - @Inject private ItemStatChanges statChanges; + private ItemStatPlugin plugin; @Inject - private ItemStatConfig config; + ItemStatOverlay(Client client, ItemStatPlugin plugin, ItemManager itemManager, TooltipManager tooltipManager, ItemStatChanges itemStatChanges) + { + this.client = client; + this.itemManager = itemManager; + this.tooltipManager = tooltipManager; + this.statChanges = itemStatChanges; + this.plugin = plugin; + } @Override public Dimension render(Graphics2D graphics) { - if (client.isMenuOpen() || (!config.relative() && !config.absolute() && !config.theoretical())) + if (client.isMenuOpen() || (!plugin.isRelative() && !plugin.isAbsolute() && !plugin.isTheoretical())) { return null; } @@ -115,7 +116,7 @@ public class ItemStatOverlay extends Overlay } } - if (config.consumableStats()) + if (plugin.isConsumableStats()) { final Effect change = statChanges.get(itemId); if (change != null) @@ -137,7 +138,7 @@ public class ItemStatOverlay extends Overlay } } - if (config.equipmentStats()) + if (plugin.isEquipmentStats()) { final ItemStats stats = itemManager.getItemStats(itemId, false); @@ -161,8 +162,8 @@ public class ItemStatOverlay extends Overlay final boolean inverse, final boolean showPercent) { - final Color plus = Positivity.getColor(config, Positivity.BETTER_UNCAPPED); - final Color minus = Positivity.getColor(config, Positivity.WORSE); + final Color plus = Positivity.getColor(plugin, Positivity.BETTER_UNCAPPED); + final Color minus = Positivity.getColor(plugin, Positivity.WORSE); if (value == 0) { @@ -189,7 +190,7 @@ public class ItemStatOverlay extends Overlay private String buildStatBonusString(ItemStats s) { final StringBuilder b = new StringBuilder(); - if (config.showWeight()) + if (plugin.isShowWeight()) { b.append(getChangeString("Weight", s.getWeight(), true, false)); } @@ -257,32 +258,32 @@ public class ItemStatOverlay extends Overlay private String buildStatChangeString(StatChange c) { StringBuilder b = new StringBuilder(); - b.append(ColorUtil.colorTag(Positivity.getColor(config, c.getPositivity()))); + b.append(ColorUtil.colorTag(Positivity.getColor(plugin, c.getPositivity()))); - if (config.relative()) + if (plugin.isRelative()) { b.append(c.getFormattedRelative()); } - if (config.theoretical()) + if (plugin.isTheoretical()) { - if (config.relative()) + if (plugin.isRelative()) { b.append("/"); } b.append(c.getFormattedTheoretical()); } - if (config.absolute() && (config.relative() || config.theoretical())) + if (plugin.isAbsolute() && (plugin.isRelative() || plugin.isTheoretical())) { b.append(" ("); } - if (config.absolute()) + if (plugin.isAbsolute()) { b.append(c.getAbsolute()); } - if (config.absolute() && (config.relative() || config.theoretical())) + if (plugin.isAbsolute() && (plugin.isRelative() || plugin.isTheoretical())) { b.append(")"); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatPlugin.java index 2b0e476677..f94a17df0c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/ItemStatPlugin.java @@ -30,10 +30,13 @@ import com.google.common.collect.ImmutableSet; import com.google.inject.Binder; import com.google.inject.Inject; import com.google.inject.Provides; +import java.awt.Color; import java.awt.FontMetrics; import java.util.List; import java.util.Map; import java.util.Set; +import lombok.AccessLevel; +import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.Constants; import net.runelite.api.FontID; @@ -97,6 +100,30 @@ public class ItemStatPlugin extends Plugin private Widget itemInformationTitle; + @Getter(AccessLevel.PACKAGE) + private boolean consumableStats; + @Getter(AccessLevel.PACKAGE) + private boolean equipmentStats; + private boolean geStats; + @Getter(AccessLevel.PACKAGE) + private boolean relative; + @Getter(AccessLevel.PACKAGE) + private boolean absolute; + @Getter(AccessLevel.PACKAGE) + private boolean theoretical; + @Getter(AccessLevel.PACKAGE) + private boolean showWeight; + @Getter(AccessLevel.PACKAGE) + private Color colorBetterUncapped; + @Getter(AccessLevel.PACKAGE) + private Color colorBetterSomeCapped; + @Getter(AccessLevel.PACKAGE) + private Color colorBetterCapped; + @Getter(AccessLevel.PACKAGE) + private Color colorNoChange; + @Getter(AccessLevel.PACKAGE) + private Color colorWorse; + @Provides ItemStatConfig getConfig(ConfigManager configManager) { @@ -112,6 +139,7 @@ public class ItemStatPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); overlayManager.add(overlay); } @@ -127,6 +155,7 @@ public class ItemStatPlugin extends Plugin { if (event.getKey().equals("geStats")) { + updateConfig(); clientThread.invokeLater(this::resetGEInventory); } } @@ -134,7 +163,7 @@ public class ItemStatPlugin extends Plugin @Subscribe public void onGameTick(GameTick event) { - if (itemInformationTitle != null && config.geStats() + if (itemInformationTitle != null && this.geStats && (client.getWidget(WidgetInfo.GRAND_EXCHANGE_WINDOW_CONTAINER) == null || client.getWidget(WidgetInfo.GRAND_EXCHANGE_WINDOW_CONTAINER).isHidden())) { @@ -145,7 +174,7 @@ public class ItemStatPlugin extends Plugin @Subscribe public void onVarbitChanged(VarbitChanged event) { - if (client.getVar(VarPlayer.CURRENT_GE_ITEM) == -1 && config.geStats()) + if (client.getVar(VarPlayer.CURRENT_GE_ITEM) == -1 && this.geStats) { resetGEInventory(); } @@ -154,7 +183,7 @@ public class ItemStatPlugin extends Plugin @Subscribe public void onScriptCallbackEvent(ScriptCallbackEvent event) { - if (event.getEventName().equals("geBuilt") && config.geStats()) + if (event.getEventName().equals("geBuilt") && this.geStats) { int currentGeItem = client.getVar(VarPlayer.CURRENT_GE_ITEM); if (currentGeItem != -1 && client.getVar(Varbits.GE_OFFER_CREATION_TYPE) == 0) @@ -431,4 +460,20 @@ public class ItemStatPlugin extends Plugin return client.getWidget(WidgetInfo.FIXED_VIEWPORT_INVENTORY_CONTAINER); } } + + private void updateConfig() + { + this.consumableStats = config.consumableStats(); + this.equipmentStats = config.equipmentStats(); + this.geStats = config.geStats(); + this.relative = config.relative(); + this.absolute = config.absolute(); + this.theoretical = config.theoretical(); + this.showWeight = config.showWeight(); + this.colorBetterUncapped = config.colorBetterUncapped(); + this.colorBetterSomeCapped = config.colorBetterSomeCapped(); + this.colorBetterCapped = config.colorBetterCapped(); + this.colorNoChange = config.colorNoChange(); + this.colorWorse = config.colorWorse(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Positivity.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Positivity.java index d1da3c8176..ea83360a9b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Positivity.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemstats/Positivity.java @@ -56,20 +56,20 @@ public enum Positivity */ BETTER_UNCAPPED; - public static Color getColor(ItemStatConfig config, Positivity positivity) + public static Color getColor(ItemStatPlugin plugin, Positivity positivity) { switch (positivity) { case BETTER_UNCAPPED: - return config.colorBetterUncapped(); + return plugin.getColorBetterUncapped(); case BETTER_SOMECAPPED: - return config.colorBetterSomeCapped(); + return plugin.getColorBetterSomeCapped(); case BETTER_CAPPED: - return config.colorBetterCapped(); + return plugin.getColorBetterCapped(); case NO_CHANGE: - return config.colorNoChange(); + return plugin.getColorNoChange(); case WORSE: - return config.colorWorse(); + return plugin.getColorWorse(); default: return Color.WHITE; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingListener.java index 56cf3bbedc..d4a493769f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingListener.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingListener.java @@ -30,6 +30,7 @@ import java.awt.event.KeyEvent; import java.util.HashMap; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.VarClientStr; @@ -39,6 +40,7 @@ import net.runelite.client.config.ModifierlessKeybind; import net.runelite.client.input.KeyListener; import net.runelite.client.input.MouseAdapter; +@Singleton class KeyRemappingListener extends MouseAdapter implements KeyListener { private static final Keybind ONE = new ModifierlessKeybind(KeyEvent.VK_1, 0); @@ -57,9 +59,6 @@ class KeyRemappingListener extends MouseAdapter implements KeyListener @Inject private KeyRemappingPlugin plugin; - @Inject - private KeyRemappingConfig config; - @Inject private Client client; @@ -83,24 +82,24 @@ class KeyRemappingListener extends MouseAdapter implements KeyListener if (!plugin.isTyping()) { - if (config.cameraRemap()) + if (plugin.isCameraRemap()) { - if (config.up().matches(e)) + if (plugin.getUp().matches(e)) { modified.put(e.getKeyCode(), KeyEvent.VK_UP); e.setKeyCode(KeyEvent.VK_UP); } - else if (config.down().matches(e)) + else if (plugin.getDown().matches(e)) { modified.put(e.getKeyCode(), KeyEvent.VK_DOWN); e.setKeyCode(KeyEvent.VK_DOWN); } - else if (config.left().matches(e)) + else if (plugin.getLeft().matches(e)) { modified.put(e.getKeyCode(), KeyEvent.VK_LEFT); e.setKeyCode(KeyEvent.VK_LEFT); } - else if (config.right().matches(e)) + else if (plugin.getRight().matches(e)) { modified.put(e.getKeyCode(), KeyEvent.VK_RIGHT); e.setKeyCode(KeyEvent.VK_RIGHT); @@ -110,7 +109,7 @@ class KeyRemappingListener extends MouseAdapter implements KeyListener // In addition to the above checks, the F-key remapping shouldn't // activate when dialogs are open which listen for number keys // to select options - if (config.fkeyRemap() && !plugin.isDialogOpen()) + if (plugin.isFkeyRemap() && !plugin.isDialogOpen()) { if (ONE.matches(e)) { @@ -219,27 +218,27 @@ class KeyRemappingListener extends MouseAdapter implements KeyListener { modified.remove(e.getKeyCode()); - if (config.cameraRemap()) + if (plugin.isCameraRemap()) { - if (config.up().matches(e)) + if (plugin.getUp().matches(e)) { e.setKeyCode(KeyEvent.VK_UP); } - else if (config.down().matches(e)) + else if (plugin.getDown().matches(e)) { e.setKeyCode(KeyEvent.VK_DOWN); } - else if (config.left().matches(e)) + else if (plugin.getLeft().matches(e)) { e.setKeyCode(KeyEvent.VK_LEFT); } - else if (config.right().matches(e)) + else if (plugin.getRight().matches(e)) { e.setKeyCode(KeyEvent.VK_RIGHT); } } - if (config.fkeyRemap()) + if (plugin.isFkeyRemap()) { if (ONE.matches(e)) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java index 5b38cbdc25..2d94b6e4d1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/keyremapping/KeyRemappingPlugin.java @@ -28,6 +28,7 @@ package net.runelite.client.plugins.keyremapping; import com.google.inject.Provides; import java.awt.Color; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; @@ -43,6 +44,7 @@ import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ConfigManager; +import net.runelite.client.config.ModifierlessKeybind; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.input.KeyManager; import net.runelite.client.plugins.Plugin; @@ -56,6 +58,7 @@ import net.runelite.client.util.ColorUtil; tags = {"enter", "chat", "wasd", "camera"}, enabledByDefault = false ) +@Singleton public class KeyRemappingPlugin extends Plugin { private static final String PRESS_ENTER_TO_CHAT = "Press Enter to Chat..."; @@ -81,9 +84,25 @@ public class KeyRemappingPlugin extends Plugin @Setter(AccessLevel.PACKAGE) private boolean typing; + private boolean hideDisplayName; + @Getter(AccessLevel.PACKAGE) + private boolean cameraRemap; + @Getter(AccessLevel.PACKAGE) + private ModifierlessKeybind up; + @Getter(AccessLevel.PACKAGE) + private ModifierlessKeybind down; + @Getter(AccessLevel.PACKAGE) + private ModifierlessKeybind left; + @Getter(AccessLevel.PACKAGE) + private ModifierlessKeybind right; + @Getter(AccessLevel.PACKAGE) + private boolean fkeyRemap; + @Override protected void startUp() throws Exception { + updateConfig(); + typing = false; keyManager.registerKeyListener(inputListener); @@ -153,11 +172,13 @@ public class KeyRemappingPlugin extends Plugin @Subscribe public void onConfigChanged(ConfigChanged configChanged) { - if (!configChanged.getGroup().equals("keyremapping") || !configChanged.getKey().equals("hideDisplayName")) + if (!configChanged.getGroup().equals("keyremapping")) { return; } + updateConfig(); + clientThread.invoke(() -> { Widget chatboxInput = client.getWidget(WidgetInfo.CHATBOX_INPUT); @@ -242,7 +263,7 @@ public class KeyRemappingPlugin extends Plugin private String getWaitingText() { - if (config.hideDisplayName()) + if (this.hideDisplayName) { return PRESS_ENTER_TO_CHAT; } @@ -251,4 +272,15 @@ public class KeyRemappingPlugin extends Plugin return getPlayerNameWithIcon() + ": " + PRESS_ENTER_TO_CHAT; } } + + private void updateConfig() + { + this.hideDisplayName = config.hideDisplayName(); + this.cameraRemap = config.cameraRemap(); + this.up = config.up(); + this.down = config.down(); + this.left = config.left(); + this.right = config.right(); + this.fkeyRemap = config.fkeyRemap(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kingdomofmiscellania/KingdomCounter.java b/runelite-client/src/main/java/net/runelite/client/plugins/kingdomofmiscellania/KingdomCounter.java index 8a2871125f..7c3dc3b56a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kingdomofmiscellania/KingdomCounter.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/kingdomofmiscellania/KingdomCounter.java @@ -25,14 +25,16 @@ package net.runelite.client.plugins.kingdomofmiscellania; import java.awt.image.BufferedImage; +import javax.inject.Singleton; import net.runelite.client.ui.overlay.infobox.Counter; import net.runelite.client.util.StackFormatter; +@Singleton public class KingdomCounter extends Counter { private final KingdomPlugin plugin; - KingdomCounter(BufferedImage image, KingdomPlugin plugin) + KingdomCounter(final BufferedImage image, final KingdomPlugin plugin) { super(image, plugin, plugin.getFavor()); this.plugin = plugin; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kingdomofmiscellania/KingdomPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/kingdomofmiscellania/KingdomPlugin.java index 17347b3aac..e0445d6576 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kingdomofmiscellania/KingdomPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/kingdomofmiscellania/KingdomPlugin.java @@ -26,6 +26,8 @@ package net.runelite.client.plugins.kingdomofmiscellania; import com.google.common.collect.ImmutableSet; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; @@ -48,6 +50,7 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager; enabledByDefault = false ) @Slf4j +@Singleton public class KingdomPlugin extends Plugin { private static final ImmutableSet KINGDOM_REGION = ImmutableSet.of(10044, 10300); @@ -61,7 +64,7 @@ public class KingdomPlugin extends Plugin @Inject private ItemManager itemManager; - @Getter + @Getter(AccessLevel.PACKAGE) private int favor = 0, coffer = 0; private KingdomCounter counter; @@ -75,9 +78,12 @@ public class KingdomPlugin extends Plugin @Subscribe public void onVarbitChanged(VarbitChanged event) { - favor = client.getVar(Varbits.KINGDOM_FAVOR); - coffer = client.getVar(Varbits.KINGDOM_COFFER); - processInfobox(); + if (isInKingdom()) + { + favor = client.getVar(Varbits.KINGDOM_FAVOR); + coffer = client.getVar(Varbits.KINGDOM_COFFER); + processInfobox(); + } } @Subscribe diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/Book.java b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/Book.java index 49f6ccf7f9..43b31e52aa 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/Book.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/Book.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.kourendlibrary; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.ItemID; import net.runelite.client.game.AsyncBufferedImage; @@ -99,22 +100,22 @@ enum Book return BY_NAME.get(name); } - @Getter + @Getter(AccessLevel.PACKAGE) private final int item; - @Getter + @Getter(AccessLevel.PACKAGE) private final String name; - @Getter + @Getter(AccessLevel.PACKAGE) private final String shortName; - @Getter + @Getter(AccessLevel.PACKAGE) private AsyncBufferedImage icon; - @Getter + @Getter(AccessLevel.PACKAGE) private final boolean isDarkManuscript; - Book(int id, String shortName, String name) + Book(final int id, final String shortName, final String name) { this.item = id; this.isDarkManuscript = false; @@ -122,7 +123,7 @@ enum Book this.name = name; } - Book(int id) + Book(final int id) { this.item = id; this.isDarkManuscript = true; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/BookPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/BookPanel.java index 29976bc0bb..fe11faac3b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/BookPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/BookPanel.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.kourendlibrary; import java.awt.Color; +import javax.inject.Singleton; import javax.swing.GroupLayout; import javax.swing.JLabel; import javax.swing.JPanel; @@ -32,11 +33,12 @@ import javax.swing.border.EmptyBorder; import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.FontManager; +@Singleton class BookPanel extends JPanel { private JLabel location = new JLabel(); - BookPanel(Book b) + BookPanel(final Book b) { setBorder(new EmptyBorder(3, 3, 3, 3)); setBackground(ColorScheme.DARK_GRAY_COLOR); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/Bookcase.java b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/Bookcase.java index ee7d7d295d..c4a95d7215 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/Bookcase.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/Bookcase.java @@ -29,37 +29,38 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.coords.WorldPoint; class Bookcase { - Bookcase(WorldPoint location) + Bookcase(final WorldPoint location) { this.location = location; this.index = new ArrayList<>(); } - @Getter + @Getter(AccessLevel.PACKAGE) private final WorldPoint location; - @Getter + @Getter(AccessLevel.PACKAGE) private final List index; - @Getter + @Getter(AccessLevel.PACKAGE) private boolean isBookSet; /** * Book in this bookcase as found by the player. * Will be correct as long as isBookSet is true, unless the library has reset; */ - @Getter + @Getter(AccessLevel.PACKAGE) private Book book; /** * Books that can be in this slot. Will only be populated if library.state != SolvedState.NO_DATA */ - @Getter + @Getter(AccessLevel.PACKAGE) private Set possibleBooks = new HashSet<>(); void clearBook() diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryOverlay.java index 5cf7910ee6..9af693fed2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryOverlay.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.kourendlibrary; import com.google.inject.Inject; +import com.google.inject.Singleton; import java.awt.Color; import java.awt.Dimension; import java.awt.FontMetrics; @@ -50,23 +51,22 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton class KourendLibraryOverlay extends Overlay { private final static int MAXIMUM_DISTANCE = 24; private final Library library; private final Client client; - private final KourendLibraryConfig config; private final KourendLibraryPlugin plugin; @Setter(AccessLevel.PACKAGE) private boolean hidden; @Inject - private KourendLibraryOverlay(Library library, Client client, KourendLibraryConfig config, KourendLibraryPlugin plugin) + private KourendLibraryOverlay(final Library library, final Client client, final KourendLibraryPlugin plugin) { this.library = library; this.client = client; - this.config = config; this.plugin = plugin; setPosition(OverlayPosition.DYNAMIC); @@ -238,7 +238,7 @@ class KourendLibraryOverlay extends Overlay private boolean shouldHideOverlayIfDuplicateBook(@Nullable Book book) { - return config.hideDuplicateBook() + return plugin.isHideDuplicateBook() && book != null && !book.isDarkManuscript() && plugin.doesPlayerContainBook(book); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryPlugin.java index aea8d9b034..54e60eb415 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryPlugin.java @@ -30,7 +30,10 @@ import java.util.EnumSet; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.SwingUtilities; +import lombok.AccessLevel; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.AnimationID; import net.runelite.api.ChatMessageType; @@ -65,6 +68,7 @@ import net.runelite.client.util.ImageUtil; tags = {"arceuus", "magic", "runecrafting", "overlay", "panel"} ) @Slf4j +@Singleton public class KourendLibraryPlugin extends Plugin { private static final Pattern BOOK_EXTRACTOR = Pattern.compile("'(.*)'"); @@ -101,6 +105,10 @@ public class KourendLibraryPlugin extends Plugin private WorldPoint lastBookcaseAnimatedOn = null; private EnumSet playerBooks = null; + private boolean hideButton; + @Getter(AccessLevel.PACKAGE) + private boolean hideDuplicateBook; + @Provides KourendLibraryConfig provideConfig(ConfigManager configManager) { @@ -110,6 +118,9 @@ public class KourendLibraryPlugin extends Plugin @Override protected void startUp() throws Exception { + hideButton = config.hideButton(); + hideDuplicateBook = config.hideDuplicateBook(); + Book.fillImages(itemManager); panel = injector.getInstance(KourendLibraryPanel.class); @@ -128,7 +139,7 @@ public class KourendLibraryPlugin extends Plugin updatePlayerBooks(); - if (!config.hideButton()) + if (!this.hideButton) { clientToolbar.addNavigation(navButton); } @@ -154,9 +165,12 @@ public class KourendLibraryPlugin extends Plugin return; } + this.hideButton = config.hideButton(); + this.hideDuplicateBook = config.hideDuplicateBook(); + SwingUtilities.invokeLater(() -> { - if (!config.hideButton()) + if (!this.hideButton) { clientToolbar.addNavigation(navButton); } @@ -213,7 +227,7 @@ public class KourendLibraryPlugin extends Plugin public void onGameTick(GameTick tick) { boolean inRegion = client.getLocalPlayer().getWorldLocation().getRegionID() == REGION; - if (config.hideButton() && inRegion != buttonAttached) + if (this.hideButton && inRegion != buttonAttached) { SwingUtilities.invokeLater(() -> { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/Library.java b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/Library.java index 23afd804a5..85103e8135 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/Library.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/Library.java @@ -33,6 +33,7 @@ import java.util.List; import java.util.Map; import java.util.stream.IntStream; import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.coords.WorldPoint; @@ -91,13 +92,13 @@ class Library private final int step; - @Getter + @Getter(AccessLevel.PACKAGE) private SolvedState state; - @Getter + @Getter(AccessLevel.PACKAGE) private Book customerBook; - @Getter + @Getter(AccessLevel.PACKAGE) private LibraryCustomer customer; Library() diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/LibraryCustomer.java b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/LibraryCustomer.java index 04cb4829a1..9de04a826a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/LibraryCustomer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/LibraryCustomer.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.kourendlibrary; import java.util.HashMap; import java.util.Map; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.NpcID; @@ -35,10 +36,10 @@ enum LibraryCustomer PROFESSOR_GRACKLEBONE(NpcID.PROFESSOR_GRACKLEBONE, "Prof. Gracklebone"), SAM(NpcID.SAM_7049, "Sam"); - @Getter + @Getter(AccessLevel.PACKAGE) private final int id; - @Getter + @Getter(AccessLevel.PACKAGE) private final String name; private static final Map byId = buildIdMap(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/learntoclick/LearnToClickPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/learntoclick/LearnToClickPlugin.java index cea339008b..94d1aa6c18 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/learntoclick/LearnToClickPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/learntoclick/LearnToClickPlugin.java @@ -13,6 +13,7 @@ package net.runelite.client.plugins.learntoclick; import com.google.common.collect.ImmutableList; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.MenuEntry; @@ -29,7 +30,6 @@ import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginType; import org.apache.commons.lang3.ArrayUtils; - @PluginDescriptor( name = "Learn to Click", description = "A few modifications to prevent misclicks", @@ -37,8 +37,8 @@ import org.apache.commons.lang3.ArrayUtils; type = PluginType.PVP, enabledByDefault = false ) - @Slf4j +@Singleton public class LearnToClickPlugin extends Plugin { private static final ImmutableList ORB_WIDGETS = ImmutableList.of(WidgetInfo.MINIMAP_WORLDMAP_ORB, @@ -50,6 +50,12 @@ public class LearnToClickPlugin extends Plugin @Inject private Client client; + private boolean shouldBlockCompass; + private boolean shouldRightClickMap; + private boolean shouldRightClickXp; + private boolean shouldRightClickRetaliate; + private boolean hideOrbs; + @Provides LearnToClickConfig provideConfig(ConfigManager configManager) { @@ -59,6 +65,7 @@ public class LearnToClickPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); } @Override @@ -71,11 +78,14 @@ public class LearnToClickPlugin extends Plugin @Subscribe public void onConfigChanged(ConfigChanged event) { - if (!event.getGroup().equals("learntoclick") && !event.getKey().equals("hideOrbs")) + if (!event.getGroup().equals("learntoclick")) { return; } - if (config.hideOrbs()) + + updateConfig(); + + if (this.hideOrbs) { hideOrbWidgets(true); } @@ -89,7 +99,7 @@ public class LearnToClickPlugin extends Plugin @Subscribe public void onWidgetLoaded(WidgetLoaded event) { - if (!config.hideOrbs()) + if (!this.hideOrbs) { return; } @@ -110,10 +120,10 @@ public class LearnToClickPlugin extends Plugin MenuEntry[] menuEntries = client.getMenuEntries(); for (MenuEntry entry : menuEntries) { - if ((entry.getOption().equals("Floating") && config.shouldRightClickMap()) || - (entry.getOption().equals("Hide") && config.shouldRightClickXp()) || (entry.getOption().equals("Show") - && config.shouldRightClickXp()) || (entry.getOption().equals("Auto retaliate") - && config.shouldRightClickRetaliate())) + if ((entry.getOption().equals("Floating") && this.shouldRightClickMap) || + (entry.getOption().equals("Hide") && this.shouldRightClickXp) || (entry.getOption().equals("Show") + && this.shouldRightClickXp) || (entry.getOption().equals("Auto retaliate") + && this.shouldRightClickRetaliate)) { event.setForceRightClick(true); return; @@ -124,14 +134,14 @@ public class LearnToClickPlugin extends Plugin @Subscribe public void onMenuEntryAdded(MenuEntryAdded event) { - if ((event.getOption().equals("Floating") && config.shouldRightClickMap()) || (event.getOption().equals("Hide") - && config.shouldRightClickXp()) || (event.getOption().equals("Show") && config.shouldRightClickXp()) || - (event.getOption().equals("Auto retaliate") && config.shouldRightClickRetaliate())) + if ((event.getOption().equals("Floating") && this.shouldRightClickMap) || (event.getOption().equals("Hide") + && this.shouldRightClickXp) || (event.getOption().equals("Show") && this.shouldRightClickXp) || + (event.getOption().equals("Auto retaliate") && this.shouldRightClickRetaliate)) { forceRightClickFlag = true; } MenuEntry[] entries = client.getMenuEntries(); - if (config.shouldBlockCompass()) + if (this.shouldBlockCompass) { for (int i = entries.length - 1; i >= 0; i--) { @@ -153,4 +163,13 @@ public class LearnToClickPlugin extends Plugin { ORB_WIDGETS.forEach(widgetInfo -> client.getWidget(widgetInfo).setHidden(hidden)); } + + private void updateConfig() + { + this.shouldBlockCompass = config.shouldBlockCompass(); + this.shouldRightClickMap = config.shouldRightClickMap(); + this.shouldRightClickXp = config.shouldRightClickXp(); + this.shouldRightClickRetaliate = config.shouldRightClickRetaliate(); + this.hideOrbs = config.hideOrbs(); + } } 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 e9eb807ca8..e850169cbf 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 @@ -28,14 +28,15 @@ import com.google.inject.Provides; import java.util.HashMap; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Actor; -import net.runelite.api.Client; import net.runelite.api.coords.LocalPoint; import net.runelite.api.events.AnimationChanged; import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ConfigChanged; import net.runelite.client.Notifier; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; @@ -51,8 +52,8 @@ import net.runelite.client.ui.overlay.OverlayManager; type = PluginType.PVM, enabledByDefault = false ) - @Slf4j +@Singleton public class LizardmenShamanPlugin extends Plugin { private static final String SHAMAN = "Lizardman shaman"; @@ -73,8 +74,8 @@ public class LizardmenShamanPlugin extends Plugin @Inject private Notifier notifier; - @Inject - private Client client; + private boolean showTimer; + private boolean notifyOnSpawn; @Provides LizardmenShamanConfig getConfig(ConfigManager configManager) @@ -85,6 +86,9 @@ public class LizardmenShamanPlugin extends Plugin @Override protected void startUp() throws Exception { + this.showTimer = config.showTimer(); + this.notifyOnSpawn = config.notifyOnSpawn(); + overlayManager.add(overlay); } @@ -98,7 +102,7 @@ public class LizardmenShamanPlugin extends Plugin @Subscribe public void onChatMessage(ChatMessage event) { - if (config.notifyOnSpawn()) + if (this.notifyOnSpawn) { if (event.getMessage().contains(MESSAGE)) { @@ -118,10 +122,22 @@ public class LizardmenShamanPlugin extends Plugin if (actor.getName().equals(SHAMAN) && actor.getAnimation() == 7157) { - if (config.showTimer()) + if (this.showTimer) { spawns.put(event.getActor().getLocalLocation(), new LizardmenShamanSpawn(8.4, null)); } } } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("shaman")) + { + return; + } + + this.showTimer = config.showTimer(); + this.notifyOnSpawn = config.notifyOnSpawn(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/lizardmenshaman/LizardmenShamanSpawn.java b/runelite-client/src/main/java/net/runelite/client/plugins/lizardmenshaman/LizardmenShamanSpawn.java index ac52b75fce..627af82c31 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/lizardmenshaman/LizardmenShamanSpawn.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/lizardmenshaman/LizardmenShamanSpawn.java @@ -25,13 +25,14 @@ package net.runelite.client.plugins.lizardmenshaman; import java.time.Instant; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.Setter; -@Getter -@Setter +@Getter(AccessLevel.PACKAGE) +@Setter(AccessLevel.PACKAGE) @RequiredArgsConstructor @AllArgsConstructor class LizardmenShamanSpawn diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/lizardmenshaman/ShamanSpawnOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/lizardmenshaman/ShamanSpawnOverlay.java index 58f5c6a73a..9d60355d6d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/lizardmenshaman/ShamanSpawnOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/lizardmenshaman/ShamanSpawnOverlay.java @@ -30,6 +30,7 @@ import java.awt.Graphics2D; import java.time.Duration; import java.time.Instant; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.Point; @@ -38,13 +39,14 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.components.ProgressPieComponent; +@Singleton class ShamanSpawnOverlay extends Overlay { private final Client client; private final LizardmenShamanPlugin plugin; @Inject - private ShamanSpawnOverlay(Client client, LizardmenShamanPlugin plugin) + private ShamanSpawnOverlay(final Client client, final LizardmenShamanPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loginscreen/LoginScreenPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/loginscreen/LoginScreenPlugin.java index b99efb6e62..dbf0a6df64 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loginscreen/LoginScreenPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loginscreen/LoginScreenPlugin.java @@ -32,9 +32,11 @@ import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.event.KeyEvent; import java.io.IOException; 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.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.client.events.SessionOpen; import net.runelite.client.config.ConfigManager; @@ -50,6 +52,7 @@ import net.runelite.client.util.OSType; description = "Provides various enhancements for login screen" ) @Slf4j +@Singleton public class LoginScreenPlugin extends Plugin implements KeyListener { private static final int MAX_USERNAME_LENGTH = 254; @@ -67,9 +70,14 @@ public class LoginScreenPlugin extends Plugin implements KeyListener private String usernameCache; + private boolean syncUsername; + private boolean pasteEnabled; + private String username; + @Override protected void startUp() throws Exception { + updateConfig(); applyUsername(); keyManager.registerKeyListener(this); } @@ -77,7 +85,7 @@ public class LoginScreenPlugin extends Plugin implements KeyListener @Override protected void shutDown() throws Exception { - if (config.syncUsername()) + if (this.syncUsername) { client.getPreferences().setRememberedUsername(usernameCache); } @@ -94,7 +102,7 @@ public class LoginScreenPlugin extends Plugin implements KeyListener @Subscribe public void onGameStateChanged(GameStateChanged event) { - if (!config.syncUsername()) + if (!this.syncUsername) { return; } @@ -112,13 +120,14 @@ public class LoginScreenPlugin extends Plugin implements KeyListener username = client.getUsername(); } - if (config.username().equals(username)) + if (this.username.equals(username)) { return; } log.debug("Saving username: {}", username); config.username(username); + this.username = username; } } @@ -131,7 +140,7 @@ public class LoginScreenPlugin extends Plugin implements KeyListener private void applyUsername() { - if (!config.syncUsername()) + if (!this.syncUsername) { return; } @@ -139,7 +148,7 @@ public class LoginScreenPlugin extends Plugin implements KeyListener GameState gameState = client.getGameState(); if (gameState == GameState.LOGIN_SCREEN) { - String username = config.username(); + String username = this.username; if (Strings.isNullOrEmpty(username)) { @@ -164,7 +173,7 @@ public class LoginScreenPlugin extends Plugin implements KeyListener @Override public void keyPressed(KeyEvent e) { - if (!config.pasteEnabled() || ( + if (!this.pasteEnabled || ( client.getGameState() != GameState.LOGIN_SCREEN && client.getGameState() != GameState.LOGIN_SCREEN_AUTHENTICATOR)) { @@ -220,4 +229,22 @@ public class LoginScreenPlugin extends Plugin implements KeyListener { } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("loginscreen")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.syncUsername = config.syncUsername(); + this.pasteEnabled = config.pasteEnabled(); + this.username = config.username(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/lootassist/LootAssistOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/lootassist/LootAssistOverlay.java index 132c98e33c..8041ef36b0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/lootassist/LootAssistOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/lootassist/LootAssistOverlay.java @@ -7,6 +7,7 @@ import java.awt.Polygon; import java.text.DecimalFormat; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.Point; @@ -18,13 +19,14 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton public class LootAssistOverlay extends Overlay { private Client client; private DecimalFormat d = new DecimalFormat("##.#"); @Inject - public LootAssistOverlay(Client client) + public LootAssistOverlay(final Client client) { this.client = client; setLayer(OverlayLayer.ABOVE_SCENE); @@ -41,15 +43,17 @@ public class LootAssistOverlay extends Overlay LootPile pile = entry.getValue(); int x; int y; - try + LocalPoint lp = LocalPoint.fromWorld(client, pile.getLocation()); + if (lp != null) { - x = LocalPoint.fromWorld(client, pile.getLocation()).getSceneX(); - y = LocalPoint.fromWorld(client, pile.getLocation()).getSceneY(); + x = lp.getSceneX(); + y = lp.getSceneY(); } - catch (NullPointerException e) + else { continue; } + if (!localPoint.isInScene(client)) { continue; @@ -70,11 +74,9 @@ public class LootAssistOverlay extends Overlay client.getScene().getTiles()[client.getPlane()][x][y].getLocalLocation()); if (poly != null) { - Point textLoc = Perspective.getCanvasTextLocation(client, graphics, - LocalPoint.fromWorld(client, pile.getLocation()), + Point textLoc = Perspective.getCanvasTextLocation(client, graphics, lp, nameOverlay, graphics.getFontMetrics().getHeight() * 7); - Point timeLoc = Perspective.getCanvasTextLocation(client, graphics, - LocalPoint.fromWorld(client, pile.getLocation()), + Point timeLoc = Perspective.getCanvasTextLocation(client, graphics, lp, timeOverlay, graphics.getFontMetrics().getHeight()); OverlayUtil.renderPolygon(graphics, poly, Color.WHITE); if (timeRemaining < 5) @@ -84,8 +86,7 @@ public class LootAssistOverlay extends Overlay } if (timeRemaining < 2) { - client.setHintArrow(WorldPoint.fromLocal(client, - LocalPoint.fromWorld(client, pile.getLocation()))); + client.setHintArrow(WorldPoint.fromLocal(client, lp)); } else { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/lootassist/LootAssistPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/lootassist/LootAssistPlugin.java index 7087ec423f..35e02cff98 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/lootassist/LootAssistPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/lootassist/LootAssistPlugin.java @@ -1,15 +1,14 @@ package net.runelite.client.plugins.lootassist; -import com.google.inject.Provides; import java.util.concurrent.ConcurrentHashMap; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Actor; import net.runelite.api.AnimationID; import net.runelite.api.Player; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.AnimationChanged; 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; @@ -23,7 +22,7 @@ import net.runelite.client.ui.overlay.OverlayManager; type = PluginType.PVP, enabledByDefault = false ) - +@Singleton public class LootAssistPlugin extends Plugin { @Inject @@ -34,12 +33,6 @@ public class LootAssistPlugin extends Plugin static ConcurrentHashMap lootPiles = new ConcurrentHashMap<>(); - @Provides - LootAssitConfig getConfig(ConfigManager configManager) - { - return configManager.getConfig(LootAssitConfig.class); - } - @Override protected void startUp() throws Exception { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/lootassist/LootAssitConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/lootassist/LootAssitConfig.java deleted file mode 100644 index 8c4d5b1a10..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/lootassist/LootAssitConfig.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.runelite.client.plugins.lootassist; - -import java.awt.Color; -import net.runelite.client.config.Config; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; - -@ConfigGroup("lootassist") -public interface LootAssitConfig extends Config -{ - @ConfigItem( - keyName = "color", - name = "Color", - description = "The Color of the tile and name overlay that indicates where loot will appear" - ) - default Color color() - { - return Color.WHITE; - } -} diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/lootassist/LootPile.java b/runelite-client/src/main/java/net/runelite/client/plugins/lootassist/LootPile.java index 32fa145088..f59e842730 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/lootassist/LootPile.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/lootassist/LootPile.java @@ -1,5 +1,6 @@ package net.runelite.client.plugins.lootassist; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import net.runelite.api.coords.WorldPoint; @@ -8,17 +9,17 @@ class LootPile { private static final long TIME_UNTIL_VISIBLE = 60000; - @Getter + @Getter(AccessLevel.PACKAGE) private final long timeAppearing; - @Getter + @Getter(AccessLevel.PACKAGE) private final WorldPoint location; - @Getter + @Getter(AccessLevel.PACKAGE) private final String playerName; - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private boolean beingRendered = false; LootPile(WorldPoint location, String playerName) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerOverlay.java index ecfe3dc5da..c8353c0181 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerOverlay.java @@ -30,6 +30,7 @@ import java.awt.Graphics2D; import java.awt.Point; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.InventoryID; import net.runelite.api.Item; @@ -41,6 +42,7 @@ import net.runelite.client.ui.overlay.components.ComponentOrientation; import net.runelite.client.ui.overlay.components.ImageComponent; import net.runelite.client.ui.overlay.components.PanelComponent; +@Singleton public class LootingBagViewerOverlay extends Overlay { private static final int INVENTORY_SIZE = 28; @@ -57,7 +59,7 @@ public class LootingBagViewerOverlay extends Overlay private Item[] items; @Inject - private LootingBagViewerOverlay(Client client, ItemManager itemManager) + private LootingBagViewerOverlay(final Client client, final ItemManager itemManager) { setPosition(OverlayPosition.BOTTOM_RIGHT); panelComponent.setWrapping(4); 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 69563ab2c4..a0e3591dbf 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 @@ -29,6 +29,8 @@ package net.runelite.client.plugins.lootingbagviewer; import com.google.common.base.Strings; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -57,6 +59,7 @@ import net.runelite.client.ui.overlay.OverlayManager; * TODO: Write something to capture adding items to a looting bag and add its price to the current looting bag value */ @Slf4j +@Singleton // WHY IS THIS PLUGIN EVEN MERGED IT'S AGES FROM BEING DONE!?!?!?!? public class LootingBagViewerPlugin extends Plugin { @Inject @@ -77,8 +80,8 @@ public class LootingBagViewerPlugin extends Plugin @Inject private LootingBagViewerConfig config; - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private int valueToShow = -1; @Provides diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerWidgetOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerWidgetOverlay.java index 00c716f2fb..d3356155c4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerWidgetOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/lootingbagviewer/LootingBagViewerWidgetOverlay.java @@ -27,22 +27,21 @@ package net.runelite.client.plugins.lootingbagviewer; import java.awt.Color; import java.awt.Graphics2D; import javax.inject.Inject; -import net.runelite.api.Client; +import javax.inject.Singleton; import net.runelite.api.ItemID; import net.runelite.api.Point; import net.runelite.api.widgets.WidgetItem; import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.ui.overlay.WidgetItemOverlay; +@Singleton public class LootingBagViewerWidgetOverlay extends WidgetItemOverlay { - private Client client; private LootingBagViewerPlugin plugin; @Inject - LootingBagViewerWidgetOverlay(Client client, LootingBagViewerPlugin plugin) + LootingBagViewerWidgetOverlay(final LootingBagViewerPlugin plugin) { - this.client = client; this.plugin = plugin; showOnInventory(); } @@ -72,9 +71,6 @@ public class LootingBagViewerWidgetOverlay extends WidgetItemOverlay { switch ((int) (Math.log10(lootingBagValue) + 1)) { - case 1: - case 2: - return 8; case 3: case 4: return 6; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java index bd00e16cf3..4098bed359 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerBox.java @@ -63,7 +63,7 @@ class LootTrackerBox extends JPanel @Getter(AccessLevel.PACKAGE) private final String id; - @Getter + @Getter(AccessLevel.PACKAGE) private final List records = new ArrayList<>(); private long totalPrice; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerItem.java index feb1504681..b676924c8e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerItem.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerItem.java @@ -24,6 +24,7 @@ */ package net.runelite.client.plugins.loottracker; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; @@ -31,15 +32,15 @@ import lombok.Setter; @AllArgsConstructor class LootTrackerItem { - @Getter + @Getter(AccessLevel.PACKAGE) private final int id; - @Getter + @Getter(AccessLevel.PACKAGE) private final String name; - @Getter + @Getter(AccessLevel.PACKAGE) private final int quantity; - @Getter + @Getter(AccessLevel.PACKAGE) private final long price; - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private boolean ignored; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java index 4e5afb9637..91f9218ad9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPanel.java @@ -36,6 +36,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Objects; +import javax.inject.Singleton; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.ImageIcon; @@ -59,6 +60,7 @@ import net.runelite.client.util.StackFormatter; import net.runelite.http.api.loottracker.LootTrackerClient; @Slf4j +@Singleton class LootTrackerPanel extends PluginPanel { private static final int MAX_LOOT_BOXES = 500; @@ -137,8 +139,6 @@ class LootTrackerPanel extends PluginPanel INVISIBLE_ICON_HOVER = new ImageIcon(ImageUtil.alphaOffset(invisibleImg, -220)); } - private final JPanel displaySelector; - @Getter @Setter private LootRecordSortType lootRecordSortType = LootRecordSortType.TIMESTAMP; @@ -300,7 +300,7 @@ class LootTrackerPanel extends PluginPanel overallPanel.add(overallIcon, BorderLayout.WEST); overallPanel.add(overallInfo, BorderLayout.CENTER); - displaySelector = new JPanel(); + JPanel displaySelector = new JPanel(); displaySelector.setLayout(new GridLayout(1, 1)); displaySelector.setBorder(new EmptyBorder(2, 10, 10, 10)); displaySelector.setBackground(ColorScheme.DARKER_GRAY_COLOR); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java index bea6d2d477..2f863394fe 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java @@ -57,6 +57,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.SwingUtilities; import lombok.AccessLevel; import lombok.Getter; @@ -117,6 +118,7 @@ import net.runelite.http.api.loottracker.LootTrackerClient; enabledByDefault = false ) @Slf4j +@Singleton public class LootTrackerPlugin extends Plugin { // Activity/Event loot handling @@ -212,6 +214,18 @@ public class LootTrackerPlugin extends Plugin .collect(Collectors.toList()); } + private String getIgnoredItems; + private boolean saveLoot; + private boolean chestLootChat; + private boolean syncPanel; + private boolean localPersistence; + private LootRecordSortType sortType; + private boolean whitelistEnabled; + private String getWhitelist; + private boolean blacklistEnabled; + private String getBlacklist; + private boolean sendLootValueMessages; + @Provides LootTrackerConfig provideConfig(ConfigManager configManager) { @@ -253,14 +267,16 @@ public class LootTrackerPlugin extends Plugin { if (event.getGroup().equals("loottracker")) { + updateConfig(); + if (event.getKey().equals("ignoredItems")) { - ignoredItems = Text.fromCSV(config.getIgnoredItems()); + ignoredItems = Text.fromCSV(this.getIgnoredItems); SwingUtilities.invokeLater(panel::updateIgnoredRecords); } if (event.getKey().equals("sortType")) { - panel.setLootRecordSortType(config.sortType()); + panel.setLootRecordSortType(this.sortType); SwingUtilities.invokeLater(panel::rebuild); } } @@ -270,7 +286,9 @@ public class LootTrackerPlugin extends Plugin @Override protected void startUp() throws Exception { - ignoredItems = Text.fromCSV(config.getIgnoredItems()); + updateConfig(); + + ignoredItems = Text.fromCSV(this.getIgnoredItems); panel = new LootTrackerPanel(this, itemManager, config); spriteManager.getSpriteAsync(SpriteID.TAB_INVENTORY, 0, panel::loadHeaderIcon); @@ -288,7 +306,7 @@ public class LootTrackerPlugin extends Plugin AccountSession accountSession = sessionManager.getAccountSession(); LOOT_RECORDS_FILE.createNewFile(); bufferedReader = Files.newBufferedReader(LOOT_RECORDS_FILE.toPath()); - if (accountSession != null || config.localPersistence()) + if (accountSession != null || this.localPersistence) { clientThread.invokeLater(() -> @@ -303,7 +321,7 @@ public class LootTrackerPlugin extends Plugin executor.submit(() -> { - if (config.syncPanel() && lootTrackerClient != null) + if (this.syncPanel && lootTrackerClient != null) { lootTrackerClient = new LootTrackerClient(accountSession.getUuid()); try @@ -318,7 +336,7 @@ public class LootTrackerPlugin extends Plugin log.debug("Loaded {} remote data entries", lootRecords.size()); } - if (config.localPersistence()) + if (this.localPersistence) { try { @@ -367,18 +385,18 @@ public class LootTrackerPlugin extends Plugin final LootTrackerItem[] entries = buildEntries(stack(items)); String localUsername = client.getLocalPlayer().getName(); - if (config.whitelistEnabled()) + if (this.whitelistEnabled) { - final String configNpcs = config.getWhitelist().toLowerCase(); + final String configNpcs = this.getWhitelist.toLowerCase(); List whitelist = Text.fromCSV(configNpcs); if (!whitelist.contains(name.toLowerCase())) { return; } } - else if (config.blacklistEnabled()) + else if (this.blacklistEnabled) { - final String configNpcs = config.getBlacklist().toLowerCase(); + final String configNpcs = this.getBlacklist.toLowerCase(); List blacklist = Text.fromCSV(configNpcs); if (blacklist.contains(name.toLowerCase())) { @@ -390,11 +408,11 @@ public class LootTrackerPlugin extends Plugin LootRecord lootRecord = new LootRecord(name, localUsername, LootRecordType.NPC, toGameItems(items), Instant.now()); - if (lootTrackerClient != null && config.saveLoot()) + if (lootTrackerClient != null && this.saveLoot) { lootTrackerClient.submit(lootRecord); } - if (config.localPersistence()) + if (this.localPersistence) { saveLocalLootRecord(lootRecord); } @@ -412,7 +430,7 @@ public class LootTrackerPlugin extends Plugin @Subscribe public void onPlayerLootReceived(final PlayerLootReceived playerLootReceived) { - if (config.sendLootValueMessages()) + if (this.sendLootValueMessages) { if (WorldType.isDeadmanWorld(client.getWorldType()) || WorldType.isHighRiskWorld(client.getWorldType()) || WorldType.isPvpWorld(client.getWorldType()) || client.getVar(Varbits.IN_WILDERNESS) == 1) { @@ -433,11 +451,11 @@ public class LootTrackerPlugin extends Plugin SwingUtilities.invokeLater(() -> panel.add(name, localUsername, combat, entries)); LootRecord lootRecord = new LootRecord(name, localUsername, LootRecordType.PLAYER, toGameItems(items), Instant.now()); - if (lootTrackerClient != null && config.saveLoot()) + if (lootTrackerClient != null && this.saveLoot) { lootTrackerClient.submit(lootRecord); } - if (config.localPersistence() && lootTrackerClient == null) + if (this.localPersistence && lootTrackerClient == null) { saveLocalLootRecord(lootRecord); } @@ -480,7 +498,7 @@ public class LootTrackerPlugin extends Plugin return; } - if (!(event.getGroupId() == WidgetID.CLUE_SCROLL_REWARD_GROUP_ID) && config.chestLootChat()) + if (!(event.getGroupId() == WidgetID.CLUE_SCROLL_REWARD_GROUP_ID) && this.chestLootChat) { Item[] items = container.getItems(); long chestPrice = 0; @@ -523,7 +541,7 @@ public class LootTrackerPlugin extends Plugin final LootTrackerItem[] entries = buildEntries(stack(items)); SwingUtilities.invokeLater(() -> panel.add(eventType, client.getLocalPlayer().getName(), -1, entries)); - if (lootTrackerClient != null && config.saveLoot()) + if (lootTrackerClient != null && this.saveLoot) { LootRecord lootRecord = new LootRecord(eventType, client.getLocalPlayer().getName(), LootRecordType.EVENT, toGameItems(items), Instant.now()); @@ -627,11 +645,11 @@ public class LootTrackerPlugin extends Plugin client.getLocalPlayer().getCombatLevel(), entries)); LootRecord lootRecord = new LootRecord(name, client.getLocalPlayer().getName(), LootRecordType.DEATH, toGameItems(itemsLost), Instant.now()); - if (lootTrackerClient != null && config.saveLoot()) + if (lootTrackerClient != null && this.saveLoot) { lootTrackerClient.submit(lootRecord); } - if (config.localPersistence() && lootTrackerClient == null) + if (this.localPersistence && lootTrackerClient == null) { saveLocalLootRecord(lootRecord); } @@ -734,7 +752,7 @@ public class LootTrackerPlugin extends Plugin final LootTrackerItem[] entries = buildEntries(stack(items)); SwingUtilities.invokeLater(() -> panel.add(chestType, client.getLocalPlayer().getName(), -1, entries)); - if (lootTrackerClient != null && config.saveLoot()) + if (lootTrackerClient != null && this.saveLoot) { LootRecord lootRecord = new LootRecord(chestType, client.getLocalPlayer().getName(), LootRecordType.EVENT, toGameItems(items), Instant.now()); @@ -759,6 +777,7 @@ public class LootTrackerPlugin extends Plugin } config.setIgnoredItems(Text.toCSV(ignoredItemSet)); + this.getIgnoredItems = Text.toCSV(ignoredItemSet); panel.updateIgnoredRecords(); } @@ -814,4 +833,19 @@ public class LootTrackerPlugin extends Plugin return trackerRecords; } + + private void updateConfig() + { + this.getIgnoredItems = config.getIgnoredItems(); + this.saveLoot = config.saveLoot(); + this.chestLootChat = config.chestLootChat(); + this.syncPanel = config.syncPanel(); + this.localPersistence = config.localPersistence(); + this.sortType = config.sortType(); + this.whitelistEnabled = config.whitelistEnabled(); + this.getWhitelist = config.getWhitelist(); + this.blacklistEnabled = config.blacklistEnabled(); + this.getBlacklist = config.getBlacklist(); + this.sendLootValueMessages = config.sendLootValueMessages(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/lowmemory/LowMemoryPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/lowmemory/LowMemoryPlugin.java index 41caa93ebd..589ac4e202 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/lowmemory/LowMemoryPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/lowmemory/LowMemoryPlugin.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.lowmemory; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.events.GameStateChanged; @@ -38,6 +39,7 @@ import net.runelite.client.plugins.PluginDescriptor; tags = {"memory", "usage", "ground", "decorations"}, enabledByDefault = false ) +@Singleton public class LowMemoryPlugin extends Plugin { @Inject 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 index 2315d2e2ca..ac85314026 100644 --- 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 @@ -25,6 +25,7 @@ package net.runelite.client.plugins.maxhit; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.InventoryID; import net.runelite.api.Item; @@ -48,7 +49,7 @@ import net.runelite.client.plugins.maxhit.calculators.RangeMaxHitCalculator; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton public class MaxHitPlugin extends Plugin { 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 index 53833123cb..5e440d5064 100644 --- 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 @@ -43,7 +43,7 @@ public class EquipmentSlotItem return this.itemIds; } - public EquipmentInventorySlot getEquipmentSlot() + EquipmentInventorySlot getEquipmentSlot() { return this.equipmentSlot; } 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 4e8490a4c4..05ce35a254 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 @@ -40,6 +40,8 @@ import java.util.Map; import java.util.Objects; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import net.runelite.api.Client; @@ -78,11 +80,25 @@ import net.runelite.client.menus.WidgetMenuOption; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginType; +import net.runelite.client.plugins.menuentryswapper.util.BurningAmuletMode; +import net.runelite.client.plugins.menuentryswapper.util.CombatBraceletMode; +import net.runelite.client.plugins.menuentryswapper.util.DigsitePendantMode; +import net.runelite.client.plugins.menuentryswapper.util.DuelingRingMode; import net.runelite.client.plugins.menuentryswapper.util.FairyRingMode; +import net.runelite.client.plugins.menuentryswapper.util.GamesNecklaceMode; +import net.runelite.client.plugins.menuentryswapper.util.GloryMode; import net.runelite.client.plugins.menuentryswapper.util.HouseMode; +import net.runelite.client.plugins.menuentryswapper.util.MaxCapeMode; +import net.runelite.client.plugins.menuentryswapper.util.NecklaceOfPassageMode; import net.runelite.client.plugins.menuentryswapper.util.ObeliskMode; import net.runelite.client.plugins.menuentryswapper.util.OccultAltarMode; import net.runelite.client.plugins.menuentryswapper.util.CharterOption; +import net.runelite.client.plugins.menuentryswapper.util.QuestCapeMode; +import net.runelite.client.plugins.menuentryswapper.util.RingOfWealthMode; +import net.runelite.client.plugins.menuentryswapper.util.SkillsNecklaceMode; +import net.runelite.client.plugins.menuentryswapper.util.SlayerRingMode; +import net.runelite.client.plugins.menuentryswapper.util.XericsTalismanMode; +import net.runelite.client.plugins.menuentryswapper.util.teleEquippedMode; import static net.runelite.client.util.MenuUtil.swap; import net.runelite.client.util.MiscUtils; import net.runelite.client.util.Text; @@ -95,7 +111,7 @@ import org.apache.commons.lang3.ArrayUtils; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton public class MenuEntrySwapperPlugin extends Plugin { private static final String CONFIGURE = "Configure"; @@ -109,7 +125,7 @@ public class MenuEntrySwapperPlugin extends Plugin private static final String WALK_HERE = "WALK HERE"; private static final String CANCEL = "CANCEL"; private static final String CAST_OPTIONS_ATTACK = "CAST"; - public static final HashSet CAST_OPTIONS_KEYWORDS = new HashSet<>(); + private static final HashSet CAST_OPTIONS_KEYWORDS = new HashSet<>(); static { CAST_OPTIONS_KEYWORDS.add(CAST_OPTIONS_ATTACK); @@ -176,11 +192,139 @@ public class MenuEntrySwapperPlugin extends Plugin @Inject private ItemManager itemManager; - @Getter + @Getter(AccessLevel.PACKAGE) private boolean configuringShiftClick = false; - @Setter + @Setter(AccessLevel.PACKAGE) private boolean shiftModifier = false; + + private boolean getWithdrawOne; + private String getWithdrawOneItems; + private boolean getWithdrawFive; + private String getWithdrawFiveItems; + private boolean getWithdrawTen; + private String getWithdrawTenItems; + private boolean getWithdrawX; + private String getWithdrawXAmount; + private String getWithdrawXItems; + private boolean getWithdrawAll; + private String getWithdrawAllItems; + private boolean swapMax; + private boolean teleEquippedCape; + private teleEquippedMode telecapeMode; + private MaxCapeMode maxMode; + private boolean getSwapArdougneCape; + private boolean getSwapConstructionCape; + private boolean getSwapCraftingCape; + private boolean getSwapMagicCape; + private boolean getSwapExplorersRing; + private boolean swapAdmire; + private boolean swapQuestCape; + private QuestCapeMode questCapeMode; + private String configCustomSwaps; + private boolean shiftClickCustomization; + private boolean swapCoalBag; + private boolean swapBirdhouseEmpty; + private boolean swapBones; + private boolean swapChase; + private boolean swapHarpoon; + private boolean swapOccult; + private OccultAltarMode swapOccultMode; + private boolean swapHomePortal; + private HouseMode swapHomePortalMode; + private boolean swapPrivate; + private boolean swapPick; + private boolean swapQuick; + private boolean swapBoxTrap; + private boolean rockCake; + private boolean swapRogueschests; + private boolean swapClimbUpDown; + private boolean swapStun; + private boolean swapSearch; + private boolean swapHardWoodGrove; + private boolean getRemoveObjects; + private String getRemovedObjects; + private boolean swapImps; + private CharterOption charterOption; + private boolean getSwapBuyOne; + private String getBuyOneItems; + private boolean getSwapBuyFive; + private String getBuyFiveItems; + private boolean getSwapBuyTen; + private String getBuyTenItems; + private boolean getSwapBuyFifty; + private String getBuyFiftyItems; + private boolean getSwapSellOne; + private String getSellOneItems; + private boolean getSwapSellFive; + private String getSellFiveItems; + private boolean getSwapSellTen; + private String getSellTenItems; + private boolean getSwapSellFifty; + private String getSellFiftyItems; + private boolean getEasyConstruction; + private String getEasyConstructionItems; + private boolean getSwapSmithing; + private boolean getSwapTanning; + private boolean getSwapSawmill; + private boolean getSwapSawmillPlanks; + private boolean getSwapPuro; + private boolean swapAssignment; + private boolean swapBankExchange; + private boolean swapContract; + private boolean swapInteract; + private boolean swapPickpocket; + private boolean swapPay; + private boolean swapAbyssTeleport; + private boolean swapTrade; + private boolean swapTravel; + private boolean swapMinigame; + private boolean swapPlank; + private boolean swapMetamorphosis; + private boolean swapEnchant; + private boolean swapFairyRing; + private FairyRingMode swapFairyRingMode; + private boolean swapObelisk; + private ObeliskMode swapObeliskMode; + private boolean swapTeleportItem; + private boolean swapWildernessLever; + private boolean swapNexus; + private boolean getGamesNecklace; + private GamesNecklaceMode getGamesNecklaceMode; + private boolean getDuelingRing; + private DuelingRingMode getDuelingRingMode; + private boolean getGlory; + private GloryMode getGloryMode; + private boolean getSkillsNecklace; + private SkillsNecklaceMode getSkillsNecklaceMode; + private boolean getNecklaceofPassage; + private NecklaceOfPassageMode getNecklaceofPassageMode; + private boolean getDigsitePendant; + private DigsitePendantMode getDigsitePendantMode; + private boolean getCombatBracelet; + private CombatBraceletMode getCombatBraceletMode; + private boolean getBurningAmulet; + private BurningAmuletMode getBurningAmuletMode; + private boolean getXericsTalisman; + private XericsTalismanMode getXericsTalismanMode; + private boolean getRingofWealth; + private RingOfWealthMode getRingofWealthMode; + private boolean getSlayerRing; + private SlayerRingMode getSlayerRingMode; + private boolean hideExamine; + private boolean hideTradeWith; + private boolean hideReport; + private boolean hideLookup; + private boolean hideNet; + private boolean hideBait; + private boolean hideDestroyRunepouch; + private boolean hideDestroyCoalbag; + private boolean hideDestroyHerbsack; + private boolean hideDestroyBoltpouch; + private boolean hideDestroyGembag; + private boolean hideDropRunecraftingPouch; + private boolean getRemoveFreezePlayerToB; + private boolean getRemoveFreezePlayerCoX; @Provides MenuEntrySwapperConfig provideConfig(ConfigManager configManager) @@ -191,6 +335,7 @@ public class MenuEntrySwapperPlugin extends Plugin @Override public void startUp() { + updateConfig(); addSwaps(); loadConstructionItems(config.getEasyConstructionItems()); @@ -218,8 +363,10 @@ public class MenuEntrySwapperPlugin extends Plugin { return; } + + updateConfig(); - loadConstructionItems(config.getEasyConstructionItems()); + loadConstructionItems(this.getEasyConstructionItems); removeSwaps(); addSwaps(); @@ -227,7 +374,7 @@ public class MenuEntrySwapperPlugin extends Plugin { if (event.getKey().equals("customSwaps")) { - loadCustomSwaps(config.customSwaps()); + loadCustomSwaps(this.configCustomSwaps); } return; @@ -235,7 +382,7 @@ public class MenuEntrySwapperPlugin extends Plugin if (event.getKey().equals("shiftClickCustomization")) { - if (config.shiftClickCustomization()) + if (this.shiftClickCustomization) { enableCustomization(); } @@ -315,7 +462,7 @@ public class MenuEntrySwapperPlugin extends Plugin return; } - loadConstructionItems(config.getEasyConstructionItems()); + loadConstructionItems(this.getEasyConstructionItems); } @Subscribe @@ -345,55 +492,55 @@ public class MenuEntrySwapperPlugin extends Plugin { String option = Text.removeTags(entry.getOption()).toLowerCase(); - if (option.contains("trade with") && config.hideTradeWith()) + if (option.contains("trade with") && this.hideTradeWith) { continue; } - if (option.contains("lookup") && config.hideLookup()) + if (option.contains("lookup") && this.hideLookup) { continue; } - if (option.contains("report") && config.hideReport()) + if (option.contains("report") && this.hideReport) { continue; } - if (option.contains("examine") && config.hideExamine()) + if (option.contains("examine") && this.hideExamine) { continue; } - if (option.contains("net") && config.hideNet()) + if (option.contains("net") && this.hideNet) { continue; } - if (option.contains("bait") && config.hideBait()) + if (option.contains("bait") && this.hideBait) { continue; } if (option.contains("destroy")) { - if (config.hideDestroyRunepouch() && entry.getTarget().contains("Rune pouch")) + if (this.hideDestroyRunepouch && entry.getTarget().contains("Rune pouch")) { continue; } - if (config.hideDestroyCoalbag() && entry.getTarget().contains("Coal bag")) + if (this.hideDestroyCoalbag && entry.getTarget().contains("Coal bag")) { continue; } - if (config.hideDestroyHerbsack() && entry.getTarget().contains("Herb sack")) + if (this.hideDestroyHerbsack && entry.getTarget().contains("Herb sack")) { continue; } - if (config.hideDestroyBoltpouch() && entry.getTarget().contains("Bolt pouch")) + if (this.hideDestroyBoltpouch && entry.getTarget().contains("Bolt pouch")) { continue; } - if (config.hideDestroyGembag() && entry.getTarget().contains("Gem bag")) + if (this.hideDestroyGembag && entry.getTarget().contains("Gem bag")) { continue; } @@ -401,8 +548,8 @@ public class MenuEntrySwapperPlugin extends Plugin if (option.contains("drop")) { - if (config.hideDropRunecraftingPouch() && ( - entry.getTarget().contains("Small pouch") + if (this.hideDropRunecraftingPouch && ( + entry.getTarget().contains("Small pouch") || entry.getTarget().contains("Medium pouch") || entry.getTarget().contains("Large pouch") || entry.getTarget().contains("Giant pouch"))) @@ -551,9 +698,9 @@ public class MenuEntrySwapperPlugin extends Plugin if (option.contains("withdraw") || option.contains("deposit")) { - if (config.getWithdrawOne()) + if (this.getWithdrawOne) { - for (String item : Text.fromCSV(config.getWithdrawOneItems())) + for (String item : Text.fromCSV(this.getWithdrawOneItems)) { if (target.equals(Text.standardize(item))) { @@ -563,9 +710,9 @@ public class MenuEntrySwapperPlugin extends Plugin } } - if (config.getWithdrawFive()) + if (this.getWithdrawFive) { - for (String item : Text.fromCSV(config.getWithdrawFiveItems())) + for (String item : Text.fromCSV(this.getWithdrawFiveItems)) { if (target.equals(Text.standardize(item))) { @@ -575,9 +722,9 @@ public class MenuEntrySwapperPlugin extends Plugin } } - if (config.getWithdrawTen()) + if (this.getWithdrawTen) { - for (String item : Text.fromCSV(config.getWithdrawTenItems())) + for (String item : Text.fromCSV(this.getWithdrawTenItems)) { if (target.equals(Text.standardize(item))) { @@ -587,21 +734,21 @@ public class MenuEntrySwapperPlugin extends Plugin } } - if (config.getWithdrawX()) + if (this.getWithdrawX) { - for (String item : Text.fromCSV(config.getWithdrawXItems())) + for (String item : Text.fromCSV(this.getWithdrawXItems)) { if (target.equals(Text.standardize(item))) { - swap(client, "Withdraw-" + config.getWithdrawXAmount(), option, target); - swap(client, "Deposit-" + config.getWithdrawXAmount(), option, target); + swap(client, "Withdraw-" + this.getWithdrawXAmount, option, target); + swap(client, "Deposit-" + this.getWithdrawXAmount, option, target); } } } - if (config.getWithdrawAll()) + if (this.getWithdrawAll) { - for (String item : Text.fromCSV(config.getWithdrawAllItems())) + for (String item : Text.fromCSV(this.getWithdrawAllItems)) { if (target.equals(Text.standardize(item))) { @@ -613,13 +760,11 @@ public class MenuEntrySwapperPlugin extends Plugin } if ((option.contains("buy") || option.contains("value")) && Arrays.stream(entries).anyMatch(menuEntry -> + menuEntry.getOption().toLowerCase().contains("buy"))) { - return menuEntry.getOption().toLowerCase().contains("buy"); - })) - { - if (config.getSwapBuyOne() && !config.getBuyOneItems().equals("")) + if (this.getSwapBuyOne && !this.getBuyOneItems.equals("")) { - for (String item : Text.fromCSV(config.getBuyOneItems())) + for (String item : Text.fromCSV(this.getBuyOneItems)) { if (target.equals(Text.standardize(item))) { @@ -628,9 +773,9 @@ public class MenuEntrySwapperPlugin extends Plugin } } - if (config.getSwapBuyFive() && !config.getBuyFiveItems().equals("")) + if (this.getSwapBuyFive && !this.getBuyFiveItems.equals("")) { - for (String item : Text.fromCSV(config.getBuyFiveItems())) + for (String item : Text.fromCSV(this.getBuyFiveItems)) { if (target.equals(Text.standardize(item))) { @@ -639,9 +784,9 @@ public class MenuEntrySwapperPlugin extends Plugin } } - if (config.getSwapBuyTen() && !config.getBuyTenItems().equals("")) + if (this.getSwapBuyTen && !this.getBuyTenItems.equals("")) { - for (String item : Text.fromCSV(config.getBuyTenItems())) + for (String item : Text.fromCSV(this.getBuyTenItems)) { if (target.equals(Text.standardize(item))) { @@ -650,9 +795,9 @@ public class MenuEntrySwapperPlugin extends Plugin } } - if (config.getSwapBuyFifty() && !config.getBuyFiftyItems().equals("")) + if (this.getSwapBuyFifty && !this.getBuyFiftyItems.equals("")) { - for (String item : Text.fromCSV(config.getBuyFiftyItems())) + for (String item : Text.fromCSV(this.getBuyFiftyItems)) { if (target.equals(Text.standardize(item))) { @@ -662,13 +807,11 @@ public class MenuEntrySwapperPlugin extends Plugin } } else if ((option.contains("sell") || option.contains("value")) && Arrays.stream(entries).anyMatch(menuEntry -> + menuEntry.getOption().toLowerCase().contains("sell"))) { - return menuEntry.getOption().toLowerCase().contains("sell"); - })) - { - if (config.getSwapSellOne() && !config.getSellOneItems().equals("")) + if (this.getSwapSellOne && !this.getSellOneItems.equals("")) { - for (String item : Text.fromCSV(config.getSellOneItems())) + for (String item : Text.fromCSV(this.getSellOneItems)) { if (target.equals(Text.standardize(item))) { @@ -677,9 +820,9 @@ public class MenuEntrySwapperPlugin extends Plugin } } - if (config.getSwapSellFive() && !Strings.isNullOrEmpty(config.getSellFiveItems())) + if (this.getSwapSellFive && !Strings.isNullOrEmpty(this.getSellFiveItems)) { - for (String item : Text.fromCSV(config.getSellFiveItems())) + for (String item : Text.fromCSV(this.getSellFiveItems)) { if (target.equals(Text.standardize(item))) { @@ -688,9 +831,9 @@ public class MenuEntrySwapperPlugin extends Plugin } } - if (config.getSwapSellTen() && !Strings.isNullOrEmpty(config.getSellTenItems())) + if (this.getSwapSellTen && !Strings.isNullOrEmpty(this.getSellTenItems)) { - for (String item : Text.fromCSV(config.getSellTenItems())) + for (String item : Text.fromCSV(this.getSellTenItems)) { if (target.equals(Text.standardize(item))) { @@ -699,9 +842,9 @@ public class MenuEntrySwapperPlugin extends Plugin } } - if (config.getSwapSellFifty() && !Strings.isNullOrEmpty(config.getSellFiftyItems())) + if (this.getSwapSellFifty && !Strings.isNullOrEmpty(this.getSellFiftyItems)) { - for (String item : Text.fromCSV(config.getSellFiftyItems())) + for (String item : Text.fromCSV(this.getSellFiftyItems)) { if (target.equals(Text.standardize(item))) { @@ -711,9 +854,9 @@ public class MenuEntrySwapperPlugin extends Plugin } } - if (config.getRemoveObjects() && !config.getRemovedObjects().equals("")) + if (this.getRemoveObjects && !this.getRemovedObjects.equals("")) { - for (String removed : Text.fromCSV(config.getRemovedObjects())) + for (String removed : Text.fromCSV(this.getRemovedObjects)) { removed = Text.standardize(removed); if (target.contains("(") && target.split(" \\(")[0].equals(removed)) @@ -737,7 +880,7 @@ public class MenuEntrySwapperPlugin extends Plugin } } - if (config.getSwapPuro() && isPuroPuro()) + if (this.getSwapPuro && isPuroPuro()) { if (event.getType() == WALK.getId()) { @@ -756,7 +899,7 @@ public class MenuEntrySwapperPlugin extends Plugin } } - else if (config.getSwapSmithing() && option.contains("smith")) + else if (this.getSwapSmithing && option.contains("smith")) { if (option.equalsIgnoreCase("Smith 1")) { @@ -768,17 +911,17 @@ public class MenuEntrySwapperPlugin extends Plugin } } - else if (config.getSwapTanning() && option.equalsIgnoreCase("Tan 1")) + else if (this.getSwapTanning && option.equalsIgnoreCase("Tan 1")) { swap(client, "Tan All", option, target); } - else if (config.getSwapSawmill() && target.equalsIgnoreCase("Sawmill operator")) + else if (this.getSwapSawmill && target.equalsIgnoreCase("Sawmill operator")) { swap(client, "Buy-plank", option, target); } - else if (config.getSwapSawmillPlanks() && option.equalsIgnoreCase("Buy 1")) + else if (this.getSwapSawmillPlanks && option.equalsIgnoreCase("Buy 1")) { swap(client, "Buy All", option, target); } @@ -788,28 +931,28 @@ public class MenuEntrySwapperPlugin extends Plugin swap(client, "Clear", option, target); } - else if (target.contains("ardougne cloak") && config.getSwapArdougneCape()) + else if (target.contains("ardougne cloak") && this.getSwapArdougneCape) { swap(client, "Kandarin Monastery", option, target); swap(client, "Monastery Teleport", option, target); } - else if (target.contains("crafting cape") && config.getSwapCraftingCape()) + else if (target.contains("crafting cape") && this.getSwapCraftingCape) { swap(client, "Teleport", option, target); } - else if (target.contains("construct. cape") && config.getSwapConstructionCape()) + else if (target.contains("construct. cape") && this.getSwapConstructionCape) { swap(client, "Tele to poh", option, target); } - else if (target.contains("magic cape") && config.getSwapMagicCape()) + else if (target.contains("magic cape") && this.getSwapMagicCape) { swap(client, "Spellbook", option, target); } - else if (target.contains("explorer's ring") && config.getSwapExplorersRing()) + else if (target.contains("explorer's ring") && this.getSwapExplorersRing) { swap(client, "Teleport", option, target); } @@ -821,7 +964,7 @@ public class MenuEntrySwapperPlugin extends Plugin return; } - if (config.swapImps() && target.contains("impling")) + if (this.swapImps && target.contains("impling")) { if (client.getItemContainer(InventoryID.BANK) != null) @@ -851,59 +994,61 @@ public class MenuEntrySwapperPlugin extends Plugin } } } - if (target.equals("eclectic impling jar")) + switch (target) { - if (client.getItemContainer(InventoryID.INVENTORY) != null) - { - for (Item i : Objects.requireNonNull(client.getItemContainer(InventoryID.INVENTORY)).getItems()) + case "eclectic impling jar": + if (client.getItemContainer(InventoryID.INVENTORY) != null) { - invItemNames.add(client.getItemDefinition((i.getId())).getName()); + for (Item i : Objects.requireNonNull(client.getItemContainer(InventoryID.INVENTORY)).getItems()) + { + invItemNames.add(client.getItemDefinition((i.getId())).getName()); + } + if ((invItemNames.contains("Clue scroll (medium)") || bankItemNames.contains("Clue scroll (medium)"))) + { + menuManager.addSwap("loot", target, "use"); + } + else + { + menuManager.removeSwaps(target); + } } - if ((invItemNames.contains("Clue scroll (medium)") || bankItemNames.contains("Clue scroll (medium)"))) + break; + case "magpie impling jar": + case "nature impling jar": + case "ninja impling jar": + if (client.getItemContainer(InventoryID.INVENTORY) != null) { - menuManager.addSwap("loot", target, "use"); + for (Item i : Objects.requireNonNull(client.getItemContainer(InventoryID.INVENTORY)).getItems()) + { + invItemNames.add(client.getItemDefinition((i.getId())).getName()); + } + if ((invItemNames.contains("Clue scroll (hard)") || bankItemNames.contains("Clue scroll (hard)"))) + { + menuManager.addSwap("loot", target, "use"); + } + else + { + menuManager.removeSwaps(target); + } } - else + break; + case "dragon impling jar": + if (client.getItemContainer(InventoryID.INVENTORY) != null) { - menuManager.removeSwaps(target); + for (Item i : Objects.requireNonNull(client.getItemContainer(InventoryID.INVENTORY)).getItems()) + { + invItemNames.add(client.getItemDefinition((i.getId())).getName()); + } + if ((invItemNames.contains("Clue scroll (elite)") || bankItemNames.contains("Clue scroll (elite)"))) + { + menuManager.addSwap("loot", target, "use"); + } + else + { + menuManager.removeSwaps(target); + } } - } - } - else if (target.equals("magpie impling jar") || (target.equals("nature impling jar")) || (target.equals("ninja impling jar"))) - { - if (client.getItemContainer(InventoryID.INVENTORY) != null) - { - for (Item i : Objects.requireNonNull(client.getItemContainer(InventoryID.INVENTORY)).getItems()) - { - invItemNames.add(client.getItemDefinition((i.getId())).getName()); - } - if ((invItemNames.contains("Clue scroll (hard)") || bankItemNames.contains("Clue scroll (hard)"))) - { - menuManager.addSwap("loot", target, "use"); - } - else - { - menuManager.removeSwaps(target); - } - } - } - else if (target.equals("dragon impling jar")) - { - if (client.getItemContainer(InventoryID.INVENTORY) != null) - { - for (Item i : Objects.requireNonNull(client.getItemContainer(InventoryID.INVENTORY)).getItems()) - { - invItemNames.add(client.getItemDefinition((i.getId())).getName()); - } - if ((invItemNames.contains("Clue scroll (elite)") || bankItemNames.contains("Clue scroll (elite)"))) - { - menuManager.addSwap("loot", target, "use"); - } - else - { - menuManager.removeSwaps(target); - } - } + break; } } @@ -918,8 +1063,8 @@ public class MenuEntrySwapperPlugin extends Plugin Player player = players[identifier]; if (player != null) { - if (((config.getRemoveFreezePlayerCoX() && client.getVar(Varbits.IN_RAID) == 1) - || (config.getRemoveFreezePlayerToB() && client.getVar(Varbits.THEATRE_OF_BLOOD) == 2)) + if (((this.getRemoveFreezePlayerCoX && client.getVar(Varbits.IN_RAID) == 1) + || (this.getRemoveFreezePlayerToB && client.getVar(Varbits.THEATRE_OF_BLOOD) == 2)) && (player.isFriend() || player.isClanMember()) && CAST_OPTIONS_KEYWORDS.contains(pOptionToReplace)) { @@ -931,27 +1076,27 @@ public class MenuEntrySwapperPlugin extends Plugin if (option.equals("talk-to")) { - if (config.swapPickpocket()) + if (this.swapPickpocket) { swap(client, "pickpocket", option, target, true); } - if (config.swapHardWoodGrove() && target.contains("rionasta")) + if (this.swapHardWoodGrove && target.contains("rionasta")) { swap(client, "send-parcel", option, target, true); } - if (config.swapBankExchange()) + if (this.swapBankExchange) { swap(client, "bank", option, target, true); swap(client, "exchange", option, target, true); } - if (config.swapContract()) + if (this.swapContract) { swap(client, "contract", option, target, true); } - if (config.swapInteract()) + if (this.swapInteract) { swap(client, "repairs", option, target, true); swap(client, "claim-slime", option, target, true); @@ -962,24 +1107,24 @@ public class MenuEntrySwapperPlugin extends Plugin } // make sure assignment swap is higher priority than trade swap for slayer masters - if (config.swapAssignment()) + if (this.swapAssignment) { swap(client, "assignment", option, target, true); } - if (config.swapPlank()) + if (this.swapPlank) { swap(client, "buy-plank", option, target, true); } - if (config.swapTrade() && (!(target.equals("trader crewmember") || target.equals("trader stan")) || config.charterOption().equals(CharterOption.TRADE))) + if (this.swapTrade && (!(target.equals("trader crewmember") || target.equals("trader stan")) || this.charterOption.equals(CharterOption.TRADE))) { swap(client, "trade", option, target, true); swap(client, "trade-with", option, target, true); swap(client, "shop", option, target, true); } - if (config.swapMinigame()) + if (this.swapMinigame) { swap(client, "story", option, target, true); swap(client, "escort", option, target, true); @@ -987,7 +1132,7 @@ public class MenuEntrySwapperPlugin extends Plugin swap(client, "start-minigame", option, target, true); } - if (config.swapTravel()) + if (this.swapTravel) { swap(client, "travel", option, target, true); swap(client, "pay-fare", option, target, true); @@ -1000,83 +1145,83 @@ public class MenuEntrySwapperPlugin extends Plugin swap(client, "follow", option, target, true); swap(client, "transport", option, target, true); - if (config.swapAbyssTeleport() && target.contains("mage of zamorak")) + if (this.swapAbyssTeleport && target.contains("mage of zamorak")) { swap(client, "teleport", option, target, true); } - if (!(target.equals("trader crewmember") || target.equals("trader stan")) || config.charterOption().equals(CharterOption.CHARTER)) + if (!(target.equals("trader crewmember") || target.equals("trader stan")) || this.charterOption.equals(CharterOption.CHARTER)) { swap(client, "charter", option, target, true); } } - if (config.swapPay()) + if (this.swapPay) { swap(client, "pay", option, target, true); swap(client, "pay (", option, target, false); } - if (config.swapQuick()) + if (this.swapQuick) { swap(client, "quick-travel", option, target, true); } - if (config.swapEnchant()) + if (this.swapEnchant) { swap(client, "enchant", option, target, true); } } - else if (config.swapWildernessLever() && target.equals("lever") && option.equals("ardougne")) + else if (this.swapWildernessLever && target.equals("lever") && option.equals("ardougne")) { swap(client, "edgeville", option, target, true); } - else if (config.swapMetamorphosis() && target.contains("baby chinchompa")) + else if (this.swapMetamorphosis && target.contains("baby chinchompa")) { swap(client, "metamorphosis", option, target, true); } - else if (config.swapStun() && target.contains("hoop snake")) + else if (this.swapStun && target.contains("hoop snake")) { swap(client, "stun", option, target, true); } - else if (config.swapTravel() && option.equals("pass") && target.equals("energy barrier")) + else if (this.swapTravel && option.equals("pass") && target.equals("energy barrier")) { swap(client, "pay-toll(2-ecto)", option, target, true); } - else if (config.swapTravel() && option.equals("open") && target.equals("gate")) + else if (this.swapTravel && option.equals("open") && target.equals("gate")) { swap(client, "pay-toll(10gp)", option, target, true); } - else if (config.swapHardWoodGrove() && option.equals("open") && target.equals("hardwood grove doors")) + else if (this.swapHardWoodGrove && option.equals("open") && target.equals("hardwood grove doors")) { swap(client, "quick-pay(100)", option, target, true); } - else if (config.swapTravel() && option.equals("inspect") && target.equals("trapdoor")) + else if (this.swapTravel && option.equals("inspect") && target.equals("trapdoor")) { swap(client, "travel", option, target, true); } - else if (config.swapHarpoon() && option.equals("cage")) + else if (this.swapHarpoon && option.equals("cage")) { swap(client, "harpoon", option, target, true); } - else if (config.swapHarpoon() && (option.equals("big net") || option.equals("net"))) + else if (this.swapHarpoon && (option.equals("big net") || option.equals("net"))) { swap(client, "harpoon", option, target, true); } - else if (config.swapOccultMode() != OccultAltarMode.VENERATE && option.equals("venerate")) + else if (this.swapOccultMode != OccultAltarMode.VENERATE && option.equals("venerate")) { - switch (config.swapOccultMode()) + switch (this.swapOccultMode) { case VENERATE: swap(client, "Venerate", option, target, true); @@ -1093,9 +1238,9 @@ public class MenuEntrySwapperPlugin extends Plugin } - else if (config.swapObeliskMode() != ObeliskMode.ACTIVATE && option.equals("activate")) + else if (this.swapObeliskMode != ObeliskMode.ACTIVATE && option.equals("activate")) { - switch (config.swapObeliskMode()) + switch (this.swapObeliskMode) { case ACTIVATE: swap(client, "activate", option, target, true); @@ -1109,9 +1254,9 @@ public class MenuEntrySwapperPlugin extends Plugin } } - else if (config.swapHomePortalMode() != HouseMode.ENTER && option.equals("enter")) + else if (this.swapHomePortalMode != HouseMode.ENTER && option.equals("enter")) { - switch (config.swapHomePortalMode()) + switch (this.swapHomePortalMode) { case HOME: swap(client, "home", option, target, true); @@ -1124,101 +1269,101 @@ public class MenuEntrySwapperPlugin extends Plugin break; } } - else if (config.swapFairyRingMode() != FairyRingMode.OFF && config.swapFairyRingMode() != FairyRingMode.ZANARIS + else if (this.swapFairyRingMode != FairyRingMode.OFF && this.swapFairyRingMode != FairyRingMode.ZANARIS && (option.equals("zanaris") || option.equals("configure") || option.equals("tree"))) { - if (config.swapFairyRingMode() == FairyRingMode.LAST_DESTINATION) + if (this.swapFairyRingMode == FairyRingMode.LAST_DESTINATION) { swap(client, "last-destination", option, target, false); } - else if (config.swapFairyRingMode() == FairyRingMode.CONFIGURE) + else if (this.swapFairyRingMode == FairyRingMode.CONFIGURE) { swap(client, "configure", option, target, false); } } - else if (config.swapFairyRingMode() == FairyRingMode.ZANARIS && option.equals("tree")) + else if (this.swapFairyRingMode == FairyRingMode.ZANARIS && option.equals("tree")) { swap(client, "zanaris", option, target, false); } - else if (config.swapBoxTrap() && (option.equals("check") || option.equals("dismantle"))) + else if (this.swapBoxTrap && (option.equals("check") || option.equals("dismantle"))) { swap(client, "reset", option, target, true); } - else if (config.swapBoxTrap() && option.equals("take")) + else if (this.swapBoxTrap && option.equals("take")) { swap(client, "lay", option, target, true); swap(client, "activate", option, target, true); } - else if (config.swapChase() && option.equals("pick-up")) + else if (this.swapChase && option.equals("pick-up")) { swap(client, "chase", option, target, true); } - else if (config.swapBirdhouseEmpty() && option.equals("interact") && target.contains("birdhouse")) + else if (this.swapBirdhouseEmpty && option.equals("interact") && target.contains("birdhouse")) { swap(client, "empty", option, target, true); } - else if (config.swapQuick() && option.equals("ring")) + else if (this.swapQuick && option.equals("ring")) { swap(client, "quick-start", option, target, true); } - else if (config.swapQuick() && option.equals("pass")) + else if (this.swapQuick && option.equals("pass")) { swap(client, "quick-pass", option, target, true); } - else if (config.swapQuick() && option.equals("open")) + else if (this.swapQuick && option.equals("open")) { swap(client, "quick-open", option, target, true); } - else if (config.swapQuick() && option.equals("enter")) + else if (this.swapQuick && option.equals("enter")) { swap(client, "quick-enter", option, target, true); } - else if (config.swapQuick() && option.equals("leave tomb")) + else if (this.swapQuick && option.equals("leave tomb")) { swap(client, "quick-leave", option, target, true); } - else if (config.swapAdmire() && option.equals("admire")) + else if (this.swapAdmire && option.equals("admire")) { swap(client, "teleport", option, target, true); swap(client, "spellbook", option, target, true); swap(client, "perks", option, target, true); } - else if (config.swapPrivate() && option.equals("shared")) + else if (this.swapPrivate && option.equals("shared")) { swap(client, "private", option, target, true); } - else if (config.swapPick() && option.equals("pick")) + else if (this.swapPick && option.equals("pick")) { swap(client, "pick-lots", option, target, true); } - else if (config.swapSearch() && (option.equals("close") || option.equals("shut"))) + else if (this.swapSearch && (option.equals("close") || option.equals("shut"))) { swap(client, "search", option, target, true); } - else if (config.swapRogueschests() && target.contains("chest")) + else if (this.swapRogueschests && target.contains("chest")) { swap(client, "search for traps", option, target, true); } - else if (config.rockCake() && option.equals("eat")) + else if (this.rockCake && option.equals("eat")) { swap(client, "guzzle", option, target, true); } - else if (config.shiftClickCustomization() && shiftModifier && !option.equals("use")) + else if (this.shiftClickCustomization && shiftModifier && !option.equals("use")) { Integer customOption = getSwapConfig(eventId); @@ -1229,20 +1374,20 @@ public class MenuEntrySwapperPlugin extends Plugin } // Put all item-related swapping after shift-click - else if (config.swapTeleportItem() && (option.equals("wear") || option.equals("wield"))) + else if (this.swapTeleportItem && (option.equals("wear") || option.equals("wield"))) { swap(client, "rub", option, target, true); swap(client, "teleport", option, target, true); } - else if (config.swapCoalBag() && option.contains("deposit") && target.equals("coal bag")) + else if (this.swapCoalBag && option.contains("deposit") && target.equals("coal bag")) { swap(client, "empty", option, target, true); } - else if (config.swapBones() && option.equals("bury")) + else if (this.swapBones && option.equals("bury")) { swap(client, "use", option, target, true); } - else if (config.swapNexus() && target.contains("portal nexus")) + else if (this.swapNexus && target.contains("portal nexus")) { swap(client, "teleport menu", option, target, true); } @@ -1308,7 +1453,7 @@ public class MenuEntrySwapperPlugin extends Plugin { if (!str.startsWith("//")) { - sb.append(str + "\n"); + sb.append(str).append("\n"); } } @@ -1370,76 +1515,76 @@ public class MenuEntrySwapperPlugin extends Plugin private void addSwaps() { - if (config.getBurningAmulet()) + if (this.getBurningAmulet) { - menuManager.addSwap("remove", "burning amulet", config.getBurningAmuletMode().toString()); + menuManager.addSwap("remove", "burning amulet", this.getBurningAmuletMode.toString()); } - if (config.teleEquippedCape()) + if (this.teleEquippedCape) { - menuManager.addSwap("remove", "tele to poh", config.telecapeMode().toString()); - menuManager.addSwap("remove", "teleport", config.telecapeMode().toString()); + menuManager.addSwap("remove", "tele to poh", this.telecapeMode.toString()); + menuManager.addSwap("remove", "teleport", this.telecapeMode.toString()); } - if (config.getCombatBracelet()) + if (this.getCombatBracelet) { - menuManager.addSwap("remove", "combat bracelet", config.getCombatBraceletMode().toString()); + menuManager.addSwap("remove", "combat bracelet", this.getCombatBraceletMode.toString()); } - if (config.getGamesNecklace()) + if (this.getGamesNecklace) { - menuManager.addSwap("remove", "games necklace", config.getGamesNecklaceMode().toString()); + menuManager.addSwap("remove", "games necklace", this.getGamesNecklaceMode.toString()); } - if (config.getDuelingRing()) + if (this.getDuelingRing) { - menuManager.addSwap("remove", "ring of dueling", config.getDuelingRingMode().toString()); + menuManager.addSwap("remove", "ring of dueling", this.getDuelingRingMode.toString()); } - if (config.getGlory()) + if (this.getGlory) { - menuManager.addSwap("remove", "amulet of glory", config.getGloryMode().toString()); - menuManager.addSwap("remove", "amulet of eternal glory", config.getGloryMode().toString()); + menuManager.addSwap("remove", "amulet of glory", this.getGloryMode.toString()); + menuManager.addSwap("remove", "amulet of eternal glory", this.getGloryMode.toString()); } - if (config.getSkillsNecklace()) + if (this.getSkillsNecklace) { - menuManager.addSwap("remove", "skills necklace", config.getSkillsNecklaceMode().toString()); + menuManager.addSwap("remove", "skills necklace", this.getSkillsNecklaceMode.toString()); } - if (config.getNecklaceofPassage()) + if (this.getNecklaceofPassage) { - menuManager.addSwap("remove", "necklace of passage", config.getNecklaceofPassageMode().toString()); + menuManager.addSwap("remove", "necklace of passage", this.getNecklaceofPassageMode.toString()); } - if (config.getDigsitePendant()) + if (this.getDigsitePendant) { - menuManager.addSwap("remove", "digsite pendant", config.getDigsitePendantMode().toString()); + menuManager.addSwap("remove", "digsite pendant", this.getDigsitePendantMode.toString()); } - if (config.getSlayerRing()) + if (this.getSlayerRing) { - menuManager.addSwap("remove", "slayer ring", config.getSlayerRingMode().toString()); - menuManager.addSwap("remove", "slayer ring (eternal)", config.getSlayerRingMode().toString()); + menuManager.addSwap("remove", "slayer ring", this.getSlayerRingMode.toString()); + menuManager.addSwap("remove", "slayer ring (eternal)", this.getSlayerRingMode.toString()); } - if (config.getXericsTalisman()) + if (this.getXericsTalisman) { - menuManager.addSwap("remove", "xeric's talisman", config.getXericsTalismanMode().toString()); + menuManager.addSwap("remove", "xeric's talisman", this.getXericsTalismanMode.toString()); } - if (config.getRingofWealth()) + if (this.getRingofWealth) { - menuManager.addSwap("remove", "ring of wealth", config.getRingofWealthMode().toString()); + menuManager.addSwap("remove", "ring of wealth", this.getRingofWealthMode.toString()); } - if (config.swapMax()) + if (this.swapMax) { - menuManager.addSwap("remove", "max cape", config.maxMode().toString()); + menuManager.addSwap("remove", "max cape", this.maxMode.toString()); } - if (config.swapQuestCape()) + if (this.swapQuestCape) { - menuManager.addSwap("remove", "quest point cape", config.questCapeMode().toString()); + menuManager.addSwap("remove", "quest point cape", this.questCapeMode.toString()); } } @@ -1509,7 +1654,7 @@ public class MenuEntrySwapperPlugin extends Plugin leftClickConstructionItems.clear(); } - if (config.getEasyConstruction() && + if (this.getEasyConstruction && !Strings.isNullOrEmpty(from) && buildingMode) { @@ -1530,7 +1675,7 @@ public class MenuEntrySwapperPlugin extends Plugin void startShift() { - if (!config.swapClimbUpDown()) + if (!this.swapClimbUpDown) { return; } @@ -1545,7 +1690,7 @@ public class MenuEntrySwapperPlugin extends Plugin void startControl() { - if (!config.swapClimbUpDown()) + if (!this.swapClimbUpDown) { return; } @@ -1600,4 +1745,135 @@ public class MenuEntrySwapperPlugin extends Plugin } return null; } + + private void updateConfig() + { + this.getWithdrawOne = config.getWithdrawOne(); + this.getWithdrawOneItems = config.getWithdrawOneItems(); + this.getWithdrawFive = config.getWithdrawFive(); + this.getWithdrawFiveItems = config.getWithdrawFiveItems(); + this.getWithdrawTen = config.getWithdrawTen(); + this.getWithdrawTenItems = config.getWithdrawTenItems(); + this.getWithdrawX = config.getWithdrawX(); + this.getWithdrawXAmount = config.getWithdrawXAmount(); + this.getWithdrawXItems = config.getWithdrawXItems(); + this.getWithdrawAll = config.getWithdrawAll(); + this.getWithdrawAllItems = config.getWithdrawAllItems(); + this.swapMax = config.swapMax(); + this.teleEquippedCape = config.teleEquippedCape(); + this.telecapeMode = config.telecapeMode(); + this.maxMode = config.maxMode(); + this.getSwapArdougneCape = config.getSwapArdougneCape(); + this.getSwapConstructionCape = config.getSwapConstructionCape(); + this.getSwapCraftingCape = config.getSwapCraftingCape(); + this.getSwapMagicCape = config.getSwapMagicCape(); + this.getSwapExplorersRing = config.getSwapExplorersRing(); + this.swapAdmire = config.swapAdmire(); + this.swapQuestCape = config.swapQuestCape(); + this.questCapeMode = config.questCapeMode(); + this.configCustomSwaps = config.customSwaps(); + this.shiftClickCustomization = config.shiftClickCustomization(); + this.swapCoalBag = config.swapCoalBag(); + this.swapBirdhouseEmpty = config.swapBirdhouseEmpty(); + this.swapBones = config.swapBones(); + this.swapChase = config.swapChase(); + this.swapHarpoon = config.swapHarpoon(); + this.swapOccult = config.swapOccult(); + this.swapOccultMode = config.swapOccultMode(); + this.swapHomePortal = config.swapHomePortal(); + this.swapHomePortalMode = config.swapHomePortalMode(); + this.swapPrivate = config.swapPrivate(); + this.swapPick = config.swapPick(); + this.swapQuick = config.swapQuick(); + this.swapBoxTrap = config.swapBoxTrap(); + this.rockCake = config.rockCake(); + this.swapRogueschests = config.swapRogueschests(); + this.swapClimbUpDown = config.swapClimbUpDown(); + this.swapStun = config.swapStun(); + this.swapSearch = config.swapSearch(); + this.swapHardWoodGrove = config.swapHardWoodGrove(); + this.getRemoveObjects = config.getRemoveObjects(); + this.getRemovedObjects = config.getRemovedObjects(); + this.swapImps = config.swapImps(); + this.charterOption = config.charterOption(); + this.getSwapBuyOne = config.getSwapBuyOne(); + this.getBuyOneItems = config.getBuyOneItems(); + this.getSwapBuyFive = config.getSwapBuyFive(); + this.getBuyFiveItems = config.getBuyFiveItems(); + this.getSwapBuyTen = config.getSwapBuyTen(); + this.getBuyTenItems = config.getBuyTenItems(); + this.getSwapBuyFifty = config.getSwapBuyFifty(); + this.getBuyFiftyItems = config.getBuyFiftyItems(); + this.getSwapSellOne = config.getSwapSellOne(); + this.getSellOneItems = config.getSellOneItems(); + this.getSwapSellFive = config.getSwapSellFive(); + this.getSellFiveItems = config.getSellFiveItems(); + this.getSwapSellTen = config.getSwapSellTen(); + this.getSellTenItems = config.getSellTenItems(); + this.getSwapSellFifty = config.getSwapSellFifty(); + this.getSellFiftyItems = config.getSellFiftyItems(); + this.getEasyConstruction = config.getEasyConstruction(); + this.getEasyConstructionItems = config.getEasyConstructionItems(); + this.getSwapSmithing = config.getSwapSmithing(); + this.getSwapTanning = config.getSwapTanning(); + this.getSwapSawmill = config.getSwapSawmill(); + this.getSwapSawmillPlanks = config.getSwapSawmillPlanks(); + this.getSwapPuro = config.getSwapPuro(); + this.swapAssignment = config.swapAssignment(); + this.swapBankExchange = config.swapBankExchange(); + this.swapContract = config.swapContract(); + this.swapInteract = config.swapInteract(); + this.swapPickpocket = config.swapPickpocket(); + this.swapPay = config.swapPay(); + this.swapAbyssTeleport = config.swapAbyssTeleport(); + this.swapTrade = config.swapTrade(); + this.swapTravel = config.swapTravel(); + this.swapMinigame = config.swapMinigame(); + this.swapPlank = config.swapPlank(); + this.swapMetamorphosis = config.swapMetamorphosis(); + this.swapEnchant = config.swapEnchant(); + this.swapFairyRing = config.swapFairyRing(); + this.swapFairyRingMode = config.swapFairyRingMode(); + this.swapObelisk = config.swapObelisk(); + this.swapObeliskMode = config.swapObeliskMode(); + this.swapTeleportItem = config.swapTeleportItem(); + this.swapWildernessLever = config.swapWildernessLever(); + this.swapNexus = config.swapNexus(); + this.getGamesNecklace = config.getGamesNecklace(); + this.getGamesNecklaceMode = config.getGamesNecklaceMode(); + this.getDuelingRing = config.getDuelingRing(); + this.getDuelingRingMode = config.getDuelingRingMode(); + this.getGlory = config.getGlory(); + this.getGloryMode = config.getGloryMode(); + this.getSkillsNecklace = config.getSkillsNecklace(); + this.getSkillsNecklaceMode = config.getSkillsNecklaceMode(); + this.getNecklaceofPassage = config.getNecklaceofPassage(); + this.getNecklaceofPassageMode = config.getNecklaceofPassageMode(); + this.getDigsitePendant = config.getDigsitePendant(); + this.getDigsitePendantMode = config.getDigsitePendantMode(); + this.getCombatBracelet = config.getCombatBracelet(); + this.getCombatBraceletMode = config.getCombatBraceletMode(); + this.getBurningAmulet = config.getBurningAmulet(); + this.getBurningAmuletMode = config.getBurningAmuletMode(); + this.getXericsTalisman = config.getXericsTalisman(); + this.getXericsTalismanMode = config.getXericsTalismanMode(); + this.getRingofWealth = config.getRingofWealth(); + this.getRingofWealthMode = config.getRingofWealthMode(); + this.getSlayerRing = config.getSlayerRing(); + this.getSlayerRingMode = config.getSlayerRingMode(); + this.hideExamine = config.hideExamine(); + this.hideTradeWith = config.hideTradeWith(); + this.hideReport = config.hideReport(); + this.hideLookup = config.hideLookup(); + this.hideNet = config.hideNet(); + this.hideBait = config.hideBait(); + this.hideDestroyRunepouch = config.hideDestroyRunepouch(); + this.hideDestroyCoalbag = config.hideDestroyCoalbag(); + this.hideDestroyHerbsack = config.hideDestroyHerbsack(); + this.hideDestroyBoltpouch = config.hideDestroyBoltpouch(); + this.hideDestroyGembag = config.hideDestroyGembag(); + this.hideDropRunecraftingPouch = config.hideDropRunecraftingPouch(); + this.getRemoveFreezePlayerToB = config.getRemoveFreezePlayerToB(); + this.getRemoveFreezePlayerCoX = config.getRemoveFreezePlayerCoX(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftClickInputListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftClickInputListener.java index 5df37f45b2..c258bfb30a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftClickInputListener.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/ShiftClickInputListener.java @@ -26,8 +26,10 @@ package net.runelite.client.plugins.menuentryswapper; import java.awt.event.KeyEvent; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.client.input.KeyListener; +@Singleton public class ShiftClickInputListener implements KeyListener { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/metronome/MetronomePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/metronome/MetronomePlugin.java index 148d7e4255..766b80c434 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/metronome/MetronomePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/metronome/MetronomePlugin.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.metronome; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.SoundEffectVolume; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; @@ -50,6 +51,7 @@ import net.runelite.client.plugins.PluginDescriptor; tags = {"skilling", "tick", "timers"}, enabledByDefault = false ) +@Singleton public class MetronomePlugin extends Plugin { @Inject @@ -63,6 +65,14 @@ public class MetronomePlugin extends Plugin private Clip tickClip; private Clip tockClip; + private int tickCount; + private boolean enableTock; + private int tockNumber; + private int tickOffset; + private String tickPath; + private String tockPath; + private int volume; + @Provides MetronomePluginConfiguration provideConfig(ConfigManager configManager) { @@ -90,7 +100,7 @@ public class MetronomePlugin extends Plugin Clip audioClip = AudioSystem.getClip(); audioClip.open(audioStream); FloatControl gainControl = (FloatControl) audioClip.getControl(FloatControl.Type.MASTER_GAIN); - float gainValue = (((float) config.volume()) * 40f / 100f) - 35f; + float gainValue = (((float) this.volume) * 40f / 100f) - 35f; gainControl.setValue(gainValue); return audioClip; } @@ -105,8 +115,10 @@ public class MetronomePlugin extends Plugin @Override protected void startUp() { - tickClip = GetAudioClip(config.tickPath()); - tockClip = GetAudioClip(config.tockPath()); + updateConfig(); + + tickClip = GetAudioClip(this.tickPath); + tockClip = GetAudioClip(this.tockPath); } @Override @@ -125,9 +137,16 @@ public class MetronomePlugin extends Plugin @Subscribe public void onConfigChanged(ConfigChanged event) { + if (!event.getGroup().equals("metronome")) + { + return; + } + + updateConfig(); + if (event.getKey().equals("volume")) { - float gainValue = (((float) config.volume()) * 40f / 100f) - 35f; + float gainValue = (((float) this.volume) * 40f / 100f) - 35f; FloatControl gainControlTick = (FloatControl) tickClip.getControl(FloatControl.Type.MASTER_GAIN); gainControlTick.setValue(gainValue); FloatControl gainControlTock = (FloatControl) tockClip.getControl(FloatControl.Type.MASTER_GAIN); @@ -139,7 +158,7 @@ public class MetronomePlugin extends Plugin { tickClip.close(); } - tickClip = GetAudioClip(config.tickPath()); + tickClip = GetAudioClip(this.tickPath); } if (event.getKey().equals("tockSoundFilePath")) { @@ -147,21 +166,21 @@ public class MetronomePlugin extends Plugin { tockClip.close(); } - tockClip = GetAudioClip(config.tockPath()); + tockClip = GetAudioClip(this.tockPath); } } @Subscribe public void onGameTick(GameTick tick) { - if (config.tickCount() == 0) + if (this.tickCount == 0) { return; } - if ((++tickCounter + config.tickOffset()) % config.tickCount() == 0) + if ((++tickCounter + this.tickOffset) % this.tickCount == 0) { - if (++tockCounter % config.tockNumber() == 0 & config.enableTock()) + if (++tockCounter % this.tockNumber == 0 & this.enableTock) { if (tockClip == null) { @@ -195,4 +214,15 @@ public class MetronomePlugin extends Plugin } } } + + private void updateConfig() + { + this.tickCount = config.tickCount(); + this.enableTock = config.enableTock(); + this.tockNumber = config.tockNumber(); + this.tickOffset = config.tickOffset(); + this.tickPath = config.tickPath(); + this.tockPath = config.tockPath(); + this.volume = config.volume(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/minimap/MinimapPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/minimap/MinimapPlugin.java index d68e6f56f4..205e67d03e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/minimap/MinimapPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/minimap/MinimapPlugin.java @@ -28,6 +28,7 @@ import com.google.inject.Provides; import java.awt.Color; import java.util.Arrays; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.Sprite; @@ -46,6 +47,7 @@ import net.runelite.client.plugins.PluginDescriptor; description = "Customize the color of minimap dots", tags = {"items", "npcs", "players"} ) +@Singleton public class MinimapPlugin extends Plugin { private static final int NUM_MAPDOTS = 6; @@ -58,6 +60,14 @@ public class MinimapPlugin extends Plugin private Sprite[] originalDotSprites; + private Color itemColor; + private Color npcColor; + private Color playerColor; + private Color friendColor; + private Color teamColor; + private Color clanColor; + private boolean hideMinimap; + @Provides private MinimapConfig provideConfig(ConfigManager configManager) { @@ -67,7 +77,9 @@ public class MinimapPlugin extends Plugin @Override protected void startUp() throws Exception { - updateMinimapWidgetVisibility(config.hideMinimap()); + updateConfig(); + + updateMinimapWidgetVisibility(this.hideMinimap); storeOriginalDots(); replaceMapDots(); } @@ -97,9 +109,11 @@ public class MinimapPlugin extends Plugin return; } + updateConfig(); + if (event.getKey().equals("hideMinimap")) { - updateMinimapWidgetVisibility(config.hideMinimap()); + updateMinimapWidgetVisibility(this.hideMinimap); return; } @@ -109,7 +123,7 @@ public class MinimapPlugin extends Plugin @Subscribe public void onWidgetHiddenChanged(WidgetHiddenChanged event) { - updateMinimapWidgetVisibility(config.hideMinimap()); + updateMinimapWidgetVisibility(this.hideMinimap); } private void updateMinimapWidgetVisibility(boolean enable) @@ -155,12 +169,13 @@ public class MinimapPlugin extends Plugin private Color[] getColors() { Color[] colors = new Color[NUM_MAPDOTS]; - colors[0] = config.itemColor(); - colors[1] = config.npcColor(); - colors[2] = config.playerColor(); - colors[3] = config.friendColor(); - colors[4] = config.teamColor(); - colors[5] = config.clanColor(); + colors[0] = this.itemColor; + colors[1] = this.npcColor; + colors[2] = this.playerColor; + colors[3] = this.friendColor; + colors[4] = this.teamColor; + colors[5] = this.clanColor; + return colors; } @@ -187,4 +202,15 @@ public class MinimapPlugin extends Plugin System.arraycopy(originalDotSprites, 0, mapDots, 0, mapDots.length); } + + private void updateConfig() + { + this.itemColor = config.itemColor(); + this.npcColor = config.npcColor(); + this.playerColor = config.playerColor(); + this.friendColor = config.friendColor(); + this.teamColor = config.teamColor(); + this.clanColor = config.clanColor(); + this.hideMinimap = config.hideMinimap(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningCoalBagOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningCoalBagOverlay.java index 2acbf90aa8..cdcf2ad670 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningCoalBagOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/MiningCoalBagOverlay.java @@ -27,29 +27,29 @@ package net.runelite.client.plugins.mining; import java.awt.Color; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.ItemID; import net.runelite.api.Point; import net.runelite.api.widgets.WidgetItem; import net.runelite.client.ui.FontManager; import net.runelite.client.ui.overlay.WidgetItemOverlay; +@Singleton public class MiningCoalBagOverlay extends WidgetItemOverlay { private final MiningPlugin plugin; - private final MiningConfig config; @Inject - MiningCoalBagOverlay(MiningPlugin plugin, MiningConfig config) + MiningCoalBagOverlay(final MiningPlugin plugin) { showOnInventory(); this.plugin = plugin; - this.config = config; } @Override public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget) { - if (!config.showCoalBagOverlay() || (itemId != ItemID.COAL_BAG && itemId != ItemID.COAL_BAG_12019)) + if (!plugin.isShowCoalBagOverlay() || (itemId != ItemID.COAL_BAG && itemId != ItemID.COAL_BAG_12019)) { return; } @@ -58,6 +58,6 @@ public class MiningCoalBagOverlay extends WidgetItemOverlay graphics.setColor(Color.WHITE); Point location = itemWidget.getCanvasLocation(); - graphics.drawString(config.amountOfCoalInCoalBag() + "", location.getX(), location.getY() + 14); + graphics.drawString(plugin.getAmountOfCoalInCoalBag() + "", location.getX(), location.getY() + 14); } } 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 index fc673f2784..f0ca9fea59 100644 --- 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 @@ -31,6 +31,7 @@ import java.time.Instant; import java.util.Iterator; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Client; @@ -43,6 +44,7 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.components.ProgressPieComponent; +@Singleton class MiningOverlay extends Overlay { // Range of Motherlode vein respawn time not 100% confirmed but based on observation @@ -57,7 +59,7 @@ class MiningOverlay extends Overlay private final MiningPlugin plugin; @Inject - private MiningOverlay(Client client, MiningPlugin plugin) + private MiningOverlay(final Client client, final MiningPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); 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 index f8f4ae7bc7..29f5df03e0 100644 --- 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 @@ -34,6 +34,7 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -72,6 +73,7 @@ import net.runelite.client.ui.overlay.OverlayManager; tags = {"overlay", "skilling", "timers", "coal", "coalbag", "coal bag"}, enabledByDefault = false ) +@Singleton public class MiningPlugin extends Plugin { private static final int ROCK_DISTANCE = 14; @@ -87,7 +89,6 @@ public class MiningPlugin extends Plugin private static final String FILL_OPTION = "fill"; private static final String EMPTY_OPTION = "empty"; - @Inject private Client client; @@ -107,9 +108,17 @@ public class MiningPlugin extends Plugin private final List respawns = new ArrayList<>(); private boolean recentlyLoggedIn; + @Getter(AccessLevel.PACKAGE) + private boolean showCoalBagOverlay; + @Getter(AccessLevel.PACKAGE) + private int amountOfCoalInCoalBag; + @Override protected void startUp() { + this.showCoalBagOverlay = config.showCoalBagOverlay(); + this.amountOfCoalInCoalBag = config.amountOfCoalInCoalBag(); + overlayManager.add(miningOverlay); overlayManager.add(coalBagOverlay); } @@ -222,7 +231,11 @@ public class MiningPlugin extends Plugin } ItemContainer inventoryItemContainer = client.getItemContainer(InventoryID.INVENTORY); - Item[] inventoryItems = inventoryItemContainer.getItems(); + Item[] inventoryItems = new Item[0]; + if (inventoryItemContainer != null) + { + inventoryItems = inventoryItemContainer.getItems(); + } switch (event.getOption().toLowerCase()) { @@ -261,7 +274,7 @@ public class MiningPlugin extends Plugin Matcher matcher = COAL_BAG_AMOUNT_MESSAGE.matcher(chatMsg); if (matcher.find()) { - updateAmountOfCoalInBag(Integer.parseInt(matcher.group(1)) - config.amountOfCoalInCoalBag()); + updateAmountOfCoalInBag(Integer.parseInt(matcher.group(1)) - this.amountOfCoalInCoalBag); } } } @@ -276,11 +289,25 @@ public class MiningPlugin extends Plugin { // check for upper/lower bounds of amount of coal in a bag // 0 <= X <= 27 - config.amountOfCoalInCoalBag(Math.max(0, Math.min(FULL_COAL_BAG_AMOUNT, config.amountOfCoalInCoalBag() + delta))); + int coalbagAmount = Math.max(0, Math.min(FULL_COAL_BAG_AMOUNT, this.amountOfCoalInCoalBag + delta)); + config.amountOfCoalInCoalBag(coalbagAmount); + this.amountOfCoalInCoalBag = coalbagAmount; } private boolean inMiningGuild() { return client.getLocalPlayer().getWorldLocation().getRegionID() == MINING_GUILD_REGION; } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("mining")) + { + return; + } + + this.showCoalBagOverlay = config.showCoalBagOverlay(); + this.amountOfCoalInCoalBag = config.amountOfCoalInCoalBag(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mining/RockRespawn.java b/runelite-client/src/main/java/net/runelite/client/plugins/mining/RockRespawn.java index daedda8f34..6b00652af4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mining/RockRespawn.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mining/RockRespawn.java @@ -25,12 +25,13 @@ package net.runelite.client.plugins.mining; import java.time.Instant; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.coords.WorldPoint; @AllArgsConstructor -@Getter +@Getter(AccessLevel.PACKAGE) class RockRespawn { private final Rock rock; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeGemOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeGemOverlay.java index 7b95147aeb..c87469b6bc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeGemOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeGemOverlay.java @@ -29,6 +29,7 @@ import java.awt.Graphics2D; import java.time.Duration; import java.time.Instant; import javax.inject.Inject; +import javax.inject.Singleton; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.client.ui.overlay.Overlay; import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE; @@ -38,22 +39,20 @@ import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.TitleComponent; import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; - +@Singleton public class MotherlodeGemOverlay extends Overlay { private final MotherlodePlugin plugin; private final MotherlodeSession motherlodeSession; - private final MotherlodeConfig config; private final PanelComponent panelComponent = new PanelComponent(); @Inject - MotherlodeGemOverlay(MotherlodePlugin plugin, MotherlodeSession motherlodeSession, MotherlodeConfig config) + MotherlodeGemOverlay(final MotherlodePlugin plugin, final MotherlodeSession motherlodeSession) { super(plugin); setPosition(OverlayPosition.TOP_LEFT); this.plugin = plugin; this.motherlodeSession = motherlodeSession; - this.config = config; getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Gem overlay")); } @@ -62,12 +61,12 @@ public class MotherlodeGemOverlay extends Overlay { MotherlodeSession session = motherlodeSession; - if (session.getLastGemFound() == null || !plugin.isInMlm() || !config.showGemsFound()) + if (session.getLastGemFound() == null || !plugin.isInMlm() || !plugin.isShowGemsFound()) { return null; } - Duration statTimeout = Duration.ofMinutes(config.statTimeout()); + Duration statTimeout = Duration.ofMinutes(plugin.getStatTimeout()); Duration sinceCut = Duration.between(session.getLastGemFound(), Instant.now()); if (sinceCut.compareTo(statTimeout) >= 0) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeOreOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeOreOverlay.java index 3533537987..65888c0f74 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeOreOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeOreOverlay.java @@ -27,33 +27,32 @@ package net.runelite.client.plugins.motherlode; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; 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.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; - +@Singleton public class MotherlodeOreOverlay extends Overlay { private final MotherlodePlugin plugin; private final MotherlodeSession motherlodeSession; - private final MotherlodeConfig config; private final PanelComponent panelComponent = new PanelComponent(); @Inject - MotherlodeOreOverlay(MotherlodePlugin plugin, MotherlodeSession motherlodeSession, MotherlodeConfig config) + MotherlodeOreOverlay(final MotherlodePlugin plugin, final MotherlodeSession motherlodeSession) { setPosition(OverlayPosition.TOP_LEFT); this.plugin = plugin; this.motherlodeSession = motherlodeSession; - this.config = config; } @Override public Dimension render(Graphics2D graphics) { - if (!plugin.isInMlm() || !config.showOresFound()) + if (!plugin.isInMlm() || !plugin.isShowOresFound()) { return null; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeOverlay.java index c43e012bfb..7bd10dd62c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeOverlay.java @@ -30,7 +30,7 @@ import java.awt.Graphics2D; import java.time.Duration; import java.time.Instant; import javax.inject.Inject; -import net.runelite.api.Client; +import javax.inject.Singleton; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.components.PanelComponent; @@ -38,29 +38,26 @@ import net.runelite.client.ui.overlay.components.TitleComponent; import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; +@Singleton class MotherlodeOverlay extends Overlay { - private final Client client; private final MotherlodePlugin plugin; private final MotherlodeSession motherlodeSession; - private final MotherlodeConfig config; private final PanelComponent panelComponent = new PanelComponent(); @Inject - MotherlodeOverlay(Client client, MotherlodePlugin plugin, MotherlodeSession motherlodeSession, MotherlodeConfig config) + MotherlodeOverlay(final MotherlodePlugin plugin, final MotherlodeSession motherlodeSession) { super(plugin); setPosition(OverlayPosition.TOP_LEFT); - this.client = client; this.plugin = plugin; this.motherlodeSession = motherlodeSession; - this.config = config; } @Override public Dimension render(Graphics2D graphics) { - if (!plugin.isInMlm() || !config.showMiningStats()) + if (!plugin.isInMlm() || !plugin.isShowMiningStats()) { return null; } @@ -72,7 +69,7 @@ class MotherlodeOverlay extends Overlay return null; } - Duration statTimeout = Duration.ofMinutes(config.statTimeout()); + Duration statTimeout = Duration.ofMinutes(plugin.getStatTimeout()); Duration sinceCut = Duration.between(session.getLastPayDirtMined(), Instant.now()); if (sinceCut.compareTo(statTimeout) >= 0) @@ -82,7 +79,7 @@ class MotherlodeOverlay extends Overlay panelComponent.getChildren().clear(); - if (config.showMiningState()) + if (plugin.isShowMiningState()) { if (plugin.isMining()) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodePlugin.java index 0e23e85a19..7e202ef3ac 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodePlugin.java @@ -38,6 +38,7 @@ import java.util.Arrays; import java.util.HashSet; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.AnimationID; @@ -80,6 +81,7 @@ import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.AnimationChanged; 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; @@ -110,6 +112,7 @@ import net.runelite.client.ui.overlay.OverlayManager; tags = {"pay", "dirt", "mining", "mlm", "skilling", "overlay"}, enabledByDefault = false ) +@Singleton public class MotherlodePlugin extends Plugin { private static final Set MOTHERLODE_MAP_REGIONS = ImmutableSet.of(14679, 14680, 14681, 14935, 14936, 14937, 15191, 15192, 15193); @@ -188,6 +191,28 @@ public class MotherlodePlugin extends Plugin private int lastAnimation = AnimationID.IDLE; private Instant lastAnimating; + @Getter(AccessLevel.PACKAGE) + private boolean showVeins; + @Getter(AccessLevel.PACKAGE) + private boolean showRockFalls; + @Getter(AccessLevel.PACKAGE) + private int statTimeout; + @Getter(AccessLevel.PACKAGE) + private boolean showSack; + @Getter(AccessLevel.PACKAGE) + private boolean showMiningStats; + @Getter(AccessLevel.PACKAGE) + private boolean showDepositsLeft; + @Getter(AccessLevel.PACKAGE) + private boolean showMiningState; + @Getter(AccessLevel.PACKAGE) + private boolean showGemsFound; + @Getter(AccessLevel.PACKAGE) + private boolean showOresFound; + private boolean notifyOnIdle; + @Getter(AccessLevel.PACKAGE) + private boolean showTargetVein; + @Provides MotherlodeConfig getConfig(ConfigManager configManager) { @@ -197,6 +222,8 @@ public class MotherlodePlugin extends Plugin @Override protected void startUp() { + updateConfig(); + overlayManager.add(overlay); overlayManager.add(rocksOverlay); overlayManager.add(motherlodeGemOverlay); @@ -311,7 +338,7 @@ public class MotherlodePlugin extends Plugin } // reset recentPayDirtMined if you haven't mined anything recently - Duration statTimeout = Duration.ofMinutes(config.statTimeout()); + Duration statTimeout = Duration.ofMinutes(this.statTimeout); Duration sinceMined = Duration.between(lastPayDirtMined, Instant.now()); if (sinceMined.compareTo(statTimeout) >= 0) @@ -467,7 +494,7 @@ public class MotherlodePlugin extends Plugin private void sendIdleNotification() { - if (!config.notifyOnIdle()) + if (!this.notifyOnIdle) { return; } @@ -703,4 +730,30 @@ public class MotherlodePlugin extends Plugin { return Perspective.getTileHeight(client, localPoint, 0) < UPPER_FLOOR_HEIGHT; } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("motherlode")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.showVeins = config.showVeins(); + this.showRockFalls = config.showRockFalls(); + this.statTimeout = config.statTimeout(); + this.showSack = config.showSack(); + this.showMiningStats = config.showMiningStats(); + this.showDepositsLeft = config.showDepositsLeft(); + this.showMiningState = config.showMiningState(); + this.showGemsFound = config.showGemsFound(); + this.showOresFound = config.showOresFound(); + this.notifyOnIdle = config.notifyOnIdle(); + this.showTargetVein = config.showTargetVein(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeRocksOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeRocksOverlay.java index bcd4d2946e..3fa2aba3dd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeRocksOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeRocksOverlay.java @@ -32,6 +32,7 @@ import java.awt.Graphics2D; import java.awt.Polygon; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.GameObject; import net.runelite.api.Perspective; @@ -48,13 +49,13 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.util.ImageUtil; +@Singleton class MotherlodeRocksOverlay extends Overlay { private static final int MAX_DISTANCE = 2350; private final Client client; private final MotherlodePlugin plugin; - private final MotherlodeConfig config; private final BufferedImage miningIcon; private final BufferedImage targetMiningIcon; @@ -62,13 +63,12 @@ class MotherlodeRocksOverlay extends Overlay private static final Color miningIconNewColor = new Color(0, 150, 0); @Inject - MotherlodeRocksOverlay(Client client, MotherlodePlugin plugin, MotherlodeConfig config, SkillIconManager iconManager) + MotherlodeRocksOverlay(final Client client, final MotherlodePlugin plugin, final SkillIconManager iconManager) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); this.client = client; this.plugin = plugin; - this.config = config; miningIcon = iconManager.getSkillImage(Skill.MINING); targetMiningIcon = ImageUtil.recolorImage(miningIcon, miningIconNewColor, Color -> Color.getRGB() == miningIconOldColor.getRGB()); @@ -77,7 +77,7 @@ class MotherlodeRocksOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if ((!config.showVeins() && !config.showRockFalls()) || !plugin.isInMlm()) + if ((!plugin.isShowVeins() && !plugin.isShowRockFalls()) || !plugin.isInMlm()) { return null; } @@ -92,7 +92,7 @@ class MotherlodeRocksOverlay extends Overlay private void renderTiles(Graphics2D graphics, Player local) { LocalPoint localLocation = local.getLocalLocation(); - if (config.showVeins()) + if (plugin.isShowVeins()) { for (WallObject vein : plugin.getVeins()) { @@ -104,7 +104,7 @@ class MotherlodeRocksOverlay extends Overlay { if (WorldPoint.fromLocal(client, location).equals(plugin.getTargetVeinLocation()) && plugin.isMining() - && config.showTargetVein()) + && plugin.isShowTargetVein()) { renderVein(graphics, vein, true); } @@ -117,7 +117,7 @@ class MotherlodeRocksOverlay extends Overlay } } - if (config.showRockFalls()) + if (plugin.isShowRockFalls()) { for (GameObject rock : plugin.getRocks()) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeSackOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeSackOverlay.java index 2b53ff5bee..bf8e1d31a3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeSackOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeSackOverlay.java @@ -30,6 +30,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.api.Varbits; @@ -45,22 +46,21 @@ import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; import net.runelite.client.util.ColorUtil; +@Singleton class MotherlodeSackOverlay extends Overlay { private static final Color DANGER = new Color(150, 0, 0, 150); private final Client client; - private final MotherlodeConfig config; private final MotherlodePlugin plugin; private final PanelComponent panelComponent = new PanelComponent(); @Inject - MotherlodeSackOverlay(Client client, MotherlodeConfig config, MotherlodePlugin plugin) + MotherlodeSackOverlay(final Client client, final MotherlodePlugin plugin) { super(plugin); setPosition(OverlayPosition.TOP_LEFT); this.client = client; - this.config = config; this.plugin = plugin; getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Sack overlay")); } @@ -85,7 +85,7 @@ class MotherlodeSackOverlay extends Overlay { sack.setHidden(true); - if (config.showSack()) + if (plugin.isShowSack()) { if (plugin.getCurSackSize() >= plugin.getMaxSackSize()) { @@ -95,7 +95,7 @@ class MotherlodeSackOverlay extends Overlay tableComponent.addRow("Pay-dirt in sack:", String.valueOf(client.getVar(Varbits.SACK_NUMBER))); } - if (config.showDepositsLeft()) + if (plugin.isShowDepositsLeft()) { final Integer depositsLeft = plugin.getDepositsLeft(); Color color = Color.WHITE; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeSession.java b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeSession.java index e4d00cfda6..6a9c97d4b4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeSession.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/motherlode/MotherlodeSession.java @@ -133,7 +133,7 @@ public class MotherlodeSession } } - public void incrementPayDirtMined() + void incrementPayDirtMined() { Instant now = Instant.now(); @@ -153,33 +153,28 @@ public class MotherlodeSession } } - public void resetRecent() + void resetRecent() { recentPayDirtMined = null; recentMined = 0; } - public int getPerHour() + int getPerHour() { return perHour; } - public Instant getLastPayDirtMined() + Instant getLastPayDirtMined() { return lastPayDirtMined; } - public int getTotalMined() + int getTotalMined() { return totalMined; } - public Instant getRecentPayDirtMined() - { - return recentPayDirtMined; - } - - public int getRecentMined() + int getRecentMined() { return recentMined; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightOverlay.java index 79700ce096..34cae5980f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightOverlay.java @@ -28,6 +28,7 @@ import com.google.common.base.Strings; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.MenuAction; import net.runelite.api.MenuEntry; @@ -39,19 +40,20 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.tooltip.Tooltip; import net.runelite.client.ui.overlay.tooltip.TooltipManager; +@Singleton class MouseHighlightOverlay extends Overlay { private final TooltipManager tooltipManager; private final Client client; - private final MouseHighlightConfig config; + private final MouseHighlightPlugin plugin; @Inject - MouseHighlightOverlay(Client client, TooltipManager tooltipManager, MouseHighlightConfig config) + MouseHighlightOverlay(final Client client, final TooltipManager tooltipManager, final MouseHighlightPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); this.client = client; this.tooltipManager = tooltipManager; - this.config = config; + this.plugin = plugin; } @Override @@ -105,12 +107,12 @@ class MouseHighlightOverlay extends Overlay final int childId = WidgetInfo.TO_CHILD(widgetId); final Widget widget = client.getWidget(groupId, childId); - if (!config.uiTooltip() && widget != null) + if (!plugin.isUiTooltip() && widget != null) { return null; } - if (!config.chatboxTooltip() && groupId == WidgetInfo.CHATBOX.getGroupId()) + if (!plugin.isChatboxTooltip() && groupId == WidgetInfo.CHATBOX.getGroupId()) { return null; } @@ -125,7 +127,7 @@ class MouseHighlightOverlay extends Overlay } } - if (widget == null && !config.mainTooltip()) + if (widget == null && !plugin.isMainTooltip()) { return null; } @@ -144,7 +146,7 @@ class MouseHighlightOverlay extends Overlay private boolean shouldNotRenderMenuAction(int type) { return type == MenuAction.RUNELITE_OVERLAY.getId() - || (!config.isRightClickTooltipEnabled() && isMenuActionRightClickOnly(type)); + || (!plugin.isRightClickTooltipEnabled() && isMenuActionRightClickOnly(type)); } private boolean isMenuActionRightClickOnly(int type) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightPlugin.java index 85f95aa6bd..ded370e957 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightPlugin.java @@ -26,8 +26,12 @@ package net.runelite.client.plugins.mousehighlight; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; 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.api.events.GameTick; import net.runelite.api.events.WidgetLoaded; @@ -45,6 +49,7 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Render default actions as a tooltip", tags = {"actions", "overlay", "tooltip", "hide"} ) +@Singleton public class MouseHighlightPlugin extends Plugin { @Inject @@ -58,6 +63,17 @@ public class MouseHighlightPlugin extends Plugin @Inject private MouseHighlightOverlay overlay; + @Getter(AccessLevel.PACKAGE) + private boolean mainTooltip; + @Getter(AccessLevel.PACKAGE) + private boolean uiTooltip; + @Getter(AccessLevel.PACKAGE) + private boolean chatboxTooltip; + private boolean shouldHideSpells; + private boolean shouldHideCombat; + @Getter(AccessLevel.PACKAGE) + private boolean isRightClickTooltipEnabled; + @Provides MouseHighlightConfig provideConfig(ConfigManager configManager) { @@ -67,6 +83,8 @@ public class MouseHighlightPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + adjustTips(); overlayManager.add(overlay); } @@ -111,15 +129,13 @@ public class MouseHighlightPlugin extends Plugin try { - setTipHidden(WidgetInfo.SPELL_TOOLTIP, config.shouldHideSpells()); - setTipHidden(WidgetInfo.COMBAT_TOOLTIP, config.shouldHideCombat()); + setTipHidden(WidgetInfo.SPELL_TOOLTIP, this.shouldHideSpells); + setTipHidden(WidgetInfo.COMBAT_TOOLTIP, this.shouldHideCombat); } catch (Exception e) { //swallow } - - } private void resetTips() @@ -152,4 +168,24 @@ public class MouseHighlightPlugin extends Plugin widget.setHidden(hidden); } + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("motherlode")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.mainTooltip = config.mainTooltip(); + this.uiTooltip = config.uiTooltip(); + this.chatboxTooltip = config.chatboxTooltip(); + this.shouldHideSpells = config.shouldHideSpells(); + this.shouldHideCombat = config.shouldHideCombat(); + this.isRightClickTooltipEnabled = config.isRightClickTooltipEnabled(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTAInventoryOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTAInventoryOverlay.java index ea99cf7f00..928522a48a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTAInventoryOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTAInventoryOverlay.java @@ -27,17 +27,19 @@ package net.runelite.client.plugins.mta; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; 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; +@Singleton public class MTAInventoryOverlay extends Overlay { private final MTAPlugin plugin; @Inject - public MTAInventoryOverlay(MTAPlugin plugin) + public MTAInventoryOverlay(final MTAPlugin plugin) { this.plugin = plugin; setPosition(OverlayPosition.DYNAMIC); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTAPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTAPlugin.java index 5b7d6bffa1..907f66f03d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTAPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTAPlugin.java @@ -26,9 +26,9 @@ package net.runelite.client.plugins.mta; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; -import net.runelite.api.Client; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.EventBus; import net.runelite.client.plugins.Plugin; @@ -44,11 +44,9 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Show helpful information for the Mage Training Arena minigame", tags = {"mta", "magic", "minigame", "overlay"} ) +@Singleton public class MTAPlugin extends Plugin { - @Inject - private Client client; - @Inject private OverlayManager overlayManager; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTARoom.java b/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTARoom.java index a77f8170d8..6df7c96c37 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTARoom.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTARoom.java @@ -35,7 +35,7 @@ public abstract class MTARoom protected final MTAConfig config; @Inject - protected MTARoom(MTAConfig config) + protected MTARoom(final MTAConfig config) { this.config = config; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTASceneOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTASceneOverlay.java index 5ed9a7e6b1..c9c405aa75 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTASceneOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mta/MTASceneOverlay.java @@ -27,17 +27,19 @@ package net.runelite.client.plugins.mta; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; 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; +@Singleton public class MTASceneOverlay extends Overlay { private final MTAPlugin plugin; @Inject - public MTASceneOverlay(MTAPlugin plugin) + public MTASceneOverlay(final MTAPlugin plugin) { this.plugin = plugin; setPosition(OverlayPosition.DYNAMIC); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mta/alchemy/AlchemyItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/mta/alchemy/AlchemyItem.java index d690b7f16b..c7f45bfc50 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mta/alchemy/AlchemyItem.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mta/alchemy/AlchemyItem.java @@ -43,7 +43,7 @@ public enum AlchemyItem @Getter private final String name; - AlchemyItem(String name, int id) + AlchemyItem(final String name, final int id) { this.id = id; this.name = name; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mta/alchemy/AlchemyRoom.java b/runelite-client/src/main/java/net/runelite/client/plugins/mta/alchemy/AlchemyRoom.java index ff8224238f..b8bd37fa9c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mta/alchemy/AlchemyRoom.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mta/alchemy/AlchemyRoom.java @@ -58,6 +58,7 @@ import net.runelite.api.Player; import net.runelite.api.Point; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameObjectSpawned; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; @@ -97,20 +98,24 @@ public class AlchemyRoom extends MTARoom private AlchemyItem best; private Cupboard suggestion; + private boolean alchemy; + @Inject - private AlchemyRoom(Client client, MTAConfig config, MTAPlugin plugin, ItemManager itemManager, InfoBoxManager infoBoxManager) + private AlchemyRoom(final Client client, final MTAConfig config, final MTAPlugin plugin, final ItemManager itemManager, final InfoBoxManager infoBoxManager) { super(config); this.client = client; this.plugin = plugin; this.itemManager = itemManager; this.infoBoxManager = infoBoxManager; + + this.alchemy = config.alchemy(); } @Subscribe public void onGameTick(GameTick event) { - if (!inside() || !config.alchemy()) + if (!inside() || !this.alchemy) { return; } @@ -272,6 +277,17 @@ public class AlchemyRoom extends MTARoom } } + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("mta") || !event.getKey().equals("alchemy")) + { + return; + } + + this.alchemy = config.alchemy(); + } + private void reset() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mta/alchemy/AlchemyRoomTimer.java b/runelite-client/src/main/java/net/runelite/client/plugins/mta/alchemy/AlchemyRoomTimer.java index 693e0517c9..d5b23a07e9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mta/alchemy/AlchemyRoomTimer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mta/alchemy/AlchemyRoomTimer.java @@ -30,12 +30,12 @@ import net.runelite.client.plugins.Plugin; import net.runelite.client.ui.overlay.infobox.Timer; import net.runelite.client.util.ImageUtil; -public class AlchemyRoomTimer extends Timer +class AlchemyRoomTimer extends Timer { private static final int RESET_PERIOD = 42; private static BufferedImage image; - public AlchemyRoomTimer(Plugin plugin) + AlchemyRoomTimer(final Plugin plugin) { super(RESET_PERIOD, ChronoUnit.SECONDS, getResetImage(), plugin); this.setTooltip("Time until items swap"); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mta/enchantment/EnchantmentRoom.java b/runelite-client/src/main/java/net/runelite/client/plugins/mta/enchantment/EnchantmentRoom.java index ce82dc00cc..40a46c332d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mta/enchantment/EnchantmentRoom.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mta/enchantment/EnchantmentRoom.java @@ -35,6 +35,7 @@ import net.runelite.api.ItemID; import net.runelite.api.Player; import net.runelite.api.Tile; import net.runelite.api.coords.WorldPoint; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.ItemDespawned; @@ -51,11 +52,15 @@ public class EnchantmentRoom extends MTARoom private final Client client; private final List dragonstones = new ArrayList<>(); + private boolean enchantment; + @Inject - private EnchantmentRoom(MTAConfig config, Client client) + private EnchantmentRoom(final MTAConfig config, final Client client) { super(config); this.client = client; + + this.enchantment = config.enchantment(); } @Subscribe @@ -70,7 +75,7 @@ public class EnchantmentRoom extends MTARoom @Subscribe public void onGameTick(GameTick event) { - if (!inside() || !config.enchantment()) + if (!inside() || !this.enchantment) { return; } @@ -131,6 +136,17 @@ public class EnchantmentRoom extends MTARoom } } + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("mta") || !event.getKey().equals("enchantment")) + { + return; + } + + this.enchantment = config.enchantment(); + } + @Override public boolean inside() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mta/graveyard/GraveyardCounter.java b/runelite-client/src/main/java/net/runelite/client/plugins/mta/graveyard/GraveyardCounter.java index 59f78785c8..8db687282f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mta/graveyard/GraveyardCounter.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mta/graveyard/GraveyardCounter.java @@ -31,7 +31,7 @@ import net.runelite.client.ui.overlay.infobox.Counter; public class GraveyardCounter extends Counter { - GraveyardCounter(BufferedImage image, Plugin plugin) + GraveyardCounter(final BufferedImage image, final Plugin plugin) { super(image, plugin, 0); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mta/graveyard/GraveyardRoom.java b/runelite-client/src/main/java/net/runelite/client/plugins/mta/graveyard/GraveyardRoom.java index 6661b141ff..2c683989c6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mta/graveyard/GraveyardRoom.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mta/graveyard/GraveyardRoom.java @@ -35,6 +35,7 @@ import static net.runelite.api.ItemID.ANIMALS_BONES_6905; import static net.runelite.api.ItemID.ANIMALS_BONES_6906; import static net.runelite.api.ItemID.ANIMALS_BONES_6907; import net.runelite.api.Player; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.ItemContainerChanged; import net.runelite.client.eventbus.Subscribe; @@ -57,15 +58,18 @@ public class GraveyardRoom extends MTARoom private GraveyardCounter counter; + private boolean graveyard; + @Inject - private GraveyardRoom(MTAConfig config, Client client, MTAPlugin plugin, - ItemManager itemManager, InfoBoxManager infoBoxManager) + private GraveyardRoom(final MTAConfig config, final Client client, final MTAPlugin plugin, final ItemManager itemManager, final InfoBoxManager infoBoxManager) { super(config); this.client = client; this.plugin = plugin; this.itemManager = itemManager; this.infoBoxManager = infoBoxManager; + + this.graveyard = config.graveyard(); } @Override @@ -79,7 +83,7 @@ public class GraveyardRoom extends MTARoom @Subscribe public void onGameTick(GameTick tick) { - if (!inside() || !config.graveyard()) + if (!inside() || !this.graveyard) { if (this.counter != null) { @@ -113,6 +117,17 @@ public class GraveyardRoom extends MTARoom } } + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("mta") || !event.getKey().equals("graveyard")) + { + return; + } + + this.graveyard = config.graveyard(); + } + private int score(Item[] items) { int score = 0; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mta/telekinetic/Maze.java b/runelite-client/src/main/java/net/runelite/client/plugins/mta/telekinetic/Maze.java index bef5c1d201..77871deb92 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mta/telekinetic/Maze.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mta/telekinetic/Maze.java @@ -42,7 +42,7 @@ public enum Maze private final int walls; private final LocalPoint start; - Maze(int walls, LocalPoint start) + Maze(final int walls, final LocalPoint start) { this.walls = walls; this.start = start; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mta/telekinetic/TelekineticRoom.java b/runelite-client/src/main/java/net/runelite/client/plugins/mta/telekinetic/TelekineticRoom.java index ae797b74cd..557792c398 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mta/telekinetic/TelekineticRoom.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mta/telekinetic/TelekineticRoom.java @@ -54,6 +54,7 @@ import net.runelite.api.coords.Direction; import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.WorldArea; import net.runelite.api.coords.WorldPoint; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.GroundObjectSpawned; @@ -84,11 +85,15 @@ public class TelekineticRoom extends MTARoom private NPC guardian; private Maze maze; + private boolean telekinetic; + @Inject - private TelekineticRoom(MTAConfig config, Client client) + private TelekineticRoom(final MTAConfig config, final Client client) { super(config); this.client = client; + + this.telekinetic = config.telekinetic(); } public void resetRoom() @@ -133,7 +138,7 @@ public class TelekineticRoom extends MTARoom @Subscribe public void onGameTick(GameTick event) { - if (!config.telekinetic() + if (!this.telekinetic || !inside() || client.getGameState() != GameState.LOGGED_IN) { @@ -220,6 +225,17 @@ public class TelekineticRoom extends MTARoom } } + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("mta") || !event.getKey().equals("telekinetic")) + { + return; + } + + this.telekinetic = config.telekinetic(); + } + @Override public boolean inside() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MapLocations.java b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MapLocations.java index 044e9bdb36..cf7a0ef3da 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MapLocations.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MapLocations.java @@ -35,12 +35,12 @@ import net.runelite.api.Constants; public class MapLocations { - private static final List[] MULTICOMBAT = new List[Constants.MAX_Z]; - private static final List[] NOT_MULTICOMBAT = new List[Constants.MAX_Z]; - private static final List[] ROUGH_WILDERNESS = new List[Constants.MAX_Z]; + private static final List[] MULTICOMBAT = new List[Constants.MAX_Z]; + private static final List[] NOT_MULTICOMBAT = new List[Constants.MAX_Z]; + private static final List[] ROUGH_WILDERNESS = new List[Constants.MAX_Z]; private static final List[] WILDERNESS_LEVEL_LINES = new List[Constants.MAX_Z]; - private static final List[] DEADMAN_SAFE_ZONES = new List[Constants.MAX_Z]; - private static final List[] PVP_WORLD_SAFE_ZONES = new List[Constants.MAX_Z]; + private static final List[] DEADMAN_SAFE_ZONES = new List[Constants.MAX_Z]; + private static final List[] PVP_WORLD_SAFE_ZONES = new List[Constants.MAX_Z]; private static Area getArea(List shapes) { @@ -3453,7 +3453,6 @@ public class MapLocations int wildyLeftX = 2944; int wildyRightX = 3392; int wildyBottomY = 3525; - int wildyTopY = 3971; // define wilderness level lines at ground level int accumulatedY = 0; @@ -3482,9 +3481,9 @@ public class MapLocations { poly.addPoint(coords[i], coords[i + 1]); } - for (int i = 0; i < shapes.length; i++) + for (List shape : shapes) { - shapes[i].add(poly); + shape.add(poly); } } @@ -3497,17 +3496,4 @@ public class MapLocations } shapes[plane].add(poly); } - - private static void addPolygonOnPlanes(List[] shapes, int minPlane, int maxPlane, int... coords) - { - Polygon poly = new Polygon(); - for (int i = 0; i < coords.length; i += 2) - { - poly.addPoint(coords[i], coords[i + 1]); - } - for (int i = minPlane; i <= maxPlane; i++) - { - shapes[i].add(poly); - } - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsMinimapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsMinimapOverlay.java index b0c1187745..5ea7f57b24 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsMinimapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsMinimapOverlay.java @@ -32,6 +32,7 @@ import java.awt.Rectangle; import java.awt.geom.GeneralPath; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.geometry.Geometry; import net.runelite.api.Client; import net.runelite.api.Perspective; @@ -42,6 +43,7 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; +@Singleton public class MultiIndicatorsMinimapOverlay extends Overlay { private final static int MAX_LOCAL_DRAW_LENGTH = 20 * Perspective.LOCAL_TILE_SIZE; @@ -52,9 +54,6 @@ public class MultiIndicatorsMinimapOverlay extends Overlay @Inject private MultiIndicatorsPlugin plugin; - @Inject - private MultiIndicatorsConfig config; - @Inject public MultiIndicatorsMinimapOverlay() { @@ -86,8 +85,11 @@ public class MultiIndicatorsMinimapOverlay extends Overlay path = Geometry.transformPath(path, coords -> { Point point = Perspective.localToMinimap(client, new LocalPoint((int) coords[0], (int) coords[1])); - coords[0] = point.getX(); - coords[1] = point.getY(); + if (point != null) + { + coords[0] = point.getX(); + coords[1] = point.getY(); + } }); graphics.draw(path); @@ -96,7 +98,7 @@ public class MultiIndicatorsMinimapOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!config.showMinimapLines()) + if (!plugin.isShowMinimapLines()) { return null; } @@ -105,17 +107,17 @@ public class MultiIndicatorsMinimapOverlay extends Overlay GeneralPath pvpPath = plugin.getPvpPathToDisplay()[client.getPlane()]; GeneralPath wildernessLevelLinesPath = plugin.getWildernessLevelLinesPathToDisplay()[client.getPlane()]; - if (config.multicombatZoneVisibility() != ZoneVisibility.HIDE && multicombatPath != null) + if (plugin.getMulticombatZoneVisibility() != ZoneVisibility.HIDE && multicombatPath != null) { - renderPath(graphics, multicombatPath, getTransparentColorVersion(config.multicombatColor())); + renderPath(graphics, multicombatPath, getTransparentColorVersion(plugin.getMulticombatColor())); } - if ((config.showPvpSafeZones() || config.showDeadmanSafeZones()) && pvpPath != null) + if ((plugin.isShowPvpSafeZones() || plugin.isShowDeadmanSafeZones()) && pvpPath != null) { - renderPath(graphics, pvpPath, getTransparentColorVersion(config.safeZoneColor())); + renderPath(graphics, pvpPath, getTransparentColorVersion(plugin.getSafeZoneColor())); } - if (config.showWildernessLevelLines() && wildernessLevelLinesPath != null) + if (plugin.isShowWildernessLevelLines() && wildernessLevelLinesPath != null) { - renderPath(graphics, wildernessLevelLinesPath, getTransparentColorVersion(config.wildernessLevelLinesColor())); + renderPath(graphics, wildernessLevelLinesPath, getTransparentColorVersion(plugin.getWildernessLevelLinesColor())); } return null; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsOverlay.java index d9268121f0..dd134690ed 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsOverlay.java @@ -32,6 +32,7 @@ import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.geom.GeneralPath; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.geometry.Geometry; import net.runelite.api.Client; import net.runelite.api.Perspective; @@ -42,6 +43,7 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; +@Singleton public class MultiIndicatorsOverlay extends Overlay { private final static int MAX_LOCAL_DRAW_LENGTH = 20 * Perspective.LOCAL_TILE_SIZE; @@ -52,9 +54,6 @@ public class MultiIndicatorsOverlay extends Overlay @Inject private MultiIndicatorsPlugin plugin; - @Inject - private MultiIndicatorsConfig config; - @Inject public MultiIndicatorsOverlay() { @@ -101,17 +100,17 @@ public class MultiIndicatorsOverlay extends Overlay GeneralPath pvpPath = plugin.getPvpPathToDisplay()[client.getPlane()]; GeneralPath wildernessLevelLinesPath = plugin.getWildernessLevelLinesPathToDisplay()[client.getPlane()]; - if (config.multicombatZoneVisibility() != ZoneVisibility.HIDE && multicombatPath != null) + if (plugin.getMulticombatZoneVisibility() != ZoneVisibility.HIDE && multicombatPath != null) { - renderPath(graphics, multicombatPath, getTransparentColorVersion(config.multicombatColor())); + renderPath(graphics, multicombatPath, getTransparentColorVersion(plugin.getMulticombatColor())); } - if ((config.showPvpSafeZones() || config.showDeadmanSafeZones()) && pvpPath != null) + if ((plugin.isShowPvpSafeZones() || plugin.isShowDeadmanSafeZones()) && pvpPath != null) { - renderPath(graphics, pvpPath, getTransparentColorVersion(config.safeZoneColor())); + renderPath(graphics, pvpPath, getTransparentColorVersion(plugin.getSafeZoneColor())); } - if (config.showWildernessLevelLines() && wildernessLevelLinesPath != null) + if (plugin.isShowWildernessLevelLines() && wildernessLevelLinesPath != null) { - renderPath(graphics, wildernessLevelLinesPath, getTransparentColorVersion(config.wildernessLevelLinesColor())); + renderPath(graphics, wildernessLevelLinesPath, getTransparentColorVersion(plugin.getWildernessLevelLinesColor())); } return null; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsPlugin.java index c20fa25810..c9b025502f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/multiindicators/MultiIndicatorsPlugin.java @@ -26,11 +26,14 @@ package net.runelite.client.plugins.multiindicators; import com.google.inject.Provides; +import java.awt.Color; import java.awt.Rectangle; import java.awt.geom.GeneralPath; import java.time.temporal.ChronoUnit; import java.util.Arrays; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.Constants; @@ -62,7 +65,7 @@ import net.runelite.client.ui.overlay.OverlayManager; type = PluginType.PVP, enabledByDefault = false ) - +@Singleton public class MultiIndicatorsPlugin extends Plugin { @Inject @@ -83,23 +86,40 @@ public class MultiIndicatorsPlugin extends Plugin @Inject private OverlayManager overlayManager; - @Getter + @Getter(AccessLevel.PACKAGE) private GeneralPath[] multicombatPathToDisplay; - @Getter + @Getter(AccessLevel.PACKAGE) private GeneralPath[] pvpPathToDisplay; - @Getter + @Getter(AccessLevel.PACKAGE) private GeneralPath[] wildernessLevelLinesPathToDisplay; - @Getter + @Getter(AccessLevel.PACKAGE) private boolean inPvp; - @Getter + @Getter(AccessLevel.PACKAGE) private boolean inDeadman; private int currentPlane; + @Getter(AccessLevel.PACKAGE) + private ZoneVisibility multicombatZoneVisibility; + @Getter(AccessLevel.PACKAGE) + private boolean showPvpSafeZones; + @Getter(AccessLevel.PACKAGE) + private boolean showDeadmanSafeZones; + @Getter(AccessLevel.PACKAGE) + private boolean showWildernessLevelLines; + @Getter(AccessLevel.PACKAGE) + private boolean showMinimapLines; + @Getter(AccessLevel.PACKAGE) + private Color multicombatColor; + @Getter(AccessLevel.PACKAGE) + private Color safeZoneColor; + @Getter(AccessLevel.PACKAGE) + private Color wildernessLevelLinesColor; + @Provides MultiIndicatorsConfig getConfig(ConfigManager configManager) { @@ -109,6 +129,8 @@ public class MultiIndicatorsPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(overlay); overlayManager.add(minimapOverlay); @@ -165,9 +187,13 @@ public class MultiIndicatorsPlugin extends Plugin private void transformWorldToLocal(float[] coords) { LocalPoint lp = LocalPoint.fromWorld(client, (int) coords[0], (int) coords[1]); - coords[0] = lp.getX() - Perspective.LOCAL_TILE_SIZE / 2; - coords[1] = lp.getY() - Perspective.LOCAL_TILE_SIZE / 2; + if (lp != null) + { + coords[0] = lp.getX() - Perspective.LOCAL_TILE_SIZE / 2; + coords[1] = lp.getY() - Perspective.LOCAL_TILE_SIZE / 2; + } } + private boolean isOpenableAt(WorldPoint wp) { int sceneX = wp.getX() - client.getBaseX(); @@ -253,7 +279,7 @@ public class MultiIndicatorsPlugin extends Plugin Constants.SCENE_SIZE - 2, Constants.SCENE_SIZE - 2); // Generate lines for multicombat zones - if (config.multicombatZoneVisibility() == ZoneVisibility.HIDE) + if (this.multicombatZoneVisibility == ZoneVisibility.HIDE) { for (int i = 0; i < multicombatPathToDisplay.length; i++) { @@ -268,7 +294,7 @@ public class MultiIndicatorsPlugin extends Plugin GeneralPath lines = new GeneralPath(MapLocations.getMulticombat(sceneRect, i)); lines = Geometry.clipPath(lines, sceneRect); - if (config.multicombatZoneVisibility() == ZoneVisibility.SHOW_IN_PVP && + if (this.multicombatZoneVisibility == ZoneVisibility.SHOW_IN_PVP && !isInDeadman() && !isInPvp()) { lines = Geometry.clipPath(lines, MapLocations.getRoughWilderness(i)); @@ -289,11 +315,11 @@ public class MultiIndicatorsPlugin extends Plugin currentPlane = i; GeneralPath safeZonePath = null; - if (config.showDeadmanSafeZones() && isInDeadman()) + if (this.showDeadmanSafeZones && isInDeadman()) { safeZonePath = new GeneralPath(MapLocations.getDeadmanSafeZones(sceneRect, i)); } - else if (config.showPvpSafeZones() && isInPvp()) + else if (this.showPvpSafeZones && isInPvp()) { safeZonePath = new GeneralPath(MapLocations.getPvpSafeZones(sceneRect, i)); } @@ -316,7 +342,7 @@ public class MultiIndicatorsPlugin extends Plugin currentPlane = i; GeneralPath wildernessLevelLinesPath = null; - if (config.showWildernessLevelLines()) + if (this.showWildernessLevelLines) { wildernessLevelLinesPath = new GeneralPath(MapLocations.getWildernessLevelLines(sceneRect, i)); } @@ -343,6 +369,13 @@ public class MultiIndicatorsPlugin extends Plugin @Subscribe public void onConfigChanged(ConfigChanged event) { + if (!event.getGroup().equals("multiindicators")) + { + return; + } + + updateConfig(); + if (event.getKey().equals("collisionDetection") || event.getKey().equals("multicombatZoneVisibility") || event.getKey().equals("deadmanSafeZones") || @@ -361,4 +394,16 @@ public class MultiIndicatorsPlugin extends Plugin findLinesInScene(); } } + + private void updateConfig() + { + this.multicombatZoneVisibility = config.multicombatZoneVisibility(); + this.showPvpSafeZones = config.showPvpSafeZones(); + this.showDeadmanSafeZones = config.showDeadmanSafeZones(); + this.showWildernessLevelLines = config.showDeadmanSafeZones(); + this.showMinimapLines = config.showMinimapLines(); + this.multicombatColor = config.multicombatColor(); + this.safeZoneColor = config.safeZoneColor(); + this.wildernessLevelLinesColor = config.wildernessLevelLinesColor(); + } } 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 index 694fc83698..1974109215 100644 --- 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 @@ -32,6 +32,7 @@ import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.EnumDefinition; @@ -55,7 +56,7 @@ import net.runelite.client.plugins.PluginType; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton public class MusicIndicatorPlugin extends Plugin { private static final List MUSIC_TRACK_VARPS = ImmutableList.of( diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/musiclist/MusicListPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/musiclist/MusicListPlugin.java index ab38b515f9..683666c2bc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/musiclist/MusicListPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/musiclist/MusicListPlugin.java @@ -29,6 +29,7 @@ import java.util.Collection; import java.util.Comparator; import java.util.stream.Collectors; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.Client; @@ -57,6 +58,7 @@ import net.runelite.client.plugins.PluginDescriptor; name = "Music List", description = "Adds search and filter for the music list" ) +@Singleton public class MusicListPlugin extends Plugin { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/AbsorptionCounter.java b/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/AbsorptionCounter.java index 3f91d8ee15..e6491a6205 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/AbsorptionCounter.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/AbsorptionCounter.java @@ -26,11 +26,12 @@ package net.runelite.client.plugins.nightmarezone; import java.awt.Color; import java.awt.image.BufferedImage; +import lombok.AccessLevel; import lombok.Setter; import net.runelite.client.plugins.Plugin; import net.runelite.client.ui.overlay.infobox.Counter; -@Setter +@Setter(AccessLevel.PACKAGE) public class AbsorptionCounter extends Counter { private int threshold; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZoneOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZoneOverlay.java index 5a0a58e9da..247b2f97ab 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZoneOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZoneOverlay.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.nightmarezone; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.ItemID; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; @@ -46,10 +47,10 @@ import net.runelite.client.ui.overlay.components.table.TableComponent; import net.runelite.client.ui.overlay.infobox.InfoBoxManager; import net.runelite.client.util.StackFormatter; +@Singleton class NightmareZoneOverlay extends Overlay { private final Client client; - private final NightmareZoneConfig config; private final NightmareZonePlugin plugin; private final InfoBoxManager infoBoxManager; private final ItemManager itemManager; @@ -59,17 +60,15 @@ class NightmareZoneOverlay extends Overlay @Inject NightmareZoneOverlay( - Client client, - NightmareZoneConfig config, - NightmareZonePlugin plugin, - InfoBoxManager infoBoxManager, - ItemManager itemManager) + final Client client, + final NightmareZonePlugin plugin, + final InfoBoxManager infoBoxManager, + final ItemManager itemManager) { super(plugin); setPosition(OverlayPosition.TOP_LEFT); setPriority(OverlayPriority.LOW); this.client = client; - this.config = config; this.plugin = plugin; this.infoBoxManager = infoBoxManager; this.itemManager = itemManager; @@ -79,7 +78,7 @@ class NightmareZoneOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!plugin.isInNightmareZone() || !config.moveOverlay()) + if (plugin.isNotInNightmareZone() || !plugin.isMoveOverlay()) { if (absorptionCounter != null) { @@ -108,7 +107,7 @@ class NightmareZoneOverlay extends Overlay tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT); tableComponent.addRow("Points:", StackFormatter.formatNumber(client.getVar(Varbits.NMZ_POINTS))); - if (config.showtotalpoints()) + if (plugin.isShowtotalpoints()) { tableComponent.addRow("Total:", StackFormatter.formatNumber(client.getVar(VarPlayer.NMZ_REWARD_POINTS) + client.getVar(Varbits.NMZ_POINTS))); } @@ -129,7 +128,7 @@ class NightmareZoneOverlay extends Overlay absorptionCounter = null; } } - else if (config.moveOverlay()) + else if (plugin.isMoveOverlay()) { if (absorptionCounter == null) { @@ -144,9 +143,9 @@ class NightmareZoneOverlay extends Overlay private void addAbsorptionCounter(int startValue) { - absorptionCounter = new AbsorptionCounter(itemManager.getImage(ItemID.ABSORPTION_4), plugin, startValue, config.absorptionThreshold()); - absorptionCounter.setAboveThresholdColor(config.absorptionColorAboveThreshold()); - absorptionCounter.setBelowThresholdColor(config.absorptionColorBelowThreshold()); + absorptionCounter = new AbsorptionCounter(itemManager.getImage(ItemID.ABSORPTION_4), plugin, startValue, plugin.getAbsorptionThreshold()); + absorptionCounter.setAboveThresholdColor(plugin.getAbsorptionColorAboveThreshold()); + absorptionCounter.setBelowThresholdColor(plugin.getAbsorptionColorBelowThreshold()); infoBoxManager.addInfoBox(absorptionCounter); } @@ -160,9 +159,9 @@ class NightmareZoneOverlay extends Overlay { if (absorptionCounter != null) { - absorptionCounter.setAboveThresholdColor(config.absorptionColorAboveThreshold()); - absorptionCounter.setBelowThresholdColor(config.absorptionColorBelowThreshold()); - absorptionCounter.setThreshold(config.absorptionThreshold()); + absorptionCounter.setAboveThresholdColor(plugin.getAbsorptionColorAboveThreshold()); + absorptionCounter.setBelowThresholdColor(plugin.getAbsorptionColorBelowThreshold()); + absorptionCounter.setThreshold(plugin.getAbsorptionThreshold()); } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZonePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZonePlugin.java index 3d038163d7..63fffe5396 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZonePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZonePlugin.java @@ -25,8 +25,12 @@ package net.runelite.client.plugins.nightmarezone; import com.google.inject.Provides; +import java.awt.Color; import java.util.Arrays; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; import net.runelite.api.Varbits; @@ -48,6 +52,7 @@ import net.runelite.client.util.Text; description = "Show NMZ points/absorption and/or notify about expiring potions", tags = {"combat", "nmz", "minigame", "notifications"} ) +@Singleton public class NightmareZonePlugin extends Plugin { private static final int[] NMZ_MAP_REGION = {9033}; @@ -71,9 +76,28 @@ public class NightmareZonePlugin extends Plugin // above the threshold before sending notifications private boolean absorptionNotificationSend = true; + @Getter(AccessLevel.PACKAGE) + private boolean moveOverlay; + @Getter(AccessLevel.PACKAGE) + private boolean showtotalpoints; + private boolean powerSurgeNotification; + private boolean recurrentDamageNotification; + private boolean zapperNotification; + private boolean ultimateForceNotification; + private boolean overloadNotification; + private boolean absorptionNotification; + @Getter(AccessLevel.PACKAGE) + private int absorptionThreshold; + @Getter(AccessLevel.PACKAGE) + private Color absorptionColorAboveThreshold; + @Getter(AccessLevel.PACKAGE) + private Color absorptionColorBelowThreshold; + @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(overlay); overlay.removeAbsorptionCounter(); } @@ -95,6 +119,12 @@ public class NightmareZonePlugin extends Plugin @Subscribe public void onConfigChanged(ConfigChanged event) { + if (!event.getGroup().equals("nightmareZone")) + { + return; + } + + updateConfig(); overlay.updateConfig(); } @@ -107,7 +137,7 @@ public class NightmareZonePlugin extends Plugin @Subscribe public void onGameTick(GameTick event) { - if (!isInNightmareZone()) + if (isNotInNightmareZone()) { if (!absorptionNotificationSend) { @@ -116,7 +146,8 @@ public class NightmareZonePlugin extends Plugin return; } - if (config.absorptionNotification()) + + if (this.absorptionNotification) { checkAbsorption(); } @@ -126,7 +157,7 @@ public class NightmareZonePlugin extends Plugin public void onChatMessage(ChatMessage event) { if (event.getType() != ChatMessageType.GAMEMESSAGE - || !isInNightmareZone()) + || isNotInNightmareZone()) { return; } @@ -134,7 +165,7 @@ public class NightmareZonePlugin extends Plugin String msg = Text.removeTags(event.getMessage()); //remove color if (msg.contains("The effects of overload have worn off, and you feel normal again.")) { - if (config.overloadNotification()) + if (this.overloadNotification) { notifier.notify("Your overload has worn off"); } @@ -143,28 +174,28 @@ public class NightmareZonePlugin extends Plugin { if (msg.contains("Power surge")) { - if (config.powerSurgeNotification()) + if (this.powerSurgeNotification) { notifier.notify(msg); } } else if (msg.contains("Recurrent damage")) { - if (config.recurrentDamageNotification()) + if (this.recurrentDamageNotification) { notifier.notify(msg); } } else if (msg.contains("Zapper")) { - if (config.zapperNotification()) + if (this.zapperNotification) { notifier.notify(msg); } } else if (msg.contains("Ultimate force")) { - if (config.ultimateForceNotification()) + if (this.ultimateForceNotification) { notifier.notify(msg); } @@ -178,23 +209,38 @@ public class NightmareZonePlugin extends Plugin if (!absorptionNotificationSend) { - if (absorptionPoints < config.absorptionThreshold()) + if (absorptionPoints < this.absorptionThreshold) { - notifier.notify("Absorption points below: " + config.absorptionThreshold()); + notifier.notify("Absorption points below: " + this.absorptionThreshold); absorptionNotificationSend = true; } } else { - if (absorptionPoints > config.absorptionThreshold()) + if (absorptionPoints > this.absorptionThreshold) { absorptionNotificationSend = false; } } } - public boolean isInNightmareZone() + boolean isNotInNightmareZone() { - return Arrays.equals(client.getMapRegions(), NMZ_MAP_REGION); + return !Arrays.equals(client.getMapRegions(), NMZ_MAP_REGION); + } + + private void updateConfig() + { + this.moveOverlay = config.moveOverlay(); + this.showtotalpoints = config.showtotalpoints(); + this.powerSurgeNotification = config.powerSurgeNotification(); + this.recurrentDamageNotification = config.recurrentDamageNotification(); + this.zapperNotification = config.zapperNotification(); + this.ultimateForceNotification = config.ultimateForceNotification(); + this.overloadNotification = config.overloadNotification(); + this.absorptionNotification = config.absorptionNotification(); + this.absorptionThreshold = config.absorptionThreshold(); + this.absorptionColorAboveThreshold = config.absorptionColorAboveThreshold(); + this.absorptionColorBelowThreshold = config.absorptionColorBelowThreshold(); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/notes/NotesPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/notes/NotesPanel.java index b051cf0e5e..4092f2c15b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/notes/NotesPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/notes/NotesPanel.java @@ -29,6 +29,7 @@ import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; +import javax.inject.Singleton; import javax.swing.AbstractAction; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -44,12 +45,13 @@ import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.PluginPanel; @Slf4j +@Singleton class NotesPanel extends PluginPanel { private final JTextArea notesEditor = new JTextArea(); private final UndoManager undoRedo = new UndoManager(); - void init(NotesConfig config) + void init(final NotesConfig config) { // this may or may not qualify as a hack // but this lets the editor pane expand to fill the whole parent panel diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/notes/NotesPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/notes/NotesPlugin.java index c923a0eefe..e765944fbd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/notes/NotesPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/notes/NotesPlugin.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.notes; import com.google.inject.Provides; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.SessionOpen; @@ -42,6 +43,7 @@ import net.runelite.client.util.ImageUtil; tags = {"panel"}, loadWhenOutdated = true ) +@Singleton public class NotesPlugin extends Plugin { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/MemorizedNpc.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/MemorizedNpc.java index 404748db74..8bc34e7738 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/MemorizedNpc.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/MemorizedNpc.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import net.runelite.api.NPC; @@ -36,34 +37,34 @@ import net.runelite.api.coords.WorldPoint; class MemorizedNpc { - @Getter + @Getter(AccessLevel.PACKAGE) private int npcIndex; - @Getter + @Getter(AccessLevel.PACKAGE) private Set npcNames; - @Getter + @Getter(AccessLevel.PACKAGE) private int npcSize; /** * The time the npc died at, in game ticks, relative to the tick counter */ - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private int diedOnTick; /** * The time it takes for the npc to respawn, in game ticks */ - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private int respawnTime; - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private List possibleRespawnLocations; - MemorizedNpc(NPC npc) + MemorizedNpc(final NPC npc) { this.npcNames = new HashSet<>(); this.npcNames.add(npc.getName()); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java index 2e1d0cdfa4..122599d15c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java @@ -28,6 +28,7 @@ package net.runelite.client.plugins.npchighlight; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableSet; import com.google.inject.Provides; +import java.awt.Color; import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; @@ -39,6 +40,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; @@ -78,6 +80,7 @@ import net.runelite.client.util.WildcardMatcher; tags = {"highlight", "minimap", "npcs", "overlay", "respawn", "tags"} ) @Slf4j +@Singleton public class NpcIndicatorsPlugin extends Plugin { private static final int MAX_ACTOR_VIEW_RANGE = 15; @@ -179,6 +182,21 @@ public class NpcIndicatorsPlugin extends Plugin */ private boolean skipNextSpawnCheck = false; + @Getter(AccessLevel.PACKAGE) + private RenderStyle renderStyle; + @Setter(AccessLevel.PACKAGE) + private String getNpcToHighlight; + @Getter(AccessLevel.PACKAGE) + private Color getHighlightColor; + @Getter(AccessLevel.PACKAGE) + private boolean drawNames; + @Getter(AccessLevel.PACKAGE) + private boolean drawMinimapNames; + @Getter(AccessLevel.PACKAGE) + private boolean highlightMenuNames; + @Getter(AccessLevel.PACKAGE) + private boolean showRespawnTimer; + @Provides NpcIndicatorsConfig provideConfig(ConfigManager configManager) { @@ -188,6 +206,8 @@ public class NpcIndicatorsPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(npcSceneOverlay); overlayManager.add(npcMinimapOverlay); keyManager.registerKeyListener(inputListener); @@ -236,6 +256,8 @@ public class NpcIndicatorsPlugin extends Plugin return; } + updateConfig(); + highlights = getHighlights(); rebuildAllNpcs(); } @@ -261,7 +283,7 @@ public class NpcIndicatorsPlugin extends Plugin type -= MENU_ACTION_DEPRIORITIZE_OFFSET; } - if (config.highlightMenuNames() && + if (this.highlightMenuNames && NPC_MENU_ACTIONS.contains(MenuAction.of(type)) && highlightedNpcs.stream().anyMatch(npc -> npc.getIndex() == event.getIdentifier())) { @@ -490,7 +512,7 @@ public class NpcIndicatorsPlugin extends Plugin @VisibleForTesting List getHighlights() { - final String configNpcs = config.getNpcToHighlight().toLowerCase(); + final String configNpcs = this.getNpcToHighlight.toLowerCase(); if (configNpcs.isEmpty()) { @@ -619,4 +641,15 @@ public class NpcIndicatorsPlugin extends Plugin despawnedNpcsThisTick.clear(); teleportGraphicsObjectSpawnedThisTick.clear(); } + + private void updateConfig() + { + this.renderStyle = config.renderStyle(); + this.getNpcToHighlight = config.getNpcToHighlight(); + this.getHighlightColor = config.getHighlightColor(); + this.drawNames = config.drawNames(); + this.drawMinimapNames = config.drawMinimapNames(); + this.highlightMenuNames = config.highlightMenuNames(); + this.showRespawnTimer = config.showRespawnTimer(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcMinimapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcMinimapOverlay.java index 2e46b11bd7..bb5519202c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcMinimapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcMinimapOverlay.java @@ -29,7 +29,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; -import net.runelite.api.Client; +import javax.inject.Singleton; import net.runelite.api.NPC; import net.runelite.api.Point; import net.runelite.client.ui.overlay.Overlay; @@ -37,17 +37,14 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton public class NpcMinimapOverlay extends Overlay { - private final Client client; - private final NpcIndicatorsConfig config; private final NpcIndicatorsPlugin plugin; @Inject - NpcMinimapOverlay(Client client, NpcIndicatorsConfig config, NpcIndicatorsPlugin plugin) + NpcMinimapOverlay(final NpcIndicatorsPlugin plugin) { - this.client = client; - this.config = config; this.plugin = plugin; setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); @@ -58,7 +55,7 @@ public class NpcMinimapOverlay extends Overlay { for (NPC npc : plugin.getHighlightedNpcs()) { - renderNpcOverlay(graphics, npc, npc.getName(), config.getHighlightColor()); + renderNpcOverlay(graphics, npc, npc.getName(), plugin.getGetHighlightColor()); } return null; @@ -71,7 +68,7 @@ public class NpcMinimapOverlay extends Overlay { OverlayUtil.renderMinimapLocation(graphics, minimapLocation, color.darker()); - if (config.drawMinimapNames()) + if (plugin.isDrawMinimapNames()) { OverlayUtil.renderTextLocation(graphics, minimapLocation, name, color); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java index 7fd4cff995..900072d4e3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcSceneOverlay.java @@ -35,6 +35,7 @@ import java.text.NumberFormat; import java.time.Instant; import java.util.Locale; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Constants; import net.runelite.api.NPC; @@ -50,6 +51,7 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.util.Text; +@Singleton public class NpcSceneOverlay extends Overlay { private static final Color TRANSPARENT = new Color(0, 0, 0, 0); @@ -66,15 +68,13 @@ public class NpcSceneOverlay extends Overlay } private final Client client; - private final NpcIndicatorsConfig config; private final NpcIndicatorsPlugin plugin; private final ModelOutlineRenderer modelOutliner; @Inject - NpcSceneOverlay(Client client, NpcIndicatorsConfig config, NpcIndicatorsPlugin plugin, ModelOutlineRenderer modelOutliner) + NpcSceneOverlay(final Client client, final NpcIndicatorsPlugin plugin, final ModelOutlineRenderer modelOutliner) { this.client = client; - this.config = config; this.plugin = plugin; this.modelOutliner = modelOutliner; setPosition(OverlayPosition.DYNAMIC); @@ -84,14 +84,14 @@ public class NpcSceneOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (config.showRespawnTimer()) + if (plugin.isShowRespawnTimer()) { plugin.getDeadNpcsToDisplay().forEach((id, npc) -> renderNpcRespawn(npc, graphics)); } for (NPC npc : plugin.getHighlightedNpcs()) { - renderNpcOverlay(graphics, npc, config.getHighlightColor()); + renderNpcOverlay(graphics, npc, plugin.getGetHighlightColor()); } return null; @@ -112,7 +112,7 @@ public class NpcSceneOverlay extends Overlay return; } - final Color color = config.getHighlightColor(); + final Color color = plugin.getGetHighlightColor(); final LocalPoint centerLp = new LocalPoint( lp.getX() + Perspective.LOCAL_TILE_SIZE * (npc.getNpcSize() - 1) / 2, @@ -149,7 +149,7 @@ public class NpcSceneOverlay extends Overlay private void renderNpcOverlay(Graphics2D graphics, NPC actor, Color color) { - switch (config.renderStyle()) + switch (plugin.getRenderStyle()) { case SOUTH_WEST_TILE: LocalPoint lp1 = LocalPoint.fromWorld(client, actor.getWorldLocation()); @@ -194,7 +194,7 @@ public class NpcSceneOverlay extends Overlay break; } - if (config.drawNames() && actor.getName() != null) + if (plugin.isDrawNames() && actor.getName() != null) { String npcName = Text.removeTags(actor.getName()); Point textLocation = actor.getCanvasTextLocation(graphics, npcName, actor.getLogicalHeight() + 40); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/MemorizedNPC.java b/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/MemorizedNPC.java index 4a746e63db..01d44c8379 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/MemorizedNPC.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/MemorizedNPC.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.npcstatus; import java.awt.Color; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; @@ -39,22 +40,22 @@ class MemorizedNPC private int npcIndex; private String npcName; private int attackSpeed; - @Setter + @Setter(AccessLevel.PACKAGE) private int combatTimerEnd; - @Setter + @Setter(AccessLevel.PACKAGE) private int timeLeft; - @Setter + @Setter(AccessLevel.PACKAGE) private int flinchTimerEnd; - @Setter + @Setter(AccessLevel.PACKAGE) private Status status; - @Setter + @Setter(AccessLevel.PACKAGE) private WorldArea lastnpcarea; - @Setter + @Setter(AccessLevel.PACKAGE) private Actor lastinteracted; - @Setter + @Setter(AccessLevel.PACKAGE) private int lastspotanimation; - MemorizedNPC(NPC npc, int attackSpeed, WorldArea worldArea) + MemorizedNPC(final NPC npc, final int attackSpeed, final WorldArea worldArea) { this.npc = npc; this.npcIndex = npc.getIndex(); @@ -69,7 +70,7 @@ class MemorizedNPC this.lastspotanimation = -1; } - @Getter + @Getter(AccessLevel.PACKAGE) @AllArgsConstructor enum Status { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/NpcStatusConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/NpcStatusConfig.java index bf0495fae5..5b0b0c97e7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/NpcStatusConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/NpcStatusConfig.java @@ -32,9 +32,9 @@ import net.runelite.client.config.ConfigItem; public interface NpcStatusConfig extends Config { @ConfigItem( - keyName = "AttackRange", - name = "NPC Attack range", - description = "The attack range of the NPC" + keyName = "AttackRange", + name = "NPC Attack range", + description = "The attack range of the NPC" ) default int getRange() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/NpcStatusOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/NpcStatusOverlay.java index 7b948f24c0..8814b6769a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/NpcStatusOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/NpcStatusOverlay.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.npcstatus; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Point; import net.runelite.client.ui.overlay.Overlay; @@ -34,13 +35,14 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton public class NpcStatusOverlay extends Overlay { private final Client client; private final NpcStatusPlugin plugin; @Inject - NpcStatusOverlay(Client client, NpcStatusPlugin plugin) + NpcStatusOverlay(final Client client, final NpcStatusPlugin plugin) { this.client = client; this.plugin = plugin; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/NpcStatusPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/NpcStatusPlugin.java index 0f1a59a17a..9e6af3cc93 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/NpcStatusPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npcstatus/NpcStatusPlugin.java @@ -30,6 +30,7 @@ import java.util.Arrays; import java.util.HashSet; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -39,6 +40,7 @@ import net.runelite.api.GraphicID; import net.runelite.api.Hitsplat; import net.runelite.api.NPC; import net.runelite.api.coords.WorldArea; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.HitsplatApplied; @@ -46,7 +48,6 @@ import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcSpawned; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; -import net.runelite.client.game.ItemManager; import net.runelite.client.game.NPCManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; @@ -59,26 +60,34 @@ import net.runelite.client.ui.overlay.OverlayManager; tags = {"flinch", "npc"}, enabledByDefault = false ) +@Singleton public class NpcStatusPlugin extends Plugin { @Getter(AccessLevel.PACKAGE) private final Set memorizedNPCs = new HashSet<>(); + @Inject private Client client; + @Inject private OverlayManager overlayManager; - @Inject - private ItemManager itemManager; + @Inject private NPCManager npcManager; + @Inject private NpcStatusConfig config; + @Inject private NpcStatusOverlay npcStatusOverlay; + @Getter(AccessLevel.PACKAGE) private Instant lastTickUpdate; + private WorldArea lastPlayerLocation; + private int getRange; + @Provides NpcStatusConfig provideConfig(ConfigManager configManager) { @@ -88,6 +97,7 @@ public class NpcStatusPlugin extends Plugin @Override protected void startUp() throws Exception { + this.getRange = config.getRange(); overlayManager.add(npcStatusOverlay); } @@ -169,7 +179,7 @@ public class NpcStatusPlugin extends Plugin if (npc.getLastspotanimation() == GraphicID.SPLASH && npc.getNpc().getSpotAnimation() == GraphicID.SPLASH) //For splash flinching { npc.setLastspotanimation(-1); - if ((npc.getStatus() == MemorizedNPC.Status.OUT_OF_COMBAT ) || npc.getLastinteracted() == null) + if ((npc.getStatus() == MemorizedNPC.Status.OUT_OF_COMBAT) || npc.getLastinteracted() == null) { npc.setStatus(MemorizedNPC.Status.FLINCHING); npc.setCombatTimerEnd(-1); @@ -180,8 +190,8 @@ public class NpcStatusPlugin extends Plugin } } //Checks: will the NPC attack this tick? - if (((npc.getNpc().getWorldArea().canMelee(client, lastPlayerLocation) && config.getRange() == 1) //Separate mechanics for meleerange-only NPC's because they have extra collisiondata checks (fences etc.) and can't attack diagonally - || (lastPlayerLocation.hasLineOfSightTo(client, npc.getNpc().getWorldArea()) && npc.getNpc().getWorldArea().distanceTo(lastPlayerLocation) <= config.getRange() && config.getRange() > 1)) + if (((npc.getNpc().getWorldArea().canMelee(client, lastPlayerLocation) && this.getRange == 1) //Separate mechanics for meleerange-only NPC's because they have extra collisiondata checks (fences etc.) and can't attack diagonally + || (lastPlayerLocation.hasLineOfSightTo(client, npc.getNpc().getWorldArea()) && npc.getNpc().getWorldArea().distanceTo(lastPlayerLocation) <= this.getRange && this.getRange > 1)) && ((npc.getStatus() != MemorizedNPC.Status.FLINCHING && CombatTime < 9) || (npc.getStatus() == MemorizedNPC.Status.FLINCHING && FlinchTime < 2)) && npc.getNpc().getAnimation() != -1 //Failsafe, attacking NPC's always have an animation. && !(npc.getLastnpcarea().distanceTo(lastPlayerLocation) == 0 && npc.getLastnpcarea() != npc.getNpc().getWorldArea())) //Weird mechanic: NPC's can't attack on the tick they do a random move @@ -228,4 +238,15 @@ public class NpcStatusPlugin extends Plugin checkStatus(); lastPlayerLocation = client.getLocalPlayer().getWorldArea(); } + + @Subscribe + public void onConfigChanged(ConfigChanged configChanged) + { + if (!configChanged.getGroup().equals("npcstatus")) + { + return; + } + + this.getRange = config.getRange(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/AggressionTimer.java b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/AggressionTimer.java index 7194d2ddd6..5a091eaabd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/AggressionTimer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/AggressionTimer.java @@ -29,6 +29,7 @@ import java.awt.image.BufferedImage; import java.time.Duration; import java.time.Instant; import java.time.temporal.ChronoUnit; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import net.runelite.client.plugins.Plugin; @@ -36,11 +37,11 @@ import net.runelite.client.ui.overlay.infobox.Timer; class AggressionTimer extends Timer { - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private boolean visible; - AggressionTimer(Duration duration, BufferedImage image, Plugin plugin, boolean visible) + AggressionTimer(final Duration duration, final BufferedImage image, final Plugin plugin, final boolean visible) { super(duration.toMillis(), ChronoUnit.MILLIS, image, plugin); setTooltip("Time until NPCs become unaggressive"); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaNotWorkingOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaNotWorkingOverlay.java index 3d238cce85..533d4ae93b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaNotWorkingOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaNotWorkingOverlay.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.npcunaggroarea; import com.google.inject.Inject; +import com.google.inject.Singleton; import java.awt.Dimension; import java.awt.Graphics2D; import net.runelite.client.ui.overlay.Overlay; @@ -33,17 +34,16 @@ import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.components.LineComponent; import net.runelite.client.ui.overlay.components.PanelComponent; +@Singleton class NpcAggroAreaNotWorkingOverlay extends Overlay { private final NpcAggroAreaPlugin plugin; - private final NpcAggroAreaConfig config; private final PanelComponent panelComponent; @Inject - private NpcAggroAreaNotWorkingOverlay(NpcAggroAreaPlugin plugin, NpcAggroAreaConfig config) + private NpcAggroAreaNotWorkingOverlay(final NpcAggroAreaPlugin plugin) { this.plugin = plugin; - this.config = config; panelComponent = new PanelComponent(); panelComponent.setPreferredSize(new Dimension(150, 0)); @@ -58,7 +58,7 @@ class NpcAggroAreaNotWorkingOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!plugin.isActive() || plugin.getSafeCenters()[1] != null || config.hideOverlayHint()) + if (!plugin.isActive() || plugin.getSafeCenters()[1] != null || plugin.isHideOverlayHint()) { return null; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaOverlay.java index 2090fca5c2..5a295e2f35 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaOverlay.java @@ -24,6 +24,7 @@ */ package net.runelite.client.plugins.npcunaggroarea; +import javax.inject.Singleton; import net.runelite.api.geometry.Geometry; import java.awt.BasicStroke; import java.awt.Color; @@ -42,19 +43,18 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; +@Singleton class NpcAggroAreaOverlay extends Overlay { private static final int MAX_LOCAL_DRAW_LENGTH = 20 * Perspective.LOCAL_TILE_SIZE; private final Client client; - private final NpcAggroAreaConfig config; private final NpcAggroAreaPlugin plugin; @Inject - private NpcAggroAreaOverlay(Client client, NpcAggroAreaConfig config, NpcAggroAreaPlugin plugin) + private NpcAggroAreaOverlay(final Client client, final NpcAggroAreaPlugin plugin) { this.client = client; - this.config = config; this.plugin = plugin; setLayer(OverlayLayer.ABOVE_SCENE); @@ -76,7 +76,7 @@ class NpcAggroAreaOverlay extends Overlay return null; } - Color outlineColor = config.aggroAreaColor(); + Color outlineColor = plugin.getAggroAreaColor(); AggressionTimer timer = plugin.getCurrentTimer(); if (timer == null || Instant.now().compareTo(timer.getEndTime()) < 0) { 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 d7aede1a4f..d4093c07a5 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 @@ -24,6 +24,9 @@ */ package net.runelite.client.plugins.npcunaggroarea; +import java.awt.Color; +import javax.inject.Singleton; +import lombok.AccessLevel; import net.runelite.api.geometry.Geometry; import com.google.common.base.Splitter; import com.google.common.base.Strings; @@ -69,6 +72,7 @@ import net.runelite.client.util.WildcardMatcher; tags = {"highlight", "lines", "unaggro", "aggro", "aggressive", "npcs", "area", "slayer"}, enabledByDefault = false ) +@Singleton public class NpcAggroAreaPlugin extends Plugin { /* @@ -112,18 +116,28 @@ public class NpcAggroAreaPlugin extends Plugin @Inject private ConfigManager configManager; - @Getter + @Getter(AccessLevel.PACKAGE) private final WorldPoint[] safeCenters = new WorldPoint[2]; - @Getter + @Getter(AccessLevel.PACKAGE) private final GeneralPath[] linesToDisplay = new GeneralPath[Constants.MAX_Z]; - @Getter + @Getter(AccessLevel.PACKAGE) private boolean active; - @Getter + @Getter(AccessLevel.PACKAGE) private AggressionTimer currentTimer; + private boolean alwaysActive; + private String configNpcNamePatterns; + private boolean showTimer; + private boolean showAreaLines; + @Getter(AccessLevel.PACKAGE) + private Color aggroAreaColor; + private boolean showNotWorkingOverlay; + @Getter(AccessLevel.PACKAGE) + private boolean hideOverlayHint; + private WorldPoint lastPlayerLocation; private WorldPoint previousUnknownCenter; private boolean loggingIn; @@ -139,14 +153,16 @@ public class NpcAggroAreaPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(overlay); - if (config.showNotWorkingOverlay()) + if (this.showNotWorkingOverlay) { overlayManager.add(notWorkingOverlay); notWorkingOverlayShown = true; } - npcNamePatterns = NAME_SPLITTER.splitToList(config.npcNamePatterns()); + npcNamePatterns = NAME_SPLITTER.splitToList(this.configNpcNamePatterns); recheckActive(); } @@ -203,7 +219,7 @@ public class NpcAggroAreaPlugin extends Plugin { if (currentTimer != null) { - currentTimer.setVisible(active && config.showTimer()); + currentTimer.setVisible(active && this.showTimer); } calculateLinesToDisplay(); @@ -211,7 +227,7 @@ public class NpcAggroAreaPlugin extends Plugin private void calculateLinesToDisplay() { - if (!active || !config.showAreaLines()) + if (!active || !this.showAreaLines) { Arrays.fill(linesToDisplay, null); return; @@ -241,7 +257,7 @@ public class NpcAggroAreaPlugin extends Plugin { removeTimer(); BufferedImage image = itemManager.getImage(ItemID.ENSOULED_DEMON_HEAD); - currentTimer = new AggressionTimer(duration, image, this, active && config.showTimer()); + currentTimer = new AggressionTimer(duration, image, this, active && this.showTimer); infoBoxManager.addInfoBox(currentTimer); } @@ -310,14 +326,14 @@ public class NpcAggroAreaPlugin extends Plugin private void recheckActive() { - active = config.alwaysActive(); + active = this.alwaysActive; checkAreaNpcs(client.getCachedNPCs()); } @Subscribe public void onNpcSpawned(NpcSpawned event) { - if (config.alwaysActive()) + if (this.alwaysActive) { return; } @@ -374,6 +390,13 @@ public class NpcAggroAreaPlugin extends Plugin @Subscribe public void onConfigChanged(ConfigChanged event) { + if (!event.getGroup().equals("npcUnaggroArea")) + { + return; + } + + updateConfig(); + String key = event.getKey(); switch (key) { @@ -383,7 +406,7 @@ public class NpcAggroAreaPlugin extends Plugin case "npcUnaggroShowTimer": if (currentTimer != null) { - currentTimer.setVisible(active && config.showTimer()); + currentTimer.setVisible(active && this.showTimer); } break; case "npcUnaggroCollisionDetection": @@ -391,7 +414,7 @@ public class NpcAggroAreaPlugin extends Plugin calculateLinesToDisplay(); break; case "npcUnaggroNames": - npcNamePatterns = NAME_SPLITTER.splitToList(config.npcNamePatterns()); + npcNamePatterns = NAME_SPLITTER.splitToList(this.configNpcNamePatterns); recheckActive(); break; } @@ -483,4 +506,15 @@ public class NpcAggroAreaPlugin extends Plugin break; } } + + private void updateConfig() + { + this.alwaysActive = config.alwaysActive(); + this.configNpcNamePatterns = config.npcNamePatterns(); + this.showTimer = config.showTimer(); + this.showAreaLines = config.showAreaLines(); + this.aggroAreaColor = config.aggroAreaColor(); + this.showNotWorkingOverlay = config.showNotWorkingOverlay(); + this.hideOverlayHint = config.hideOverlayHint(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsOverlay.java index a4e9aee7e9..e9ac6d354a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsOverlay.java @@ -32,6 +32,7 @@ import java.awt.Polygon; import java.awt.geom.Area; import static java.lang.Math.floor; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.DecorativeObject; import net.runelite.api.GameObject; @@ -43,20 +44,19 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton class ObjectIndicatorsOverlay extends Overlay { private static final Color TRANSPARENT = new Color(0, 0, 0, 0); private final Client client; - private final ObjectIndicatorsConfig config; private final ObjectIndicatorsPlugin plugin; private final ModelOutlineRenderer modelOutliner; @Inject - private ObjectIndicatorsOverlay(Client client, ObjectIndicatorsConfig config, ObjectIndicatorsPlugin plugin, ModelOutlineRenderer modelOutliner) + private ObjectIndicatorsOverlay(final Client client, final ObjectIndicatorsPlugin plugin, final ModelOutlineRenderer modelOutliner) { this.client = client; - this.config = config; this.plugin = plugin; this.modelOutliner = modelOutliner; setPosition(OverlayPosition.DYNAMIC); @@ -74,14 +74,14 @@ class ObjectIndicatorsOverlay extends Overlay continue; } - Color color = config.objectMarkerColor(); - int opacity = (int) floor(config.objectMarkerAlpha() * 2.55); + Color color = plugin.getObjectMarkerColor(); + int opacity = (int) floor(plugin.getObjectMarkerAlpha() * 2.55); Color objectColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), opacity); - switch (config.objectMarkerRenderStyle()) + switch (plugin.getObjectMarkerRenderStyle()) { case OUTLINE: - switch (config.objectMarkerOutlineRenderStyle()) + switch (plugin.getObjectMarkerOutlineRenderStyle()) { case THIN_OUTLINE: modelOutliner.drawOutline(object, 1, objectColor); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java index adb0cb4bc5..f21d7ef067 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java @@ -29,6 +29,7 @@ import com.google.common.base.Strings; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.inject.Provides; +import java.awt.Color; import java.awt.event.KeyEvent; import java.util.ArrayList; import java.util.Arrays; @@ -38,6 +39,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -53,6 +55,7 @@ import net.runelite.api.Scene; import net.runelite.api.Tile; import net.runelite.api.TileObject; import net.runelite.api.coords.WorldPoint; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.DecorativeObjectDespawned; import net.runelite.api.events.DecorativeObjectSpawned; import net.runelite.api.events.FocusChanged; @@ -76,6 +79,7 @@ import net.runelite.client.ui.overlay.OverlayManager; tags = {"overlay", "objects", "mark", "marker"}, enabledByDefault = false ) +@Singleton public class ObjectIndicatorsPlugin extends Plugin implements KeyListener { private static final String CONFIG_GROUP = "objectindicators"; @@ -100,9 +104,21 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener @Inject private ObjectIndicatorsOverlay overlay; + @Inject + private ObjectIndicatorsConfig config; + @Inject private KeyManager keyManager; + @Getter(AccessLevel.PACKAGE) + private RenderStyle objectMarkerRenderStyle; + @Getter(AccessLevel.PACKAGE) + private OutlineRenderStyle objectMarkerOutlineRenderStyle; + @Getter(AccessLevel.PACKAGE) + private Color objectMarkerColor; + @Getter(AccessLevel.PACKAGE) + private int objectMarkerAlpha; + @Provides ObjectIndicatorsConfig provideConfig(ConfigManager configManager) { @@ -112,6 +128,8 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener @Override protected void startUp() { + updateConfig(); + overlayManager.add(overlay); keyManager.registerKeyListener(this); } @@ -428,4 +446,23 @@ public class ObjectIndicatorsPlugin extends Plugin implements KeyListener { }.getType()); } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("objectindicators")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.objectMarkerRenderStyle = config.objectMarkerRenderStyle(); + this.objectMarkerOutlineRenderStyle = config.objectMarkerOutlineRenderStyle(); + this.objectMarkerColor = config.objectMarkerColor(); + this.objectMarkerAlpha = config.objectMarkerAlpha(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoOverlay.java index 9ca6337427..2913384345 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoOverlay.java @@ -32,6 +32,7 @@ import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Actor; import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; @@ -52,6 +53,7 @@ import net.runelite.client.ui.overlay.components.TitleComponent; import net.runelite.client.util.Text; import net.runelite.http.api.hiscore.HiscoreResult; +@Singleton class OpponentInfoOverlay extends Overlay { private static final Color HP_GREEN = new Color(0, 146, 54, 230); @@ -59,7 +61,6 @@ class OpponentInfoOverlay extends Overlay private final Client client; private final OpponentInfoPlugin opponentInfoPlugin; - private final OpponentInfoConfig opponentInfoConfig; private final HiscoreManager hiscoreManager; private final NPCManager npcManager; @@ -73,16 +74,14 @@ class OpponentInfoOverlay extends Overlay @Inject private OpponentInfoOverlay( - Client client, - OpponentInfoPlugin opponentInfoPlugin, - OpponentInfoConfig opponentInfoConfig, - HiscoreManager hiscoreManager, - NPCManager npcManager) + final Client client, + final OpponentInfoPlugin opponentInfoPlugin, + final HiscoreManager hiscoreManager, + final NPCManager npcManager) { super(opponentInfoPlugin); this.client = client; this.opponentInfoPlugin = opponentInfoPlugin; - this.opponentInfoConfig = opponentInfoConfig; this.hiscoreManager = hiscoreManager; this.npcManager = npcManager; @@ -164,7 +163,7 @@ class OpponentInfoOverlay extends Overlay progressBarComponent.setBackgroundColor(HP_RED); progressBarComponent.setForegroundColor(HP_GREEN); - final HitpointsDisplayStyle displayStyle = opponentInfoConfig.hitpointsDisplayStyle(); + final HitpointsDisplayStyle displayStyle = opponentInfoPlugin.getHitpointsDisplayStyle(); if ((displayStyle == HitpointsDisplayStyle.HITPOINTS || displayStyle == HitpointsDisplayStyle.BOTH) && lastMaxHealth != -1) @@ -219,7 +218,7 @@ class OpponentInfoOverlay extends Overlay } // Opponents opponent - if (opponentsOpponentName != null && opponentInfoConfig.showOpponentsOpponent()) + if (opponentsOpponentName != null && opponentInfoPlugin.isShowOpponentsOpponent()) { textWidth = Math.max(textWidth, fontMetrics.stringWidth(opponentsOpponentName)); panelComponent.setPreferredSize(new Dimension(textWidth, 0)); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoPlugin.java index 6e36665a8b..979633bdf7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/OpponentInfoPlugin.java @@ -30,12 +30,14 @@ import java.time.Duration; import java.time.Instant; import java.util.EnumSet; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Actor; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.WorldType; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.InteractingChanged; @@ -51,6 +53,7 @@ import net.runelite.http.api.hiscore.HiscoreEndpoint; description = "Show name and hitpoints information about the NPC you are fighting", tags = {"combat", "health", "hitpoints", "npcs", "overlay"} ) +@Singleton public class OpponentInfoPlugin extends Plugin { private static final Duration WAIT = Duration.ofSeconds(5); @@ -78,6 +81,13 @@ public class OpponentInfoPlugin extends Plugin private Instant lastTime; + @Getter(AccessLevel.PACKAGE) + private boolean lookupOnInteraction; + @Getter(AccessLevel.PACKAGE) + private HitpointsDisplayStyle hitpointsDisplayStyle; + @Getter(AccessLevel.PACKAGE) + private boolean showOpponentsOpponent; + @Provides OpponentInfoConfig provideConfig(ConfigManager configManager) { @@ -87,6 +97,8 @@ public class OpponentInfoPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(opponentInfoOverlay); overlayManager.add(playerComparisonOverlay); } @@ -159,4 +171,22 @@ public class OpponentInfoPlugin extends Plugin } } } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("opponentinfo")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.lookupOnInteraction = config.lookupOnInteraction(); + this.hitpointsDisplayStyle = config.hitpointsDisplayStyle(); + this.showOpponentsOpponent = config.showOpponentsOpponent(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/PlayerComparisonOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/PlayerComparisonOverlay.java index 867e0e6004..c89603364f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/PlayerComparisonOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/opponentinfo/PlayerComparisonOverlay.java @@ -29,6 +29,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Actor; import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; @@ -49,6 +50,7 @@ import net.runelite.client.util.Text; import net.runelite.http.api.hiscore.HiscoreResult; import net.runelite.http.api.hiscore.HiscoreSkill; +@Singleton class PlayerComparisonOverlay extends Overlay { private static final Color HIGHER_STAT_TEXT_COLOR = Color.GREEN; @@ -82,17 +84,15 @@ class PlayerComparisonOverlay extends Overlay private final Client client; private final OpponentInfoPlugin opponentInfoPlugin; - private final OpponentInfoConfig config; private final HiscoreManager hiscoreManager; private final PanelComponent panelComponent = new PanelComponent(); @Inject - private PlayerComparisonOverlay(Client client, OpponentInfoPlugin opponentInfoPlugin, OpponentInfoConfig config, HiscoreManager hiscoreManager) + private PlayerComparisonOverlay(final Client client, final OpponentInfoPlugin opponentInfoPlugin, final HiscoreManager hiscoreManager) { super(opponentInfoPlugin); this.client = client; this.opponentInfoPlugin = opponentInfoPlugin; - this.config = config; this.hiscoreManager = hiscoreManager; setPosition(OverlayPosition.BOTTOM_LEFT); @@ -103,7 +103,7 @@ class PlayerComparisonOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!config.lookupOnInteraction()) + if (!opponentInfoPlugin.isLookupOnInteraction()) { return null; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPingOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPingOverlay.java index 9134c1f8d1..f7811806dd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPingOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPingOverlay.java @@ -30,6 +30,7 @@ import java.awt.Graphics2D; import java.awt.Polygon; import java.util.Iterator; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.coords.LocalPoint; @@ -38,6 +39,7 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton class PartyPingOverlay extends Overlay { private final Client client; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPlugin.java index 2d7bddc3a6..ac83ef69e1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyPlugin.java @@ -38,6 +38,8 @@ import java.util.UUID; import javax.annotation.Nullable; import javax.inject.Inject; import javax.inject.Named; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; @@ -50,6 +52,7 @@ import net.runelite.api.SoundEffectID; import net.runelite.api.Tile; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.CommandExecuted; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.FocusChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.MenuOptionClicked; @@ -87,6 +90,7 @@ import net.runelite.http.api.ws.messages.party.UserSync; description = "Shows useful information about current party" ) @Slf4j +@Singleton public class PartyPlugin extends Plugin implements KeyListener { @Inject @@ -126,16 +130,24 @@ public class PartyPlugin extends Plugin implements KeyListener @Named("developerMode") boolean developerMode; - @Getter + @Getter(AccessLevel.PACKAGE) private final Map partyDataMap = Collections.synchronizedMap(new HashMap<>()); - @Getter + @Getter(AccessLevel.PACKAGE) private final List pendingTilePings = Collections.synchronizedList(new ArrayList<>()); private int lastHp, lastPray; private boolean hotkeyDown, doSync; private boolean sendAlert; + @Getter(AccessLevel.PACKAGE) + private boolean stats; + private boolean pings; + private boolean sounds; + private boolean messages; + @Getter(AccessLevel.PACKAGE) + private boolean recolorNames; + @Override public void configure(Binder binder) { @@ -145,6 +157,8 @@ public class PartyPlugin extends Plugin implements KeyListener @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(partyStatsOverlay); overlayManager.add(partyPingOverlay); wsClient.registerMessage(SkillUpdate.class); @@ -186,7 +200,7 @@ public class PartyPlugin extends Plugin implements KeyListener { party.changeParty(null); - if (!config.messages()) + if (!this.messages) { return; } @@ -206,7 +220,7 @@ public class PartyPlugin extends Plugin implements KeyListener @Subscribe public void onMenuOptionClicked(MenuOptionClicked event) { - if (!hotkeyDown || client.isMenuOpen() || party.getMembers().isEmpty() || !config.pings()) + if (!hotkeyDown || client.isMenuOpen() || party.getMembers().isEmpty() || !this.pings) { return; } @@ -246,14 +260,14 @@ public class PartyPlugin extends Plugin implements KeyListener @Subscribe public void onTilePing(TilePing event) { - if (config.pings()) + if (this.pings) { final PartyData partyData = getPartyData(event.getMemberId()); final Color color = partyData != null ? partyData.getColor() : Color.RED; pendingTilePings.add(new PartyTilePingData(event.getPoint(), color)); } - if (config.sounds()) + if (this.sounds) { WorldPoint point = event.getPoint(); @@ -375,7 +389,7 @@ public class PartyPlugin extends Plugin implements KeyListener { final PartyData partyData = getPartyData(event.getMemberId()); - if (partyData == null || !config.messages()) + if (partyData == null || !this.messages) { return; } @@ -427,7 +441,7 @@ public class PartyPlugin extends Plugin implements KeyListener if (removed != null) { - if (config.messages()) + if (this.messages) { final String joinMessage = new ChatMessageBuilder() .append(ChatColorType.HIGHLIGHT) @@ -546,4 +560,24 @@ public class PartyPlugin extends Plugin implements KeyListener .runeLiteFormattedMessage(helpMessage) .build()); } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("party")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.stats = config.stats(); + this.pings = config.pings(); + this.sounds = config.sounds(); + this.messages = config.messages(); + this.recolorNames = config.recolorNames(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyStatsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyStatsOverlay.java index 693b23cb89..17c791cf19 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyStatsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyStatsOverlay.java @@ -32,6 +32,7 @@ import java.awt.Rectangle; import java.util.Map; import java.util.UUID; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.MenuAction; import net.runelite.client.plugins.party.data.PartyData; import net.runelite.client.ui.overlay.Overlay; @@ -42,6 +43,7 @@ import net.runelite.client.ui.overlay.components.ProgressBarComponent; import net.runelite.client.ui.overlay.components.TitleComponent; import net.runelite.client.ws.PartyService; +@Singleton public class PartyStatsOverlay extends Overlay { private static final Color HP_FG = new Color(0, 146, 54, 230); @@ -51,7 +53,6 @@ public class PartyStatsOverlay extends Overlay private final PartyPlugin plugin; private final PartyService party; - private final PartyConfig config; private final PanelComponent body = new PanelComponent(); @Inject @@ -60,7 +61,6 @@ public class PartyStatsOverlay extends Overlay super(plugin); this.plugin = plugin; this.party = party; - this.config = config; body.setBorder(new Rectangle()); body.setGap(new Point(0, ComponentConstants.STANDARD_BORDER / 2)); getMenuEntries().add(new OverlayMenuEntry(MenuAction.RUNELITE_OVERLAY, "Leave", "Party")); @@ -69,7 +69,7 @@ public class PartyStatsOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!config.stats()) + if (!plugin.isStats()) { return null; } @@ -107,7 +107,7 @@ public class PartyStatsOverlay extends Overlay final TitleComponent name = TitleComponent.builder() .text(v.getName()) - .color(config.recolorNames() ? v.getColor() : Color.WHITE) + .color(plugin.isRecolorNames() ? v.getColor() : Color.WHITE) .build(); panel.getChildren().add(name); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyWorldMapPoint.java b/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyWorldMapPoint.java index a2ae27835b..8a51f5fa0c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyWorldMapPoint.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/party/PartyWorldMapPoint.java @@ -39,7 +39,7 @@ class PartyWorldMapPoint extends WorldMapPoint private BufferedImage partyImage; private PartyMember member; - PartyWorldMapPoint(WorldPoint worldPoint, PartyMember member) + PartyWorldMapPoint(final WorldPoint worldPoint, final PartyMember member) { super(worldPoint, null); this.member = member; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/performancestats/Performance.java b/runelite-client/src/main/java/net/runelite/client/plugins/performancestats/Performance.java index cc81fa1bfb..25336dbb38 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/performancestats/Performance.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/performancestats/Performance.java @@ -24,16 +24,17 @@ */ package net.runelite.client.plugins.performancestats; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import net.runelite.http.api.ws.messages.party.PartyMemberMessage; -@Getter +@Getter(AccessLevel.PACKAGE) class Performance extends PartyMemberMessage { private static final double TICK_LENGTH = 0.6; - @Setter + @Setter(AccessLevel.PACKAGE) String username; double damageDealt = 0; @@ -43,7 +44,7 @@ class Performance extends PartyMemberMessage double highestHitTaken = 0; int lastActivityTick = -1; - @Setter + @Setter(AccessLevel.PACKAGE) double ticksSpent = 0; void addDamageDealt(double a, int currentTick) @@ -83,7 +84,7 @@ class Performance extends PartyMemberMessage ticksSpent = 0; } - double getSecondsSpent() + private double getSecondsSpent() { return Math.round(this.ticksSpent * TICK_LENGTH); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/performancestats/PerformanceStatsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/performancestats/PerformanceStatsOverlay.java index c2d2961034..ede483cfa1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/performancestats/PerformanceStatsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/performancestats/PerformanceStatsOverlay.java @@ -28,6 +28,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.MenuAction; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayMenuEntry; @@ -38,6 +39,7 @@ import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; +@Singleton public class PerformanceStatsOverlay extends Overlay { private static final String TARGET = "Performance Stats"; @@ -50,7 +52,7 @@ public class PerformanceStatsOverlay extends Overlay private final TableComponent tableComponent = new TableComponent(); @Inject - PerformanceStatsOverlay(PerformanceStatsPlugin tracker) + PerformanceStatsOverlay(final PerformanceStatsPlugin tracker) { super(tracker); setPosition(OverlayPosition.TOP_RIGHT); @@ -111,8 +113,8 @@ public class PerformanceStatsOverlay extends Overlay return new String[] { performance.getUsername(), - String.valueOf((int) Math.round(performance.getDamageDealt())) + " | " + String.valueOf((int) Math.round(performance.getHighestHitDealt())), - String.valueOf((int) Math.round(performance.getDamageTaken())) + " | " + String.valueOf((int) Math.round(performance.getHighestHitTaken())), + (int) Math.round(performance.getDamageDealt()) + " | " + String.valueOf((int) Math.round(performance.getHighestHitDealt())), + (int) Math.round(performance.getDamageTaken()) + " | " + String.valueOf((int) Math.round(performance.getHighestHitTaken())), String.valueOf(performance.getDPS()), performance.getHumanReadableSecondsSpent() }; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/performancestats/PerformanceStatsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/performancestats/PerformanceStatsPlugin.java index fa3e7fd530..41fdfedfc6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/performancestats/PerformanceStatsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/performancestats/PerformanceStatsPlugin.java @@ -31,6 +31,8 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Actor; @@ -39,6 +41,7 @@ import net.runelite.api.Client; import net.runelite.api.NPC; import net.runelite.api.Skill; import net.runelite.api.WorldType; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ExperienceChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; @@ -72,6 +75,7 @@ import net.runelite.http.api.ws.messages.party.UserSync; enabledByDefault = false ) @Slf4j +@Singleton public class PerformanceStatsPlugin extends Plugin { // For every damage point dealt 1.33 experience is given to the player's hitpoints (base rate) @@ -105,11 +109,11 @@ public class PerformanceStatsPlugin extends Plugin @Inject private WSClient wsClient; - @Getter + @Getter(AccessLevel.PACKAGE) private boolean enabled = false; - @Getter + @Getter(AccessLevel.PACKAGE) private boolean paused = false; - @Getter + @Getter(AccessLevel.PACKAGE) private final Performance performance = new Performance(); // Keep track of actor last tick as sometimes getInteracting can return null when hp xp event is triggered @@ -119,8 +123,10 @@ public class PerformanceStatsPlugin extends Plugin private boolean hopping; private int pausedTicks = 0; + private int submitTimeout; + // Party System - @Getter + @Getter(AccessLevel.PACKAGE) private final Map partyDataMap = Collections.synchronizedMap(new HashMap<>()); @Provides @@ -132,6 +138,8 @@ public class PerformanceStatsPlugin extends Plugin @Override protected void startUp() { + this.submitTimeout = config.submitTimeout(); + overlayManager.add(performanceTrackerOverlay); wsClient.registerMessage(Performance.class); } @@ -266,7 +274,7 @@ public class PerformanceStatsPlugin extends Plugin performance.incrementTicksSpent(); hopping = false; - final int timeout = config.submitTimeout(); + final int timeout = this.submitTimeout; if (timeout > 0) { final double tickTimeout = timeout / GAME_TICK_SECONDS; @@ -449,4 +457,14 @@ public class PerformanceStatsPlugin extends Plugin partyDataMap.clear(); } + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("performancestats")) + { + return; + } + + this.submitTimeout = config.submitTimeout(); + } } 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 6e9e4274bd..5ed0b19202 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 @@ -30,6 +30,7 @@ import java.time.Instant; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; @@ -44,19 +45,19 @@ public class Game private PestControlPlugin plugin; - @Getter + @Getter(AccessLevel.PACKAGE) private Portal bluePortal = new Portal(PortalColor.BLUE, WidgetPortal.BLUE); - @Getter + @Getter(AccessLevel.PACKAGE) private Portal purplePortal = new Portal(PortalColor.PURPLE, WidgetPortal.PURPLE); - @Getter + @Getter(AccessLevel.PACKAGE) private Portal yellowPortal = new Portal(PortalColor.YELLOW, WidgetPortal.YELLOW); - @Getter + @Getter(AccessLevel.PACKAGE) private Portal redPortal = new Portal(PortalColor.RED, WidgetPortal.RED); - @Getter + @Getter(AccessLevel.PACKAGE) private int shieldsDropped = 0; // Game starts with all possible rotations @@ -103,7 +104,7 @@ public class Game } } - public void lowerPortalShield(String portalColor) + void lowerPortalShield(String portalColor) { switch (portalColor.toLowerCase()) { @@ -124,7 +125,7 @@ public class Game private void lowerPortalShield(Portal portal) { - if (!portal.isShielded()) + if (portal.isNotShielded()) { return; } @@ -149,7 +150,7 @@ public class Game possibleRotations = rotations.toArray(new PortalRotation[rotations.size()]); } - public void killPortal(Portal portal) + private void killPortal(Portal portal) { if (portal.isDead()) { @@ -185,7 +186,7 @@ public class Game return false; } - public void setPortalLocations(WorldPoint squireLocation) + private void setPortalLocations(WorldPoint squireLocation) { int x = squireLocation.getX(); int y = squireLocation.getY(); @@ -198,7 +199,7 @@ public class Game portalLocationsSet = true; } - public List getPortals() + List getPortals() { List portalList = new ArrayList(); @@ -210,7 +211,7 @@ public class Game return portalList; } - public Portal getPortal(PortalColor portalColor) + Portal getPortal(PortalColor portalColor) { if (bluePortal.getColor() == portalColor) { @@ -232,7 +233,7 @@ public class Game return null; } - public Collection getNextPortals() + Collection getNextPortals() { List portals = new ArrayList<>(); @@ -249,7 +250,7 @@ public class Game return portals; } - public Collection getActivePortals() + Collection getActivePortals() { List portals = new ArrayList<>(); @@ -264,7 +265,7 @@ public class Game return portals; } - public Duration getTimeTillNextPortal() + Duration getTimeTillNextPortal() { Instant 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 index db8abe87b7..31191088bd 100644 --- 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 @@ -25,6 +25,7 @@ package net.runelite.client.plugins.pestcontrol; import com.google.inject.Inject; +import com.google.inject.Singleton; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Dimension; @@ -43,17 +44,16 @@ import net.runelite.client.ui.overlay.tooltip.TooltipManager; import net.runelite.client.util.ColorUtil; @Slf4j +@Singleton 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) + GangplankOverlay(final Client client, final PestControlPlugin plugin, final TooltipManager toolTipManager) { - this.config = config; this.plugin = plugin; this.client = client; this.tooltipManager = toolTipManager; 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 index 90c81228a1..b22798f57e 100644 --- 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 @@ -30,6 +30,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.NPC; import net.runelite.api.coords.WorldPoint; @@ -37,16 +38,15 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; +@Singleton 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) + HintArrowOverlay(final PestControlPlugin plugin, final Client client) { - this.config = config; this.plugin = plugin; this.client = client; 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 index 56c51fdd8d..3dfaee777b 100644 --- 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 @@ -25,15 +25,16 @@ package net.runelite.client.plugins.pestcontrol; import java.awt.Color; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import net.runelite.client.plugins.pestcontrol.config.NpcHighlightStyle; @AllArgsConstructor -@Getter -@Setter -public class NpcHighlightContext +@Getter(AccessLevel.PACKAGE) +@Setter(AccessLevel.PACKAGE) +class NpcHighlightContext { private NpcHighlightStyle npcRenderStyle; private Color color; 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 index bb8e94c175..540134714b 100644 --- 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 @@ -25,6 +25,7 @@ package net.runelite.client.plugins.pestcontrol; import com.google.inject.Inject; +import com.google.inject.Singleton; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Dimension; @@ -43,16 +44,15 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; @Slf4j +@Singleton 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) + NpcHighlightOverlay(final PestControlPlugin plugin, final Client client) { - this.config = config; this.plugin = plugin; this.client = client; 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 index e1b9ef143e..50ca737592 100644 --- 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 @@ -26,13 +26,14 @@ package net.runelite.client.plugins.pestcontrol; import com.google.common.collect.ImmutableSet; import java.util.Set; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.NpcID; -@Getter +@Getter(AccessLevel.PACKAGE) public class PestControlNpc { - @Getter + @Getter(AccessLevel.PACKAGE) private static final Set splatterIdSet = ImmutableSet.of( NpcID.SPLATTER, NpcID.SPLATTER_1690, @@ -41,7 +42,7 @@ public class PestControlNpc NpcID.SPLATTER_1693 ); - @Getter + @Getter(AccessLevel.PACKAGE) public static final Set shifterIdSet = ImmutableSet.of( NpcID.SHIFTER, NpcID.SHIFTER_1695, @@ -55,7 +56,7 @@ public class PestControlNpc NpcID.SHIFTER_1703 ); - @Getter + @Getter(AccessLevel.PACKAGE) private static final Set spinnerIdSet = ImmutableSet.of( NpcID.SPINNER, NpcID.SPINNER_1710, @@ -64,7 +65,7 @@ public class PestControlNpc NpcID.SPINNER_1713 ); - @Getter + @Getter(AccessLevel.PACKAGE) private static final Set torcherIdSet = ImmutableSet.of( NpcID.TORCHER, NpcID.TORCHER_1715, @@ -78,7 +79,7 @@ public class PestControlNpc NpcID.TORCHER_1723 ); - @Getter + @Getter(AccessLevel.PACKAGE) private static final Set defilerIdSet = ImmutableSet.of( NpcID.DEFILER, NpcID.DEFILER_1725, @@ -92,7 +93,7 @@ public class PestControlNpc NpcID.DEFILER_1733 ); - @Getter + @Getter(AccessLevel.PACKAGE) private static final Set brawlerIdSet = ImmutableSet.of( NpcID.BRAWLER, NpcID.BRAWLER_1735, @@ -101,7 +102,7 @@ public class PestControlNpc NpcID.BRAWLER_1738 ); - @Getter + @Getter(AccessLevel.PACKAGE) private static final Set ravagerIdSet = ImmutableSet.of( NpcID.RAVAGER, NpcID.RAVAGER_1705, @@ -110,7 +111,7 @@ public class PestControlNpc NpcID.RAVAGER_1708 ); - @Getter + @Getter(AccessLevel.PACKAGE) private static final Set activePortalIdSet = ImmutableSet.of( NpcID.PORTAL_1747, // Novice Purple Active NpcID.PORTAL_1748, // Novice Blue Active @@ -122,7 +123,7 @@ public class PestControlNpc NpcID.PORTAL_1742 // Intermediate Red Active ); - @Getter + @Getter(AccessLevel.PACKAGE) private static final Set shieldedPortalIdSet = ImmutableSet.of( NpcID.PORTAL_1751, // Novice Purple Shielded NpcID.PORTAL_1752, // Novice Blue Shielded @@ -134,7 +135,7 @@ public class PestControlNpc NpcID.PORTAL_1746 // Intermediate Red Shielded ); - @Getter + @Getter(AccessLevel.PACKAGE) private static final Set purplePortalIdSet = ImmutableSet.of( NpcID.PORTAL_1747, // Novice Purple Active NpcID.PORTAL_1751, // Novice Purple Shielded @@ -142,7 +143,7 @@ public class PestControlNpc NpcID.PORTAL_1743 // Intermediate Purple Shielded ); - @Getter + @Getter(AccessLevel.PACKAGE) private static final Set bluePortalIdSet = ImmutableSet.of( NpcID.PORTAL_1748, // Novice Blue Active NpcID.PORTAL_1752, // Novice Blue Shielded @@ -150,7 +151,7 @@ public class PestControlNpc NpcID.PORTAL_1744 // Intermediate Blue Shielded ); - @Getter + @Getter(AccessLevel.PACKAGE) private static final Set yellowPortalIdSet = ImmutableSet.of( NpcID.PORTAL_1749, // Novice Yellow Active NpcID.PORTAL_1753, // Novice Yellow Shielded @@ -158,7 +159,7 @@ public class PestControlNpc NpcID.PORTAL_1745 // Intermediate Yellow Shielded ); - @Getter + @Getter(AccessLevel.PACKAGE) private static final Set redPortalIdSet = ImmutableSet.of( NpcID.PORTAL_1750, // Novice Red Active NpcID.PORTAL_1754, // Novice Red Shielded @@ -166,7 +167,7 @@ public class PestControlNpc NpcID.PORTAL_1746 // Intermediate Red Shielded ); - @Getter + @Getter(AccessLevel.PACKAGE) private static final Set ingameVoidKnightIdSet = ImmutableSet.of( NpcID.VOID_KNIGHT_2950, NpcID.VOID_KNIGHT_2951, @@ -174,85 +175,85 @@ public class PestControlNpc NpcID.VOID_KNIGHT_2953 ); - @Getter + @Getter(AccessLevel.PACKAGE) private static final Integer ingameSquireId = NpcID.SQUIRE_2949; - public static boolean isSplatterId(int npcId) + static boolean isSplatterId(int npcId) { return splatterIdSet.contains(npcId); } - public static boolean isShifterId(int npcId) + static boolean isShifterId(int npcId) { return shifterIdSet.contains(npcId); } - public static boolean isSpinnerId(int npcId) + static boolean isSpinnerId(int npcId) { return brawlerIdSet.contains(npcId); } - public static boolean isTorcherId(int npcId) + static boolean isTorcherId(int npcId) { return torcherIdSet.contains(npcId); } - public static boolean isDefilerId(int npcId) + static boolean isDefilerId(int npcId) { return defilerIdSet.contains(npcId); } - public static boolean isBrawlerId(int npcId) + static boolean isBrawlerId(int npcId) { return brawlerIdSet.contains(npcId); } - public static boolean isRavagerId(int npcId) + static boolean isRavagerId(int npcId) { return ravagerIdSet.contains(npcId); } - public static boolean isIngameVoidKnightId(int npcId) + static boolean isIngameVoidKnightId(int npcId) { return ingameVoidKnightIdSet.contains(npcId); } - public static boolean isIngameSquireId(int npcId) + static boolean isIngameSquireId(int npcId) { return ingameSquireId == npcId; } - public static boolean isPortalId(int npcId) + static boolean isPortalId(int npcId) { return (isActivePortalId(npcId) || isShieldedPortalId(npcId)); } - public static boolean isActivePortalId(int npcId) + static boolean isActivePortalId(int npcId) { return activePortalIdSet.contains(npcId); } - public static boolean isShieldedPortalId(int npcId) + private static boolean isShieldedPortalId(int npcId) { return shieldedPortalIdSet.contains(npcId); } - public static boolean isPurplePortalId(int npcId) + static boolean isPurplePortalId(int npcId) { return purplePortalIdSet.contains(npcId); } - public static boolean isBluePortalId(int npcId) + static boolean isBluePortalId(int npcId) { return bluePortalIdSet.contains(npcId); } - public static boolean isYellowPortalId(int npcId) + static boolean isYellowPortalId(int npcId) { return yellowPortalIdSet.contains(npcId); } - public static boolean isRedPortalId(int npcId) + 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 d3095afd5a..3329f6f520 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 @@ -27,12 +27,15 @@ package net.runelite.client.plugins.pestcontrol; import com.google.inject.Inject; import com.google.inject.Provides; +import com.google.inject.Singleton; +import java.awt.Color; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; @@ -71,6 +74,7 @@ import net.runelite.client.util.Text; description = "Show helpful information for the Pest Control minigame", tags = {"minigame", "overlay"} ) +@Singleton public class PestControlPlugin extends Plugin { private static final int VOID_KNIGHTS_OUTPOST = 10537; @@ -86,7 +90,7 @@ public class PestControlPlugin extends Plugin private final Pattern PURCHASE_PATTERN = Pattern.compile("Remaining Void Knight Commendation Points: ([0-9]+)"); @Inject - @Getter + @Getter(AccessLevel.PACKAGE) private Client client; @Inject @@ -99,15 +103,15 @@ public class PestControlPlugin extends Plugin private InfoBoxManager infoBoxManager; @Inject - @Getter + @Getter(AccessLevel.PACKAGE) private ItemManager itemManager; @Inject - @Getter + @Getter(AccessLevel.PACKAGE) private PestControlConfig config; @Inject - @Getter + @Getter(AccessLevel.PACKAGE) private WidgetOverlay widgetOverlay; @Inject @@ -128,25 +132,25 @@ public class PestControlPlugin extends Plugin @Inject private PortalWeaknessOverlay portalWeaknessOverlay; - @Getter + @Getter(AccessLevel.PACKAGE) private Game game; - @Getter + @Getter(AccessLevel.PACKAGE) private HashMap highlightedNpcList = new HashMap<>(); - @Getter + @Getter(AccessLevel.PACKAGE) private List highlightedRepairList = new ArrayList<>(); - @Getter + @Getter(AccessLevel.PACKAGE) private Tile noviceGangplankTile; - @Getter + @Getter(AccessLevel.PACKAGE) private Tile intermediateGangplankTile; - @Getter + @Getter(AccessLevel.PACKAGE) private Tile veteranGangplankTile; - @Getter + @Getter(AccessLevel.PACKAGE) private Integer commendationPoints; private String userConfigKey; @@ -155,6 +159,21 @@ public class PestControlPlugin extends Plugin private PointsInfoboxCounter pointsInfoboxCounter; + private boolean showHintArrow; + private boolean showPortalWeakness; + private boolean highlightGangplanks; + private HighlightPortalOption portalHighlight; + private Color activePortalColor; + private Color shieldedPortalColor; + private NpcHighlightStyle highlightSpinners; + private Color spinnerColor; + private NpcHighlightStyle highlightBrawlers; + private Color brawlerColor; + private boolean highlightRepairables; + @Getter(AccessLevel.PACKAGE) + private Color repairableColor; + private boolean showPoints; + private boolean showTimeTillNextPortal; @Provides PestControlConfig provideConfig(ConfigManager configManager) @@ -165,6 +184,7 @@ public class PestControlPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); loadPlugin(); } @@ -179,6 +199,7 @@ public class PestControlPlugin extends Plugin { if (configEvent.getGroup().equals("pestcontrol")) { + updateConfig(); unloadPlugin(); loadPlugin(); } @@ -210,53 +231,53 @@ public class PestControlPlugin extends Plugin overlayManager.add(widgetOverlay); - if (config.highlightSpinners() != NpcHighlightStyle.OFF) + if (this.highlightSpinners != NpcHighlightStyle.OFF) { for (Integer npcId : PestControlNpc.getSpinnerIdSet()) { highlightedNpcList.put(npcId, new NpcHighlightContext( - config.highlightSpinners(), - config.spinnerColor(), + this.highlightSpinners, + this.spinnerColor, true )); } } - if (config.highlightBrawlers() != NpcHighlightStyle.OFF) + if (this.highlightBrawlers != NpcHighlightStyle.OFF) { for (Integer npcId : PestControlNpc.getBrawlerIdSet()) { highlightedNpcList.put(npcId, new NpcHighlightContext( - config.highlightBrawlers(), - config.brawlerColor(), + this.highlightBrawlers, + this.brawlerColor, false )); } } - if (config.portalHighlight() != HighlightPortalOption.OFF) + if (this.portalHighlight != HighlightPortalOption.OFF) { - if (config.portalHighlight() == HighlightPortalOption.ACTIVE || - config.portalHighlight() == HighlightPortalOption.ALL) + if (this.portalHighlight == HighlightPortalOption.ACTIVE || + this.portalHighlight == HighlightPortalOption.ALL) { for (Integer portalNpcId : PestControlNpc.getActivePortalIdSet()) { highlightedNpcList.put(portalNpcId, new NpcHighlightContext( NpcHighlightStyle.HULL, - config.activePortalColor(), + this.activePortalColor, false )); } } - if (config.portalHighlight() == HighlightPortalOption.SHIELDED || - config.portalHighlight() == HighlightPortalOption.ALL) + if (this.portalHighlight == HighlightPortalOption.SHIELDED || + this.portalHighlight == HighlightPortalOption.ALL) { for (Integer portalNpcId : PestControlNpc.getShieldedPortalIdSet()) { highlightedNpcList.put(portalNpcId, new NpcHighlightContext( NpcHighlightStyle.HULL, - config.shieldedPortalColor(), + this.shieldedPortalColor, false )); } @@ -268,12 +289,12 @@ public class PestControlPlugin extends Plugin overlayManager.add(npcHighlightOverlay); } - if (config.highlightRepairables()) + if (this.highlightRepairables) { overlayManager.add(repairOverlay); } - if (config.showHintArrow()) + if (this.showHintArrow) { overlayManager.add(hintArrowOverlay); @@ -283,17 +304,17 @@ public class PestControlPlugin extends Plugin } } - if (config.highlightGangplanks()) + if (this.highlightGangplanks) { overlayManager.add(gangplankOverlay); } - if (config.showTimeTillNextPortal()) + if (this.showTimeTillNextPortal) { overlayManager.add(timerOverlay); } - if (config.showPortalWeakness()) + if (this.showPortalWeakness) { overlayManager.add(portalWeaknessOverlay); } @@ -314,7 +335,7 @@ public class PestControlPlugin extends Plugin highlightedNpcList.clear(); - if (game != null && config.showHintArrow() && client.hasHintArrow()) + if (game != null && this.showHintArrow && client.hasHintArrow()) { client.clearHintArrow(); } @@ -332,7 +353,7 @@ public class PestControlPlugin extends Plugin private void handlePointsInfoboxCounter() { - if (!config.showPoints()) + if (!this.showPoints) { return; } @@ -670,4 +691,22 @@ public class PestControlPlugin extends Plugin } return false; } + + private void updateConfig() + { + this.showHintArrow = config.showHintArrow(); + this.showPortalWeakness = config.showPortalWeakness(); + this.highlightGangplanks = config.highlightGangplanks(); + this.portalHighlight = config.portalHighlight(); + this.activePortalColor = config.activePortalColor(); + this.shieldedPortalColor = config.shieldedPortalColor(); + this.highlightSpinners = config.highlightSpinners(); + this.spinnerColor = config.spinnerColor(); + this.highlightBrawlers = config.highlightBrawlers(); + this.brawlerColor = config.brawlerColor(); + this.highlightRepairables = config.highlightRepairables(); + this.repairableColor = config.repairableColor(); + this.showPoints = config.showPoints(); + this.showTimeTillNextPortal = config.showTimeTillNextPortal(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlRepairObject.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlRepairObject.java index f3a8d457dd..a3b56e009d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlRepairObject.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PestControlRepairObject.java @@ -26,13 +26,14 @@ package net.runelite.client.plugins.pestcontrol; import com.google.common.collect.ImmutableSet; import java.util.Set; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.ObjectID; -@Getter -public class PestControlRepairObject +@Getter(AccessLevel.PACKAGE) +class PestControlRepairObject { - @Getter + @Getter(AccessLevel.PACKAGE) private static final Set repairableBarricades = ImmutableSet.of( //ObjectID.BARRICADE_14224, ObjectID.BARRICADE_14227, @@ -43,7 +44,7 @@ public class PestControlRepairObject ObjectID.BARRICADE_14232 ); - @Getter + @Getter(AccessLevel.PACKAGE) private static final Set repairableGates = ImmutableSet.of( ObjectID.GATE_14238, ObjectID.GATE_14239, @@ -58,17 +59,17 @@ public class PestControlRepairObject ObjectID.GATE_14248 ); - public static boolean isRepairableBarricadeId(int objectId) + static boolean isRepairableBarricadeId(int objectId) { return repairableBarricades.contains(objectId); } - public static boolean isRepairableGateId(int objectId) + static boolean isRepairableGateId(int objectId) { return repairableGates.contains(objectId); } - public static boolean isRepairableId(int objectId) + static boolean isRepairableId(int objectId) { return isRepairableBarricadeId(objectId) || isRepairableGateId(objectId); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PointsInfoboxCounter.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PointsInfoboxCounter.java index 1fa3155625..8555abf745 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PointsInfoboxCounter.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PointsInfoboxCounter.java @@ -27,13 +27,10 @@ package net.runelite.client.plugins.pestcontrol; import java.awt.image.BufferedImage; import net.runelite.client.ui.overlay.infobox.Counter; -public class PointsInfoboxCounter extends Counter +class PointsInfoboxCounter extends Counter { - private final PestControlPlugin plugin; - - PointsInfoboxCounter(BufferedImage image, PestControlPlugin plugin, int count) + PointsInfoboxCounter(final BufferedImage image, final PestControlPlugin plugin, final int count) { 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 2ad85a24ea..466c125002 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 @@ -25,12 +25,13 @@ */ package net.runelite.client.plugins.pestcontrol; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import net.runelite.api.coords.WorldPoint; -@Getter -@Setter +@Getter(AccessLevel.PACKAGE) +@Setter(AccessLevel.PACKAGE) class Portal { private PortalColor color; @@ -39,15 +40,15 @@ class Portal private PortalState portalState = PortalState.SHIELDED; - public Portal(PortalColor color, WidgetPortal widget) + Portal(final PortalColor color, final WidgetPortal widget) { this.color = color; this.widget = widget; } - public boolean isShielded() + boolean isNotShielded() { - return portalState == PortalState.SHIELDED; + return portalState != PortalState.SHIELDED; } public boolean isDead() @@ -57,6 +58,6 @@ class Portal public boolean isActive() { - return (!isShielded() && !isDead()); + return (isNotShielded() && !isDead()); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalColor.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalColor.java index 07e7336c0b..8eecadbe0e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalColor.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalColor.java @@ -24,9 +24,10 @@ */ package net.runelite.client.plugins.pestcontrol; +import lombok.AccessLevel; import lombok.Getter; -@Getter +@Getter(AccessLevel.PACKAGE) public enum PortalColor { BLUE, diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalRotation.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalRotation.java index b49d536bb8..d74846c551 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalRotation.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/PortalRotation.java @@ -41,7 +41,7 @@ enum PortalRotation private final PortalColor[] portals; - PortalRotation(PortalColor first, PortalColor second, PortalColor third, PortalColor fourth) + PortalRotation(final PortalColor first, final PortalColor second, final PortalColor third, final PortalColor fourth) { portals = new PortalColor[] { 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 index e24363ec28..7f8d94148b 100644 --- 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 @@ -25,6 +25,7 @@ package net.runelite.client.plugins.pestcontrol; import com.google.inject.Inject; +import com.google.inject.Singleton; import java.awt.AlphaComposite; import java.awt.Composite; import java.awt.Dimension; @@ -46,11 +47,9 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; @Slf4j +@Singleton public class PortalWeaknessOverlay extends Overlay { - private int zOffset = 100; - - private final PestControlConfig config; private final PestControlPlugin plugin; private final Client client; @@ -62,14 +61,12 @@ public class PortalWeaknessOverlay extends Overlay @Inject PortalWeaknessOverlay( - PestControlConfig config, - PestControlPlugin plugin, - Client client, - ItemManager itemManager, - SkillIconManager skillIconManager + final PestControlPlugin plugin, + final Client client, + final ItemManager itemManager, + final SkillIconManager skillIconManager ) { - this.config = config; this.plugin = plugin; this.client = client; @@ -96,6 +93,7 @@ public class PortalWeaknessOverlay extends Overlay // We can use any image here as it's only needed to calculate the position + int zOffset = 100; return Perspective.getCanvasImageLocation(client, localLocation, magicImage, zOffset); } 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 index a0ee3bf09f..458337fb33 100644 --- 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 @@ -25,6 +25,7 @@ package net.runelite.client.plugins.pestcontrol; import com.google.inject.Inject; +import com.google.inject.Singleton; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Dimension; @@ -43,18 +44,17 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; +@Singleton 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) + RepairOverlay(final PestControlPlugin plugin, final Client client) { - this.config = config; this.plugin = plugin; this.client = client; @@ -72,7 +72,7 @@ public class RepairOverlay extends Overlay Point mousePosition = client.getMouseCanvasPosition(); Scene scene = client.getScene(); - Color color = config.repairableColor(); + Color color = plugin.getRepairableColor(); Tile[][][] tiles = scene.getTiles(); int z = client.getPlane(); @@ -119,11 +119,6 @@ public class RepairOverlay extends Overlay GroundObject groundObject = tile.getGroundObject(); if (groundObject != null) { - if (groundObject == null) - { - continue; - } - if (PestControlRepairObject.isRepairableId(groundObject.getId())) { @@ -138,11 +133,6 @@ public class RepairOverlay extends Overlay WallObject wallObject = tile.getWallObject(); if (wallObject != null) { - if (wallObject == null) - { - continue; - } - if (PestControlRepairObject.isRepairableId(wallObject.getId())) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/TimerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/TimerOverlay.java index be45fc728e..3c118c1763 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/TimerOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/TimerOverlay.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.pestcontrol; import com.google.inject.Inject; +import com.google.inject.Singleton; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; @@ -38,16 +39,15 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton public class TimerOverlay extends Overlay { - private final PestControlConfig config; private final PestControlPlugin plugin; private final Client client; @Inject - TimerOverlay(PestControlConfig config, PestControlPlugin plugin, Client client) + TimerOverlay(final PestControlPlugin plugin, final Client client) { - this.config = config; this.plugin = plugin; this.client = client; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/WidgetOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/WidgetOverlay.java index 38c1582e32..b2cf073201 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/WidgetOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pestcontrol/WidgetOverlay.java @@ -32,6 +32,7 @@ import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.widgets.Widget; @@ -41,6 +42,7 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; @Slf4j +@Singleton public class WidgetOverlay extends Overlay { private final Client client; @@ -48,7 +50,7 @@ public class WidgetOverlay extends Overlay private final PestControlPlugin plugin; @Inject - public WidgetOverlay(Client client, PestControlPlugin plugin) + public WidgetOverlay(final Client client, final PestControlPlugin plugin) { this.plugin = plugin; this.client = client; @@ -57,7 +59,7 @@ public class WidgetOverlay extends Overlay setLayer(OverlayLayer.ABOVE_SCENE); } - public Integer getPortalHitpoints(PortalColor color) + Integer getPortalHitpoints(PortalColor color) { if (plugin.getGame() == null) { 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 index 7570cfb87f..f219a2425f 100644 --- 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 @@ -24,13 +24,14 @@ */ package net.runelite.client.plugins.pestcontrol; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.ToString; import net.runelite.api.widgets.WidgetInfo; @AllArgsConstructor -@Getter +@Getter(AccessLevel.PACKAGE) @ToString enum WidgetPortal { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pileindicators/PileIndicatorsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/pileindicators/PileIndicatorsConfig.java index 44da3efac0..af35be900e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pileindicators/PileIndicatorsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pileindicators/PileIndicatorsConfig.java @@ -35,10 +35,10 @@ import net.runelite.client.config.Stub; public interface PileIndicatorsConfig extends Config { @ConfigItem( - keyName = "playerPilesStub", - name = "Player Piles", - description = "", - position = 0 + keyName = "playerPilesStub", + name = "Player Piles", + description = "", + position = 0 ) default Stub playerPilesStub() { @@ -46,11 +46,11 @@ public interface PileIndicatorsConfig extends Config } @ConfigItem( - position = 1, - keyName = "enablePlayers", - name = "Enable Player Piling", - description = "Enable the option to highlight players when they pile.", - parent = "playerPilesStub" + position = 1, + keyName = "enablePlayers", + name = "Enable Player Piling", + description = "Enable the option to highlight players when they pile.", + parent = "playerPilesStub" ) default boolean enablePlayers() { @@ -58,11 +58,11 @@ public interface PileIndicatorsConfig extends Config } @ConfigItem( - position = 2, - keyName = "wildyOnlyPlayer", - name = "Wilderness Only", - description = "Show player piling only when in the Wilderness.", - parent = "playerPilesStub" + position = 2, + keyName = "wildyOnlyPlayer", + name = "Wilderness Only", + description = "Show player piling only when in the Wilderness.", + parent = "playerPilesStub" ) default boolean wildyOnlyPlayer() { @@ -70,11 +70,11 @@ public interface PileIndicatorsConfig extends Config } @ConfigItem( - position = 3, - keyName = "playerPileColor", - name = "Player Pile Color", - description = "Color used for player piles.", - parent = "playerPilesStub" + position = 3, + keyName = "playerPileColor", + name = "Player Pile Color", + description = "Color used for player piles.", + parent = "playerPilesStub" ) default Color playerPileColor() { @@ -82,10 +82,10 @@ public interface PileIndicatorsConfig extends Config } @ConfigItem( - keyName = "npcPilesStub", - name = "NPC Piles", - description = "", - position = 4 + keyName = "npcPilesStub", + name = "NPC Piles", + description = "", + position = 4 ) default Stub npcPilesStub() { @@ -93,11 +93,11 @@ public interface PileIndicatorsConfig extends Config } @ConfigItem( - position = 5, - keyName = "enableNPCS", - name = "Enable NPC Piling", - description = "Enable the option to highlight NPCs when they pile.", - parent = "npcPilesStub" + position = 5, + keyName = "enableNPCS", + name = "Enable NPC Piling", + description = "Enable the option to highlight NPCs when they pile.", + parent = "npcPilesStub" ) default boolean enableNPCS() { @@ -105,11 +105,11 @@ public interface PileIndicatorsConfig extends Config } @ConfigItem( - position = 6, - keyName = "npcPileColor", - name = "NPC Pile Color", - description = "Color used for NPC piles.", - parent = "npcPilesStub" + position = 6, + keyName = "npcPileColor", + name = "NPC Pile Color", + description = "Color used for NPC piles.", + parent = "npcPilesStub" ) default Color npcPileColor() { @@ -117,10 +117,10 @@ public interface PileIndicatorsConfig extends Config } @ConfigItem( - keyName = "mixedPilesStub", - name = "Mixed Piles", - description = "", - position = 7 + keyName = "mixedPilesStub", + name = "Mixed Piles", + description = "", + position = 7 ) default Stub mixedPilesStub() { @@ -128,11 +128,11 @@ public interface PileIndicatorsConfig extends Config } @ConfigItem( - position = 8, - keyName = "mixedPileColor", - name = "Mixed Pile Color", - description = "Color used for mixed piles.", - parent = "mixedPilesStub" + position = 8, + keyName = "mixedPileColor", + name = "Mixed Pile Color", + description = "Color used for mixed piles.", + parent = "mixedPilesStub" ) default Color mixedPileColor() { @@ -140,10 +140,10 @@ public interface PileIndicatorsConfig extends Config } @ConfigItem( - keyName = "pilesSizeStub", - name = "Pile size", - description = "", - position = 9 + keyName = "pilesSizeStub", + name = "Pile size", + description = "", + position = 9 ) default Stub pilesSizeStub() { @@ -151,14 +151,14 @@ public interface PileIndicatorsConfig extends Config } @Range( - min = 2 + min = 2 ) @ConfigItem( - position = 10, - keyName = "minimumPileSize", - name = "Minimum Pile Size", - description = "Any pile under this size will not show up. (Minimum: 2)", - parent = "pilesSizeStub" + position = 10, + keyName = "minimumPileSize", + name = "Minimum Pile Size", + description = "Any pile under this size will not show up. (Minimum: 2)", + parent = "pilesSizeStub" ) default int minimumPileSize() { @@ -166,10 +166,10 @@ public interface PileIndicatorsConfig extends Config } @ConfigItem( - keyName = "miscellaneousStub", - name = "Miscellaneous", - description = "", - position = 11 + keyName = "miscellaneousStub", + name = "Miscellaneous", + description = "", + position = 11 ) default Stub miscellaneousStub() { @@ -177,11 +177,11 @@ public interface PileIndicatorsConfig extends Config } @ConfigItem( - position = 12, - keyName = "numberOnly", - name = "Display Number Only", - description = "Shorten \"PILE SIZE: 1\" to \"1\"", - parent = "miscellaneousStub" + position = 12, + keyName = "numberOnly", + name = "Display Number Only", + description = "Shorten \"PILE SIZE: 1\" to \"1\"", + parent = "miscellaneousStub" ) default boolean numberOnly() { @@ -189,11 +189,11 @@ public interface PileIndicatorsConfig extends Config } @ConfigItem( - position = 13, - keyName = "drawPileTile", - name = "Draw Pile Tile", - description = "Draws the tile of the pile for best visibility.", - parent = "miscellaneousStub" + position = 13, + keyName = "drawPileTile", + name = "Draw Pile Tile", + description = "Draws the tile of the pile for best visibility.", + parent = "miscellaneousStub" ) default boolean drawPileTile() { @@ -201,11 +201,11 @@ public interface PileIndicatorsConfig extends Config } @ConfigItem( - position = 14, - keyName = "drawPileHull", - name = "Draw Pile Convex Hull", - description = "Draws the hull of the pile for best visibility.", - parent = "miscellaneousStub" + position = 14, + keyName = "drawPileHull", + name = "Draw Pile Convex Hull", + description = "Draws the hull of the pile for best visibility.", + parent = "miscellaneousStub" ) default boolean drawPileHull() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pileindicators/PileIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pileindicators/PileIndicatorsOverlay.java index 1479c1f2fa..a1d69ccff2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pileindicators/PileIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pileindicators/PileIndicatorsOverlay.java @@ -24,39 +24,35 @@ package net.runelite.client.plugins.pileindicators; -import net.runelite.api.Actor; -import net.runelite.api.Client; - -import javax.inject.Inject; -import java.awt.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; import java.util.ArrayList; +import javax.inject.Inject; +import javax.inject.Singleton; +import net.runelite.api.Actor; 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 PileIndicatorsOverlay extends Overlay { - - private final Client client; private final PileIndicatorsPlugin plugin; - private final PileIndicatorsConfig config; @Inject - PileIndicatorsOverlay(final Client client, final PileIndicatorsPlugin plugin, final PileIndicatorsConfig config) + PileIndicatorsOverlay(final PileIndicatorsPlugin plugin) { super(plugin); - this.client = client; this.plugin = plugin; - this.config = config; setLayer(OverlayLayer.ABOVE_SCENE); setPosition(OverlayPosition.DYNAMIC); setPriority(OverlayPriority.HIGH); } - @Override public Dimension render(Graphics2D graphics) { @@ -73,12 +69,12 @@ public class PileIndicatorsOverlay extends Overlay { Actor actorToRender = actorArrayList.get(0); //guaranteed to have at least two players final String pileTypeStr = pileType == PileType.PLAYER_PILE ? "PLAYER" : pileType == PileType.NPC_PILE ? "NPC" : pileType == PileType.MIXED_PILE ? "MIXED" : ""; - final String text = config.numberOnly() ? "" + actorArrayList.size() : (pileTypeStr + " PILE SIZE: " + actorArrayList.size()); - if (config.drawPileTile()) + final String text = plugin.isNumberOnly() ? "" + actorArrayList.size() : (pileTypeStr + " PILE SIZE: " + actorArrayList.size()); + if (plugin.isDrawPileTile()) { OverlayUtil.renderPolygon(graphics, actorToRender.getCanvasTilePoly(), pileColor); } - if (config.drawPileHull()) + if (plugin.isDrawPileHull()) { OverlayUtil.renderPolygon(graphics, actorToRender.getConvexHull(), pileColor); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pileindicators/PileIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/pileindicators/PileIndicatorsPlugin.java index 2afa035caa..32e04d6612 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pileindicators/PileIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pileindicators/PileIndicatorsPlugin.java @@ -24,31 +24,33 @@ package net.runelite.client.plugins.pileindicators; -import com.google.inject.Binder; import com.google.inject.Provides; +import java.awt.Color; +import java.util.ArrayList; +import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Actor; import net.runelite.api.Client; import net.runelite.api.NPC; import net.runelite.api.Player; import net.runelite.api.Varbits; +import net.runelite.api.events.ConfigChanged; import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginType; import net.runelite.client.ui.overlay.OverlayManager; -import javax.inject.Inject; -import javax.inject.Singleton; -import java.awt.*; -import java.util.ArrayList; - @PluginDescriptor( - name = "Pile Indicators", - description = "Highlight and count how many npcs/players are stacked on each other.", - tags = {"overlay", "pile", "stack", "pvp", "pvm", "pve"}, - type = PluginType.UTILITY, - enabledByDefault = false + name = "Pile Indicators", + description = "Highlight and count how many npcs/players are stacked on each other.", + tags = {"overlay", "pile", "stack", "pvp", "pvm", "pve"}, + type = PluginType.UTILITY, + enabledByDefault = false ) @Singleton @@ -68,20 +70,30 @@ public class PileIndicatorsPlugin extends Plugin @Inject private PileIndicatorsOverlay overlay; + private boolean enablePlayers; + private boolean wildyOnlyPlayer; + private Color playerPileColor; + private boolean enableNPCS; + private Color npcPileColor; + private Color mixedPileColor; + private int minimumPileSize; + @Getter(AccessLevel.PACKAGE) + private boolean numberOnly; + @Getter(AccessLevel.PACKAGE) + private boolean drawPileTile; + @Getter(AccessLevel.PACKAGE) + private boolean drawPileHull; + @Provides PileIndicatorsConfig provideConfig(ConfigManager configManager) { return configManager.getConfig(PileIndicatorsConfig.class); } - @Override - public void configure(Binder binder) - { - } - @Override protected void startUp() throws Exception { + updateConfig(); overlayManager.add(overlay); } @@ -91,13 +103,13 @@ public class PileIndicatorsPlugin extends Plugin overlayManager.remove(overlay); } - protected ArrayList> getStacks() + ArrayList> getStacks() { ArrayList> outerArrayList = new ArrayList<>(); ArrayList pileList = new ArrayList<>(); - if (config.enableNPCS()) + if (this.enableNPCS) { for (NPC npc : client.getNpcs()) { @@ -108,9 +120,9 @@ public class PileIndicatorsPlugin extends Plugin } } - if (config.enablePlayers()) + if (this.enablePlayers) { - if ((client.getVar(Varbits.IN_WILDERNESS) > 0 && config.wildyOnlyPlayer()) ^ (!config.wildyOnlyPlayer())) + if ((client.getVar(Varbits.IN_WILDERNESS) > 0 && this.wildyOnlyPlayer) ^ (!this.wildyOnlyPlayer)) { for (Player player : client.getPlayers()) { @@ -140,7 +152,7 @@ public class PileIndicatorsPlugin extends Plugin } } } - if (potentialStackArrayList.size() >= config.minimumPileSize()) + if (potentialStackArrayList.size() >= this.minimumPileSize) { outerArrayList.add(potentialStackArrayList); } @@ -149,21 +161,21 @@ public class PileIndicatorsPlugin extends Plugin return outerArrayList.size() != 0 ? outerArrayList : null; } - protected Color getColorByPileType(PileType pileType) + Color getColorByPileType(PileType pileType) { switch (pileType) { case PLAYER_PILE: - return config.playerPileColor(); + return this.playerPileColor; case NPC_PILE: - return config.npcPileColor(); + return this.npcPileColor; case MIXED_PILE: - return config.mixedPileColor(); + return this.mixedPileColor; } return null; } - protected PileType getPileType(ArrayList pile) + PileType getPileType(ArrayList pile) { PileType pileType = null; @@ -188,4 +200,29 @@ public class PileIndicatorsPlugin extends Plugin } return pileType; } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("pileindicators")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.enablePlayers = config.enablePlayers(); + this.wildyOnlyPlayer = config.wildyOnlyPlayer(); + this.playerPileColor = config.playerPileColor(); + this.enableNPCS = config.enableNPCS(); + this.npcPileColor = config.npcPileColor(); + this.mixedPileColor = config.mixedPileColor(); + this.minimumPileSize = config.minimumPileSize(); + this.numberOnly = config.numberOnly(); + this.drawPileTile = config.drawPileTile(); + this.drawPileHull = config.drawPileHull(); + } } 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 47ce1fd775..754fa73414 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 @@ -210,17 +210,17 @@ public interface PlayerIndicatorsConfig extends Config return false; } - @ConfigItem( - position = 16, - keyName = "highlightOverheadTargets", - name = "Highlights attackable players over their head", - description = "Highlights players over their head that the current player can attack based on combat/wilderness levels", - group = "Target Indicator" - ) - default boolean highlightOverheadTargets() - { - return false; - } +// @ConfigItem( +// position = 16, +// keyName = "highlightOverheadTargets", +// name = "Highlights attackable players over their head", +// description = "Highlights players over their head that the current player can attack based on combat/wilderness levels", +// group = "Target Indicator" +// ) +// default boolean highlightOverheadTargets() +// { +// return false; +// } @ConfigItem( position = 17, diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsMinimapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsMinimapOverlay.java index e356d9b5f2..b8be4f674d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsMinimapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsMinimapOverlay.java @@ -45,14 +45,14 @@ import net.runelite.client.util.ImageUtil; public class PlayerIndicatorsMinimapOverlay extends Overlay { private final PlayerIndicatorsService playerIndicatorsService; - private final PlayerIndicatorsConfig config; + private final PlayerIndicatorsPlugin plugin; private final BufferedImage skullIcon = ImageUtil.getResourceStreamFromClass(PlayerIndicatorsPlugin.class, "skull.png"); @Inject - private PlayerIndicatorsMinimapOverlay(PlayerIndicatorsConfig config, PlayerIndicatorsService playerIndicatorsService) + private PlayerIndicatorsMinimapOverlay(final PlayerIndicatorsPlugin plugin, final PlayerIndicatorsService playerIndicatorsService) { - this.config = config; + this.plugin = plugin; this.playerIndicatorsService = playerIndicatorsService; setLayer(OverlayLayer.ABOVE_WIDGETS); setPosition(OverlayPosition.DYNAMIC); @@ -68,7 +68,7 @@ public class PlayerIndicatorsMinimapOverlay extends Overlay private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color) { - if (config.drawMinimapNames()) + if (plugin.isDrawMinimapNames()) { String name = actor.getName().replace('\u00A0', ' '); String tag = ""; @@ -84,20 +84,17 @@ public class PlayerIndicatorsMinimapOverlay extends Overlay if (minimapLocation != null) { - if (config.showCombatLevel()) + if (plugin.isShowCombatLevel()) { - if (config.showCombatLevel()) - { - name += "-(" + actor.getCombatLevel() + ")"; - } + name += "-(" + actor.getCombatLevel() + ")"; } - if (config.drawMinimapNames()) + if (plugin.isDrawMinimapNames()) { - if (actor.getSkullIcon() != null && config.playerSkull() && actor.getSkullIcon() == SkullIcon.SKULL) + if (actor.getSkullIcon() != null && plugin.isPlayerSkull() && actor.getSkullIcon() == SkullIcon.SKULL) { int width = graphics.getFontMetrics().stringWidth(name); int height = graphics.getFontMetrics().getHeight(); - if (config.skullLocation().equals(PlayerIndicatorsPlugin.MinimapSkullLocations.AFTER_NAME)) + if (plugin.getSkullLocation().equals(PlayerIndicatorsPlugin.MinimapSkullLocations.AFTER_NAME)) { OverlayUtil.renderImageLocation(graphics, new Point(minimapLocation.getX() + width, minimapLocation.getY() - height), 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 bd9d0bed03..8e4bc9aa9f 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 @@ -57,8 +57,8 @@ public class PlayerIndicatorsOverlay extends Overlay private static final int ACTOR_HORIZONTAL_TEXT_MARGIN = 10; private final PlayerIndicatorsService playerIndicatorsService; - private final PlayerIndicatorsConfig config; private final ClanManager clanManager; + private final PlayerIndicatorsPlugin plugin; private final BufferedImage skullIcon = ImageUtil.getResourceStreamFromClass(PlayerIndicatorsPlugin.class, "skull.png"); @Inject @@ -69,10 +69,10 @@ public class PlayerIndicatorsOverlay extends Overlay private ItemManager itemManager; @Inject - private PlayerIndicatorsOverlay(PlayerIndicatorsConfig config, PlayerIndicatorsService playerIndicatorsService, - ClanManager clanManager) + private PlayerIndicatorsOverlay(final PlayerIndicatorsPlugin plugin, final PlayerIndicatorsService playerIndicatorsService, + final ClanManager clanManager) { - this.config = config; + this.plugin = plugin; this.playerIndicatorsService = playerIndicatorsService; this.clanManager = clanManager; setPosition(OverlayPosition.DYNAMIC); @@ -88,7 +88,7 @@ public class PlayerIndicatorsOverlay extends Overlay private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color) { - final PlayerNameLocation drawPlayerNamesConfig = config.playerNamePosition(); + final PlayerNameLocation drawPlayerNamesConfig = plugin.getPlayerNamePosition(); if (drawPlayerNamesConfig == PlayerNameLocation.DISABLED) { return; @@ -125,7 +125,7 @@ public class PlayerIndicatorsOverlay extends Overlay return; } - if (config.showClanRanks() && actor.isClanMember()) + if (plugin.isShowClanRanks() && actor.isClanMember()) { final ClanMemberRank rank = clanManager.getRank(name); @@ -168,18 +168,18 @@ public class PlayerIndicatorsOverlay extends Overlay name += tag; } - if (config.highlightCallers() && playerIndicatorsPlugin.isCaller(actor)) + if (plugin.isHighlightCallers() && playerIndicatorsPlugin.isCaller(actor)) { name = "[C] " + name; } - if (config.showCombatLevel()) + if (plugin.isShowCombatLevel()) { OverlayUtil.renderTextLocation(graphics, textLocation, name + " (" + actor.getCombatLevel() + ")", color); } - if (config.targetRisk() && PvPUtil.isAttackable(client, actor) && actor.getPlayerAppearance() != null) + if (plugin.isTargetRisk() && PvPUtil.isAttackable(client, actor) && actor.getPlayerAppearance() != null) { long totalValue = 0; int newValue; @@ -200,7 +200,7 @@ public class PlayerIndicatorsOverlay extends Overlay name = name + stringBuilder; } } - if (config.unchargedGlory() && actor.getPlayerAppearance() != null) + if (plugin.isUnchargedGlory() && actor.getPlayerAppearance() != null) { ItemDefinition itemComposition = itemManager.getItemDefinition(actor.getPlayerAppearance().getEquipmentId(KitType.AMULET)); if (itemComposition != null && itemComposition.getId() == 1704) //1704 is uncharged glory, to be certain @@ -209,11 +209,11 @@ public class PlayerIndicatorsOverlay extends Overlay } } - if (actor.getSkullIcon() != null && config.playerSkull() && actor.getSkullIcon() == SkullIcon.SKULL) + if (actor.getSkullIcon() != null && plugin.isPlayerSkull() && actor.getSkullIcon() == SkullIcon.SKULL) { int width = graphics.getFontMetrics().stringWidth(name); int height = graphics.getFontMetrics().getHeight(); - if (config.skullLocation().equals(PlayerIndicatorsPlugin.MinimapSkullLocations.AFTER_NAME)) + if (plugin.getSkullLocation().equals(PlayerIndicatorsPlugin.MinimapSkullLocations.AFTER_NAME)) { OverlayUtil.renderImageLocation(graphics, new Point(textLocation.getX() + width, textLocation.getY() - height), 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 12358a2273..90ee0fb013 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 @@ -28,8 +28,10 @@ import com.google.inject.Provides; import java.awt.Color; import java.util.ArrayList; import java.util.Arrays; -import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; import net.runelite.api.ClanMember; import net.runelite.api.ClanMemberRank; import static net.runelite.api.ClanMemberRank.UNRANKED; @@ -67,6 +69,7 @@ import net.runelite.client.util.PvPUtil; description = "Highlight players on-screen and/or on the minimap", tags = {"highlight", "minimap", "overlay", "players", "pklite"} ) +@Singleton public class PlayerIndicatorsPlugin extends Plugin { @Inject @@ -90,6 +93,60 @@ public class PlayerIndicatorsPlugin extends Plugin @Inject private ClanManager clanManager; + @Getter(AccessLevel.PACKAGE) + private boolean highlightOwnPlayer; + @Getter(AccessLevel.PACKAGE) + private Color getOwnPlayerColor; + @Getter(AccessLevel.PACKAGE) + private boolean highlightFriends; + @Getter(AccessLevel.PACKAGE) + private Color getFriendColor; + @Getter(AccessLevel.PACKAGE) + private boolean drawClanMemberNames; + @Getter(AccessLevel.PACKAGE) + private Color getClanMemberColor; + @Getter(AccessLevel.PACKAGE) + private boolean highlightTeamMembers; + @Getter(AccessLevel.PACKAGE) + private Color getTeamMemberColor; + @Getter(AccessLevel.PACKAGE) + private boolean highlightNonClanMembers; + @Getter(AccessLevel.PACKAGE) + private Color getNonClanMemberColor; + @Getter(AccessLevel.PACKAGE) + private boolean drawTiles; + @Getter(AccessLevel.PACKAGE) + private PlayerNameLocation playerNamePosition; + @Getter(AccessLevel.PACKAGE) + private boolean drawMinimapNames; + private boolean colorPlayerMenu; + @Getter(AccessLevel.PACKAGE) + private boolean showClanRanks; + @Getter(AccessLevel.PACKAGE) + private boolean highlightTargets; + @Getter(AccessLevel.PACKAGE) + private Color getTargetColor; + @Getter(AccessLevel.PACKAGE) + private boolean showCombatLevel; + @Getter(AccessLevel.PACKAGE) + private boolean playerSkull; + @Getter(AccessLevel.PACKAGE) + private PlayerIndicatorsPlugin.MinimapSkullLocations skullLocation; + @Getter(AccessLevel.PACKAGE) + private boolean skulledTargetsOnly; + @Getter(AccessLevel.PACKAGE) + private boolean targetRisk; + private boolean useClanchatRanks; + private ClanMemberRank callerRank; + @Getter(AccessLevel.PACKAGE) + private String configCallers; + @Getter(AccessLevel.PACKAGE) + private boolean highlightCallers; + @Getter(AccessLevel.PACKAGE) + private Color callerColor; + @Getter(AccessLevel.PACKAGE) + private boolean unchargedGlory; + @Provides PlayerIndicatorsConfig provideConfig(ConfigManager configManager) { @@ -99,6 +156,8 @@ public class PlayerIndicatorsPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(playerIndicatorsOverlay); overlayManager.add(playerIndicatorsTileOverlay); overlayManager.add(playerIndicatorsMinimapOverlay); @@ -114,12 +173,18 @@ public class PlayerIndicatorsPlugin extends Plugin } private ArrayList callers = new ArrayList<>(); - private List pileList; @Subscribe - public void onConfigChanged(ConfigChanged e) + public void onConfigChanged(ConfigChanged event) { - if (config.callers() != null && !config.callers().trim().equals("")) + if (!event.getGroup().equals("playerindicators")) + { + return; + } + + updateConfig(); + + if (this.configCallers != null && !this.configCallers.trim().equals("")) { getCallerList(); } @@ -140,28 +205,27 @@ public class PlayerIndicatorsPlugin extends Plugin private void getCallerList() { callers.clear(); - if (config.useClanchatRanks() && client.getClanMembers() != null) + if (this.useClanchatRanks && client.getClanMembers() != null) { for (ClanMember clanMember : client.getClanMembers()) { - if (clanMember.getRank().getValue() > config.callerRank().getValue()) + if (clanMember.getRank().getValue() > this.callerRank.getValue()) { callers.add(clanMember.getUsername()); } } } - if (config.callers().contains(",")) + if (this.configCallers.contains(",")) { - callers.addAll(Arrays.asList(config.callers().split(","))); + callers.addAll(Arrays.asList(this.configCallers.split(","))); } else { - if (!config.callers().equals("") || config.callers().length() > 1) + if (!this.configCallers.equals("")) { - callers.add(config.callers()); + callers.add(this.configCallers); } } - pileList = Arrays.asList(new String[callers.size()]); } boolean isCaller(Player player) @@ -223,13 +287,13 @@ public class PlayerIndicatorsPlugin extends Plugin int image2 = -1; Color color = null; - if (config.colorPlayerMenu() && client.isFriended(player.getName(), false)) + if (this.colorPlayerMenu && client.isFriended(player.getName(), false)) { - color = config.getFriendColor(); + color = this.getFriendColor; } - else if (config.colorPlayerMenu() && player.isClanMember()) + else if (this.colorPlayerMenu && player.isClanMember()) { - color = config.getClanMemberColor(); + color = this.getClanMemberColor; ClanMemberRank rank = clanManager.getRank(player.getName()); if (rank != UNRANKED) @@ -237,21 +301,21 @@ public class PlayerIndicatorsPlugin extends Plugin image = clanManager.getIconNumber(rank); } } - else if (config.colorPlayerMenu() && player.getTeam() > 0 && localPlayer.getTeam() == player.getTeam()) + else if (this.colorPlayerMenu && player.getTeam() > 0 && localPlayer.getTeam() == player.getTeam()) { - color = config.getTeamMemberColor(); + color = this.getTeamMemberColor; } - else if (config.highlightNonClanMembers() && !player.isClanMember() && !player.isFriend() && !PvPUtil.isAttackable(client, player)) + else if (this.highlightNonClanMembers && !player.isClanMember() && !player.isFriend() && !PvPUtil.isAttackable(client, player)) { - color = config.getNonClanMemberColor(); + color = this.getNonClanMemberColor; } - else if (config.colorPlayerMenu() && !player.isClanMember() && client.isFriended(player.getName(), false) && PvPUtil.isAttackable(client, player)) + else if (this.colorPlayerMenu && !player.isClanMember() && client.isFriended(player.getName(), false) && PvPUtil.isAttackable(client, player)) { - color = config.getTargetColor(); + color = this.getTargetColor; } - else if (config.colorPlayerMenu() && PvPUtil.isAttackable(client, player) && !player.isClanMember() && !player.isFriend()) + else if (this.colorPlayerMenu && PvPUtil.isAttackable(client, player) && !player.isClanMember() && !player.isFriend()) { - color = config.getTargetColor(); + color = this.getTargetColor; } /* if (config.rightClickOverhead() && !player.isClanMember() && player.getOverheadIcon() != null) { @@ -280,13 +344,13 @@ public class PlayerIndicatorsPlugin extends Plugin image = 34; } }*/ - if (config.playerSkull() && !player.isClanMember() && player.getSkullIcon() != null) + if (this.playerSkull && !player.isClanMember() && player.getSkullIcon() != null) { image2 = 35; } - if (config.colorPlayerMenu() && config.highlightCallers() && this.isCaller(player)) + if (this.colorPlayerMenu && this.highlightCallers && this.isCaller(player)) { - color = config.callerColor(); + color = this.callerColor; } if (image != -1 || color != null) { @@ -294,7 +358,7 @@ public class PlayerIndicatorsPlugin extends Plugin MenuEntry lastEntry = menuEntries[menuEntries.length - 1]; - if (color != null && config.colorPlayerMenu()) + if (color != null && this.colorPlayerMenu) { // strip out existing "); }*/ - if (image2 != -1 && config.playerSkull()) + if (image2 != -1 && this.playerSkull) { lastEntry.setTarget("" + lastEntry.getTarget()); } @@ -326,4 +390,36 @@ public class PlayerIndicatorsPlugin extends Plugin BEFORE_NAME, AFTER_NAME } + + private void updateConfig() + { + this.highlightOwnPlayer = config.highlightOwnPlayer(); + this.getOwnPlayerColor = config.getOwnPlayerColor(); + this.highlightFriends = config.highlightFriends(); + this.getFriendColor = config.getFriendColor(); + this.drawClanMemberNames = config.drawClanMemberNames(); + this.getClanMemberColor = config.getClanMemberColor(); + this.highlightTeamMembers = config.highlightTeamMembers(); + this.getTeamMemberColor = config.getTeamMemberColor(); + this.highlightNonClanMembers = config.highlightNonClanMembers(); + this.getNonClanMemberColor = config.getNonClanMemberColor(); + this.drawTiles = config.drawTiles(); + this.playerNamePosition = config.playerNamePosition(); + this.drawMinimapNames = config.drawMinimapNames(); + this.colorPlayerMenu = config.colorPlayerMenu(); + this.showClanRanks = config.showClanRanks(); + this.highlightTargets = config.highlightTargets(); + this.getTargetColor = config.getTargetColor(); + this.showCombatLevel = config.showCombatLevel(); + this.playerSkull = config.playerSkull(); + this.skullLocation = config.skullLocation(); + this.skulledTargetsOnly = config.skulledTargetsOnly(); + this.targetRisk = config.targetRisk(); + this.useClanchatRanks = config.useClanchatRanks(); + this.callerRank = config.callerRank(); + this.configCallers = config.callers(); + this.highlightCallers = config.highlightCallers(); + this.callerColor = config.callerColor(); + this.unchargedGlory = config.unchargedGlory(); + } } 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 51717af33f..90e224a044 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 @@ -36,21 +36,19 @@ import net.runelite.client.util.PvPUtil; public class PlayerIndicatorsService { private final Client client; - private final PlayerIndicatorsConfig config; - private final PlayerIndicatorsPlugin playerIndicatorsPlugin; + private final PlayerIndicatorsPlugin plugin; @Inject - private PlayerIndicatorsService(Client client, PlayerIndicatorsConfig config, PlayerIndicatorsPlugin plugin) + private PlayerIndicatorsService(final Client client, final PlayerIndicatorsPlugin plugin) { - this.config = config; this.client = client; - this.playerIndicatorsPlugin = plugin; + this.plugin = plugin; } public void forEachPlayer(final BiConsumer consumer) { - if (!config.highlightOwnPlayer() && !config.drawClanMemberNames() - && !config.highlightFriends() && !config.highlightNonClanMembers() && !config.highlightTargets() && !config.highlightCallers() && !config.highlightTeamMembers()) + if (!plugin.isHighlightOwnPlayer() && !plugin.isDrawClanMemberNames() + && !plugin.isHighlightFriends() && !plugin.isHighlightNonClanMembers() && !plugin.isHighlightTargets() && !plugin.isHighlightCallers() && !plugin.isHighlightTeamMembers()) { return; } @@ -68,43 +66,43 @@ public class PlayerIndicatorsService if (player == localPlayer) { - if (config.highlightOwnPlayer()) + if (plugin.isHighlightOwnPlayer()) { - consumer.accept(player, config.getOwnPlayerColor()); + consumer.accept(player, plugin.getGetOwnPlayerColor()); } } - else if (config.highlightFriends() && client.isFriended(player.getName(), false)) + else if (plugin.isHighlightFriends() && client.isFriended(player.getName(), false)) { - consumer.accept(player, config.getFriendColor()); + consumer.accept(player, plugin.getGetFriendColor()); } - else if (config.drawClanMemberNames() && isClanMember) + else if (plugin.isDrawClanMemberNames() && isClanMember) { - consumer.accept(player, config.getClanMemberColor()); + consumer.accept(player, plugin.getGetClanMemberColor()); } - else if (config.highlightTeamMembers() && localPlayer.getTeam() > 0 && + else if (plugin.isHighlightTeamMembers() && localPlayer.getTeam() > 0 && localPlayer.getTeam() == player.getTeam()) { - consumer.accept(player, config.getTeamMemberColor()); + consumer.accept(player, plugin.getGetTeamMemberColor()); } - else if (config.highlightNonClanMembers() && !isClanMember) + else if (plugin.isHighlightNonClanMembers() && !isClanMember) { - consumer.accept(player, config.getNonClanMemberColor()); + consumer.accept(player, plugin.getGetNonClanMemberColor()); } - else if (config.highlightTargets() && PvPUtil.isAttackable(client, player) && + else if (plugin.isHighlightTargets() && PvPUtil.isAttackable(client, player) && !client.isFriended(player.getName(), false) && !player.isClanMember()) { - if (config.skulledTargetsOnly() && player.getSkullIcon() != null) + if (plugin.isSkulledTargetsOnly() && player.getSkullIcon() != null) { - consumer.accept(player, config.getTargetColor()); + consumer.accept(player, plugin.getGetTargetColor()); } - else if (!config.skulledTargetsOnly()) + else if (!plugin.isSkulledTargetsOnly()) { - consumer.accept(player, config.getTargetColor()); + consumer.accept(player, plugin.getGetTargetColor()); } } - if (config.highlightCallers() && config.callers() != null && playerIndicatorsPlugin.isCaller(player)) + if (plugin.isHighlightCallers() && plugin.getConfigCallers() != null && plugin.isCaller(player)) { - consumer.accept(player, config.callerColor()); + consumer.accept(player, plugin.getCallerColor()); } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsTileOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsTileOverlay.java index 5ae7299db6..c3b35626bf 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsTileOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerindicators/PlayerIndicatorsTileOverlay.java @@ -29,23 +29,22 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Polygon; import javax.inject.Inject; +import javax.inject.Singleton; 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 PlayerIndicatorsTileOverlay extends Overlay { private final PlayerIndicatorsService playerIndicatorsService; - private final PlayerIndicatorsConfig config; private final PlayerIndicatorsPlugin playerIndicatorsPlugin; @Inject - private PlayerIndicatorsTileOverlay(PlayerIndicatorsConfig config, - PlayerIndicatorsService playerIndicatorsService, PlayerIndicatorsPlugin plugin) + private PlayerIndicatorsTileOverlay(final PlayerIndicatorsService playerIndicatorsService, final PlayerIndicatorsPlugin plugin) { - this.config = config; this.playerIndicatorsService = playerIndicatorsService; this.playerIndicatorsPlugin = plugin; setLayer(OverlayLayer.ABOVE_SCENE); @@ -56,11 +55,11 @@ public class PlayerIndicatorsTileOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!config.drawTiles() /*&& !config.drawPlayerHull()*/) + if (!playerIndicatorsPlugin.isDrawTiles() /*&& !config.drawPlayerHull()*/) { return null; } - else if (config.drawTiles()) + else { playerIndicatorsService.forEachPlayer((player, color) -> { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerinfo/PlayerInfoCustomIndicator.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerinfo/PlayerInfoCustomIndicator.java index bcb25d5577..906cd981fb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerinfo/PlayerInfoCustomIndicator.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerinfo/PlayerInfoCustomIndicator.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.playerinfo; import java.awt.Color; import java.awt.Image; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.Client; @@ -37,7 +38,7 @@ import net.runelite.client.util.ColorUtil; public class PlayerInfoCustomIndicator extends InfoBox { @AllArgsConstructor - @Getter + @Getter(AccessLevel.PACKAGE) enum IndicatorType { HEALTH("Current Hitpoints"), @@ -49,14 +50,14 @@ public class PlayerInfoCustomIndicator extends InfoBox private final String description; } - private final PlayerInfoConfig config; + private final PlayerInfoPlugin plugin; private final Client client; private final IndicatorType type; - PlayerInfoCustomIndicator(Image image, PlayerInfoPlugin plugin, PlayerInfoConfig config, Client client, IndicatorType type) + PlayerInfoCustomIndicator(final Image image, final PlayerInfoPlugin plugin, final Client client, final IndicatorType type) { super(image, plugin); - this.config = config; + this.plugin = plugin; this.client = client; this.type = type; @@ -107,15 +108,15 @@ public class PlayerInfoCustomIndicator extends InfoBox if (currLvl > 1.0) { - return config.colorHigh(); + return plugin.getColorHigh(); } else if (currLvl > 0.5) { - return ColorUtil.colorLerp(config.colorMed(), config.colorHigh(), (currLvl * 2) - 1.0F); + return ColorUtil.colorLerp(plugin.getColorMed(), plugin.getColorHigh(), (currLvl * 2) - 1.0F); } else { - return ColorUtil.colorLerp(config.colorLow(), config.colorMed(), (currLvl * 2)); + return ColorUtil.colorLerp(plugin.getColorLow(), plugin.getColorMed(), (currLvl * 2)); } } @@ -125,15 +126,15 @@ public class PlayerInfoCustomIndicator extends InfoBox switch (type) { case HEALTH: - return config.enableHealth(); + return plugin.isEnableHealth(); case PRAYER: - return config.enablePrayer(); + return plugin.isEnablePrayer(); case ENERGY: - return config.enableEnergy(); + return plugin.isEnableEnergy(); case SPECIAL: - return config.enableSpec(); + return plugin.isEnableSpec(); case WORLD: - return config.enableWorld(); + return plugin.isEnableWorld(); } return false; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/playerinfo/PlayerInfoPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/playerinfo/PlayerInfoPlugin.java index 2f414f22d0..285cac241c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/playerinfo/PlayerInfoPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/playerinfo/PlayerInfoPlugin.java @@ -25,15 +25,17 @@ package net.runelite.client.plugins.playerinfo; import com.google.inject.Provides; +import java.awt.Color; import java.awt.image.BufferedImage; import javax.inject.Inject; import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.SpriteID; import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ConfigManager; -import net.runelite.client.game.SkillIconManager; import net.runelite.client.game.SpriteManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; @@ -48,7 +50,6 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager; type = PluginType.UTILITY, enabledByDefault = false ) - @Singleton public class PlayerInfoPlugin extends Plugin { @@ -67,8 +68,22 @@ public class PlayerInfoPlugin extends Plugin @Inject private SpriteManager spriteManager; - @Inject - private SkillIconManager skillIconManager; + @Getter(AccessLevel.PACKAGE) + private boolean enableHealth; + @Getter(AccessLevel.PACKAGE) + private boolean enablePrayer; + @Getter(AccessLevel.PACKAGE) + private boolean enableEnergy; + @Getter(AccessLevel.PACKAGE) + private boolean enableSpec; + @Getter(AccessLevel.PACKAGE) + private boolean enableWorld; + @Getter(AccessLevel.PACKAGE) + private Color colorHigh; + @Getter(AccessLevel.PACKAGE) + private Color colorMed; + @Getter(AccessLevel.PACKAGE) + private Color colorLow; @Provides PlayerInfoConfig provideConfig(ConfigManager configManager) @@ -79,6 +94,8 @@ public class PlayerInfoPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + clientThread.invoke(() -> { if (client.getGameState().ordinal() < GameState.LOGIN_SCREEN.ordinal()) @@ -92,11 +109,11 @@ public class PlayerInfoPlugin extends Plugin BufferedImage combatImg = spriteManager.getSprite(SpriteID.MINIMAP_ORB_SPECIAL_ICON, 0); BufferedImage worldImg = spriteManager.getSprite(SpriteID.MINIMAP_ORB_WORLD_MAP_PLANET, 0); - infoBoxManager.addInfoBox(new PlayerInfoCustomIndicator(healthImg, this, config, client, IndicatorType.HEALTH)); - infoBoxManager.addInfoBox(new PlayerInfoCustomIndicator(prayerImg, this, config, client, IndicatorType.PRAYER)); - infoBoxManager.addInfoBox(new PlayerInfoCustomIndicator(energyImg, this, config, client, IndicatorType.ENERGY)); - infoBoxManager.addInfoBox(new PlayerInfoCustomIndicator(combatImg, this, config, client, IndicatorType.SPECIAL)); - infoBoxManager.addInfoBox(new PlayerInfoCustomIndicator(worldImg, this, config, client, IndicatorType.WORLD)); + infoBoxManager.addInfoBox(new PlayerInfoCustomIndicator(healthImg, this, client, IndicatorType.HEALTH)); + infoBoxManager.addInfoBox(new PlayerInfoCustomIndicator(prayerImg, this, client, IndicatorType.PRAYER)); + infoBoxManager.addInfoBox(new PlayerInfoCustomIndicator(energyImg, this, client, IndicatorType.ENERGY)); + infoBoxManager.addInfoBox(new PlayerInfoCustomIndicator(combatImg, this, client, IndicatorType.SPECIAL)); + infoBoxManager.addInfoBox(new PlayerInfoCustomIndicator(worldImg, this, client, IndicatorType.WORLD)); return true; }); @@ -107,4 +124,16 @@ public class PlayerInfoPlugin extends Plugin { infoBoxManager.removeIf(i -> i instanceof PlayerInfoCustomIndicator); } + + private void updateConfig() + { + this.enableHealth = config.enableHealth(); + this.enablePrayer = config.enablePrayer(); + this.enableEnergy = config.enableEnergy(); + this.enableSpec = config.enableSpec(); + this.enableWorld = config.enableWorld(); + this.colorHigh = config.colorHigh(); + this.colorMed = config.colorMed(); + this.colorLow = config.colorLow(); + } } 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 index c33b63de06..9dfc3e30c7 100644 --- 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 @@ -30,6 +30,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.GameState; import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; @@ -47,6 +48,7 @@ import net.runelite.client.plugins.config.PluginListItem; tags = {"plugins", "organizer"}, type = PluginType.PLUGIN_ORGANIZER ) +@Singleton public class PluginSorterPlugin extends Plugin { //Cache the hidden plugins @@ -55,6 +57,13 @@ public class PluginSorterPlugin extends Plugin @Inject private PluginSorterConfig config; + private boolean hidePlugins; + private Color externalColor; + private Color pvmColor; + private Color pvpColor; + private Color skillingColor; + private Color utilityColor; + @Provides PluginSorterConfig provideConfig(ConfigManager configManager) { @@ -64,6 +73,7 @@ public class PluginSorterPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); updateColors(); } @@ -78,7 +88,7 @@ public class PluginSorterPlugin extends Plugin { if (gameStateChanged.getGameState() == GameState.LOGIN_SCREEN) { - if (config.hidePlugins()) + if (this.hidePlugins) { hidePlugins(); } @@ -89,9 +99,16 @@ public class PluginSorterPlugin extends Plugin @Subscribe public void onConfigChanged(ConfigChanged configChanged) { + if (!configChanged.getGroup().equals("pluginsorter")) + { + return; + } + + updateConfig(); + if (configChanged.getKey().equals("hidePlugins")) { - if (config.hidePlugins()) + if (this.hidePlugins) { hidePlugins(); } @@ -112,19 +129,19 @@ public class PluginSorterPlugin extends Plugin switch (pli.getPlugin().getClass().getAnnotation(PluginDescriptor.class).type()) { case EXTERNAL: - pli.nameLabel.setForeground(config.externalColor()); + pli.nameLabel.setForeground(this.externalColor); break; case PVM: - pli.nameLabel.setForeground(config.pvmColor()); + pli.nameLabel.setForeground(this.pvmColor); break; case PVP: - pli.nameLabel.setForeground(config.pvpColor()); + pli.nameLabel.setForeground(this.pvpColor); break; case SKILLING: - pli.nameLabel.setForeground(config.skillingColor()); + pli.nameLabel.setForeground(this.skillingColor); break; case UTILITY: - pli.nameLabel.setForeground(config.utilityColor()); + pli.nameLabel.setForeground(this.utilityColor); break; default: pli.nameLabel.setForeground(Color.WHITE); @@ -167,4 +184,14 @@ public class PluginSorterPlugin extends Plugin tempList.addAll(1, removedPlugins); ConfigPanel.pluginList = tempList; } + + private void updateConfig() + { + this.hidePlugins = config.hidePlugins(); + this.externalColor = config.externalColor(); + this.pvmColor = config.pvmColor(); + this.pvpColor = config.pvpColor(); + this.skillingColor = config.skillingColor(); + this.utilityColor = config.utilityColor(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/poh/BurnerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/poh/BurnerOverlay.java index 16c8d4edc3..45d38e4e8c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/poh/BurnerOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/poh/BurnerOverlay.java @@ -30,6 +30,7 @@ import java.awt.Graphics2D; import java.time.Duration; import java.time.Instant; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.Point; @@ -38,26 +39,25 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.components.ProgressPieComponent; +@Singleton class BurnerOverlay extends Overlay { private final Client client; - private final PohConfig config; private final PohPlugin plugin; @Inject - private BurnerOverlay(Client client, PohConfig config, PohPlugin plugin) + private BurnerOverlay(final Client client, final PohPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); this.client = client; - this.config = config; this.plugin = plugin; } @Override public Dimension render(Graphics2D graphics) { - if (!config.showBurner()) + if (!plugin.isShowBurner()) { return null; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/poh/IncenseBurner.java b/runelite-client/src/main/java/net/runelite/client/plugins/poh/IncenseBurner.java index c47f9bfe14..3d6acd175b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/poh/IncenseBurner.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/poh/IncenseBurner.java @@ -25,13 +25,14 @@ package net.runelite.client.plugins.poh; import java.time.Instant; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.Setter; -@Getter -@Setter +@Getter(AccessLevel.PACKAGE) +@Setter(AccessLevel.PACKAGE) @RequiredArgsConstructor @AllArgsConstructor class IncenseBurner diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/poh/PohOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/poh/PohOverlay.java index 9d048e584e..6ecb5392a4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/poh/PohOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/poh/PohOverlay.java @@ -30,6 +30,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.Perspective; @@ -38,6 +40,7 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; +@Singleton public class PohOverlay extends Overlay { private static final PohIcons[] PORTALS = new PohIcons[] @@ -50,20 +53,18 @@ public class PohOverlay extends Overlay private static final int MAX_DISTANCE = 2350; - @Getter + @Getter(AccessLevel.PACKAGE) private final List iconList = new ArrayList<>(); private final Client client; - private final PohConfig config; private final PohPlugin plugin; @Inject - public PohOverlay(Client client, PohConfig config, PohPlugin plugin) + public PohOverlay(final Client client, final PohPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); this.client = client; - this.config = config; this.plugin = plugin; } @@ -96,51 +97,51 @@ public class PohOverlay extends Overlay public void updateConfig() { iconList.clear(); - if (config.showPortals()) + if (plugin.isShowPortals()) { Collections.addAll(iconList, PORTALS); } - if (config.showAltar()) + if (plugin.isShowAltar()) { iconList.add(PohIcons.ALTAR); } - if (config.showGlory()) + if (plugin.isShowGlory()) { iconList.add(PohIcons.GLORY); } - if (config.showRepairStand()) + if (plugin.isShowRepairStand()) { iconList.add(PohIcons.REPAIR); } - if (config.showPools()) + if (plugin.isShowPools()) { iconList.add(PohIcons.POOLS); } - if (config.showExitPortal()) + if (plugin.isShowExitPortal()) { iconList.add(PohIcons.EXITPORTAL); } - if (config.showSpellbook()) + if (plugin.isShowSpellbook()) { iconList.add(PohIcons.SPELLBOOKALTAR); } - if (config.showJewelleryBox()) + if (plugin.isShowJewelleryBox()) { iconList.add(PohIcons.JEWELLERYBOX); } - if (config.showMagicTravel()) + if (plugin.isShowMagicTravel()) { iconList.add(PohIcons.MAGICTRAVEL); } - if (config.showPortalNexus()) + if (plugin.isShowPortalNexus()) { iconList.add(PohIcons.PORTALNEXUS); } - if (config.showDigsitePendant()) + if (plugin.isShowDigsitePendant()) { iconList.add(PohIcons.DIGSITEPENDANT); } - if (config.showXericsTalisman()) + if (plugin.isShowXericsTalisman()) { iconList.add(PohIcons.XERICSTALISMAN); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/poh/PohPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/poh/PohPlugin.java index be70c9689d..c71bfad61e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/poh/PohPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/poh/PohPlugin.java @@ -33,6 +33,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ScheduledExecutorService; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -71,6 +72,7 @@ import net.runelite.http.api.hiscore.Skill; tags = {"construction", "poh", "minimap", "overlay"} ) @Slf4j +@Singleton public class PohPlugin extends Plugin { static final Set BURNER_UNLIT = Sets.newHashSet(ObjectID.INCENSE_BURNER, ObjectID.INCENSE_BURNER_13210, ObjectID.INCENSE_BURNER_13212); @@ -88,6 +90,9 @@ public class PohPlugin extends Plugin @Inject private PohOverlay overlay; + @Inject + private PohConfig config; + @Inject private Client client; @@ -100,6 +105,33 @@ public class PohPlugin extends Plugin @Inject private BurnerOverlay burnerOverlay; + @Getter(AccessLevel.PACKAGE) + private boolean showPortals; + @Getter(AccessLevel.PACKAGE) + private boolean showAltar; + @Getter(AccessLevel.PACKAGE) + private boolean showGlory; + @Getter(AccessLevel.PACKAGE) + private boolean showPools; + @Getter(AccessLevel.PACKAGE) + private boolean showRepairStand; + @Getter(AccessLevel.PACKAGE) + private boolean showExitPortal; + @Getter(AccessLevel.PACKAGE) + private boolean showBurner; + @Getter(AccessLevel.PACKAGE) + private boolean showSpellbook; + @Getter(AccessLevel.PACKAGE) + private boolean showJewelleryBox; + @Getter(AccessLevel.PACKAGE) + private boolean showMagicTravel; + @Getter(AccessLevel.PACKAGE) + private boolean showPortalNexus; + @Getter(AccessLevel.PACKAGE) + private boolean showDigsitePendant; + @Getter(AccessLevel.PACKAGE) + private boolean showXericsTalisman; + @Provides PohConfig getConfig(ConfigManager configManager) { @@ -109,6 +141,8 @@ public class PohPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(overlay); overlayManager.add(burnerOverlay); overlay.updateConfig(); @@ -126,6 +160,13 @@ public class PohPlugin extends Plugin @Subscribe public void onConfigChanged(ConfigChanged event) { + if (!event.getGroup().equals("poh")) + { + return; + } + + updateConfig(); + overlay.updateConfig(); } @@ -247,4 +288,21 @@ public class PohPlugin extends Plugin incenseBurner.setCountdownTimer((200 + fmLevel) * tickLengthSeconds); incenseBurner.setRandomTimer(fmLevel * tickLengthSeconds); } + + private void updateConfig() + { + this.showPortals = config.showPortals(); + this.showAltar = config.showAltar(); + this.showGlory = config.showGlory(); + this.showPools = config.showPools(); + this.showRepairStand = config.showRepairStand(); + this.showExitPortal = config.showExitPortal(); + this.showBurner = config.showBurner(); + this.showSpellbook = config.showSpellbook(); + this.showJewelleryBox = config.showJewelleryBox(); + this.showMagicTravel = config.showMagicTravel(); + this.showPortalNexus = config.showPortalNexus(); + this.showDigsitePendant = config.showDigsitePendant(); + this.showXericsTalisman = config.showXericsTalisman(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/poison/PoisonActorOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/poison/PoisonActorOverlay.java index 020cf2e869..50fa729a60 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/poison/PoisonActorOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/poison/PoisonActorOverlay.java @@ -7,6 +7,7 @@ import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Actor; import net.runelite.api.Client; import net.runelite.api.Constants; @@ -22,6 +23,7 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton public class PoisonActorOverlay extends Overlay { private final PoisonPlugin plugin; @@ -30,7 +32,7 @@ public class PoisonActorOverlay extends Overlay private Font font; @Inject - PoisonActorOverlay(PoisonPlugin plugin, Client client) + PoisonActorOverlay(final PoisonPlugin plugin, final Client client) { this.plugin = plugin; this.client = client; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/poison/PoisonInfobox.java b/runelite-client/src/main/java/net/runelite/client/plugins/poison/PoisonInfobox.java index d7a3527a51..0810be80a9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/poison/PoisonInfobox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/poison/PoisonInfobox.java @@ -35,7 +35,7 @@ class PoisonInfobox extends Timer { private final PoisonPlugin plugin; - PoisonInfobox(int duration, BufferedImage image, PoisonPlugin plugin) + PoisonInfobox(final int duration, final BufferedImage image, final PoisonPlugin plugin) { super(duration, ChronoUnit.MILLIS, image, plugin); this.plugin = plugin; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/poison/PoisonOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/poison/PoisonOverlay.java index 758811f292..e709e4473a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/poison/PoisonOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/poison/PoisonOverlay.java @@ -28,6 +28,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Rectangle; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Point; import net.runelite.api.widgets.Widget; @@ -38,6 +39,7 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.tooltip.Tooltip; import net.runelite.client.ui.overlay.tooltip.TooltipManager; +@Singleton class PoisonOverlay extends Overlay { private final PoisonPlugin plugin; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/poison/PoisonPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/poison/PoisonPlugin.java index ff39332758..abf1f4c56e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/poison/PoisonPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/poison/PoisonPlugin.java @@ -37,6 +37,7 @@ import java.time.temporal.ChronoUnit; import java.util.HashMap; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.Getter; import net.runelite.api.Actor; import net.runelite.api.Client; @@ -69,6 +70,7 @@ import net.runelite.client.util.ImageUtil; description = "Tracks current damage values for Poison and Venom", tags = {"combat", "poison", "venom", "heart", "hp"} ) +@Singleton public class PoisonPlugin extends Plugin { private static final int POISON_TICK_MILLIS = 18000; @@ -126,6 +128,12 @@ public class PoisonPlugin extends Plugin @Getter private Map poisonedActors = new HashMap<>(); + private boolean showInfoboxes; + private boolean changeHealthIcon; + private boolean showForPlayers; + private boolean showForNpcs; + private int fontSize; + @Provides PoisonConfig getConfig(ConfigManager configManager) { @@ -135,10 +143,12 @@ public class PoisonPlugin extends Plugin @Override protected void startUp() throws Exception { - actorOverlay.setFontSize(config.fontSize()); + updateConfig(); + + actorOverlay.setFontSize(this.fontSize); overlayManager.add(poisonOverlay); - if (config.showForNpcs() || config.showForPlayers()) + if (this.showForNpcs || this.showForPlayers) { overlayManager.add(actorOverlay); } @@ -188,7 +198,7 @@ public class PoisonPlugin extends Plugin final int damage = nextDamage(poisonValue); this.lastDamage = damage; - if (config.showInfoboxes()) + if (this.showInfoboxes) { if (infobox != null) { @@ -232,8 +242,8 @@ public class PoisonPlugin extends Plugin Actor actor = event.getActor(); if (actor == client.getLocalPlayer() || - actor instanceof NPC && !config.showForNpcs() || - actor instanceof Player && !config.showForPlayers()) + actor instanceof NPC && !this.showForNpcs || + actor instanceof Player && !this.showForPlayers) { return; } @@ -313,13 +323,15 @@ public class PoisonPlugin extends Plugin return; } - if (!config.showInfoboxes() && infobox != null) + updateConfig(); + + if (!this.showInfoboxes && infobox != null) { infoBoxManager.removeInfoBox(infobox); infobox = null; } - if (config.changeHealthIcon()) + if (this.changeHealthIcon) { clientThread.invoke(this::checkHealthIcon); } @@ -332,18 +344,18 @@ public class PoisonPlugin extends Plugin { overlayManager.remove(actorOverlay); - if (!config.showForPlayers() && !config.showForNpcs()) + if (!this.showForPlayers && !this.showForNpcs) { poisonedActors.clear(); } else { - if (!config.showForNpcs()) + if (!this.showForNpcs) { poisonedActors.entrySet().removeIf(a -> a instanceof NPC); } - if (!config.showForPlayers()) + if (!this.showForPlayers) { poisonedActors.entrySet().removeIf(a -> a instanceof Player); } @@ -354,7 +366,7 @@ public class PoisonPlugin extends Plugin if (event.getKey().equals("fontsize")) { - actorOverlay.setFontSize(config.fontSize()); + actorOverlay.setFontSize(this.fontSize); } } @@ -449,7 +461,7 @@ public class PoisonPlugin extends Plugin private void checkHealthIcon() { - if (!config.changeHealthIcon()) + if (!this.changeHealthIcon) { return; } @@ -495,4 +507,13 @@ public class PoisonPlugin extends Plugin client.getSpriteOverrides().remove(SpriteID.MINIMAP_ORB_HITPOINTS_ICON); heart = null; } + + private void updateConfig() + { + this.showInfoboxes = config.showInfoboxes(); + this.changeHealthIcon = config.changeHealthIcon(); + this.showForPlayers = config.showForPlayers(); + this.showForNpcs = config.showForNpcs(); + this.fontSize = config.fontSize(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/prayagainstplayer/PlayerContainer.java b/runelite-client/src/main/java/net/runelite/client/plugins/prayagainstplayer/PlayerContainer.java index 68f78ab065..4ff815d6cd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/prayagainstplayer/PlayerContainer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/prayagainstplayer/PlayerContainer.java @@ -38,7 +38,7 @@ public class PlayerContainer private long whenTheyAttackedMe; private int millisToExpireHighlight; - PlayerContainer(Player player, long whenTheyAttackedMe, int millisToExpireHighlight) + PlayerContainer(final Player player, final long whenTheyAttackedMe, final int millisToExpireHighlight) { this.player = player; this.whenTheyAttackedMe = whenTheyAttackedMe; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/prayagainstplayer/PrayAgainstPlayerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/prayagainstplayer/PrayAgainstPlayerOverlay.java index a0ba2445cc..07ec30fec7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/prayagainstplayer/PrayAgainstPlayerOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/prayagainstplayer/PrayAgainstPlayerOverlay.java @@ -31,6 +31,7 @@ import java.awt.Polygon; import java.awt.image.BufferedImage; import java.util.ConcurrentModificationException; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.ItemDefinition; import net.runelite.api.Player; @@ -43,19 +44,18 @@ import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.util.Text; +@Singleton class PrayAgainstPlayerOverlay extends Overlay { private final PrayAgainstPlayerPlugin plugin; - private final PrayAgainstPlayerConfig config; private final Client client; @Inject - private PrayAgainstPlayerOverlay(PrayAgainstPlayerPlugin plugin, PrayAgainstPlayerConfig config, Client client) + private PrayAgainstPlayerOverlay(final PrayAgainstPlayerPlugin plugin, final Client client) { super(plugin); this.plugin = plugin; - this.config = config; this.client = client; setLayer(OverlayLayer.ABOVE_SCENE); @@ -86,21 +86,21 @@ class PrayAgainstPlayerOverlay extends Overlay { plugin.removePlayerFromPotentialContainer(container); } - if (config.drawPotentialTargetsName()) + if (plugin.isDrawPotentialTargetsName()) { - renderNameAboveHead(graphics, container.getPlayer(), config.potentialPlayerColor()); + renderNameAboveHead(graphics, container.getPlayer(), plugin.getPotentialPlayerColor()); } - if (config.drawPotentialTargetHighlight()) + if (plugin.isDrawPotentialTargetHighlight()) { - renderHighlightedPlayer(graphics, container.getPlayer(), config.potentialPlayerColor()); + renderHighlightedPlayer(graphics, container.getPlayer(), plugin.getPotentialPlayerColor()); } - if (config.drawPotentialTargetTile()) + if (plugin.isDrawPotentialTargetTile()) { - renderTileUnderPlayer(graphics, container.getPlayer(), config.potentialPlayerColor()); + renderTileUnderPlayer(graphics, container.getPlayer(), plugin.getPotentialPlayerColor()); } - if (config.drawPotentialTargetPrayAgainst()) + if (plugin.isDrawPotentialTargetPrayAgainst()) { - renderPrayAgainstOnPlayer(graphics, container.getPlayer(), config.potentialPlayerColor()); + renderPrayAgainstOnPlayer(graphics, container.getPlayer(), plugin.getPotentialPlayerColor()); } } } @@ -126,21 +126,21 @@ class PrayAgainstPlayerOverlay extends Overlay plugin.removePlayerFromAttackerContainer(container); } - if (config.drawTargetsName()) + if (plugin.isDrawTargetsName()) { - renderNameAboveHead(graphics, container.getPlayer(), config.attackerPlayerColor()); + renderNameAboveHead(graphics, container.getPlayer(), plugin.getAttackerPlayerColor()); } - if (config.drawTargetHighlight()) + if (plugin.isDrawTargetHighlight()) { - renderHighlightedPlayer(graphics, container.getPlayer(), config.attackerPlayerColor()); + renderHighlightedPlayer(graphics, container.getPlayer(), plugin.getAttackerPlayerColor()); } - if (config.drawTargetTile()) + if (plugin.isDrawTargetTile()) { - renderTileUnderPlayer(graphics, container.getPlayer(), config.attackerPlayerColor()); + renderTileUnderPlayer(graphics, container.getPlayer(), plugin.getAttackerPlayerColor()); } - if (config.drawTargetPrayAgainst()) + if (plugin.isDrawTargetPrayAgainst()) { - renderPrayAgainstOnPlayer(graphics, container.getPlayer(), config.attackerPlayerColor()); + renderPrayAgainstOnPlayer(graphics, container.getPlayer(), plugin.getAttackerPlayerColor()); } } } @@ -208,7 +208,7 @@ class PrayAgainstPlayerOverlay extends Overlay } else { - if (config.drawUnknownWeapons()) + if (plugin.isDrawUnknownWeapons()) { int itemId = player.getPlayerAppearance().getEquipmentId(KitType.WEAPON); ItemDefinition itemComposition = client.getItemDefinition(itemId); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/prayagainstplayer/PrayAgainstPlayerOverlayPrayerTab.java b/runelite-client/src/main/java/net/runelite/client/plugins/prayagainstplayer/PrayAgainstPlayerOverlayPrayerTab.java index 885bdd2e7d..0af7b52e28 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/prayagainstplayer/PrayAgainstPlayerOverlayPrayerTab.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/prayagainstplayer/PrayAgainstPlayerOverlayPrayerTab.java @@ -31,6 +31,7 @@ import java.awt.Polygon; import java.awt.Rectangle; import java.util.ConcurrentModificationException; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Player; import net.runelite.api.widgets.Widget; @@ -41,19 +42,18 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton class PrayAgainstPlayerOverlayPrayerTab extends Overlay { private final PrayAgainstPlayerPlugin plugin; - private final PrayAgainstPlayerConfig config; private final Client client; @Inject - private PrayAgainstPlayerOverlayPrayerTab(PrayAgainstPlayerPlugin plugin, PrayAgainstPlayerConfig config, Client client) + private PrayAgainstPlayerOverlayPrayerTab(final PrayAgainstPlayerPlugin plugin, final Client client) { super(plugin); this.plugin = plugin; - this.config = config; this.client = client; setPosition(OverlayPosition.DETACHED); @@ -76,7 +76,7 @@ class PrayAgainstPlayerOverlayPrayerTab extends Overlay if (plugin.getPlayersAttackingMe() != null && plugin.getPlayersAttackingMe().size() > 0) { // no reason to show you what prayers to pray in your prayer tab if multiple people are attacking you - if ((plugin.getPlayersAttackingMe().size() == 1) && (config.drawTargetPrayAgainstPrayerTab())) + if ((plugin.getPlayersAttackingMe().size() == 1) && (plugin.isDrawTargetPrayAgainstPrayerTab())) { renderPrayerToClick(graphics, container.getPlayer()); } 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 bc0598a4c9..db42cc14fa 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 @@ -33,12 +33,16 @@ import java.awt.image.IndexColorModel; import java.awt.image.WritableRaster; import java.util.ArrayList; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; import net.runelite.api.AnimationID; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.Player; import net.runelite.api.SpriteID; import net.runelite.api.events.AnimationChanged; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.InteractingChanged; import net.runelite.api.events.PlayerDespawned; @@ -64,6 +68,7 @@ import net.runelite.client.util.ImageUtil; * I am fully aware that there is plenty of overhead and is a MESS! * If you'd like to contribute please do! */ +@Singleton public class PrayAgainstPlayerPlugin extends Plugin { @@ -97,6 +102,37 @@ public class PrayAgainstPlayerPlugin extends Plugin @Inject private PrayAgainstPlayerConfig config; + @Getter(AccessLevel.PACKAGE) + private Color attackerPlayerColor; + @Getter(AccessLevel.PACKAGE) + private Color potentialPlayerColor; + private int attackerTargetTimeout; + private int potentialTargetTimeout; + private int newSpawnTimeout; + private boolean ignoreFriends; + private boolean ignoreClanMates; + private boolean markNewPlayer; + @Getter(AccessLevel.PACKAGE) + private boolean drawTargetPrayAgainst; + @Getter(AccessLevel.PACKAGE) + private boolean drawPotentialTargetPrayAgainst; + @Getter(AccessLevel.PACKAGE) + private boolean drawTargetPrayAgainstPrayerTab; + @Getter(AccessLevel.PACKAGE) + private boolean drawTargetsName; + @Getter(AccessLevel.PACKAGE) + private boolean drawPotentialTargetsName; + @Getter(AccessLevel.PACKAGE) + private boolean drawTargetHighlight; + @Getter(AccessLevel.PACKAGE) + private boolean drawPotentialTargetHighlight; + @Getter(AccessLevel.PACKAGE) + private boolean drawTargetTile; + @Getter(AccessLevel.PACKAGE) + private boolean drawPotentialTargetTile; + @Getter(AccessLevel.PACKAGE) + private boolean drawUnknownWeapons; + @Provides PrayAgainstPlayerConfig provideConfig(ConfigManager configManager) { @@ -115,6 +151,8 @@ public class PrayAgainstPlayerPlugin extends Plugin @Override protected void startUp() { + updateConfig(); + potentialPlayersAttackingMe = new ArrayList<>(); playersAttackingMe = new ArrayList<>(); overlayManager.add(overlay); @@ -136,11 +174,11 @@ public class PrayAgainstPlayerPlugin extends Plugin Player sourcePlayer = (Player) animationChanged.getActor(); // is the client is a friend/clan and the config is set to ignore friends/clan dont add them to list - if (client.isFriended(sourcePlayer.getName(), true) && config.ignoreFriends()) + if (client.isFriended(sourcePlayer.getName(), true) && this.ignoreFriends) { return; } - if (client.isClanMember(sourcePlayer.getName()) && config.ignoreClanMates()) + if (client.isClanMember(sourcePlayer.getName()) && this.ignoreClanMates) { return; } @@ -160,7 +198,7 @@ public class PrayAgainstPlayerPlugin extends Plugin // if he's not in the attackers list, add him if (findPlayerInAttackerList(sourcePlayer) == null) { - PlayerContainer container = new PlayerContainer(sourcePlayer, System.currentTimeMillis(), (config.attackerTargetTimeout() * 1000)); + PlayerContainer container = new PlayerContainer(sourcePlayer, System.currentTimeMillis(), (this.attackerTargetTimeout * 1000)); playersAttackingMe.add(container); } } @@ -179,16 +217,16 @@ public class PrayAgainstPlayerPlugin extends Plugin { //we're being interacted with // is the client is a friend/clan and the config is set to ignore friends/clan dont add them to list - if (client.isFriended(sourcePlayer.getName(), true) && config.ignoreFriends()) + if (client.isFriended(sourcePlayer.getName(), true) && this.ignoreFriends) { return; } - if (client.isClanMember(sourcePlayer.getName()) && config.ignoreClanMates()) + if (client.isClanMember(sourcePlayer.getName()) && this.ignoreClanMates) { return; } - PlayerContainer container = new PlayerContainer(sourcePlayer, System.currentTimeMillis(), (config.potentialTargetTimeout() * 1000)); + PlayerContainer container = new PlayerContainer(sourcePlayer, System.currentTimeMillis(), (this.potentialTargetTimeout * 1000)); potentialPlayersAttackingMe.add(container); } } @@ -212,15 +250,15 @@ public class PrayAgainstPlayerPlugin extends Plugin @Subscribe protected void onPlayerSpawned(PlayerSpawned playerSpawned) { - if (config.markNewPlayer()) + if (this.markNewPlayer) { Player p = playerSpawned.getPlayer(); - if (client.isFriended(p.getName(), true) && config.ignoreFriends()) + if (client.isFriended(p.getName(), true) && this.ignoreFriends) { return; } - if (client.isClanMember(p.getName()) && config.ignoreClanMates()) + if (client.isClanMember(p.getName()) && this.ignoreClanMates) { return; } @@ -228,7 +266,7 @@ public class PrayAgainstPlayerPlugin extends Plugin PlayerContainer container = findPlayerInPotentialList(p); if (container == null) { - container = new PlayerContainer(p, System.currentTimeMillis(), (config.newSpawnTimeout() * 1000)); + container = new PlayerContainer(p, System.currentTimeMillis(), (this.newSpawnTimeout * 1000)); potentialPlayersAttackingMe.add(container); } } @@ -274,7 +312,7 @@ public class PrayAgainstPlayerPlugin extends Plugin private void resetPlayerFromAttackerContainerTimer(PlayerContainer container) { removePlayerFromAttackerContainer(container); - PlayerContainer newContainer = new PlayerContainer(container.getPlayer(), System.currentTimeMillis(), (config.attackerTargetTimeout() * 1000)); + PlayerContainer newContainer = new PlayerContainer(container.getPlayer(), System.currentTimeMillis(), (this.attackerTargetTimeout * 1000)); playersAttackingMe.add(newContainer); } @@ -377,4 +415,36 @@ public class PrayAgainstPlayerPlugin extends Plugin return null; } + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("prayagainstplayer")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.attackerPlayerColor = config.attackerPlayerColor(); + this.potentialPlayerColor = config.potentialPlayerColor(); + this.attackerTargetTimeout = config.attackerTargetTimeout(); + this.potentialTargetTimeout = config.potentialTargetTimeout(); + this.newSpawnTimeout = config.newSpawnTimeout(); + this.ignoreFriends = config.ignoreFriends(); + this.ignoreClanMates = config.ignoreClanMates(); + this.markNewPlayer = config.markNewPlayer(); + this.drawTargetPrayAgainst = config.drawTargetPrayAgainst(); + this.drawPotentialTargetPrayAgainst = config.drawPotentialTargetPrayAgainst(); + this.drawTargetPrayAgainstPrayerTab = config.drawTargetPrayAgainstPrayerTab(); + this.drawTargetsName = config.drawTargetsName(); + this.drawPotentialTargetsName = config.drawPotentialTargetsName(); + this.drawTargetHighlight = config.drawTargetHighlight(); + this.drawPotentialTargetHighlight = config.drawPotentialTargetHighlight(); + this.drawTargetTile = config.drawTargetTile(); + this.drawPotentialTargetTile = config.drawPotentialTargetTile(); + this.drawUnknownWeapons = config.drawUnknownWeapons(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerBarOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerBarOverlay.java index 5798698621..aa363ecb10 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerBarOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerBarOverlay.java @@ -56,16 +56,14 @@ class PrayerBarOverlay extends Overlay private static final BufferedImage HD_BACK_BAR = ImageUtil.getResourceStreamFromClass(PrayerPlugin.class, "back.png"); private final Client client; - private final PrayerConfig config; private final PrayerPlugin plugin; private boolean showingPrayerBar; @Inject - private PrayerBarOverlay(final Client client, final PrayerConfig config, final PrayerPlugin plugin) + private PrayerBarOverlay(final Client client, final PrayerPlugin plugin) { this.client = client; - this.config = config; this.plugin = plugin; setPosition(OverlayPosition.DYNAMIC); @@ -76,7 +74,7 @@ class PrayerBarOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!config.showPrayerBar() || !showingPrayerBar) + if (!plugin.isShowPrayerBar() || !showingPrayerBar) { return null; } @@ -102,9 +100,9 @@ class PrayerBarOverlay extends Overlay // Use a sub-image to create the same effect the HD Health Bar has graphics.drawImage(HD_FRONT_BAR.getSubimage(0, 0, progressFill, barHeight), barX, barY, progressFill, barHeight, null); - if ((plugin.isPrayersActive() || config.prayerFlickAlwaysOn()) - && (config.prayerFlickLocation().equals(PrayerFlickLocation.PRAYER_BAR) - || config.prayerFlickLocation().equals(PrayerFlickLocation.BOTH))) + if ((plugin.isPrayersActive() || plugin.isPrayerFlickAlwaysOn()) + && (plugin.getPrayerFlickLocation().equals(PrayerFlickLocation.PRAYER_BAR) + || plugin.getPrayerFlickLocation().equals(PrayerFlickLocation.BOTH))) { final double t = plugin.getTickProgress(); final int halfBarWidth = (barWidth / 2) - HD_PRAYER_BAR_PADDING; @@ -132,9 +130,9 @@ class PrayerBarOverlay extends Overlay graphics.setColor(BAR_FILL_COLOR); graphics.fillRect(barX, barY, progressFill, barHeight); - if ((plugin.isPrayersActive() || config.prayerFlickAlwaysOn()) - && (config.prayerFlickLocation().equals(PrayerFlickLocation.PRAYER_BAR) - || config.prayerFlickLocation().equals(PrayerFlickLocation.BOTH))) + if ((plugin.isPrayersActive() || plugin.isPrayerFlickAlwaysOn()) + && (plugin.getPrayerFlickLocation().equals(PrayerFlickLocation.PRAYER_BAR) + || plugin.getPrayerFlickLocation().equals(PrayerFlickLocation.BOTH))) { double t = plugin.getTickProgress(); @@ -158,13 +156,13 @@ class PrayerBarOverlay extends Overlay return; } - if (config.hideIfNotPraying() && !plugin.isPrayersActive()) + if (plugin.isHideIfNotPraying() && !plugin.isPrayersActive()) { showingPrayerBar = false; return; } - if (config.hideIfOutOfCombat() && localPlayer.getHealth() == -1) + if (plugin.isHideIfOutOfCombat() && localPlayer.getHealth() == -1) { showingPrayerBar = false; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerCounter.java b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerCounter.java index c510dab82e..68f36872ce 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerCounter.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerCounter.java @@ -25,16 +25,17 @@ package net.runelite.client.plugins.prayer; import java.awt.Color; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.client.plugins.Plugin; import net.runelite.client.ui.overlay.infobox.InfoBox; class PrayerCounter extends InfoBox { - @Getter + @Getter(AccessLevel.PACKAGE) private final PrayerType prayerType; - PrayerCounter(Plugin plugin, PrayerType prayerType) + PrayerCounter(final Plugin plugin, final PrayerType prayerType) { super(null, plugin); this.prayerType = prayerType; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerDoseOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerDoseOverlay.java index c9b590a4d2..549d4d6d2e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerDoseOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerDoseOverlay.java @@ -32,6 +32,7 @@ import java.awt.Rectangle; import java.time.Duration; import java.time.Instant; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Setter; import net.runelite.api.Client; @@ -49,6 +50,7 @@ import net.runelite.client.ui.overlay.tooltip.TooltipManager; import net.runelite.client.util.ColorUtil; import org.apache.commons.lang3.StringUtils; +@Singleton class PrayerDoseOverlay extends Overlay { private static final float PULSE_TIME = 2f * Constants.GAME_TICK_LENGTH; @@ -57,7 +59,7 @@ class PrayerDoseOverlay extends Overlay private static final Color END_COLOR = new Color(0, 92, 92); private final Client client; - private final PrayerConfig config; + private final PrayerPlugin plugin; private final TooltipManager tooltipManager; private Instant startOfLastTick = Instant.now(); private boolean trackTick = true; @@ -72,11 +74,11 @@ class PrayerDoseOverlay extends Overlay private boolean hasHolyWrench; @Inject - private PrayerDoseOverlay(final Client client, final TooltipManager tooltipManager, final PrayerConfig config) + private PrayerDoseOverlay(final Client client, final TooltipManager tooltipManager, final PrayerPlugin plugin) { this.client = client; this.tooltipManager = tooltipManager; - this.config = config; + this.plugin = plugin; setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); } @@ -112,7 +114,7 @@ class PrayerDoseOverlay extends Overlay final Point mousePosition = client.getMouseCanvasPosition(); - if (config.showPrayerStatistics() && bounds.contains(mousePosition.getX(), mousePosition.getY())) + if (plugin.isShowPrayerStatistics() && bounds.contains(mousePosition.getX(), mousePosition.getY())) { final String tooltip = "Time Remaining: " + getEstimatedTimeRemaining() + "
" + @@ -121,7 +123,7 @@ class PrayerDoseOverlay extends Overlay tooltipManager.add(new Tooltip(tooltip)); } - if (!config.showPrayerDoseIndicator() || !hasPrayerRestore) + if (!plugin.isShowPrayerDoseIndicator() || !hasPrayerRestore) { return null; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerFlickOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerFlickOverlay.java index 6a9bfbfd61..144f443dd1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerFlickOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerFlickOverlay.java @@ -29,6 +29,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetInfo; @@ -36,19 +37,18 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; +@Singleton class PrayerFlickOverlay extends Overlay { private final Client client; - private final PrayerConfig config; private final PrayerPlugin plugin; @Inject - private PrayerFlickOverlay(Client client, PrayerConfig config, PrayerPlugin plugin) + private PrayerFlickOverlay(Client client, PrayerPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); this.client = client; - this.config = config; this.plugin = plugin; } @@ -56,9 +56,9 @@ class PrayerFlickOverlay extends Overlay public Dimension render(Graphics2D graphics) { // If there are no prayers active or flick location is set to the prayer bar we don't require the flick helper - if ((!plugin.isPrayersActive() && !config.prayerFlickAlwaysOn()) - || config.prayerFlickLocation().equals(PrayerFlickLocation.NONE) - || config.prayerFlickLocation().equals(PrayerFlickLocation.PRAYER_BAR)) + if ((!plugin.isPrayersActive() && !plugin.isPrayerFlickAlwaysOn()) + || plugin.getPrayerFlickLocation().equals(PrayerFlickLocation.NONE) + || plugin.getPrayerFlickLocation().equals(PrayerFlickLocation.PRAYER_BAR)) { return null; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerItems.java b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerItems.java index 6037701014..023dd8383f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerItems.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerItems.java @@ -26,12 +26,13 @@ package net.runelite.client.plugins.prayer; import com.google.common.collect.ImmutableMap; import java.util.Map; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.ItemID; @AllArgsConstructor -@Getter +@Getter(AccessLevel.PACKAGE) enum PrayerItems { // Blessings diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerPlugin.java index 2755703f8f..85d8111a94 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerPlugin.java @@ -29,6 +29,7 @@ import com.google.inject.Provides; import java.time.Duration; import java.time.Instant; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Client; @@ -53,6 +54,7 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager; description = "Show various information related to prayer", tags = {"combat", "flicking", "overlay"} ) +@Singleton public class PrayerPlugin extends Plugin { private final PrayerCounter[] prayerCounter = new PrayerCounter[PrayerType.values().length]; @@ -86,6 +88,23 @@ public class PrayerPlugin extends Plugin @Inject private PrayerConfig config; + @Getter(AccessLevel.PACKAGE) + private PrayerFlickLocation prayerFlickLocation; + @Getter(AccessLevel.PACKAGE) + private boolean prayerFlickAlwaysOn; + private boolean prayerIndicator; + private boolean prayerIndicatorOverheads; + @Getter(AccessLevel.PACKAGE) + private boolean showPrayerDoseIndicator; + @Getter(AccessLevel.PACKAGE) + private boolean showPrayerStatistics; + @Getter(AccessLevel.PACKAGE) + private boolean showPrayerBar; + @Getter(AccessLevel.PACKAGE) + private boolean hideIfNotPraying; + @Getter(AccessLevel.PACKAGE) + private boolean hideIfOutOfCombat; + @Provides PrayerConfig provideConfig(ConfigManager configManager) { @@ -95,6 +114,7 @@ public class PrayerPlugin extends Plugin @Override protected void startUp() { + updateConfig(); overlayManager.add(flickOverlay); overlayManager.add(doseOverlay); overlayManager.add(barOverlay); @@ -114,11 +134,12 @@ public class PrayerPlugin extends Plugin { if (event.getGroup().equals("prayer")) { - if (!config.prayerIndicator()) + updateConfig(); + if (!this.prayerIndicator) { removeIndicators(); } - else if (!config.prayerIndicatorOverheads()) + else if (!this.prayerIndicatorOverheads) { removeOverheadsIndicators(); } @@ -156,22 +177,22 @@ public class PrayerPlugin extends Plugin { prayersActive = isAnyPrayerActive(); - if (!config.prayerFlickLocation().equals(PrayerFlickLocation.NONE)) + if (!this.prayerFlickLocation.equals(PrayerFlickLocation.NONE)) { startOfLastTick = Instant.now(); } - if (config.showPrayerDoseIndicator()) + if (this.showPrayerDoseIndicator) { doseOverlay.onTick(); } - if (config.showPrayerBar()) + if (this.showPrayerBar) { barOverlay.onTick(); } - if (!config.prayerIndicator()) + if (!this.prayerIndicator) { return; } @@ -183,7 +204,7 @@ public class PrayerPlugin extends Plugin if (client.isPrayerActive(prayer)) { - if (prayerType.isOverhead() && !config.prayerIndicatorOverheads()) + if (prayerType.isOverhead() && !this.prayerIndicatorOverheads) { continue; } @@ -296,4 +317,17 @@ public class PrayerPlugin extends Plugin infoBoxManager.removeIf(entry -> entry instanceof PrayerCounter && ((PrayerCounter) entry).getPrayerType().isOverhead()); } + + private void updateConfig() + { + this.prayerFlickLocation = config.prayerFlickLocation(); + this.prayerFlickAlwaysOn = config.prayerFlickAlwaysOn(); + this.prayerIndicator = config.prayerIndicator(); + this.prayerIndicatorOverheads = config.prayerIndicatorOverheads(); + this.showPrayerDoseIndicator = config.showPrayerDoseIndicator(); + this.showPrayerStatistics = config.showPrayerStatistics(); + this.showPrayerBar = config.showPrayerBar(); + this.hideIfNotPraying = config.hideIfNotPraying(); + this.hideIfOutOfCombat = config.hideIfOutOfCombat(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerRestoreType.java b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerRestoreType.java index d30b790a9e..426eacf782 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerRestoreType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerRestoreType.java @@ -40,7 +40,7 @@ enum PrayerRestoreType private final int[] items; - PrayerRestoreType(int... items) + PrayerRestoreType(final int... items) { this.items = items; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerType.java b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerType.java index 6ef41a7676..9431f81566 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/prayer/PrayerType.java @@ -24,13 +24,14 @@ */ package net.runelite.client.plugins.prayer; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.Prayer; import net.runelite.api.SpriteID; @AllArgsConstructor -@Getter +@Getter(AccessLevel.PACKAGE) enum PrayerType { THICK_SKIN("Thick Skin", Prayer.THICK_SKIN, "+5% Defence", SpriteID.PRAYER_THICK_SKIN, false), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/prayeralert/PrayerAlertOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/prayeralert/PrayerAlertOverlay.java index 617cd3e611..d96f1161e6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/prayeralert/PrayerAlertOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/prayeralert/PrayerAlertOverlay.java @@ -21,6 +21,7 @@ import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.InventoryID; import net.runelite.api.Item; @@ -37,22 +38,23 @@ import net.runelite.client.ui.overlay.components.ImageComponent; import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.TitleComponent; +@Singleton class PrayerAlertOverlay extends Overlay { private final Client client; - private final PrayerAlertConfig config; + private final PrayerAlertPlugin plugin; private final PanelComponent panelComponent = new PanelComponent(); private final ItemManager itemManager; private final Stat prayer = Stats.PRAYER; @Inject - private PrayerAlertOverlay(Client client, PrayerAlertConfig config, ItemManager itemManager) + private PrayerAlertOverlay(final Client client, final PrayerAlertPlugin plugin, final ItemManager itemManager) { setPosition(OverlayPosition.TOP_RIGHT); setLayer(OverlayLayer.ABOVE_WIDGETS); this.client = client; - this.config = config; + this.plugin = plugin; this.itemManager = itemManager; } @@ -62,9 +64,9 @@ class PrayerAlertOverlay extends Overlay panelComponent.getChildren().clear(); int prayerLevel = getPrayerLevel(); int prayerPoints = getPrayerPoints(); - if (config.oldRenderMode()) + if (plugin.isOldRenderMode()) { - if (config.alwaysShowAlert()) + if (plugin.isAlwaysShowAlert()) { boolean drink = drinkPrayerPotion(prayerLevel, prayerPoints); if (drink) @@ -84,7 +86,7 @@ class PrayerAlertOverlay extends Overlay } else { - if (config.alwaysShowAlert()) + if (plugin.isAlwaysShowAlert()) { boolean drink = drinkPrayerPotion(prayerLevel, prayerPoints); if (drink) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/prayeralert/PrayerAlertPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/prayeralert/PrayerAlertPlugin.java index abeaef0e54..edba3b0550 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/prayeralert/PrayerAlertPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/prayeralert/PrayerAlertPlugin.java @@ -18,7 +18,12 @@ package net.runelite.client.plugins.prayeralert; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; +import net.runelite.api.events.ConfigChanged; import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginType; @@ -31,7 +36,7 @@ import net.runelite.client.ui.overlay.OverlayManager; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton public class PrayerAlertPlugin extends Plugin { @Inject @@ -40,6 +45,14 @@ public class PrayerAlertPlugin extends Plugin @Inject private PrayerAlertOverlay overlay; + @Inject + private PrayerAlertConfig config; + + @Getter(AccessLevel.PACKAGE) + private boolean alwaysShowAlert; + @Getter(AccessLevel.PACKAGE) + private boolean oldRenderMode; + @Provides PrayerAlertConfig provideConfig(ConfigManager configManager) { @@ -49,6 +62,9 @@ public class PrayerAlertPlugin extends Plugin @Override protected void startUp() throws Exception { + this.alwaysShowAlert = config.alwaysShowAlert(); + this.oldRenderMode = config.oldRenderMode(); + overlayManager.add(overlay); } @@ -57,4 +73,14 @@ public class PrayerAlertPlugin extends Plugin { overlayManager.remove(overlay); } + + @Subscribe + private void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("prayeralert")) + { + this.alwaysShowAlert = config.alwaysShowAlert(); + this.oldRenderMode = config.oldRenderMode(); + } + } } 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 eb43d74f59..878ed2b220 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 @@ -32,6 +32,7 @@ import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.security.NoSuchAlgorithmException; import java.security.spec.InvalidKeySpecException; +import javax.inject.Singleton; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JLabel; @@ -46,6 +47,7 @@ import net.runelite.client.ui.ColorScheme; import net.runelite.client.util.ImageUtil; @Slf4j +@Singleton class ProfilePanel extends JPanel { private static final ImageIcon DELETE_ICON; @@ -61,7 +63,7 @@ class ProfilePanel extends JPanel private final String loginText; private String password = null; - ProfilePanel(final Client client, String data, ProfilesConfig config, ProfilesPanel parent) + ProfilePanel(final Client client, final String data, final ProfilesConfig config, final ProfilesPanel parent) { String[] parts = data.split(":"); this.loginText = parts[1]; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java index dd420dcadb..bf0283a4a3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/profiles/ProfilesPanel.java @@ -51,6 +51,7 @@ import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.SecretKeySpec; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JOptionPane; @@ -66,6 +67,7 @@ import net.runelite.client.ui.FontManager; import net.runelite.client.ui.PluginPanel; @Slf4j +@Singleton class ProfilesPanel extends PluginPanel { private static final int iterations = 100000; @@ -93,7 +95,7 @@ class ProfilesPanel extends PluginPanel private GridBagConstraints c; @Inject - public ProfilesPanel(Client client, ProfilesConfig config) + public ProfilesPanel(final Client client, final ProfilesConfig config) { super(); this.client = client; 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 3eb6f00bfc..488a511a5f 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 @@ -27,6 +27,7 @@ package net.runelite.client.plugins.profiles; import com.google.inject.Provides; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.events.ConfigChanged; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; @@ -44,7 +45,7 @@ import net.runelite.client.util.ImageUtil; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton public class ProfilesPlugin extends Plugin { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/puzzlesolver/PuzzleSolverOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/puzzlesolver/PuzzleSolverOverlay.java index 2308a9adc9..55eaede2bb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/puzzlesolver/PuzzleSolverOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/puzzlesolver/PuzzleSolverOverlay.java @@ -37,6 +37,7 @@ import java.util.Arrays; import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.InventoryID; @@ -62,6 +63,7 @@ import net.runelite.client.ui.overlay.components.BackgroundComponent; import net.runelite.client.ui.overlay.components.TextComponent; import net.runelite.client.util.ImageUtil; +@Singleton public class PuzzleSolverOverlay extends Overlay { private static final int INFO_BOX_WIDTH = 100; @@ -73,7 +75,7 @@ public class PuzzleSolverOverlay extends Overlay private static final int DOT_MARKER_SIZE = 16; private final Client client; - private final PuzzleSolverConfig config; + private final PuzzleSolverPlugin plugin; private final ScheduledExecutorService executorService; private final SpriteManager spriteManager; @@ -86,13 +88,13 @@ public class PuzzleSolverOverlay extends Overlay private BufferedImage rightArrow; @Inject - public PuzzleSolverOverlay(Client client, PuzzleSolverConfig config, ScheduledExecutorService executorService, SpriteManager spriteManager) + public PuzzleSolverOverlay(final Client client, final PuzzleSolverPlugin plugin, final ScheduledExecutorService executorService, final SpriteManager spriteManager) { setPosition(OverlayPosition.DYNAMIC); setPriority(OverlayPriority.HIGH); setLayer(OverlayLayer.ABOVE_WIDGETS); this.client = client; - this.config = config; + this.plugin = plugin; this.executorService = executorService; this.spriteManager = spriteManager; } @@ -100,7 +102,7 @@ public class PuzzleSolverOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if ((!config.displaySolution() && !config.displayRemainingMoves()) + if ((!plugin.isDisplaySolution() && !plugin.isDisplayRemainingMoves()) || client.getGameState() != GameState.LOGGED_IN) { return null; @@ -204,7 +206,7 @@ public class PuzzleSolverOverlay extends Overlay { infoString = "Solved!"; } - else if (config.displayRemainingMoves()) + else if (plugin.isDisplayRemainingMoves()) { infoString = "Moves left: " + stepsLeft; } @@ -213,9 +215,9 @@ public class PuzzleSolverOverlay extends Overlay infoString = null; } - if (config.displaySolution()) + if (plugin.isDisplaySolution()) { - if (config.drawDots()) + if (plugin.isDrawDots()) { graphics.setColor(Color.YELLOW); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/puzzlesolver/PuzzleSolverPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/puzzlesolver/PuzzleSolverPlugin.java index d0d194cf1f..378217d02e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/puzzlesolver/PuzzleSolverPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/puzzlesolver/PuzzleSolverPlugin.java @@ -29,8 +29,12 @@ import com.google.inject.Provides; import java.awt.Color; import java.util.Arrays; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; 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.api.events.MenuOptionClicked; import net.runelite.api.events.WidgetLoaded; @@ -65,6 +69,7 @@ import net.runelite.client.util.Text; tags = {"clues", "scrolls", "overlay"} ) @Slf4j +@Singleton public class PuzzleSolverPlugin extends Plugin { private static final Color CORRECT_MUSEUM_PUZZLE_ANSWER_COLOR = new Color(0, 248, 128); @@ -78,14 +83,25 @@ public class PuzzleSolverPlugin extends Plugin @Inject private Client client; + @Inject + private PuzzleSolverConfig config; + private LightboxState lightbox; private LightboxState[] changes = new LightboxState[LightBox.COMBINATIONS_POWER]; private Combination lastClick; private boolean lastClickInvalid; + @Getter(AccessLevel.PACKAGE) + private boolean displaySolution; + @Getter(AccessLevel.PACKAGE) + private boolean displayRemainingMoves; + @Getter(AccessLevel.PACKAGE) + private boolean drawDots; + @Override protected void startUp() throws Exception { + updateConfig(); overlayManager.add(overlay); } @@ -280,4 +296,20 @@ public class PuzzleSolverPlugin extends Plugin } } } + + @Subscribe + private void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("puzzlesolver")) + { + updateConfig(); + } + } + + private void updateConfig() + { + this.displaySolution = config.displaySolution(); + this.displayRemainingMoves = config.displayRemainingMoves(); + this.drawDots = config.drawDots(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/puzzlesolver/VarrockMuseumAnswer.java b/runelite-client/src/main/java/net/runelite/client/plugins/puzzlesolver/VarrockMuseumAnswer.java index 0e4307d550..985b3a6b4e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/puzzlesolver/VarrockMuseumAnswer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/puzzlesolver/VarrockMuseumAnswer.java @@ -27,13 +27,14 @@ package net.runelite.client.plugins.puzzlesolver; import com.google.common.collect.ImmutableMap; import java.util.Map; +import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; import net.runelite.api.Client; import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetInfo; -@Getter +@Getter(AccessLevel.PACKAGE) @RequiredArgsConstructor enum VarrockMuseumAnswer { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/AttackMode.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/AttackMode.java index 95ac199470..0f5cde0c19 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/AttackMode.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/AttackMode.java @@ -32,7 +32,7 @@ public enum AttackMode private final String name; - AttackMode(String name) + AttackMode(final String name) { this.name = name; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/CurrentPlayersJFrame.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/CurrentPlayersJFrame.java index 19daf25e0f..dba8be11bd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/CurrentPlayersJFrame.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/CurrentPlayersJFrame.java @@ -16,6 +16,7 @@ import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.StringSelection; import java.awt.event.ActionListener; import java.util.List; +import javax.inject.Singleton; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; @@ -25,12 +26,11 @@ import javax.swing.JScrollPane; import net.runelite.api.Client; import net.runelite.client.ui.FontManager; -public class CurrentPlayersJFrame extends JFrame +@Singleton +class CurrentPlayersJFrame extends JFrame { - public JList currentPlayersJList; - - CurrentPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List list) + CurrentPlayersJFrame(final Client client, final PvpToolsPlugin pvpToolsPlugin, final List list) { super(); int x = client.getCanvas().getLocationOnScreen().x + client.getCanvas().getWidth(); @@ -41,7 +41,7 @@ public class CurrentPlayersJFrame extends JFrame JButton refreshJButton = new JButton("Refresh"); refreshJButton.addActionListener(pvpToolsPlugin.currentPlayersActionListener); JButton copyJButton = new JButton("Copy List"); - currentPlayersJList = new JList<>(list.toArray()); + JList currentPlayersJList = new JList<>(list.toArray()); ActionListener copyButtonActionListener = e -> { StringSelection stringSelection; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/MissingPlayersJFrame.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/MissingPlayersJFrame.java index 08831d0fca..15b34e9f25 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/MissingPlayersJFrame.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/MissingPlayersJFrame.java @@ -16,6 +16,7 @@ import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.StringSelection; import java.awt.event.ActionListener; import java.util.List; +import javax.inject.Singleton; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; @@ -25,12 +26,11 @@ import javax.swing.JScrollPane; import net.runelite.api.Client; import net.runelite.client.ui.FontManager; -public class MissingPlayersJFrame extends JFrame +@Singleton +class MissingPlayersJFrame extends JFrame { - public JList missingPlayersJList; - - MissingPlayersJFrame(Client client, PvpToolsPlugin pvpToolsPlugin, List list) + MissingPlayersJFrame(final Client client, final PvpToolsPlugin pvpToolsPlugin, final List list) { super(); int x = client.getCanvas().getLocationOnScreen().x + client.getCanvas().getWidth(); @@ -41,7 +41,7 @@ public class MissingPlayersJFrame extends JFrame JButton refreshJButton = new JButton("Refresh"); refreshJButton.addActionListener(pvpToolsPlugin.playersButtonActionListener); JButton copyJButton = new JButton("Copy List"); - missingPlayersJList = new JList<>(list.toArray()); + JList missingPlayersJList = new JList<>(list.toArray()); ActionListener copyButtonActionListener = e -> { StringSelection stringSelection; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PlayerCountOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PlayerCountOverlay.java index 1952838914..a620a6d8aa 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PlayerCountOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PlayerCountOverlay.java @@ -16,6 +16,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.util.Arrays; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Varbits; import net.runelite.api.WorldType; @@ -28,20 +29,19 @@ import net.runelite.client.ui.overlay.components.table.TableElement; import net.runelite.client.ui.overlay.components.table.TableRow; import org.apache.commons.lang3.ArrayUtils; +@Singleton public class PlayerCountOverlay extends Overlay { private static int[] CLAN_WARS_REGIONS = {9520, 13135, 13134, 13133, 13131, 13130, 13387, 13386}; private final PvpToolsPlugin pvpToolsPlugin; - private final PvpToolsConfig config; private final Client client; @Inject - public PlayerCountOverlay(PvpToolsPlugin pvpToolsPlugin, PvpToolsConfig pvpToolsConfig, Client client) + public PlayerCountOverlay(final PvpToolsPlugin pvpToolsPlugin, final Client client) { this.pvpToolsPlugin = pvpToolsPlugin; - this.config = pvpToolsConfig; this.client = client; setLayer(OverlayLayer.ABOVE_WIDGETS); setPriority(OverlayPriority.HIGHEST); @@ -52,7 +52,7 @@ public class PlayerCountOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (config.countPlayers()) + if (pvpToolsPlugin.isCountPlayers()) { if ((client.getVar(Varbits.IN_WILDERNESS) == 1) || WorldType.isPvpWorld(client.getWorldType()) || ArrayUtils.contains(CLAN_WARS_REGIONS, client.getMapRegions()[0]) || diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsOverlay.java index 7d042374ac..09e0cccdf1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsOverlay.java @@ -9,13 +9,11 @@ package net.runelite.client.plugins.pvptools; -import java.awt.BasicStroke; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; -import java.awt.Polygon; import javax.inject.Inject; -import net.runelite.api.Client; +import javax.inject.Singleton; import net.runelite.api.Point; import net.runelite.client.ui.FontManager; import net.runelite.client.ui.overlay.Overlay; @@ -24,18 +22,15 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton public class PvpToolsOverlay extends Overlay { private PvpToolsPlugin pvpToolsPlugin; - private PvpToolsConfig pvpToolsConfig; - private Client client; @Inject - private PvpToolsOverlay(PvpToolsConfig pvpToolsConfig, PvpToolsPlugin pvpToolsPlugin, Client client) + private PvpToolsOverlay(final PvpToolsPlugin pvpToolsPlugin) { this.pvpToolsPlugin = pvpToolsPlugin; - this.pvpToolsConfig = pvpToolsConfig; - this.client = client; setLayer(OverlayLayer.ABOVE_WIDGETS); setPriority(OverlayPriority.HIGH); setPosition(OverlayPosition.DYNAMIC); @@ -45,7 +40,7 @@ public class PvpToolsOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (pvpToolsConfig.fallInHelper()) + if (pvpToolsPlugin.isFallInHelper()) { if (pvpToolsPlugin.fallinHelperEnabled) { @@ -55,16 +50,4 @@ public class PvpToolsOverlay extends Overlay } return null; } - - private void renderPoly(Graphics2D graphics, Color color, Polygon polygon) - { - if (polygon != null) - { - graphics.setColor(color); - graphics.setStroke(new BasicStroke(2)); - graphics.draw(polygon); - graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20)); - graphics.fill(polygon); - } - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPanel.java index 3156f8061c..1686cd2353 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPanel.java @@ -14,6 +14,7 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.GridLayout; +import javax.inject.Singleton; import javax.swing.Box; import javax.swing.JButton; import javax.swing.JLabel; @@ -27,6 +28,7 @@ import net.runelite.client.ui.FontManager; import net.runelite.client.ui.PluginPanel; @Slf4j +@Singleton public class PvpToolsPanel extends PluginPanel { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPlugin.java index 4a7c393f31..2e54b09cf0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/pvptools/PvpToolsPlugin.java @@ -26,6 +26,7 @@ import java.util.TreeMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.stream.Collectors; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; @@ -46,8 +47,8 @@ import net.runelite.api.events.MenuEntryAdded; import net.runelite.api.events.MenuOpened; import net.runelite.api.events.PlayerDespawned; import net.runelite.api.events.PlayerSpawned; -import net.runelite.client.chat.ChatMessageManager; import net.runelite.client.config.ConfigManager; +import net.runelite.client.config.Keybind; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.game.AsyncBufferedImage; import net.runelite.client.game.ItemManager; @@ -75,7 +76,7 @@ import org.apache.commons.lang3.StringUtils; type = PluginType.PVP, enabledByDefault = false ) - +@Singleton public class PvpToolsPlugin extends Plugin { @Inject @@ -107,16 +108,13 @@ public class PvpToolsPlugin extends Plugin @Inject private ItemManager itemManager; - @Inject - private ChatMessageManager chatMessageManager; - private PvpToolsPlugin uhPvpToolsPlugin = this; private static final String WALK_HERE = "WALK HERE"; private static final String CANCEL = "CANCEL"; private static final String CAST = "CAST"; private static final String ATTACK_OPTIONS_ATTACK = "ATTACK"; - public static final HashSet ATTACK_OPTIONS_KEYWORDS = new HashSet<>(); + private static final HashSet ATTACK_OPTIONS_KEYWORDS = new HashSet<>(); static { ATTACK_OPTIONS_KEYWORDS.add(CAST); @@ -162,7 +160,25 @@ public class PvpToolsPlugin extends Plugin } }; - + @Getter(AccessLevel.PACKAGE) + private boolean countPlayers; + private boolean countOverHeads; + @Getter(AccessLevel.PACKAGE) + private boolean fallInHelper; + private Keybind hotkey; + private Keybind renderSelf; + private boolean hideAttack; + private AttackMode hideAttackMode; + private boolean hideCast; + private AttackMode hideCastMode; + private String hideCastIgnored; + private boolean attackOptionsClan; + private boolean attackOptionsFriend; + private boolean levelRangeAttackOptions; + private boolean riskCalculatorEnabled; + private boolean missingPlayersEnabled; + private boolean currentPlayersEnabled; + @Inject private ClientToolbar clientToolbar; @@ -175,7 +191,7 @@ public class PvpToolsPlugin extends Plugin /** * The HotKeyListener for the hot key assigned in the config that triggers the Fall In Helper feature */ - private final HotkeyListener fallinHotkeyListener = new HotkeyListener(() -> config.hotkey()) + private final HotkeyListener fallinHotkeyListener = new HotkeyListener(() -> this.hotkey) { public void hotkeyPressed() { @@ -183,7 +199,7 @@ public class PvpToolsPlugin extends Plugin } }; - private final HotkeyListener renderselfHotkeyListener = new HotkeyListener(() -> config.renderSelf()) + private final HotkeyListener renderselfHotkeyListener = new HotkeyListener(() -> this.renderSelf) { public void hotkeyPressed() { @@ -253,6 +269,8 @@ public class PvpToolsPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(pvpToolsOverlay); overlayManager.add(playerCountOverlay); @@ -275,17 +293,17 @@ public class PvpToolsPlugin extends Plugin clientToolbar.addNavigation(navButton); - if (config.missingPlayersEnabled()) + if (this.missingPlayersEnabled) { panel.missingPlayers.setVisible(true); } - if (config.currentPlayersEnabled()) + if (this.currentPlayersEnabled) { panel.currentPlayers.setVisible(true); } - ignoredSpells = Arrays.asList(config.hideCastIgnored().toLowerCase().split("\\s*,\\s*")); + ignoredSpells = Arrays.asList(this.hideCastIgnored.toLowerCase().split("\\s*,\\s*")); } @Override @@ -303,52 +321,54 @@ public class PvpToolsPlugin extends Plugin { if (configChanged.getGroup().equals("pvptools")) { + updateConfig(); + switch (configChanged.getKey()) { case "countPlayers": - if (config.countPlayers()) + if (this.countPlayers) { updatePlayers(); } - if (!config.countPlayers()) + if (!this.countPlayers) { panel.disablePlayerCount(); } break; case "countOverHeads": - if (config.countOverHeads()) + if (this.countOverHeads) { countOverHeads(); } - if (!config.countOverHeads()) + if (!this.countOverHeads) { panel.disablePrayerCount(); } break; case "riskCalculator": - if (config.riskCalculatorEnabled()) + if (this.riskCalculatorEnabled) { getCarriedWealth(); } - if (!config.riskCalculatorEnabled()) + if (!this.riskCalculatorEnabled) { panel.disableRiskCalculator(); } break; case "missingPlayers": - if (config.missingPlayersEnabled()) + if (this.missingPlayersEnabled) { panel.missingPlayers.setVisible(true); } break; case "currentPlayers": - if (config.currentPlayersEnabled()) + if (this.currentPlayersEnabled) { panel.currentPlayers.setVisible(true); } break; case "hideCastIgnored": - ignoredSpells = Arrays.asList(config.hideCastIgnored().toLowerCase().split("\\s*,\\s*")); + ignoredSpells = Arrays.asList(this.hideCastIgnored.toLowerCase().split("\\s*,\\s*")); break; default: break; @@ -360,7 +380,7 @@ public class PvpToolsPlugin extends Plugin public void onItemContainerChanged(ItemContainerChanged event) { if (event.getItemContainer().equals(client.getItemContainer(InventoryID.INVENTORY)) && - config.riskCalculatorEnabled()) + this.riskCalculatorEnabled) { getCarriedWealth(); } @@ -369,13 +389,13 @@ public class PvpToolsPlugin extends Plugin @Subscribe public void onGameStateChanged(GameStateChanged event) { - if (event.getGameState().equals(GameState.LOGGED_IN) && config.riskCalculatorEnabled()) + if (event.getGameState().equals(GameState.LOGGED_IN) && this.riskCalculatorEnabled) { getCarriedWealth(); } if (event.getGameState().equals(GameState.LOGGED_IN)) { - if (config.countPlayers()) + if (this.countPlayers) { updatePlayers(); } @@ -385,11 +405,11 @@ public class PvpToolsPlugin extends Plugin @Subscribe public void onPlayerSpawned(PlayerSpawned event) { - if (config.countPlayers() && PvPUtil.isAttackable(client, event.getPlayer())) + if (this.countPlayers && PvPUtil.isAttackable(client, event.getPlayer())) { updatePlayers(); } - if (config.countOverHeads()) + if (this.countOverHeads) { countOverHeads(); } @@ -398,11 +418,11 @@ public class PvpToolsPlugin extends Plugin @Subscribe public void onPlayerDespawned(PlayerDespawned event) { - if (config.countPlayers() && PvPUtil.isAttackable(client, event.getPlayer())) + if (this.countPlayers && PvPUtil.isAttackable(client, event.getPlayer())) { updatePlayers(); } - if (config.countOverHeads()) + if (this.countOverHeads) { countOverHeads(); } @@ -411,7 +431,7 @@ public class PvpToolsPlugin extends Plugin @Subscribe public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) { - if (config.attackOptionsFriend() || config.attackOptionsClan() || config.levelRangeAttackOptions()) + if (this.attackOptionsFriend || this.attackOptionsClan || this.levelRangeAttackOptions) { final String pOptionToReplace = Text.removeTags(menuEntryAdded.getOption()).toUpperCase(); @@ -438,18 +458,18 @@ public class PvpToolsPlugin extends Plugin } - if (attackHotKeyPressed && config.attackOptionsClan() || config.attackOptionsFriend() || - config.levelRangeAttackOptions()) + if (attackHotKeyPressed && this.attackOptionsClan || this.attackOptionsFriend || + this.levelRangeAttackOptions) { - if (config.attackOptionsFriend() && player.isFriend()) + if (this.attackOptionsFriend && player.isFriend()) { swap(pOptionToReplace); } - else if (config.attackOptionsClan() && player.isClanMember()) + else if (this.attackOptionsClan && player.isClanMember()) { swap(pOptionToReplace); } - else if (config.levelRangeAttackOptions() && !PvPUtil.isAttackable(client, player)) + else if (this.levelRangeAttackOptions && !PvPUtil.isAttackable(client, player)) { swap(pOptionToReplace); } @@ -490,12 +510,12 @@ public class PvpToolsPlugin extends Plugin continue; } - if (option.contains("attack") && config.hideAttack() && shouldHide(config.hideAttackMode(), player)) + if (option.contains("attack") && this.hideAttack && shouldHide(this.hideAttackMode, player)) { continue; } - else if (option.contains("cast") && config.hideCast() && shouldHide(config.hideCastMode(), player) + else if (option.contains("cast") && this.hideCast && shouldHide(this.hideCastMode, player) && !ignoredSpells.contains(StringUtils.substringBefore(target, " ->"))) { continue; @@ -555,7 +575,7 @@ public class PvpToolsPlugin extends Plugin { friendlyPlayerCount = 0; enemyPlayerCount = 0; - if (config.countPlayers()) + if (this.countPlayers) { for (Player p : client.getPlayers()) { @@ -621,7 +641,7 @@ public class PvpToolsPlugin extends Plugin */ private void getCarriedWealth() { - if (!config.riskCalculatorEnabled()) + if (!this.riskCalculatorEnabled) { return; } @@ -783,4 +803,23 @@ public class PvpToolsPlugin extends Plugin return false; } + private void updateConfig() + { + this.countPlayers = config.countPlayers(); + this.countOverHeads = config.countOverHeads(); + this.fallInHelper = config.fallInHelper(); + this.hotkey = config.hotkey(); + this.renderSelf = config.renderSelf(); + this.hideAttack = config.hideAttack(); + this.hideAttackMode = config.hideAttackMode(); + this.hideCast = config.hideCast(); + this.hideCastMode = config.hideCastMode(); + this.hideCastIgnored = config.hideCastIgnored(); + this.attackOptionsClan = config.attackOptionsClan(); + this.attackOptionsFriend = config.attackOptionsFriend(); + this.levelRangeAttackOptions = config.levelRangeAttackOptions(); + this.riskCalculatorEnabled = config.riskCalculatorEnabled(); + this.missingPlayersEnabled = config.missingPlayersEnabled(); + this.currentPlayersEnabled = config.currentPlayersEnabled(); + } } 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 deleted file mode 100644 index 09869ea0e1c2e15208ccac2839127b0c42ae7d6f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 448 zcmV;x0YCnUP)TQr$`dK^Q$VO1C|N+GS}7rM-cVqS3WUk6_YWWGKBv zP=V5Qm_+^r-C6VwYwjxU>1Jn}*_j}y10VbCH{YB&bG`xo2_lgT05Xcy-gf2_02nnq zzkX~22m!342(_??Q>A>C!F$!N z)r!mIl0gvA_kH@l&magmylqn>k%}mtAR+)rDKNdi!r}3$vDj`kAca756&ibzlFEf# zD1?Yf29p^ElNkWusL_Iy0;PO*9T70OUnioDFbs_#$#NlQ5u|kjm5=*f06?))g%ICf zs=D4ke0di}QDM~Uuw2N+Uj@CEtQ$n5UWcPz$0Bnbp#D|OFuPW7TJmf4CdU0P#{F)* zuJ`CQ>oKVlI%g-YS;U(SZ+?RE!F4s)#0*8M;c@zAT|uE(smA%i?v|}AIW^bmx=LNC qWwx%s<%7yyLvi}zUj2Ljuki)1TS~g;MmS3V0000 bossMatches) + || plugin.isEnableRotationWhitelist() && bossCount > bossMatches) { color = Color.RED; } String bossName = room.getBoss().getName(); String bossNameLC = bossName.toLowerCase(); - if (config.showRecommendedItems()) + if (plugin.isShowRecommendedItems()) { if (plugin.getRecommendedItemsList().get(bossNameLC) != null) { @@ -331,7 +332,7 @@ public class RaidsOverlay extends Overlay } } - tableComponent.addRow(config.showRecommendedItems() ? "" : room.getType().getName(), ColorUtil.prependColorTag(bossName, color)); + tableComponent.addRow(plugin.isShowRecommendedItems() ? "" : room.getType().getName(), ColorUtil.prependColorTag(bossName, color)); break; @@ -350,11 +351,11 @@ public class RaidsOverlay extends Overlay { color = Color.RED; } - if (config.colorTightrope() && puzzleNameLC.equals("tightrope")) + if (plugin.isColorTightrope() && puzzleNameLC.equals("tightrope")) { - color = config.tightropeColor(); + color = plugin.getTightropeColor(); } - if (config.crabHandler() && puzzleNameLC.equals("crabs")) + if (plugin.isCrabHandler() && puzzleNameLC.equals("crabs")) { if (plugin.getGoodCrabs() == null) { @@ -365,33 +366,33 @@ public class RaidsOverlay extends Overlay switch (plugin.getGoodCrabs()) { case "Good Crabs": - color = config.goodCrabColor(); + color = plugin.getGoodCrabColor(); break; case "Rare Crabs": - color = config.rareCrabColor(); + color = plugin.getRareCrabColor(); break; } } } - tableComponent.addRow(config.showRecommendedItems() ? "" : room.getType().getName(), ColorUtil.prependColorTag(puzzleName, color)); + tableComponent.addRow(plugin.isShowRecommendedItems() ? "" : room.getType().getName(), ColorUtil.prependColorTag(puzzleName, color)); break; case FARMING: - if (config.showScavsFarms()) + if (plugin.isShowScavsFarms()) { tableComponent.addRow("", ColorUtil.prependColorTag(room.getType().getName(), new Color(181, 230, 29))); } break; case SCAVENGERS: - if (config.scavsBeforeOlm() && roomCount == lastScavs) + if (plugin.isScavsBeforeOlm() && roomCount == lastScavs) { - tableComponent.addRow(config.showRecommendedItems() ? "" : "OlmPrep", ColorUtil.prependColorTag("Scavs", config.scavPrepColor())); + tableComponent.addRow(plugin.isShowRecommendedItems() ? "" : "OlmPrep", ColorUtil.prependColorTag("Scavs", plugin.getScavPrepColor())); } - else if (config.scavsBeforeIce() && scavsBeforeIceRooms.contains(roomCount)) + else if (plugin.isScavsBeforeIce() && scavsBeforeIceRooms.contains(roomCount)) { - tableComponent.addRow(config.showRecommendedItems() ? "" : "IcePrep", ColorUtil.prependColorTag("Scavs", config.scavPrepColor())); + tableComponent.addRow(plugin.isShowRecommendedItems() ? "" : "IcePrep", ColorUtil.prependColorTag("Scavs", plugin.getScavPrepColor())); } - else if (config.showScavsFarms()) + else if (plugin.isShowScavsFarms()) { tableComponent.addRow("", ColorUtil.prependColorTag("Scavs", new Color(181, 230, 29))); } @@ -407,12 +408,12 @@ public class RaidsOverlay extends Overlay height = (int) panelDims.getHeight(); //add recommended items - if (config.showRecommendedItems() && imageIds.size() > 0) + if (plugin.isShowRecommendedItems() && imageIds.size() > 0) { panelImages.getChildren().clear(); Integer[] idArray = imageIds.toArray(new Integer[0]); - int imagesVerticalOffset = TITLE_COMPONENT_HEIGHT + (sharable || config.alwaysShowWorldAndCC() ? LINE_COMPONENT_HEIGHT : 0) - BORDER_OFFSET; - int imagesMaxHeight = height - 2 * BORDER_OFFSET - TITLE_COMPONENT_HEIGHT - (sharable || config.alwaysShowWorldAndCC() ? LINE_COMPONENT_HEIGHT : 0); + int imagesVerticalOffset = TITLE_COMPONENT_HEIGHT + (sharable || plugin.isAlwaysShowWorldAndCC() ? LINE_COMPONENT_HEIGHT : 0) - BORDER_OFFSET; + int imagesMaxHeight = height - 2 * BORDER_OFFSET - TITLE_COMPONENT_HEIGHT - (sharable || plugin.isAlwaysShowWorldAndCC() ? LINE_COMPONENT_HEIGHT : 0); boolean smallImages = false; panelImages.setPreferredLocation(new Point(0, imagesVerticalOffset)); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPanel.java index 0f4e8c916b..2c16219f06 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPanel.java @@ -28,16 +28,17 @@ import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import net.runelite.api.Client; import net.runelite.api.GameState; -import net.runelite.client.callback.ClientThread; import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.PluginPanel; +@Singleton class RaidsPanel extends PluginPanel { @Inject @@ -45,13 +46,11 @@ class RaidsPanel extends PluginPanel @Inject private RaidsPlugin raidsPlugin; - @Inject - private ClientThread clientThread; private JButton reloadButton = new JButton("Reload Instance"); private JButton reloadScouter = new JButton("Reload Raid Overlay"); private JLabel reloadMessage = new JLabel("

Instance Reload Helper

Reloading an instance will cause your client to disconnect temporarily.
"); - void init(RaidsConfig config) + void init() { // this may or may not qualify as a hack diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPartyOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPartyOverlay.java index 85295b7083..330902c22e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPartyOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPartyOverlay.java @@ -29,6 +29,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.ClanMember; import net.runelite.api.Client; import net.runelite.api.MenuAction; @@ -44,6 +45,7 @@ import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; import net.runelite.client.util.ColorUtil; +@Singleton public class RaidsPartyOverlay extends Overlay { static final String PARTY_OVERLAY_RESET = "Reset missing"; @@ -56,7 +58,7 @@ public class RaidsPartyOverlay extends Overlay private RaidsPlugin plugin; @Inject - private RaidsPartyOverlay(RaidsPlugin plugin) + private RaidsPartyOverlay(final RaidsPlugin plugin) { super(plugin); setPosition(OverlayPosition.TOP_RIGHT); 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 4ea46f01cd..fd465aa6bd 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 @@ -29,6 +29,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.inject.Binder; import com.google.inject.Provides; +import java.awt.Color; import java.awt.image.BufferedImage; import java.text.DecimalFormat; import java.time.Instant; @@ -42,6 +43,8 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; @@ -101,7 +104,7 @@ import org.apache.commons.lang3.StringUtils; type = PluginType.PVM, enabledByDefault = false ) - +@Singleton @Slf4j public class RaidsPlugin extends Plugin { @@ -144,15 +147,15 @@ public class RaidsPlugin extends Plugin ); private static final String TRIPLE_PUZZLE = "SFCCPC.PCSCPF - #WSEENES#WWWNEEE"; //good crabs first rare crabs second rare crabs third private static final Pattern PUZZLES = Pattern.compile("Puzzle - (\\w+)"); - @Getter + @Getter(AccessLevel.PACKAGE) private final ArrayList roomWhitelist = new ArrayList<>(); - @Getter + @Getter(AccessLevel.PACKAGE) private final ArrayList roomBlacklist = new ArrayList<>(); - @Getter + @Getter(AccessLevel.PACKAGE) private final ArrayList rotationWhitelist = new ArrayList<>(); - @Getter + @Getter(AccessLevel.PACKAGE) private final ArrayList layoutWhitelist = new ArrayList<>(); - @Getter + @Getter(AccessLevel.PACKAGE) private final Map> recommendedItemsList = new HashMap<>(); @Inject private ChatMessageManager chatMessageManager; @@ -182,23 +185,23 @@ public class RaidsPlugin extends Plugin private ClientToolbar clientToolbar; @Inject private ItemManager itemManager; - @Getter + @Getter(AccessLevel.PACKAGE) private Raid raid; - @Getter + @Getter(AccessLevel.PACKAGE) private boolean inRaidChambers; - @Getter + @Getter(AccessLevel.PACKAGE) private String goodCrabs; - @Getter + @Getter(AccessLevel.PACKAGE) private int startPlayerCount; - @Getter + @Getter(AccessLevel.PACKAGE) private List partyMembers = new ArrayList<>(); - @Getter + @Getter(AccessLevel.PACKAGE) private List startingPartyMembers = new ArrayList<>(); - @Getter + @Getter(AccessLevel.PACKAGE) private Set missingPartyMembers = new HashSet<>(); - @Getter + @Getter(AccessLevel.PACKAGE) private String layoutFullCode; - @Getter + @Getter(AccessLevel.PACKAGE) private boolean raidStarted; private int upperTime = -1; private int middleTime = -1; @@ -209,6 +212,59 @@ public class RaidsPlugin extends Plugin private NavigationButton navButton; private RaidsTimer timer; + @Getter(AccessLevel.PACKAGE) + private boolean enhanceScouterTitle; + @Getter(AccessLevel.PACKAGE) + private boolean hideBackground; + private boolean raidsTimer; + private boolean pointsMessage; + private boolean ptsHr; + @Getter(AccessLevel.PACKAGE) + private boolean scoutOverlay; + private boolean scoutOverlayAtBank; + private boolean scoutOverlayInRaid; + @Getter(AccessLevel.PACKAGE) + private boolean displayFloorBreak; + @Getter(AccessLevel.PACKAGE) + private boolean showRecommendedItems; + private String recommendedItems; + @Getter(AccessLevel.PACKAGE) + private boolean alwaysShowWorldAndCC; + private boolean layoutMessage; + @Getter(AccessLevel.PACKAGE) + private boolean colorTightrope; + @Getter(AccessLevel.PACKAGE) + private Color tightropeColor; + @Getter(AccessLevel.PACKAGE) + private boolean crabHandler; + @Getter(AccessLevel.PACKAGE) + private Color goodCrabColor; + @Getter(AccessLevel.PACKAGE) + private Color rareCrabColor; + @Getter(AccessLevel.PACKAGE) + private boolean enableRotationWhitelist; + private String whitelistedRotations; + @Getter(AccessLevel.PACKAGE) + private boolean enableLayoutWhitelist; + private String whitelistedLayouts; + @Getter(AccessLevel.PACKAGE) + private boolean showScavsFarms; + @Getter(AccessLevel.PACKAGE) + private boolean scavsBeforeIce; + @Getter(AccessLevel.PACKAGE) + private boolean scavsBeforeOlm; + @Getter(AccessLevel.PACKAGE) + private Color scavPrepColor; + private String whitelistedRooms; + private String blacklistedRooms; + @Getter(AccessLevel.PACKAGE) + private boolean hideRopeless; + @Getter(AccessLevel.PACKAGE) + private boolean hideVanguards; + @Getter(AccessLevel.PACKAGE) + private boolean hideUnknownCombat; + private boolean partyDisplay; + @Provides RaidsConfig provideConfig(ConfigManager configManager) { @@ -224,9 +280,11 @@ public class RaidsPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(overlay); overlayManager.add(pointsOverlay); - if (config.partyDisplay()) + if (this.partyDisplay) { overlayManager.add(partyOverlay); } @@ -234,7 +292,7 @@ public class RaidsPlugin extends Plugin clientThread.invokeLater(() -> checkRaidPresence(true)); widgetOverlay = overlayManager.getWidgetOverlay(WidgetInfo.RAIDS_POINTS_INFOBOX); RaidsPanel panel = injector.getInstance(RaidsPanel.class); - panel.init(config); + panel.init(); final BufferedImage icon = ImageUtil.getResourceStreamFromClass(this.getClass(), "instancereloadhelper.png"); navButton = NavigationButton.builder() .tooltip("Raids Reload") @@ -251,7 +309,7 @@ public class RaidsPlugin extends Plugin overlayManager.remove(overlay); overlayManager.remove(pointsOverlay); clientToolbar.removeNavigation(navButton); - if (config.partyDisplay()) + if (this.partyDisplay) { overlayManager.remove(partyOverlay); } @@ -271,6 +329,8 @@ public class RaidsPlugin extends Plugin { return; } + + updateConfig(); if (event.getKey().equals("raidsTimer")) { @@ -280,7 +340,7 @@ public class RaidsPlugin extends Plugin if (event.getKey().equals("partyDisplay")) { - if (config.partyDisplay()) + if (this.partyDisplay) { overlayManager.add(partyOverlay); } @@ -314,7 +374,7 @@ public class RaidsPlugin extends Plugin public void onVarbitChanged(VarbitChanged event) { checkRaidPresence(false); - if (config.partyDisplay()) + if (this.partyDisplay) { updatePartyMembers(false); } @@ -330,13 +390,13 @@ public class RaidsPlugin extends Plugin if (message.startsWith(RAID_START_MESSAGE)) { - if (config.raidsTimer()) + if (this.raidsTimer) { timer = new RaidsTimer(spriteManager.getSprite(TAB_QUESTS_BROWN_RAIDING_PARTY, 0), this, Instant.now()); infoBoxManager.addInfoBox(timer); raidStarted = true; } - if (config.partyDisplay()) + if (this.partyDisplay) { // Base this on visible players since party size shows people outside the lobby // and they did not get to come on the raid @@ -373,7 +433,7 @@ public class RaidsPlugin extends Plugin int timesec = timeToSeconds(matcher.group(1)); updateTooltip(); - if (config.pointsMessage()) + if (this.pointsMessage) { int totalPoints = client.getVar(Varbits.TOTAL_POINTS); int personalPoints = client.getVar(Varbits.PERSONAL_POINTS); @@ -402,7 +462,7 @@ public class RaidsPlugin extends Plugin .type(ChatMessageType.FRIENDSCHATNOTIFICATION) .runeLiteFormattedMessage(chatMessage) .build()); - if (config.ptsHr()) + if (this.ptsHr) { String ptssolo; { @@ -456,7 +516,7 @@ public class RaidsPlugin extends Plugin @Subscribe public void onClientTick(ClientTick event) { - if (!config.raidsTimer() + if (!this.raidsTimer || !client.getGameState().equals(GameState.LOGGED_IN) || tooltip == null) { @@ -617,14 +677,14 @@ public class RaidsPlugin extends Plugin } } } - else if (!config.scoutOverlayAtBank()) + else if (!this.scoutOverlayAtBank) { setOverlayStatus(false); } } // If we left party raid was started or we left raid - if (client.getVar(VarPlayer.IN_RAID_PARTY) == -1 && (!inRaidChambers || !config.scoutOverlayInRaid())) + if (client.getVar(VarPlayer.IN_RAID_PARTY) == -1 && (!inRaidChambers || !this.scoutOverlayInRaid)) { setOverlayStatus(false); raidStarted = false; @@ -633,7 +693,7 @@ public class RaidsPlugin extends Plugin private void sendRaidLayoutMessage() { - if (!config.layoutMessage()) + if (!this.layoutMessage) { return; } @@ -679,7 +739,7 @@ public class RaidsPlugin extends Plugin return; } - if (inRaidChambers && config.raidsTimer()) + if (inRaidChambers && this.raidsTimer) { if (!infoBoxManager.getInfoBoxes().contains(timer)) { @@ -699,11 +759,11 @@ public class RaidsPlugin extends Plugin private void updateLists() { - updateList(roomWhitelist, config.whitelistedRooms()); - updateList(roomBlacklist, config.blacklistedRooms()); - updateList(rotationWhitelist, config.whitelistedRotations()); - updateList(layoutWhitelist, config.whitelistedLayouts()); - updateMap(recommendedItemsList, config.recommendedItems()); + updateList(roomWhitelist, this.whitelistedRooms); + updateList(roomBlacklist, this.blacklistedRooms); + updateList(rotationWhitelist, this.whitelistedRotations); + updateList(layoutWhitelist, this.whitelistedLayouts); + updateMap(recommendedItemsList, this.recommendedItems); } private void updateMap(Map> map, String input) @@ -1172,4 +1232,40 @@ public class RaidsPlugin extends Plugin { overlay.setScoutOverlayShown(bool); } + + private void updateConfig() + { + this.enhanceScouterTitle = config.enhanceScouterTitle(); + this.hideBackground = config.hideBackground(); + this.raidsTimer = config.raidsTimer(); + this.pointsMessage = config.pointsMessage(); + this.ptsHr = config.ptsHr(); + this.scoutOverlay = config.scoutOverlay(); + this.scoutOverlayAtBank = config.scoutOverlayAtBank(); + this.scoutOverlayInRaid = config.scoutOverlayInRaid(); + this.displayFloorBreak = config.displayFloorBreak(); + this.showRecommendedItems = config.showRecommendedItems(); + this.recommendedItems = config.recommendedItems(); + this.alwaysShowWorldAndCC = config.alwaysShowWorldAndCC(); + this.layoutMessage = config.layoutMessage(); + this.colorTightrope = config.colorTightrope(); + this.tightropeColor = config.tightropeColor(); + this.crabHandler = config.crabHandler(); + this.goodCrabColor = config.goodCrabColor(); + this.rareCrabColor = config.rareCrabColor(); + this.enableRotationWhitelist = config.enableRotationWhitelist(); + this.whitelistedRotations = config.whitelistedRotations(); + this.enableLayoutWhitelist = config.enableLayoutWhitelist(); + this.whitelistedLayouts = config.whitelistedLayouts(); + this.showScavsFarms = config.showScavsFarms(); + this.scavsBeforeIce = config.scavsBeforeIce(); + this.scavsBeforeOlm = config.scavsBeforeOlm(); + this.scavPrepColor = config.scavPrepColor(); + this.whitelistedRooms = config.whitelistedRooms(); + this.blacklistedRooms = config.blacklistedRooms(); + this.hideRopeless = config.hideRopeless(); + this.hideVanguards = config.hideVanguards(); + this.hideUnknownCombat = config.hideUnknownCombat(); + this.partyDisplay = config.partyDisplay(); + } } 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 index baedb561d7..7d75264915 100644 --- 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 @@ -29,6 +29,7 @@ import java.awt.Graphics2D; import java.text.NumberFormat; import java.util.Locale; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.api.Varbits; @@ -42,6 +43,7 @@ import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; +@Singleton public class RaidsPointsOverlay extends Overlay { private static final NumberFormat UNIQUE_FORMAT = NumberFormat.getPercentInstance(Locale.ENGLISH); @@ -59,7 +61,7 @@ public class RaidsPointsOverlay extends Overlay private RaidsPlugin plugin; @Inject - private RaidsPointsOverlay(RaidsPlugin plugin) + private RaidsPointsOverlay(final RaidsPlugin plugin) { super(plugin); setPosition(OverlayPosition.TOP_RIGHT); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsTimer.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsTimer.java index 8e7dec1309..b1cf6600ef 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsTimer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsTimer.java @@ -30,6 +30,7 @@ import java.time.Duration; import java.time.Instant; import java.time.LocalTime; import java.time.format.DateTimeFormatter; +import lombok.AccessLevel; import lombok.Setter; import net.runelite.client.plugins.Plugin; import net.runelite.client.ui.overlay.infobox.InfoBox; @@ -44,10 +45,10 @@ public class RaidsTimer extends InfoBox private LocalTime thirdFloorTime; private LocalTime olmTime; - @Setter + @Setter(AccessLevel.PACKAGE) private boolean stopped; - RaidsTimer(BufferedImage image, Plugin plugin, Instant startTime) + RaidsTimer(final BufferedImage image, final Plugin plugin, final Instant startTime) { super(image, plugin); this.startTime = startTime; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/shortcuts/ShortcutOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/shortcuts/ShortcutOverlay.java index 30762daf39..2ba5cd8d1b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/shortcuts/ShortcutOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/shortcuts/ShortcutOverlay.java @@ -5,6 +5,7 @@ import java.awt.Graphics2D; import java.awt.Polygon; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.GameObject; import net.runelite.api.Perspective; @@ -17,20 +18,19 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; +@Singleton public class ShortcutOverlay extends Overlay { private final Client client; - private final ShortcutConfig config; private final ShortcutPlugin plugin; private final BufferedImage treeIcon; private final BufferedImage strengthIcon; private final BufferedImage miningIcon; @Inject - ShortcutOverlay(Client client, ShortcutConfig config, ShortcutPlugin plugin, SkillIconManager iconManager) + ShortcutOverlay(final Client client, final ShortcutPlugin plugin, final SkillIconManager iconManager) { this.client = client; - this.config = config; this.plugin = plugin; setPosition(OverlayPosition.DYNAMIC); setPriority(OverlayPriority.LOW); @@ -76,7 +76,7 @@ public class ShortcutOverlay extends Overlay default: name = "null"; } - if (config.highlightShortcuts()) + if (plugin.isHighlightShortcuts()) { if (name.equals("Tree")) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/shortcuts/ShortcutPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/shortcuts/ShortcutPlugin.java index 422c85225f..b8bb023e98 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/shortcuts/ShortcutPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/shortcuts/ShortcutPlugin.java @@ -2,13 +2,16 @@ package net.runelite.client.plugins.raids.shortcuts; import com.google.inject.Provides; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.TileObject; import net.runelite.api.coords.WorldPoint; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameObjectDespawned; import net.runelite.api.events.GameObjectSpawned; import net.runelite.api.events.GameTick; @@ -24,6 +27,7 @@ import net.runelite.client.ui.overlay.OverlayManager; tags = {"boulder", "cox", "raids", "highlight"} ) @Slf4j +@Singleton public class ShortcutPlugin extends Plugin { private final List shortcut = new ArrayList<>(); @@ -33,6 +37,11 @@ public class ShortcutPlugin extends Plugin private OverlayManager overlayManager; @Inject private ShortcutOverlay overlay; + @Inject + private ShortcutConfig config; + + @Getter(AccessLevel.PACKAGE) + private boolean highlightShortcuts; List getShortcut() { @@ -48,6 +57,7 @@ public class ShortcutPlugin extends Plugin @Override protected void startUp() { + this.highlightShortcuts = config.highlightShortcuts(); overlayManager.add(overlay); } @@ -80,18 +90,17 @@ public class ShortcutPlugin extends Plugin @Subscribe public void onGameTick(GameTick tick) { - if (shortcut == null) + shortcut.removeIf(object -> object.getCanvasLocation() == null); + } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("shortcut")) { return; } - Iterator it = shortcut.iterator(); - while (it.hasNext()) - { - TileObject object = it.next(); - if (object.getCanvasLocation() == null) - { - it.remove(); - } - } + + this.highlightShortcuts = config.highlightShortcuts(); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/Layout.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/Layout.java index 09357f7774..5694b2333c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/Layout.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/Layout.java @@ -26,16 +26,17 @@ package net.runelite.client.plugins.raids.solver; import java.util.ArrayList; import java.util.List; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; public class Layout { - @Getter + @Getter(AccessLevel.PUBLIC) private final List rooms = new ArrayList<>(); - @Getter - @Setter + @Getter(AccessLevel.PUBLIC) + @Setter(AccessLevel.PACKAGE) private String code; public void add(Room room) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/LayoutSolver.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/LayoutSolver.java index f53de67596..a189d78ca7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/LayoutSolver.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/LayoutSolver.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -50,7 +51,7 @@ import lombok.extern.slf4j.Slf4j; @Singleton public class LayoutSolver { - @Getter + @Getter(AccessLevel.PACKAGE) private static final List layouts = new ArrayList<>(); private static final Pattern regex = Pattern.compile("^([A-Z]*)\\.([A-Z]*) - #([A-Z]*)#([A-Z]*)$"); private static final String[] codes = @@ -211,7 +212,10 @@ public class LayoutSolver room = new Room(position, '¤'); room.setPrevious(lastRoom); - lastRoom.setNext(room); + if (lastRoom != null) + { + lastRoom.setNext(room); + } layout.add(room); layout.setCode(code); position += 8; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/Room.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/Room.java index 4ffa7efb60..ab231774ed 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/Room.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/Room.java @@ -24,26 +24,27 @@ */ package net.runelite.client.plugins.raids.solver; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; public class Room { - @Getter + @Getter(AccessLevel.PUBLIC) private final int position; - @Getter + @Getter(AccessLevel.PUBLIC) private final char symbol; - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private Room next; - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private Room previous; - Room(int position, char symbol) + Room(final int position, final char symbol) { this.position = position; this.symbol = symbol; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/RotationSolver.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/RotationSolver.java index 04e0323a5c..fe32ceaf76 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/RotationSolver.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/RotationSolver.java @@ -40,14 +40,14 @@ public class RotationSolver new Rotation<>(Arrays.asList(Boss.MYSTICS, Boss.VANGUARDS, Boss.VASA, Boss.SHAMANS, Boss.VESPULA, Boss.GUARDIANS, Boss.MUTTADILES, Boss.TEKTON)) }; - public static boolean solve(RaidRoom[] rooms) + public static void solve(RaidRoom[] rooms) { if (rooms == null) { - return false; + return; } - Rotation match = null; + Rotation match = null; Integer start = null; Integer index = null; int known = 0; @@ -69,12 +69,12 @@ public class RotationSolver if (known < 2) { - return false; + return; } if (known == rooms.length) { - return true; + return; } for (Rotation rotation : ROTATIONS) @@ -99,7 +99,7 @@ public class RotationSolver if (match != null && match != rotation) { - return false; + return; } index = i - start; @@ -110,7 +110,7 @@ public class RotationSolver if (match == null) { - return false; + return; } for (int i = 0; i < rooms.length; i++) @@ -122,16 +122,15 @@ public class RotationSolver if (rooms[i].getBoss() == null || rooms[i].getBoss() == Boss.UNKNOWN) { - rooms[i].setBoss(match.get(index + i)); + rooms[i].setBoss((Boss) match.get(index + i)); } } - return true; } private static class Rotation extends ArrayList { - Rotation(Collection bosses) + Rotation(final Collection bosses) { super(bosses); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/BatSolver/BatSolver.java b/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/BatSolver/BatSolver.java index e937633dc8..4f59a5c241 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/BatSolver/BatSolver.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/BatSolver/BatSolver.java @@ -39,7 +39,7 @@ public class BatSolver private final HashSet grubsChests; - public BatSolver(ThievingRoomType roomType) + public BatSolver(final ThievingRoomType roomType) { solution = new SolutionSet(roomType); grubsChests = new HashSet<>(); @@ -185,9 +185,4 @@ public class BatSolver double chestChance = (double) (timesFound) / (double) (mostFrequentPoison); return 1. / (1 + Math.exp(5 - 10 * chestChance)); } - - public int getNumberOfEmptyChests() - { - return solution.getEmptyChests().size(); - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/BatSolver/ChestIdentifier.java b/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/BatSolver/ChestIdentifier.java index 8e9bce1dc4..8cf12f817a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/BatSolver/ChestIdentifier.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/BatSolver/ChestIdentifier.java @@ -31,7 +31,7 @@ import net.runelite.client.plugins.raidsthieving.ThievingChest; public class ChestIdentifier { - public ChestIdentifier(ThievingRoomType roomType) + public ChestIdentifier(final ThievingRoomType roomType) { chestIds = new HashMap<>(); switch (roomType) @@ -250,11 +250,10 @@ public class ChestIdentifier } - public int indentifyChest(ThievingChest chest) + public void indentifyChest(ThievingChest chest) { int id = chestIds.get(chest.getInstancePoint()); chest.setChestId(id); - return id; } private Map chestIds; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/BatSolver/SolutionSet.java b/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/BatSolver/SolutionSet.java index 82c36163e4..9b0df5be86 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/BatSolver/SolutionSet.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/BatSolver/SolutionSet.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.raidsthieving.BatSolver; import java.util.Arrays; import java.util.HashSet; import java.util.Set; +import lombok.AccessLevel; import lombok.Getter; // Each Thieving room has 4 empty chests @@ -135,7 +136,7 @@ class SolutionSet new SolutionSet(ThievingRoomType.STRAIGHT, 51, 53, 56, 59) }; - SolutionSet(ThievingRoomType type) + SolutionSet(final ThievingRoomType type) { this.type = type; emptyChests = new HashSet<>(); @@ -157,9 +158,9 @@ class SolutionSet return emptyChests.contains(chestId); } - @Getter + @Getter(AccessLevel.PACKAGE) private ThievingRoomType type; - @Getter + @Getter(AccessLevel.PACKAGE) private Set emptyChests; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/BatSolver/ThievingRoomType.java b/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/BatSolver/ThievingRoomType.java index 26fabe5a8c..66581b5314 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/BatSolver/ThievingRoomType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/BatSolver/ThievingRoomType.java @@ -38,7 +38,7 @@ public enum ThievingRoomType private final int x; private final int y; - ThievingRoomType(int x, int y) + ThievingRoomType(final int x, final int y) { this.x = x; this.y = y; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/ChestOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/ChestOverlay.java index 077132dc61..03c34ce7c0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/ChestOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/ChestOverlay.java @@ -30,6 +30,7 @@ import java.awt.Graphics2D; import java.util.Map; import java.util.TreeSet; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.Point; @@ -40,25 +41,25 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.components.ProgressPieComponent; +import static net.runelite.client.util.ColorUtil.setAlphaComponent; /** * Represents the overlay that shows timers on traps that are placed by the * player. */ +@Singleton public class ChestOverlay extends Overlay { private final Client client; private final RaidsThievingPlugin plugin; - private final RaidsThievingConfig config; @Inject - ChestOverlay(Client client, RaidsThievingPlugin plugin, RaidsThievingConfig config) + ChestOverlay(final Client client, final RaidsThievingPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); this.plugin = plugin; - this.config = config; this.client = client; } @@ -97,16 +98,13 @@ public class ChestOverlay extends Overlay { if (shouldDrawChest(pos)) { - Color drawColor = new Color(config.getPotentialBatColor().getRed(), - config.getPotentialBatColor().getGreen(), - config.getPotentialBatColor().getBlue(), - getChestOpacity(pos)); + Color drawColor = new Color(setAlphaComponent(plugin.getGetPotentialBatColor().getRGB(), getChestOpacity(pos))); drawCircleOnTrap(graphics, chest, drawColor); } } if (chest.isPoison()) { - drawCircleOnTrap(graphics, chest, config.getPoisonTrapColor()); + drawCircleOnTrap(graphics, chest, plugin.getGetPoisonTrapColor()); } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/InstancePoint.java b/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/InstancePoint.java index b1ba3e0102..7b6da0a445 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/InstancePoint.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/InstancePoint.java @@ -1,6 +1,7 @@ package net.runelite.client.plugins.raidsthieving; import java.util.Objects; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.Point; @@ -9,20 +10,20 @@ import net.runelite.api.coords.WorldPoint; /** * Represents a point in the instance chunk, invariant of rotation. */ -@Getter +@Getter(AccessLevel.PACKAGE) public class InstancePoint { private static final int CHUNK_SIZE = 8; private static final double CHUNK_OFFSET = 3.5; - private InstancePoint(int x, int y, int rot) + private InstancePoint(final int x, final int y, final int rot) { this.x = x; this.y = y; this.rot = rot; } - public InstancePoint(int x, int y) + public InstancePoint(final int x, final int y) { this.x = x; this.y = y; @@ -97,7 +98,9 @@ public class InstancePoint return Objects.hash(x, y); } + @Getter(AccessLevel.PUBLIC) private int x; + @Getter(AccessLevel.PUBLIC) private int y; private int rot; } 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 a7679b985a..5df929535f 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 @@ -25,11 +25,14 @@ package net.runelite.client.plugins.raidsthieving; import com.google.inject.Provides; +import java.awt.Color; import java.text.MessageFormat; import java.time.Instant; import java.util.HashMap; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; @@ -60,7 +63,7 @@ import net.runelite.client.ui.overlay.OverlayManager; type = PluginType.PVM, enabledByDefault = false ) - +@Singleton public class RaidsThievingPlugin extends Plugin { @Inject @@ -78,23 +81,29 @@ public class RaidsThievingPlugin extends Plugin @Inject private RaidsThievingConfig config; - @Getter + @Getter(AccessLevel.PACKAGE) private final Map chests = new HashMap<>(); - @Getter + @Getter(AccessLevel.PACKAGE) private Instant lastActionTime = Instant.ofEpochMilli(0); private boolean inRaidChambers; - @Getter + @Getter(AccessLevel.PACKAGE) private boolean batsFound; - @Getter + @Getter(AccessLevel.PACKAGE) private BatSolver solver; - @Getter + @Getter(AccessLevel.PACKAGE) private ChestIdentifier mapper; + @Getter(AccessLevel.PACKAGE) + private Color getPotentialBatColor; + @Getter(AccessLevel.PACKAGE) + private Color getPoisonTrapColor; + private boolean batFoundNotify; + @Provides RaidsThievingConfig provideConfig(ConfigManager configManager) @@ -105,6 +114,8 @@ public class RaidsThievingPlugin extends Plugin @Override protected void startUp() { + updateConfig(); + overlayManager.add(overlay); overlay.updateConfig(); reset(); @@ -229,6 +240,7 @@ public class RaidsThievingPlugin extends Plugin { if (event.getGroup().equals("raidsthievingplugin")) { + updateConfig(); overlay.updateConfig(); } } @@ -261,7 +273,7 @@ public class RaidsThievingPlugin extends Plugin if (chest.isEmpty() && !chest.isPoison()) { batsFound = true; - if (config.batFoundNotify()) + if (this.batFoundNotify) { notifier.notify("Bats have been found!"); } @@ -275,5 +287,12 @@ public class RaidsThievingPlugin extends Plugin { return chests.get(worldPoint).getChestId(); } + + private void updateConfig() + { + this.getPotentialBatColor = config.getPotentialBatColor(); + this.getPoisonTrapColor = config.getPoisonTrapColor(); + this.batFoundNotify = config.batFoundNotify(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/ThievingChest.java b/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/ThievingChest.java index 05a58d554e..f508fc42cc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/ThievingChest.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raidsthieving/ThievingChest.java @@ -24,6 +24,7 @@ */ package net.runelite.client.plugins.raidsthieving; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import net.runelite.api.GameObject; @@ -32,32 +33,33 @@ import net.runelite.api.coords.WorldPoint; /** * Wrapper class for a GameObject that represents a chest in the thieving room of Chambers of Xeric. */ -@Getter +@Getter(AccessLevel.PACKAGE) public class ThievingChest { /** * If the chest has never been opened, it could have bats. */ - @Setter + @Setter(AccessLevel.PACKAGE) private boolean everOpened; /** * If the chest is empty, it could have bats. */ - @Setter + @Setter(AccessLevel.PACKAGE) private boolean empty; /** * If the chest contains a poison trap instead. */ - @Setter + @Setter(AccessLevel.PACKAGE) private boolean poison; - @Setter + @Setter(AccessLevel.PUBLIC) private int chestId; private final WorldPoint localPoint; + @Getter(AccessLevel.PUBLIC) private final InstancePoint instancePoint; /** diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/regenmeter/RegenMeterOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/regenmeter/RegenMeterOverlay.java index bff5f7c398..c96e12c0cf 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/regenmeter/RegenMeterOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/regenmeter/RegenMeterOverlay.java @@ -33,6 +33,7 @@ import java.awt.RenderingHints; import java.awt.Stroke; import java.awt.geom.Arc2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.VarPlayer; import net.runelite.api.widgets.Widget; @@ -41,6 +42,7 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; +@Singleton public class RegenMeterOverlay extends Overlay { private static final Color HITPOINTS_COLOR = brighter(0x9B0703); @@ -48,10 +50,20 @@ public class RegenMeterOverlay extends Overlay private static final Color OVERLAY_COLOR = new Color(255, 255, 255, 60); private static final double DIAMETER = 26D; private static final int OFFSET = 27; + private static final Stroke STROKE = new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER); private final Client client; private RegenMeterPlugin plugin; - private RegenMeterConfig config; + + private Rectangle getBounds(WidgetInfo widgetInfo) + { + Widget widget = client.getWidget(widgetInfo); + if (widget == null || widget.isHidden()) + { + return null; + } + return widget.getBounds(); + } private static Color brighter(int color) { @@ -61,13 +73,12 @@ public class RegenMeterOverlay extends Overlay } @Inject - public RegenMeterOverlay(Client client, RegenMeterPlugin plugin, RegenMeterConfig config) + public RegenMeterOverlay(final Client client, final RegenMeterPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); this.client = client; this.plugin = plugin; - this.config = config; } @Override @@ -75,20 +86,18 @@ public class RegenMeterOverlay extends Overlay { g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); - if (config.showHitpoints()) + if (plugin.isShowHitpoints()) { renderRegen(g, WidgetInfo.MINIMAP_HEALTH_ORB, plugin.getHitpointsPercentage(), HITPOINTS_COLOR); } - if (config.showSpecial()) + if (plugin.isShowSpecial()) { if (client.getVar(VarPlayer.SPECIAL_ATTACK_ENABLED) == 1) { - final Widget widget = client.getWidget(WidgetInfo.MINIMAP_SPEC_ORB); - - if (widget != null && !widget.isHidden()) + final Rectangle bounds = getBounds(WidgetInfo.MINIMAP_SPEC_ORB); + if (bounds != null) { - final Rectangle bounds = widget.getBounds(); g.setColor(RegenMeterOverlay.OVERLAY_COLOR); g.fillOval( bounds.x + OFFSET, @@ -105,17 +114,13 @@ public class RegenMeterOverlay extends Overlay private void renderRegen(Graphics2D g, WidgetInfo widgetInfo, double percent, Color color) { - Widget widget = client.getWidget(widgetInfo); - if (widget == null || widget.isHidden()) + final Rectangle bounds = getBounds(widgetInfo); + if (bounds != null) { - return; + Arc2D.Double arc = new Arc2D.Double(bounds.x + OFFSET, bounds.y + (bounds.height / 2 - DIAMETER / 2), DIAMETER, DIAMETER, 90.d, -360.d * percent, Arc2D.OPEN); + g.setStroke(STROKE); + g.setColor(color); + g.draw(arc); } - Rectangle bounds = widget.getBounds(); - - Arc2D.Double arc = new Arc2D.Double(bounds.x + OFFSET, bounds.y + (bounds.height / 2D - DIAMETER / 2D), DIAMETER, DIAMETER, 90.d, -360.d * percent, Arc2D.OPEN); - final Stroke STROKE = new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER); - g.setStroke(STROKE); - g.setColor(color); - g.draw(arc); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/regenmeter/RegenMeterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/regenmeter/RegenMeterPlugin.java index 004441b6e3..cc5b57e8ed 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/regenmeter/RegenMeterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/regenmeter/RegenMeterPlugin.java @@ -29,6 +29,8 @@ package net.runelite.client.plugins.regenmeter; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.Constants; @@ -36,6 +38,7 @@ import net.runelite.api.GameState; import net.runelite.api.Prayer; import net.runelite.api.Skill; import net.runelite.api.VarPlayer; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.VarbitChanged; @@ -51,6 +54,7 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Track and show the hitpoints and special attack regeneration timers", tags = {"combat", "health", "hitpoints", "special", "attack", "overlay", "notifications"} ) +@Singleton public class RegenMeterPlugin extends Plugin { private static final int SPEC_REGEN_TICKS = 50; @@ -71,16 +75,23 @@ public class RegenMeterPlugin extends Plugin @Inject private RegenMeterConfig config; - @Getter + @Getter(AccessLevel.PACKAGE) private double hitpointsPercentage; - @Getter + @Getter(AccessLevel.PACKAGE) private double specialPercentage; private int ticksSinceSpecRegen; private int ticksSinceHPRegen; private boolean wasRapidHeal; + @Getter(AccessLevel.PACKAGE) + private boolean showHitpoints; + @Getter(AccessLevel.PACKAGE) + private boolean showSpecial; + private boolean showWhenNoChange; + private int getNotifyBeforeHpRegenSeconds; + @Provides RegenMeterConfig provideConfig(ConfigManager configManager) { @@ -90,6 +101,7 @@ public class RegenMeterPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); overlayManager.add(overlay); } @@ -146,7 +158,7 @@ public class RegenMeterPlugin extends Plugin int currentHP = client.getBoostedSkillLevel(Skill.HITPOINTS); int maxHP = client.getRealSkillLevel(Skill.HITPOINTS); - if (currentHP == maxHP && !config.showWhenNoChange()) + if (currentHP == maxHP && !this.showWhenNoChange) { hitpointsPercentage = 0; } @@ -156,7 +168,7 @@ public class RegenMeterPlugin extends Plugin hitpointsPercentage = 1 - hitpointsPercentage; } - if (config.getNotifyBeforeHpRegenSeconds() > 0 && currentHP < maxHP && shouldNotifyHpRegenThisTick(ticksPerHPRegen)) + if (this.getNotifyBeforeHpRegenSeconds > 0 && currentHP < maxHP && shouldNotifyHpRegenThisTick(ticksPerHPRegen)) { notifier.notify("[" + client.getLocalPlayer().getName() + "] regenerates their next hitpoint soon!"); } @@ -166,7 +178,24 @@ public class RegenMeterPlugin extends Plugin { // if the configured duration lies between two ticks, choose the earlier tick final int ticksBeforeHPRegen = ticksPerHPRegen - ticksSinceHPRegen; - final int notifyTick = (int) Math.ceil(config.getNotifyBeforeHpRegenSeconds() * 1000d / Constants.GAME_TICK_LENGTH); + final int notifyTick = (int) Math.ceil(this.getNotifyBeforeHpRegenSeconds * 1000d / Constants.GAME_TICK_LENGTH); return ticksBeforeHPRegen == notifyTick; } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("regenmeter")) + { + updateConfig(); + } + } + + private void updateConfig() + { + this.showHitpoints = config.showHitpoints(); + this.showSpecial = config.showSpecial(); + this.showWhenNoChange = config.showWhenNoChange(); + this.getNotifyBeforeHpRegenSeconds = config.getNotifyBeforeHpRegenSeconds(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/reorderprayers/ReorderPrayersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/reorderprayers/ReorderPrayersPlugin.java index 2d95269eb5..deec5d3ec6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/reorderprayers/ReorderPrayersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/reorderprayers/ReorderPrayersPlugin.java @@ -31,6 +31,7 @@ import java.util.List; import java.util.Objects; import java.util.stream.Collectors; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.HashTable; @@ -57,6 +58,7 @@ import net.runelite.client.plugins.PluginDescriptor; name = "Reorder Prayers", description = "Reorder the prayers displayed on the Prayer panel" ) +@Singleton public class ReorderPrayersPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/ReportButtonPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/ReportButtonPlugin.java index b633a89b10..8a0f91e692 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/ReportButtonPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/ReportButtonPlugin.java @@ -36,8 +36,10 @@ import java.time.format.FormatStyle; import java.time.temporal.ChronoUnit; import java.util.Date; import javax.inject.Inject; +import javax.inject.Singleton; 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.api.widgets.Widget; import net.runelite.api.widgets.WidgetInfo; @@ -53,6 +55,7 @@ import net.runelite.client.task.Schedule; description = "Replace the text on the Report button with the current time", tags = {"time", "utc"} ) +@Singleton public class ReportButtonPlugin extends Plugin { private static final ZoneId UTC = ZoneId.of("UTC"); @@ -73,6 +76,8 @@ public class ReportButtonPlugin extends Plugin @Inject private ReportButtonConfig config; + private TimeStyle timeStyle; + @Provides ReportButtonConfig provideConfig(ConfigManager configManager) { @@ -82,6 +87,7 @@ public class ReportButtonPlugin extends Plugin @Override public void startUp() { + this.timeStyle = config.time(); clientThread.invoke(this::updateReportButtonTime); } @@ -142,7 +148,7 @@ public class ReportButtonPlugin extends Plugin return; } - switch (config.time()) + switch (this.timeStyle) { case UTC: reportButton.setText(getUTCTime()); @@ -198,4 +204,13 @@ public class ReportButtonPlugin extends Plugin { return DATE_FORMAT.format(new Date()); } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("regenmeter")) + { + this.timeStyle = config.time(); + } + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/TimeStyle.java b/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/TimeStyle.java index 40095b9a4f..b67549faf8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/TimeStyle.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/TimeStyle.java @@ -35,7 +35,7 @@ public enum TimeStyle private final String name; - TimeStyle(String name) + TimeStyle(final String name) { this.name = name; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/roguesden/RoguesDenOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/roguesden/RoguesDenOverlay.java index 4b5cc234e1..e76f6c4f70 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/roguesden/RoguesDenOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/roguesden/RoguesDenOverlay.java @@ -29,12 +29,14 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Polygon; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; 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; +@Singleton public class RoguesDenOverlay extends Overlay { private static final int MAX_DISTANCE = 2350; @@ -43,7 +45,7 @@ public class RoguesDenOverlay extends Overlay private final RoguesDenPlugin plugin; @Inject - public RoguesDenOverlay(Client client, RoguesDenPlugin plugin) + public RoguesDenOverlay(final Client client, final RoguesDenPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/roguesden/RoguesDenPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/roguesden/RoguesDenPlugin.java index 138ee3d9ac..0d7583ea7e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/roguesden/RoguesDenPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/roguesden/RoguesDenPlugin.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.roguesden; import java.util.HashMap; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Client; @@ -53,6 +54,7 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Mark tiles and clickboxes to help traverse the maze", tags = {"agility", "maze", "minigame", "overlay", "thieving"} ) +@Singleton public class RoguesDenPlugin extends Plugin { @Getter(AccessLevel.PACKAGE) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssOverlay.java index b0e2bb0b99..29ea78ad00 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssOverlay.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.runecraft; import com.google.inject.Inject; +import com.google.inject.Singleton; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; @@ -59,6 +60,7 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton class AbyssOverlay extends Overlay { private static final Dimension IMAGE_SIZE = new Dimension(15, 14); @@ -68,25 +70,23 @@ class AbyssOverlay extends Overlay private final Client client; private final RunecraftPlugin plugin; - private final RunecraftConfig config; @Inject private ItemManager itemManager; @Inject - AbyssOverlay(Client client, RunecraftPlugin plugin, RunecraftConfig config) + AbyssOverlay(final Client client, final RunecraftPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); this.client = client; this.plugin = plugin; - this.config = config; } @Override public Dimension render(Graphics2D graphics) { - if (config.showRifts()) + if (plugin.isShowRifts()) { for (DecorativeObject object : plugin.getAbyssObjects()) { @@ -94,7 +94,7 @@ class AbyssOverlay extends Overlay } } - if (config.hightlightDarkMage()) + if (plugin.isHightlightDarkMage()) { highlightDarkMage(graphics); } @@ -132,7 +132,7 @@ class AbyssOverlay extends Overlay return; } - if (config.showClickBox()) + if (plugin.isShowClickBox()) { //Draw clickbox Point mousePosition = client.getMouseCanvasPosition(); @@ -185,55 +185,55 @@ class AbyssOverlay extends Overlay public void updateConfig() { rifts.clear(); - if (config.showAir()) + if (plugin.isShowAir()) { rifts.add(AIR_RIFT); } - if (config.showBlood()) + if (plugin.isShowBlood()) { rifts.add(BLOOD_RIFT); } - if (config.showBody()) + if (plugin.isShowBody()) { rifts.add(BODY_RIFT); } - if (config.showChaos()) + if (plugin.isShowChaos()) { rifts.add(CHAOS_RIFT); } - if (config.showCosmic()) + if (plugin.isShowCosmic()) { rifts.add(COSMIC_RIFT); } - if (config.showDeath()) + if (plugin.isShowDeath()) { rifts.add(DEATH_RIFT); } - if (config.showEarth()) + if (plugin.isShowEarth()) { rifts.add(EARTH_RIFT); } - if (config.showFire()) + if (plugin.isShowFire()) { rifts.add(FIRE_RIFT); } - if (config.showLaw()) + if (plugin.isShowLaw()) { rifts.add(LAW_RIFT); } - if (config.showMind()) + if (plugin.isShowMind()) { rifts.add(MIND_RIFT); } - if (config.showNature()) + if (plugin.isShowNature()) { rifts.add(NATURE_RIFT); } - if (config.showSoul()) + if (plugin.isShowSoul()) { rifts.add(SOUL_RIFT); } - if (config.showWater()) + if (plugin.isShowWater()) { rifts.add(WATER_RIFT); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssRifts.java b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssRifts.java index e9546e3cee..20bc229b32 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssRifts.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/AbyssRifts.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.runecraft; import java.util.HashMap; import java.util.Map; +import lombok.AccessLevel; import lombok.Getter; import static net.runelite.api.ItemID.*; import net.runelite.api.ObjectID; @@ -46,10 +47,10 @@ public enum AbyssRifts SOUL_RIFT(ObjectID.SOUL_RIFT, SOUL_RUNE), WATER_RIFT(ObjectID.WATER_RIFT, WATER_RUNE); - @Getter + @Getter(AccessLevel.PACKAGE) private final int objectId; - @Getter + @Getter(AccessLevel.PACKAGE) private final int itemId; private static final Map rifts = new HashMap<>(); @@ -62,7 +63,7 @@ public enum AbyssRifts } } - AbyssRifts(int objectId, int itemId) + AbyssRifts(final int objectId, final int itemId) { this.objectId = objectId; this.itemId = itemId; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/RunecraftOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/RunecraftOverlay.java index 91a95bb885..f78880bc84 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/RunecraftOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/RunecraftOverlay.java @@ -4,24 +4,23 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; -import net.runelite.api.Client; +import javax.inject.Singleton; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.components.ComponentOrientation; import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.TitleComponent; +@Singleton public class RunecraftOverlay extends Overlay { private final RunecraftPlugin plugin; - private final Client client; private final PanelComponent panel = new PanelComponent(); @Inject - RunecraftOverlay(RunecraftPlugin plugin, Client client) + RunecraftOverlay(final RunecraftPlugin plugin) { this.plugin = plugin; - this.client = client; setPosition(OverlayPosition.CANVAS_TOP_RIGHT); panel.setOrientation(ComponentOrientation.VERTICAL); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/RunecraftPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/RunecraftPlugin.java index b653a56fb2..f42c10102b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/RunecraftPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runecraft/RunecraftPlugin.java @@ -31,6 +31,7 @@ import java.util.List; import java.util.Set; import java.util.stream.Stream; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.ChatMessageType; @@ -69,6 +70,7 @@ import net.runelite.client.util.Text; description = "Show minimap icons and clickboxes for abyssal rifts", tags = {"abyssal", "minimap", "overlay", "rifts", "rc", "runecrafting"} ) +@Singleton public class RunecraftPlugin extends Plugin { private static final int FIRE_ALTAR = 10315; @@ -113,6 +115,43 @@ public class RunecraftPlugin extends Plugin @Inject private MenuManager menuManager; + private boolean Lavas; + @Getter(AccessLevel.PACKAGE) + private boolean essPouch; + @Getter(AccessLevel.PACKAGE) + private boolean hightlightDarkMage; + private boolean degradingNotification; + @Getter(AccessLevel.PACKAGE) + private boolean showRifts; + @Getter(AccessLevel.PACKAGE) + private boolean showAir; + @Getter(AccessLevel.PACKAGE) + private boolean showBlood; + @Getter(AccessLevel.PACKAGE) + private boolean showBody; + @Getter(AccessLevel.PACKAGE) + private boolean showChaos; + @Getter(AccessLevel.PACKAGE) + private boolean showCosmic; + @Getter(AccessLevel.PACKAGE) + private boolean showDeath; + @Getter(AccessLevel.PACKAGE) + private boolean showEarth; + @Getter(AccessLevel.PACKAGE) + private boolean showFire; + @Getter(AccessLevel.PACKAGE) + private boolean showLaw; + @Getter(AccessLevel.PACKAGE) + private boolean showMind; + @Getter(AccessLevel.PACKAGE) + private boolean showNature; + @Getter(AccessLevel.PACKAGE) + private boolean showSoul; + @Getter(AccessLevel.PACKAGE) + private boolean showWater; + @Getter(AccessLevel.PACKAGE) + private boolean showClickBox; + @Provides RunecraftConfig getConfig(ConfigManager configManager) { @@ -122,6 +161,8 @@ public class RunecraftPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(abyssOverlay); abyssOverlay.updateConfig(); overlayManager.add(runecraftOverlay); @@ -147,6 +188,8 @@ public class RunecraftPlugin extends Plugin return; } + updateConfig(); + if (event.getKey().equals("essPouch")) { addSwaps(); @@ -163,7 +206,7 @@ public class RunecraftPlugin extends Plugin return; } - if (config.degradingNotification()) + if (this.degradingNotification) { if (event.getMessage().contains(POUCH_DECAYED_MESSAGE)) { @@ -294,8 +337,8 @@ public class RunecraftPlugin extends Plugin else if (event.getItemContainer() == client.getItemContainer(InventoryID.EQUIPMENT)) { final Item[] items = event.getItemContainer().getItems(); - wearingTiara = config.Lavas() && items[EquipmentInventorySlot.HEAD.getSlotIdx()].getId() == ItemID.FIRE_TIARA; - wearingCape = config.Lavas() && items[EquipmentInventorySlot.CAPE.getSlotIdx()].getId() == ItemID.RUNECRAFT_CAPE || config.Lavas() && items[EquipmentInventorySlot.CAPE.getSlotIdx()].getId() == ItemID.RUNECRAFT_CAPET || config.Lavas() && items[EquipmentInventorySlot.CAPE.getSlotIdx()].getId() == ItemID.MAX_CAPE_13342; + wearingTiara = this.Lavas && items[EquipmentInventorySlot.HEAD.getSlotIdx()].getId() == ItemID.FIRE_TIARA; + wearingCape = this.Lavas && items[EquipmentInventorySlot.CAPE.getSlotIdx()].getId() == ItemID.RUNECRAFT_CAPE || config.Lavas() && items[EquipmentInventorySlot.CAPE.getSlotIdx()].getId() == ItemID.RUNECRAFT_CAPET || config.Lavas() && items[EquipmentInventorySlot.CAPE.getSlotIdx()].getId() == ItemID.MAX_CAPE_13342; } } @@ -338,4 +381,27 @@ public class RunecraftPlugin extends Plugin menuManager.removeSwap("deposit", "pouch", 2, 57, "fill", "pouch", 9, 1007); menuManager.removeSwap("fill", "pouch", "empty", "pouch", true, false); } + + private void updateConfig() + { + this.Lavas = config.Lavas(); + this.essPouch = config.essPouch(); + this.hightlightDarkMage = config.hightlightDarkMage(); + this.degradingNotification = config.degradingNotification(); + this.showRifts = config.showRifts(); + this.showAir = config.showAir(); + this.showBlood = config.showBlood(); + this.showBody = config.showBody(); + this.showChaos = config.showChaos(); + this.showCosmic = config.showCosmic(); + this.showDeath = config.showDeath(); + this.showEarth = config.showEarth(); + this.showFire = config.showFire(); + this.showLaw = config.showLaw(); + this.showMind = config.showMind(); + this.showNature = config.showNature(); + this.showSoul = config.showSoul(); + this.showWater = config.showWater(); + this.showClickBox = config.showClickBox(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuConfig.java index 0e44decfa0..ab4face95a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuConfig.java @@ -35,10 +35,10 @@ public interface RunedokuConfig extends Config { @ConfigItem( - position = 0, - keyName = "colorStub", - name = "Colors", - description = "" //stubs don't show descriptions when hovered over + position = 0, + keyName = "colorStub", + name = "Colors", + description = "" //stubs don't show descriptions when hovered over ) default Stub colorStub() { @@ -46,11 +46,11 @@ public interface RunedokuConfig extends Config } @ConfigItem( - position = 1, - keyName = "mindRuneColor", - name = "Mind Rune Color", - description = "Color used to highlight Mind runes.", - parent = "colorStub" + position = 1, + keyName = "mindRuneColor", + name = "Mind Rune Color", + description = "Color used to highlight Mind runes.", + parent = "colorStub" ) default Color mindRuneColor() { @@ -58,11 +58,11 @@ public interface RunedokuConfig extends Config } @ConfigItem( - position = 2, - keyName = "fireRuneColor", - name = "Fire Rune Color", - description = "Color used to highlight Fire runes.", - parent = "colorStub" + position = 2, + keyName = "fireRuneColor", + name = "Fire Rune Color", + description = "Color used to highlight Fire runes.", + parent = "colorStub" ) default Color fireRuneColor() { @@ -70,11 +70,11 @@ public interface RunedokuConfig extends Config } @ConfigItem( - position = 3, - keyName = "bodyRuneColor", - name = "Body Rune Color", - description = "Color used to highlight Body runes.", - parent = "colorStub" + position = 3, + keyName = "bodyRuneColor", + name = "Body Rune Color", + description = "Color used to highlight Body runes.", + parent = "colorStub" ) default Color bodyRuneColor() { @@ -82,11 +82,11 @@ public interface RunedokuConfig extends Config } @ConfigItem( - position = 4, - keyName = "airRuneColor", - name = "Air Rune Color", - description = "Color used to highlight Air runes.", - parent = "colorStub" + position = 4, + keyName = "airRuneColor", + name = "Air Rune Color", + description = "Color used to highlight Air runes.", + parent = "colorStub" ) default Color airRuneColor() { @@ -94,11 +94,11 @@ public interface RunedokuConfig extends Config } @ConfigItem( - position = 5, - keyName = "deathRuneColor", - name = "Death Rune Color", - description = "Color used to highlight Death runes.", - parent = "colorStub" + position = 5, + keyName = "deathRuneColor", + name = "Death Rune Color", + description = "Color used to highlight Death runes.", + parent = "colorStub" ) default Color deathRuneColor() { @@ -106,11 +106,11 @@ public interface RunedokuConfig extends Config } @ConfigItem( - position = 6, - keyName = "waterRuneColor", - name = "Water Rune Color", - description = "Color used to highlight Water runes.", - parent = "colorStub" + position = 6, + keyName = "waterRuneColor", + name = "Water Rune Color", + description = "Color used to highlight Water runes.", + parent = "colorStub" ) default Color waterRuneColor() { @@ -118,11 +118,11 @@ public interface RunedokuConfig extends Config } @ConfigItem( - position = 7, - keyName = "chaosRuneColor", - name = "Chaos Rune Color", - description = "Color used to highlight Chaos runes.", - parent = "colorStub" + position = 7, + keyName = "chaosRuneColor", + name = "Chaos Rune Color", + description = "Color used to highlight Chaos runes.", + parent = "colorStub" ) default Color chaosRuneColor() { @@ -130,11 +130,11 @@ public interface RunedokuConfig extends Config } @ConfigItem( - position = 8, - keyName = "earthRuneColor", - name = "Earth Rune Color", - description = "Color used to highlight Earth runes.", - parent = "colorStub" + position = 8, + keyName = "earthRuneColor", + name = "Earth Rune Color", + description = "Color used to highlight Earth runes.", + parent = "colorStub" ) default Color earthRuneColor() { @@ -142,11 +142,11 @@ public interface RunedokuConfig extends Config } @ConfigItem( - position = 9, - keyName = "lawRuneColor", - name = "Law Rune Color", - description = "Color used to highlight Law runes.", - parent = "colorStub" + position = 9, + keyName = "lawRuneColor", + name = "Law Rune Color", + description = "Color used to highlight Law runes.", + parent = "colorStub" ) default Color lawRuneColor() { @@ -154,10 +154,10 @@ public interface RunedokuConfig extends Config } @ConfigItem( - position = 10, - keyName = "miscFeature", - name = "Miscellaneous Features", - description = "" + position = 10, + keyName = "miscFeature", + name = "Miscellaneous Features", + description = "" ) default Stub miscFeature() { @@ -165,10 +165,10 @@ public interface RunedokuConfig extends Config } @ConfigItem( - position = 11, - keyName = "onlyHighlightSelectedPiece", - name = "Only Highlight Selected Piece", - description = "Instead of showing all, this option only show what rune you have selected." + position = 11, + keyName = "onlyHighlightSelectedPiece", + name = "Only Highlight Selected Piece", + description = "Instead of showing all, this option only show what rune you have selected." ) default boolean onlyHighlightSelectedPiece() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuOverlay.java index 5e44e55bee..0756a6d4b6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuOverlay.java @@ -30,6 +30,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.util.ArrayList; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.widgets.Widget; import net.runelite.client.ui.overlay.Overlay; @@ -41,23 +42,22 @@ import net.runelite.client.ui.overlay.OverlayUtil; /** * @author gazivodag */ +@Singleton class RunedokuOverlay extends Overlay { private final RunedokuPlugin plugin; private final Client client; private final RunedokuUtil util; - private final RunedokuConfig config; @Inject - private RunedokuOverlay(final RunedokuPlugin plugin, final Client client, final RunedokuUtil util, final RunedokuConfig config) + private RunedokuOverlay(final RunedokuPlugin plugin, final Client client, final RunedokuUtil util) { super(plugin); this.plugin = plugin; this.client = client; this.util = util; - this.config = config; setPosition(OverlayPosition.DETACHED); setLayer(OverlayLayer.ALWAYS_ON_TOP); @@ -140,7 +140,7 @@ class RunedokuOverlay extends Overlay } else { - if (!config.onlyHighlightSelectedPiece() ^ (config.onlyHighlightSelectedPiece() && util.getSelectedPiece(client) == simpleArr.get(iteration))) + if (!plugin.isOnlyHighlightSelectedPiece() ^ (plugin.isOnlyHighlightSelectedPiece() && util.getSelectedPiece(client) == simpleArr.get(iteration))) { OverlayUtil.renderPolygon(graphics, RunedokuUtil.rectangleToPolygon(squareToHighlight.getBounds()), util.sudokuPieceToColor(simpleArr.get(iteration))); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuPiece.java b/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuPiece.java index 7a6f50ab08..d8e75ca1dd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuPiece.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuPiece.java @@ -51,7 +51,7 @@ public enum RunedokuPiece private final int pieceID; private final int pieceForSudoku; - RunedokuPiece(int pieceID, int pieceForSudoku) + RunedokuPiece(final int pieceID, final int pieceForSudoku) { this.pieceID = pieceID; this.pieceForSudoku = pieceForSudoku; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuPlugin.java index e441779a7a..3fa8214b50 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuPlugin.java @@ -25,11 +25,15 @@ package net.runelite.client.plugins.runedoku; import com.google.inject.Provides; +import java.awt.Color; import javax.inject.Inject; import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; -import net.runelite.api.Client; +import net.runelite.api.events.ConfigChanged; import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.PluginType; @@ -47,13 +51,6 @@ import net.runelite.client.ui.overlay.OverlayManager; @Singleton public class RunedokuPlugin extends Plugin { - - @Inject - private Client client; - - @Inject - RunedokuUtil util; - @Inject private OverlayManager overlayManager; @@ -63,6 +60,27 @@ public class RunedokuPlugin extends Plugin @Inject private RunedokuConfig config; + @Getter(AccessLevel.PACKAGE) + private Color mindRuneColor; + @Getter(AccessLevel.PACKAGE) + private Color fireRuneColor; + @Getter(AccessLevel.PACKAGE) + private Color bodyRuneColor; + @Getter(AccessLevel.PACKAGE) + private Color airRuneColor; + @Getter(AccessLevel.PACKAGE) + private Color deathRuneColor; + @Getter(AccessLevel.PACKAGE) + private Color waterRuneColor; + @Getter(AccessLevel.PACKAGE) + private Color chaosRuneColor; + @Getter(AccessLevel.PACKAGE) + private Color earthRuneColor; + @Getter(AccessLevel.PACKAGE) + private Color lawRuneColor; + @Getter(AccessLevel.PACKAGE) + private boolean onlyHighlightSelectedPiece; + @Provides RunedokuConfig provideConfig(ConfigManager configManager) { @@ -72,6 +90,7 @@ public class RunedokuPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); overlayManager.add(runedokuOverlay); } @@ -81,4 +100,28 @@ public class RunedokuPlugin extends Plugin overlayManager.remove(runedokuOverlay); } + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("runedoku")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.mindRuneColor = config.mindRuneColor(); + this.fireRuneColor = config.fireRuneColor(); + this.bodyRuneColor = config.bodyRuneColor(); + this.airRuneColor = config.airRuneColor(); + this.deathRuneColor = config.deathRuneColor(); + this.waterRuneColor = config.waterRuneColor(); + this.chaosRuneColor = config.chaosRuneColor(); + this.earthRuneColor = config.earthRuneColor(); + this.lawRuneColor = config.lawRuneColor(); + this.onlyHighlightSelectedPiece = config.onlyHighlightSelectedPiece(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuUtil.java b/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuUtil.java index 36c5ac5662..3c7b51564d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuUtil.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/RunedokuUtil.java @@ -28,6 +28,7 @@ import java.awt.Color; import java.awt.Polygon; import java.awt.Rectangle; import java.util.ArrayList; +import java.util.Objects; import javax.inject.Inject; import net.runelite.api.Client; import net.runelite.api.widgets.Widget; @@ -36,12 +37,12 @@ import net.runelite.api.widgets.WidgetItem; class RunedokuUtil { - private final RunedokuConfig config; + private final RunedokuPlugin plugin; @Inject - RunedokuUtil(final RunedokuConfig config) + RunedokuUtil(final RunedokuPlugin plugin) { - this.config = config; + this.plugin = plugin; } Color sudokuPieceToColor(int i) @@ -49,23 +50,23 @@ class RunedokuUtil switch (i) { case 1: - return config.mindRuneColor(); + return plugin.getMindRuneColor(); case 2: - return config.fireRuneColor(); + return plugin.getFireRuneColor(); case 3: - return config.bodyRuneColor(); + return plugin.getBodyRuneColor(); case 4: - return config.airRuneColor(); + return plugin.getAirRuneColor(); case 5: - return config.deathRuneColor(); + return plugin.getDeathRuneColor(); case 6: - return config.waterRuneColor(); + return plugin.getWaterRuneColor(); case 7: - return config.chaosRuneColor(); + return plugin.getChaosRuneColor(); case 8: - return config.earthRuneColor(); + return plugin.getEarthRuneColor(); case 9: - return config.lawRuneColor(); + return plugin.getLawRuneColor(); default: return Color.RED; } @@ -76,23 +77,23 @@ class RunedokuUtil switch (i) { case 121: //earth - return config.earthRuneColor(); + return plugin.getEarthRuneColor(); case 122: //water - return config.waterRuneColor(); + return plugin.getWaterRuneColor(); case 123: //air - return config.airRuneColor(); + return plugin.getAirRuneColor(); case 124: //mind - return config.mindRuneColor(); + return plugin.getMindRuneColor(); case 125: //fire - return config.fireRuneColor(); + return plugin.getFireRuneColor(); case 126: //body - return config.bodyRuneColor(); + return plugin.getBodyRuneColor(); case 127: //death - return config.deathRuneColor(); + return plugin.getDeathRuneColor(); case 128: //chaos - return config.chaosRuneColor(); - case 129: //law - return config.lawRuneColor(); + return plugin.getChaosRuneColor(); + case 129: //plugin + return plugin.getLawRuneColor(); default: return Color.RED; } @@ -123,7 +124,7 @@ class RunedokuUtil * @param rect * @return */ - public static Polygon rectangleToPolygon(Rectangle rect) + 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}; @@ -164,7 +165,7 @@ class RunedokuUtil { if (item.getId() != -1) { - myArr[i][ii] = RunedokuPiece.getById(item.getId()).getPieceForSudoku(); + myArr[i][ii] = Objects.requireNonNull(RunedokuPiece.getById(item.getId())).getPieceForSudoku(); } else { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/Sudoku.java b/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/Sudoku.java index a6b2f339de..e763013b3e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/Sudoku.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runedoku/Sudoku.java @@ -10,17 +10,14 @@ public class Sudoku private int[][] board; public static final int EMPTY = 0; - public static final int SIZE = 9; + private static final int SIZE = 9; - Sudoku(int[][] board) + Sudoku(final int[][] board) { this.board = new int[SIZE][SIZE]; for (int i = 0; i < SIZE; i++) { - for (int j = 0; j < SIZE; j++) - { - this.board[i][j] = board[i][j]; - } + System.arraycopy(board[i], 0, this.board[i], 0, SIZE); } } @@ -74,7 +71,7 @@ public class Sudoku return !isInRow(row, number) && !isInCol(col, number) && !isInBox(row, col, number); } - public boolean solve() + boolean solve() { for (int row = 0; row < SIZE; row++) { @@ -116,7 +113,7 @@ public class Sudoku } } - public int[][] getBoard() + int[][] getBoard() { return board; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runeliteplus/RuneLitePlusPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/runeliteplus/RuneLitePlusPlugin.java index 2279d2ddd8..242d7ce17e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runeliteplus/RuneLitePlusPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runeliteplus/RuneLitePlusPlugin.java @@ -31,6 +31,7 @@ import com.google.inject.Provides; import java.awt.event.KeyEvent; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.events.ConfigChanged; @@ -56,7 +57,7 @@ import net.runelite.client.ui.ClientUI; description = "Configures various aspects of RuneLitePlus", type = PluginType.EXTERNAL ) - +@Singleton @Slf4j public class RuneLitePlusPlugin extends Plugin { @@ -120,14 +121,11 @@ public class RuneLitePlusPlugin extends Plugin };*/ public static boolean customPresenceEnabled = false; public static final String rlPlusDiscordApp = "560644885250572289"; - public static final String rlDiscordApp = "409416265891971072"; + private static final String rlDiscordApp = "409416265891971072"; @Inject public RuneLitePlusConfig config; - @Inject - private ConfigManager configManager; - @Inject public DiscordService discordService; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runenergy/RunEnergyOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/runenergy/RunEnergyOverlay.java index 9ca4c40d6b..258fc98211 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runenergy/RunEnergyOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runenergy/RunEnergyOverlay.java @@ -28,6 +28,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Rectangle; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Point; import net.runelite.api.widgets.Widget; @@ -39,6 +40,7 @@ import net.runelite.client.ui.overlay.tooltip.Tooltip; import net.runelite.client.ui.overlay.tooltip.TooltipManager; import org.apache.commons.lang3.StringUtils; +@Singleton class RunEnergyOverlay extends Overlay { private final RunEnergyPlugin plugin; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runenergy/RunEnergyPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/runenergy/RunEnergyPlugin.java index 52170baa4e..81ab24eb1d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runenergy/RunEnergyPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runenergy/RunEnergyPlugin.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.runenergy; import com.google.common.collect.ImmutableSet; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Constants; import net.runelite.api.EquipmentInventorySlot; @@ -145,6 +146,7 @@ import org.apache.commons.lang3.StringUtils; description = "Show various information related to run energy", tags = {"overlay", "stamina"} ) +@Singleton public class RunEnergyPlugin extends Plugin { // TODO It would be nice if we have the IDs for just the equipped variants of the Graceful set items. 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 8088176bd9..f61935e4b7 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 @@ -29,6 +29,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.ItemID; import net.runelite.api.Point; @@ -44,6 +45,7 @@ import net.runelite.client.ui.overlay.tooltip.Tooltip; import net.runelite.client.ui.overlay.tooltip.TooltipManager; import net.runelite.client.util.ColorUtil; +@Singleton public class RunepouchOverlay extends WidgetItemOverlay { private static final Varbits[] AMOUNT_VARBITS = @@ -57,18 +59,18 @@ public class RunepouchOverlay extends WidgetItemOverlay private static final Dimension IMAGE_SIZE = new Dimension(11, 11); private final Client client; - private final RunepouchConfig config; + private final RunepouchPlugin plugin; private final TooltipManager tooltipManager; @Inject private ItemManager itemManager; @Inject - RunepouchOverlay(Client client, RunepouchConfig config, TooltipManager tooltipManager) + RunepouchOverlay(final Client client, final RunepouchPlugin plugin, final TooltipManager tooltipManager) { this.tooltipManager = tooltipManager; this.client = client; - this.config = config; + this.plugin = plugin; showOnInventory(); showOnBank(); } @@ -116,7 +118,7 @@ public class RunepouchOverlay extends WidgetItemOverlay .append(ColorUtil.wrapWithColorTag(rune.getName(), Color.YELLOW)) .append("
"); - if (config.runePouchOverlayMode() == MOUSE_HOVER) + if (plugin.getRunePouchOverlayMode() == MOUSE_HOVER) { continue; } @@ -127,18 +129,18 @@ public class RunepouchOverlay extends WidgetItemOverlay int yOffset = (1 + (graphics.getFontMetrics().getMaxAscent()) * i); graphics.setColor(Color.black); - graphics.drawString("" + formatNumber(amount), location.getX() + (config.showIcons() ? 13 : 6), + graphics.drawString("" + formatNumber(amount), location.getX() + (plugin.isShowIcons() ? 13 : 6), yLocation + yOffset); - graphics.setColor(config.fontColor()); - graphics.drawString("" + formatNumber(amount), location.getX() + (config.showIcons() ? 12 : 5), + graphics.setColor(plugin.getFontColor()); + graphics.drawString("" + formatNumber(amount), location.getX() + (plugin.isShowIcons() ? 12 : 5), yLocation + yOffset); - graphics.setColor(config.fontColor()); - graphics.drawString("" + formatNumber(amount), location.getX() + (config.showIcons() ? 11 : 4), + graphics.setColor(plugin.getFontColor()); + graphics.drawString("" + formatNumber(amount), location.getX() + (plugin.isShowIcons() ? 11 : 4), location.getY() + 12 + (graphics.getFontMetrics().getHeight() - 1) * i); - if (!config.showIcons()) + if (!plugin.isShowIcons()) { continue; } @@ -162,7 +164,7 @@ public class RunepouchOverlay extends WidgetItemOverlay if (!tooltip.isEmpty() && itemWidget.getCanvasBounds().contains(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY()) - && (config.runePouchOverlayMode() == MOUSE_HOVER || config.runePouchOverlayMode() == BOTH)) + && (plugin.getRunePouchOverlayMode() == MOUSE_HOVER || plugin.getRunePouchOverlayMode() == BOTH)) { tooltipManager.add(new Tooltip(tooltip)); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchPlugin.java index 031f0900e1..88a897d9ef 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/RunepouchPlugin.java @@ -25,10 +25,17 @@ package net.runelite.client.plugins.runepouch; import com.google.inject.Provides; +import java.awt.Color; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; +import net.runelite.api.events.ConfigChanged; 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.runepouch.config.RunePouchOverlayMode; import net.runelite.client.ui.overlay.OverlayManager; @PluginDescriptor( @@ -36,6 +43,7 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Show the contents of your rune pouch", tags = {"combat", "magic", "overlay"} ) +@Singleton public class RunepouchPlugin extends Plugin { @Inject @@ -44,6 +52,16 @@ public class RunepouchPlugin extends Plugin @Inject private RunepouchOverlay overlay; + @Inject + private RunepouchConfig config; + + @Getter(AccessLevel.PACKAGE) + private Color fontColor; + @Getter(AccessLevel.PACKAGE) + private boolean showIcons; + @Getter(AccessLevel.PACKAGE) + private RunePouchOverlayMode runePouchOverlayMode; + @Provides RunepouchConfig getConfig(ConfigManager configManager) { @@ -53,6 +71,7 @@ public class RunepouchPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); overlayManager.add(overlay); } @@ -61,4 +80,22 @@ public class RunepouchPlugin extends Plugin { overlayManager.remove(overlay); } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("runepouch")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.fontColor = config.fontColor(); + this.showIcons = config.showIcons(); + this.runePouchOverlayMode = config.runePouchOverlayMode(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/Runes.java b/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/Runes.java index 3031aa7b97..3185ac2741 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/Runes.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/runepouch/Runes.java @@ -28,6 +28,7 @@ package net.runelite.client.plugins.runepouch; import com.google.common.collect.ImmutableMap; import java.awt.image.BufferedImage; import java.util.Map; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import static net.runelite.api.ItemID.AIR_RUNE; @@ -76,13 +77,13 @@ public enum Runes SMOKE(20, SMOKE_RUNE), WRATH(21, WRATH_RUNE); - @Getter + @Getter(AccessLevel.PACKAGE) private final int id; - @Getter + @Getter(AccessLevel.PACKAGE) private final int itemId; - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private BufferedImage image; private static final Map runes; @@ -97,7 +98,7 @@ public enum Runes runes = builder.build(); } - Runes(int id, int itemId) + Runes(final int id, final int itemId) { this.id = id; this.itemId = itemId; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/safespot/SafeSpotOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/safespot/SafeSpotOverlay.java index a208f59dc2..bb12d9b191 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/safespot/SafeSpotOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/safespot/SafeSpotOverlay.java @@ -13,6 +13,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Polygon; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.client.ui.overlay.Overlay; @@ -21,19 +22,18 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton public class SafeSpotOverlay extends Overlay { private final Client client; private final SafeSpotPlugin safeSpotPlugin; - private final SafeSpotConfig config; @Inject - public SafeSpotOverlay(Client client, SafeSpotPlugin safeSpotPlugin, SafeSpotConfig config) + public SafeSpotOverlay(final Client client, final SafeSpotPlugin safeSpotPlugin) { this.client = client; this.safeSpotPlugin = safeSpotPlugin; - this.config = config; setPosition(OverlayPosition.DYNAMIC); setPriority(OverlayPriority.LOW); setLayer(OverlayLayer.ABOVE_SCENE); @@ -55,7 +55,7 @@ public class SafeSpotOverlay extends Overlay final Polygon poly = Perspective.getCanvasTilePoly(client, tile.getLocalLocation()); if (poly != null) { - OverlayUtil.renderPolygon(graphics, poly, config.tileColor()); + OverlayUtil.renderPolygon(graphics, poly, safeSpotPlugin.getTileColor()); } } }); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/safespot/SafeSpotPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/safespot/SafeSpotPlugin.java index 5d0a6df8a3..b702b5d17f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/safespot/SafeSpotPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/safespot/SafeSpotPlugin.java @@ -9,9 +9,13 @@ package net.runelite.client.plugins.safespot; import com.google.inject.Provides; +import java.awt.Color; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Actor; import net.runelite.api.Client; @@ -22,6 +26,7 @@ import net.runelite.api.Tile; import net.runelite.api.coords.LocalPoint; import net.runelite.api.coords.WorldArea; import net.runelite.api.coords.WorldPoint; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.InteractingChanged; import net.runelite.client.config.ConfigManager; @@ -38,7 +43,7 @@ import net.runelite.client.ui.overlay.OverlayManager; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton public class SafeSpotPlugin extends Plugin { @Inject @@ -50,15 +55,20 @@ public class SafeSpotPlugin extends Plugin @Inject private SafeSpotConfig config; - @Getter + @Getter(AccessLevel.PACKAGE) private ArrayList safeSpotList; - @Getter + @Getter(AccessLevel.PACKAGE) private boolean safeSpotsRenderable = false; private SafeSpotOverlay safeSpotOverlay; private int tickCount = 0; + private boolean playerSafeSpots; + private boolean npcSafeSpots; + @Getter(AccessLevel.PACKAGE) + private Color tileColor; + @Provides SafeSpotConfig config(ConfigManager configManager) { @@ -68,7 +78,9 @@ public class SafeSpotPlugin extends Plugin @Override protected void startUp() throws Exception { - safeSpotOverlay = new SafeSpotOverlay(client, this, config); + updateConfig(); + + safeSpotOverlay = new SafeSpotOverlay(client, this); overlayManager.add(safeSpotOverlay); } @@ -85,7 +97,7 @@ public class SafeSpotPlugin extends Plugin { return; } - if (event.getTarget() == null && (config.npcSafeSpots() || config.playerSafeSpots())) + if (event.getTarget() == null && (this.npcSafeSpots || this.playerSafeSpots)) { tickCount = 10; } @@ -96,12 +108,12 @@ public class SafeSpotPlugin extends Plugin { if (client.getLocalPlayer().getInteracting() != null) { - if (client.getLocalPlayer().getInteracting() instanceof Player && config.playerSafeSpots()) + if (client.getLocalPlayer().getInteracting() instanceof Player && this.playerSafeSpots) { safeSpotsRenderable = true; updateSafeSpots(); } - if (client.getLocalPlayer().getInteracting() instanceof NPC && config.npcSafeSpots()) + if (client.getLocalPlayer().getInteracting() instanceof NPC && this.npcSafeSpots) { safeSpotsRenderable = true; updateSafeSpots(); @@ -149,11 +161,19 @@ public class SafeSpotPlugin extends Plugin LocalPoint toPoint = LocalPoint.fromWorld(client, w); Tile fromTile = tiles[client.getPlane()][actor.getLocalLocation().getSceneX()] [actor.getLocalLocation().getSceneY()]; - Tile toTile = tiles[client.getPlane()][toPoint.getSceneX()] - [toPoint.getSceneY()]; + Tile toTile = null; + if (toPoint != null) + { + toTile = tiles[client.getPlane()][toPoint.getSceneX()] + [toPoint.getSceneY()]; + } final int plane = client.getLocalPlayer().getWorldArea().getPlane(); - int bit = client.getCollisionMaps()[plane].getFlags()[toPoint.getSceneX()][toPoint.getSceneY()]; - if (toTile.hasLineOfSightTo(fromTile) && !fromTile.hasLineOfSightTo(toTile)) + int bit = 0; + if (toPoint != null) + { + bit = Objects.requireNonNull(client.getCollisionMaps())[plane].getFlags()[toPoint.getSceneX()][toPoint.getSceneY()]; + } + if (toTile != null && toTile.hasLineOfSightTo(fromTile) && !fromTile.hasLineOfSightTo(toTile)) { if (!((bit & CollisionDataFlag.BLOCK_MOVEMENT_OBJECT) == CollisionDataFlag.BLOCK_MOVEMENT_OBJECT || (bit & CollisionDataFlag.BLOCK_MOVEMENT_FLOOR_DECORATION) @@ -167,4 +187,22 @@ public class SafeSpotPlugin extends Plugin } return safeSpotList; } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("safespot")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.playerSafeSpots = config.playerSafeSpots(); + this.npcSafeSpots = config.npcSafeSpots(); + this.tileColor = config.tileColor(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerCreationOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerCreationOverlay.java index f1e0c60bde..15d7d735e7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerCreationOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerCreationOverlay.java @@ -29,11 +29,13 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Stroke; import javax.inject.Inject; +import javax.inject.Singleton; 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 ScreenMarkerCreationOverlay extends Overlay { private ScreenMarkerPlugin plugin; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerMouseListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerMouseListener.java index e00114041d..93b1350999 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerMouseListener.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerMouseListener.java @@ -25,14 +25,16 @@ package net.runelite.client.plugins.screenmarkers; import java.awt.event.MouseEvent; +import javax.inject.Singleton; import javax.swing.SwingUtilities; import net.runelite.client.input.MouseAdapter; +@Singleton public class ScreenMarkerMouseListener extends MouseAdapter { private final ScreenMarkerPlugin plugin; - ScreenMarkerMouseListener(ScreenMarkerPlugin plugin) + ScreenMarkerMouseListener(final ScreenMarkerPlugin plugin) { this.plugin = plugin; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerOverlay.java index 08857c532e..408ded39f3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerOverlay.java @@ -28,19 +28,22 @@ package net.runelite.client.plugins.screenmarkers; import java.awt.BasicStroke; import java.awt.Dimension; import java.awt.Graphics2D; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; 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 ScreenMarkerOverlay extends Overlay { - @Getter + @Getter(AccessLevel.PUBLIC) private final ScreenMarker marker; private final ScreenMarkerRenderable screenMarkerRenderable; - ScreenMarkerOverlay(ScreenMarker marker) + ScreenMarkerOverlay(final ScreenMarker marker) { this.marker = marker; this.screenMarkerRenderable = new ScreenMarkerRenderable(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerPlugin.java index ff8dcf0057..ce6a8d67fa 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerPlugin.java @@ -39,6 +39,7 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.events.ConfigChanged; @@ -58,6 +59,7 @@ import net.runelite.client.util.ImageUtil; description = "Enable drawing of screen markers on top of the client", tags = {"boxes", "overlay", "panel"} ) +@Singleton public class ScreenMarkerPlugin extends Plugin { private static final String PLUGIN_NAME = "Screen Markers"; @@ -159,7 +161,7 @@ public class ScreenMarkerPlugin extends Plugin } } - public void startCreation(Point location) + void startCreation(Point location) { currentMarker = new ScreenMarker( Instant.now().toEpochMilli(), @@ -201,7 +203,7 @@ public class ScreenMarkerPlugin extends Plugin } /* The marker area has been drawn, inform the user and unlock the confirm button */ - public void completeSelection() + void completeSelection() { pluginPanel.getCreationPanel().unlockConfirm(); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerRenderable.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerRenderable.java index 95b2da1207..6182765aa4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerRenderable.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ScreenMarkerRenderable.java @@ -38,10 +38,10 @@ import net.runelite.client.ui.overlay.components.LayoutableRenderableEntity; public class ScreenMarkerRenderable implements LayoutableRenderableEntity { @Getter(AccessLevel.PACKAGE) - @Setter + @Setter(AccessLevel.PUBLIC) private Point preferredLocation; @Getter(AccessLevel.PACKAGE) - @Setter + @Setter(AccessLevel.PUBLIC) private Dimension preferredSize; @Getter(AccessLevel.PACKAGE) @Setter(AccessLevel.PACKAGE) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerCreationPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerCreationPanel.java index 0ad6b73d4e..82197c6160 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerCreationPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerCreationPanel.java @@ -30,6 +30,7 @@ import java.awt.GridLayout; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; +import javax.inject.Singleton; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; @@ -40,6 +41,7 @@ import net.runelite.client.ui.FontManager; import net.runelite.client.ui.components.shadowlabel.JShadowedLabel; import net.runelite.client.util.ImageUtil; +@Singleton public class ScreenMarkerCreationPanel extends JPanel { private static final ImageIcon CONFIRM_ICON; @@ -63,7 +65,7 @@ public class ScreenMarkerCreationPanel extends JPanel CANCEL_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(ImageUtil.bufferedImageFromImage(CANCEL_ICON.getImage()), 0.6f)); } - ScreenMarkerCreationPanel(ScreenMarkerPlugin plugin) + ScreenMarkerCreationPanel(final ScreenMarkerPlugin plugin) { setBackground(ColorScheme.DARKER_GRAY_COLOR); setBorder(new EmptyBorder(8, 8, 8, 8)); 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 e934bff8b8..217922790e 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 @@ -34,6 +34,7 @@ import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; +import javax.inject.Singleton; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JLabel; @@ -55,6 +56,7 @@ import net.runelite.client.ui.components.FlatTextField; import net.runelite.client.ui.components.colorpicker.RuneliteColorPicker; import net.runelite.client.util.ImageUtil; +@Singleton class ScreenMarkerPanel extends JPanel { private static final int DEFAULT_FILL_OPACITY = 75; @@ -144,7 +146,7 @@ class ScreenMarkerPanel extends JPanel DELETE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(deleteImg, -100)); } - ScreenMarkerPanel(ScreenMarkerPlugin plugin, ScreenMarkerOverlay marker) + ScreenMarkerPanel(final ScreenMarkerPlugin plugin, final ScreenMarkerOverlay marker) { this.plugin = plugin; this.marker = marker; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPluginPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPluginPanel.java index 3e43abaa4d..8f3fe97d3b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPluginPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenmarkers/ui/ScreenMarkerPluginPanel.java @@ -40,6 +40,7 @@ import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.client.plugins.screenmarkers.ScreenMarkerOverlay; import net.runelite.client.plugins.screenmarkers.ScreenMarkerPlugin; @@ -66,16 +67,16 @@ public class ScreenMarkerPluginPanel extends PluginPanel @Inject private ScreenMarkerPlugin plugin; - @Getter + @Getter(AccessLevel.PUBLIC) private Color selectedColor = DEFAULT_BORDER_COLOR; - @Getter + @Getter(AccessLevel.PUBLIC) private Color selectedFillColor = DEFAULT_FILL_COLOR; - @Getter + @Getter(AccessLevel.PUBLIC) private int selectedBorderThickness = DEFAULT_BORDER_THICKNESS; - @Getter + @Getter(AccessLevel.PUBLIC) private ScreenMarkerCreationPanel creationPanel; static diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotOverlay.java index a5fd92a862..27b4d9b392 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotOverlay.java @@ -38,6 +38,7 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.function.Consumer; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.MainBufferProvider; import net.runelite.client.ui.DrawManager; @@ -47,6 +48,7 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; +@Singleton class ScreenshotOverlay extends Overlay { private static final DateFormat DATE_FORMAT = new SimpleDateFormat("MMM. dd, yyyy"); @@ -59,7 +61,7 @@ class ScreenshotOverlay extends Overlay private final Queue> consumers = new ConcurrentLinkedQueue<>(); @Inject - private ScreenshotOverlay(Client client, DrawManager drawManager, ScreenshotPlugin plugin) + private ScreenshotOverlay(final Client client, final DrawManager drawManager, final ScreenshotPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setPriority(OverlayPriority.HIGH); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java index 9e4a5dcfaf..e1aeb37d68 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java @@ -56,10 +56,12 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.imageio.ImageIO; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.SwingUtilities; import lombok.AccessLevel; import lombok.Getter; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; @@ -71,6 +73,7 @@ import net.runelite.api.Varbits; import net.runelite.api.WorldType; import net.runelite.api.events.AnimationChanged; import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.WidgetLoaded; @@ -87,6 +90,7 @@ import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.Notifier; import static net.runelite.client.RuneLite.SCREENSHOT_DIR; import net.runelite.client.config.ConfigManager; +import net.runelite.client.config.Keybind; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.PlayerLootReceived; import net.runelite.client.game.SpriteManager; @@ -119,6 +123,7 @@ import org.jetbrains.annotations.Nullable; tags = {"external", "images", "imgur", "integration", "notifications"} ) @Slf4j +@Singleton public class ScreenshotPlugin extends Plugin { private static final String IMGUR_CLIENT_ID = "30d71e5f6860809"; @@ -137,7 +142,7 @@ public class ScreenshotPlugin extends Plugin "You feel something weird sneaking into your backpack", "You have a funny feeling like you would have been followed"); - static String format(Date date) + private static String format(Date date) { synchronized (TIME_FORMAT) { @@ -194,11 +199,11 @@ public class ScreenshotPlugin extends Plugin @Getter(AccessLevel.PACKAGE) private BufferedImage reportButton; - private Map dying = new HashMap(); + private Map dying = new HashMap<>(); private NavigationButton titleBarButton; - private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.hotkey()) + private final HotkeyListener hotkeyListener = new HotkeyListener(() -> this.hotkey) { @Override public void hotkeyPressed() @@ -207,6 +212,28 @@ public class ScreenshotPlugin extends Plugin } }; + private boolean includeFrame; + @Setter(AccessLevel.PACKAGE) + private boolean displayDate; + private boolean notifyWhenTaken; + @Setter(AccessLevel.PACKAGE) + private boolean screenshotRewards; + @Setter(AccessLevel.PACKAGE) + private boolean screenshotLevels; + private boolean screenshotKingdom; + private boolean screenshotPet; + private boolean uploadScreenshot; + private boolean screenshotKills; + private boolean screenshotBossKills; + private boolean screenshotFriendDeath; + private boolean screenshotPlayerDeath; + private boolean screenshotDuels; + @Setter(AccessLevel.PACKAGE) + private boolean screenshotValuableDrop; + @Setter(AccessLevel.PACKAGE) + private boolean screenshotUntradeableDrop; + private Keybind hotkey; + @Provides ScreenshotConfig getConfig(ConfigManager configManager) { @@ -216,6 +243,8 @@ public class ScreenshotPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(screenshotOverlay); SCREENSHOT_DIR.mkdirs(); keyManager.registerKeyListener(hotkeyListener); @@ -267,7 +296,7 @@ public class ScreenshotPlugin extends Plugin @Subscribe public void onGameTick(GameTick event) { - if (config.screenshotFriendDeath()) + if (this.screenshotFriendDeath) { for (Iterator it = dying.keySet().iterator(); it.hasNext();) { @@ -317,7 +346,7 @@ public class ScreenshotPlugin extends Plugin public void onAnimationChanged(AnimationChanged e) { //this got refactored somewhere, but some things were missing - if (!config.screenshotFriendDeath() || !config.screenshotPlayerDeath()) + if (!this.screenshotFriendDeath || !this.screenshotPlayerDeath) return; if (!(e.getActor() instanceof Player)) @@ -332,7 +361,7 @@ public class ScreenshotPlugin extends Plugin if (p.getName().equals(client.getLocalPlayer().getName())) { - if (config.screenshotPlayerDeath()) + if (this.screenshotPlayerDeath) { dying.put(p, 3); return; @@ -342,7 +371,7 @@ public class ScreenshotPlugin extends Plugin return; } } - if (config.screenshotFriendDeath()) + if (this.screenshotFriendDeath) { int tob = client.getVar(Varbits.THEATRE_OF_BLOOD); @@ -357,7 +386,7 @@ public class ScreenshotPlugin extends Plugin @Subscribe public void onPlayerLootReceived(final PlayerLootReceived playerLootReceived) { - if (config.screenshotKills()) + if (this.screenshotKills) { final Player player = playerLootReceived.getPlayer(); final String name = player.getName(); @@ -427,13 +456,13 @@ public class ScreenshotPlugin extends Plugin } } - if (config.screenshotPet() && PET_MESSAGES.stream().anyMatch(chatMessage::contains)) + if (this.screenshotPet && PET_MESSAGES.stream().anyMatch(chatMessage::contains)) { String fileName = "Pet " + format(new Date()); takeScreenshot(fileName); } - if (config.screenshotBossKills() ) + if (this.screenshotBossKills ) { Matcher m = BOSSKILL_MESSAGE_PATTERN.matcher(chatMessage); if (m.matches()) @@ -445,7 +474,7 @@ public class ScreenshotPlugin extends Plugin } } - if (config.screenshotValuableDrop()) + if (this.screenshotValuableDrop) { Matcher m = VALUABLE_DROP_PATTERN.matcher(chatMessage); if (m.matches()) @@ -456,7 +485,7 @@ public class ScreenshotPlugin extends Plugin } } - if (config.screenshotUntradeableDrop()) + if (this.screenshotUntradeableDrop) { Matcher m = UNTRADEABLE_DROP_PATTERN.matcher(chatMessage); if (m.matches()) @@ -467,7 +496,7 @@ public class ScreenshotPlugin extends Plugin } } - if (config.screenshotDuels()) + if (this.screenshotDuels) { Matcher m = DUEL_END_PATTERN.matcher(chatMessage); if (m.find()) @@ -493,20 +522,20 @@ public class ScreenshotPlugin extends Plugin case CHAMBERS_OF_XERIC_REWARD_GROUP_ID: case THEATRE_OF_BLOOD_REWARD_GROUP_ID: case BARROWS_REWARD_GROUP_ID: - if (!config.screenshotRewards()) + if (!this.screenshotRewards) { return; } break; case LEVEL_UP_GROUP_ID: case DIALOG_SPRITE_GROUP_ID: - if (!config.screenshotLevels()) + if (!this.screenshotLevels) { return; } break; case KINGDOM_GROUP_ID: - if (!config.screenshotKingdom()) + if (!this.screenshotKingdom) { return; } @@ -637,7 +666,7 @@ public class ScreenshotPlugin extends Plugin executor.submit(() -> takeScreenshot(fileName, img, null)); }; - if (config.displayDate()) + if (this.displayDate) { screenshotOverlay.queueForTimestamp(imageCallback); } @@ -670,7 +699,7 @@ public class ScreenshotPlugin extends Plugin }; - if (config.displayDate()) + if (this.displayDate) { screenshotOverlay.queueForTimestamp(imageCallback); } @@ -681,7 +710,7 @@ public class ScreenshotPlugin extends Plugin } private void takeScreenshot(String fileName, Image image, @Nullable String subdirectory) { - BufferedImage screenshot = config.includeFrame() + BufferedImage screenshot = this.includeFrame ? new BufferedImage(clientUi.getWidth(), clientUi.getHeight(), BufferedImage.TYPE_INT_ARGB) : new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); @@ -690,7 +719,7 @@ public class ScreenshotPlugin extends Plugin int gameOffsetX = 0; int gameOffsetY = 0; - if (config.includeFrame()) + if (this.includeFrame) { // Draw the client frame onto the screenshot try @@ -748,11 +777,11 @@ public class ScreenshotPlugin extends Plugin ImageIO.write(screenshot, "PNG", screenshotFile); - if (config.uploadScreenshot()) + if (this.uploadScreenshot) { uploadScreenshot(screenshotFile); } - else if (config.notifyWhenTaken()) + else if (this.notifyWhenTaken) { notifier.notify("A screenshot was saved to " + screenshotFile, TrayIcon.MessageType.INFO); } @@ -774,44 +803,51 @@ public class ScreenshotPlugin extends Plugin { 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(); - - RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() + Request request = null; + if (IMGUR_IMAGE_UPLOAD_URL != null) { - @Override - public void onFailure(Call call, IOException ex) - { - log.warn("error uploading screenshot", ex); - } + request = new Request.Builder() + .url(IMGUR_IMAGE_UPLOAD_URL) + .addHeader("Authorization", "Client-ID " + IMGUR_CLIENT_ID) + .post(RequestBody.create(JSON, json)) + .build(); + } - @Override - public void onResponse(Call call, Response response) throws IOException + if (request != null) + { + RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() { - try (InputStream in = response.body().byteStream()) + @Override + public void onFailure(Call call, IOException ex) { - ImageUploadResponse imageUploadResponse = RuneLiteAPI.GSON - .fromJson(new InputStreamReader(in), ImageUploadResponse.class); + log.warn("error uploading screenshot", ex); + } - if (imageUploadResponse.isSuccess()) + @Override + public void onResponse(Call call, Response response) throws IOException + { + try (InputStream in = response.body().byteStream()) { - String link = imageUploadResponse.getData().getLink(); + ImageUploadResponse imageUploadResponse = RuneLiteAPI.GSON + .fromJson(new InputStreamReader(in), ImageUploadResponse.class); - StringSelection selection = new StringSelection(link); - Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); - clipboard.setContents(selection, selection); - - if (config.notifyWhenTaken()) + if (imageUploadResponse.isSuccess()) { - notifier.notify("A screenshot was uploaded and inserted into your clipboard!", TrayIcon.MessageType.INFO); + String link = imageUploadResponse.getData().getLink(); + + StringSelection selection = new StringSelection(link); + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + clipboard.setContents(selection, selection); + + if (notifyWhenTaken) + { + notifier.notify("A screenshot was uploaded and inserted into your clipboard!", TrayIcon.MessageType.INFO); + } } } } - } - }); + }); + } } @VisibleForTesting @@ -849,4 +885,35 @@ public class ScreenshotPlugin extends Plugin { return theatreOfBloodNumber; } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("screenshot")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.includeFrame = config.includeFrame(); + this.displayDate = config.displayDate(); + this.notifyWhenTaken = config.notifyWhenTaken(); + this.screenshotRewards = config.screenshotRewards(); + this.screenshotLevels = config.screenshotLevels(); + this.screenshotKingdom = config.screenshotKingdom(); + this.screenshotPet = config.screenshotPet(); + this.uploadScreenshot = config.uploadScreenshot(); + this.screenshotKills = config.screenshotKills(); + this.screenshotBossKills = config.screenshotBossKills(); + this.screenshotFriendDeath = config.screenshotFriendDeath(); + this.screenshotPlayerDeath = config.screenshotPlayerDeath(); + this.screenshotDuels = config.screenshotDuels(); + this.screenshotValuableDrop = config.screenshotValuableDrop(); + this.screenshotUntradeableDrop = config.screenshotUntradeableDrop(); + this.hotkey = config.hotkey(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/shayzieninfirmary/ShayzienInfirmaryOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/shayzieninfirmary/ShayzienInfirmaryOverlay.java index a7b0ab1bcf..6e09eef0d4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/shayzieninfirmary/ShayzienInfirmaryOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/shayzieninfirmary/ShayzienInfirmaryOverlay.java @@ -32,6 +32,7 @@ import java.awt.Graphics2D; import java.awt.Polygon; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.ItemID; import net.runelite.api.NPC; import net.runelite.api.Point; @@ -40,6 +41,7 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton public class ShayzienInfirmaryOverlay extends Overlay { private final ShayzienInfirmaryPlugin plugin; @@ -47,7 +49,7 @@ public class ShayzienInfirmaryOverlay extends Overlay private BufferedImage medPackImage; @Inject - public ShayzienInfirmaryOverlay(ShayzienInfirmaryPlugin plugin, ItemManager itemManager) + public ShayzienInfirmaryOverlay(final ShayzienInfirmaryPlugin plugin, final ItemManager itemManager) { setPosition(OverlayPosition.DYNAMIC); this.plugin = plugin; @@ -58,7 +60,7 @@ public class ShayzienInfirmaryOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!plugin.isAtInfirmary()) + if (plugin.isNotAtInfirmary()) { return null; } 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 d5f38d8172..e74b268575 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 @@ -27,6 +27,7 @@ package net.runelite.client.plugins.shayzieninfirmary; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -47,11 +48,11 @@ import net.runelite.client.ui.overlay.OverlayManager; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton public class ShayzienInfirmaryPlugin extends Plugin { @Getter(AccessLevel.PACKAGE) - private List unhealedSoldiers = new ArrayList(); + private List unhealedSoldiers = new ArrayList<>(); @Inject private OverlayManager overlayManager; @@ -87,7 +88,7 @@ public class ShayzienInfirmaryPlugin extends Plugin @Subscribe public void onGameTick(GameTick event) { - if (!isAtInfirmary()) + if (isNotAtInfirmary()) { return; } @@ -113,8 +114,8 @@ public class ShayzienInfirmaryPlugin extends Plugin return (isSoldierId(npcId) && npcId % 2 == 0); } - boolean isAtInfirmary() + boolean isNotAtInfirmary() { - return client.getLocalPlayer().getWorldLocation().getRegionID() == 6200; + return client.getLocalPlayer().getWorldLocation().getRegionID() != 6200; } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/shiftwalker/ShiftWalkerInputListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/shiftwalker/ShiftWalkerInputListener.java index 1195966d6a..6b6560ca61 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/shiftwalker/ShiftWalkerInputListener.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/shiftwalker/ShiftWalkerInputListener.java @@ -26,8 +26,10 @@ package net.runelite.client.plugins.shiftwalker; import java.awt.event.KeyEvent; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.client.input.KeyListener; +@Singleton public class ShiftWalkerInputListener implements KeyListener { 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 7197de9eaa..9b8bcbdeb6 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 @@ -26,6 +26,8 @@ package net.runelite.client.plugins.shiftwalker; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.FocusChanged; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; @@ -45,7 +47,7 @@ import net.runelite.client.plugins.PluginType; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton public class ShiftWalkerPlugin extends Plugin { @@ -63,6 +65,9 @@ public class ShiftWalkerPlugin extends Plugin @Inject private KeyManager keyManager; + private boolean shiftWalk; + private boolean shiftLoot; + @Provides ShiftWalkerConfig provideConfig(ConfigManager configManager) { @@ -72,6 +77,9 @@ public class ShiftWalkerPlugin extends Plugin @Override public void startUp() { + this.shiftWalk = config.shiftWalk(); + this.shiftLoot = config.shiftLoot(); + keyManager.registerKeyListener(inputListener); } @@ -92,12 +100,12 @@ public class ShiftWalkerPlugin extends Plugin void startPrioritizing() { - if (config.shiftLoot()) + if (this.shiftLoot) { menuManager.addPriorityEntry(TAKE); } - if (config.shiftWalk()) + if (this.shiftWalk) { menuManager.addPriorityEntry(WALK_HERE); } @@ -108,4 +116,16 @@ public class ShiftWalkerPlugin extends Plugin menuManager.removePriorityEntry(TAKE); menuManager.removePriorityEntry(WALK_HERE); } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("shiftwalkhere")) + { + return; + } + + this.shiftWalk = config.shiftWalk(); + this.shiftLoot = config.shiftLoot(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/BankedCalculator.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/BankedCalculator.java index b4f6785a96..5216d24ace 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/BankedCalculator.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/BankedCalculator.java @@ -34,6 +34,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; +import javax.inject.Singleton; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; @@ -56,6 +57,7 @@ import net.runelite.client.ui.DynamicGridLayout; import net.runelite.client.ui.FontManager; @Slf4j +@Singleton public class BankedCalculator extends JPanel { private static final DecimalFormat XP_FORMAT_COMMA = new DecimalFormat("#,###.#"); @@ -88,11 +90,11 @@ public class BankedCalculator extends JPanel private Map linkedMap = new HashMap<>(); // ItemID of item that links to the CriticalItem BankedCalculator( - SkillCalculatorPanel parent, - Client client, - UICalculatorInputArea uiInput, - SkillCalculatorConfig config, - ItemManager itemManager) + final SkillCalculatorPanel parent, + final Client client, + final UICalculatorInputArea uiInput, + final SkillCalculatorConfig config, + final ItemManager itemManager) { this.parent = parent; this.client = client; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/CacheSkillData.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/CacheSkillData.java index f4f54e0f52..a427b602ac 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/CacheSkillData.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/CacheSkillData.java @@ -35,7 +35,7 @@ class CacheSkillData { private final Map cache = new HashMap<>(); - SkillData getSkillData(String dataFile) + SkillData getSkillData(final String dataFile) { if (cache.containsKey(dataFile)) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/CalculatorType.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/CalculatorType.java index 1b3cbf818b..8874563113 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/CalculatorType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/CalculatorType.java @@ -25,12 +25,13 @@ */ package net.runelite.client.plugins.skillcalculator; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.Skill; @AllArgsConstructor -@Getter +@Getter(AccessLevel.PACKAGE) public enum CalculatorType { AGILITY(Skill.AGILITY, "skill_agility.json", false), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculator.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculator.java index 709fdff390..ca0c650c0f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculator.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculator.java @@ -35,6 +35,7 @@ import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; import java.util.Optional; +import javax.inject.Singleton; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.JCheckBox; @@ -58,6 +59,7 @@ import net.runelite.client.ui.components.IconTextField; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; +@Singleton class SkillCalculator extends JPanel { private static final int MAX_XP = 200_000_000; @@ -85,7 +87,7 @@ class SkillCalculator extends JPanel private float lastBonus = 0.0f; private CalculatorType calculatorType; - SkillCalculator(Client client, UICalculatorInputArea uiInput, SpriteManager spriteManager, ItemManager itemManager) + SkillCalculator(final Client client, final UICalculatorInputArea uiInput, final SpriteManager spriteManager, final ItemManager itemManager) { this.client = client; this.uiInput = uiInput; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculatorPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculatorPanel.java index d7f14a0492..c337470c32 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculatorPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculatorPanel.java @@ -34,6 +34,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Objects; +import javax.inject.Singleton; import javax.swing.ImageIcon; import javax.swing.JScrollPane; import javax.swing.SwingUtilities; @@ -51,6 +52,7 @@ import net.runelite.client.ui.components.materialtabs.MaterialTab; import net.runelite.client.ui.components.materialtabs.MaterialTabGroup; @Slf4j +@Singleton class SkillCalculatorPanel extends PluginPanel { private final SkillCalculator uiCalculator; @@ -67,7 +69,7 @@ class SkillCalculatorPanel extends PluginPanel private Map bankMap = new HashMap<>(); private GridBagConstraints c; - SkillCalculatorPanel(SkillIconManager iconManager, Client client, SkillCalculatorConfig config, SpriteManager spriteManager, ItemManager itemManager) + SkillCalculatorPanel(final SkillIconManager iconManager, final Client client, final SkillCalculatorConfig config, final SpriteManager spriteManager, final ItemManager itemManager) { super(); getScrollPane().setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculatorPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculatorPlugin.java index 8cb7fbc713..e6a5316cf3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculatorPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/SkillCalculatorPlugin.java @@ -31,6 +31,7 @@ import java.awt.image.BufferedImage; import java.util.HashMap; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.SwingUtilities; import lombok.Getter; import net.runelite.api.Client; @@ -60,6 +61,7 @@ import net.runelite.client.util.ImageUtil; description = "Enable the Skill Calculator panel", tags = {"panel", "skilling"} ) +@Singleton public class SkillCalculatorPlugin extends Plugin { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UIActionSlot.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UIActionSlot.java index 696fa2dfdc..819e75ad4b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UIActionSlot.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UIActionSlot.java @@ -33,6 +33,7 @@ import java.awt.GridLayout; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import javax.inject.Singleton; import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JPanel; @@ -47,6 +48,7 @@ import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.FontManager; import net.runelite.client.ui.components.shadowlabel.JShadowedLabel; +@Singleton class UIActionSlot extends JPanel { private static final Border GREEN_BORDER = new CompoundBorder( diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UICalculatorInputArea.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UICalculatorInputArea.java index b1d9af5665..515b3997d0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UICalculatorInputArea.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UICalculatorInputArea.java @@ -28,16 +28,19 @@ package net.runelite.client.plugins.skillcalculator; import java.awt.BorderLayout; import java.awt.Color; import java.awt.GridLayout; +import javax.inject.Singleton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.border.EmptyBorder; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.FontManager; import net.runelite.client.ui.components.FlatTextField; -@Getter +@Getter(AccessLevel.PACKAGE) +@Singleton class UICalculatorInputArea extends JPanel { private final JTextField uiFieldCurrentLevel; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UICombinedActionSlot.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UICombinedActionSlot.java index a6bc9c0d52..f84cdecb23 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UICombinedActionSlot.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/UICombinedActionSlot.java @@ -30,6 +30,7 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.GridLayout; +import javax.inject.Singleton; import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JPanel; @@ -39,13 +40,14 @@ import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.FontManager; import net.runelite.client.ui.components.shadowlabel.JShadowedLabel; +@Singleton class UICombinedActionSlot extends JPanel { private static final Dimension ICON_SIZE = new Dimension(32, 32); private final JShadowedLabel uiLabelActions; private final JShadowedLabel uiLabelTitle; - UICombinedActionSlot(SpriteManager spriteManager) + UICombinedActionSlot(final SpriteManager spriteManager) { setLayout(new BorderLayout()); setBackground(ColorScheme.DARKER_GRAY_COLOR); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/banked/beans/Activity.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/banked/beans/Activity.java index d3109c15e6..8d2b122119 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/banked/beans/Activity.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/banked/beans/Activity.java @@ -27,12 +27,13 @@ package net.runelite.client.plugins.skillcalculator.banked.beans; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.ItemID; import net.runelite.api.Skill; import net.runelite.client.plugins.skillcalculator.banked.CriticalItem; -@Getter +@Getter(AccessLevel.PUBLIC) public enum Activity { /** @@ -350,7 +351,7 @@ public enum Activity this.preventLinked = false; } - Activity(int Icon, String name, Skill skill, int level, double xp, CriticalItem criticalItem, ActivitySecondaries secondaries, boolean preventLinked) + Activity(final int Icon, final String name, final Skill skill, final int level, final double xp, final CriticalItem criticalItem, final ActivitySecondaries secondaries, final boolean preventLinked) { this.icon = Icon; this.name = name; @@ -368,7 +369,7 @@ public enum Activity Map> map = new HashMap<>(); for (Activity item : values()) { - map.computeIfAbsent(item.getCriticalItem(), e -> new ArrayList()).add(item); + map.computeIfAbsent(item.getCriticalItem(), e -> new ArrayList<>()).add(item); } return map; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/banked/beans/ActivitySecondaries.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/banked/beans/ActivitySecondaries.java index 94a74bd6fd..0afb3cf033 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/banked/beans/ActivitySecondaries.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/banked/beans/ActivitySecondaries.java @@ -24,10 +24,11 @@ */ package net.runelite.client.plugins.skillcalculator.banked.beans; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.ItemID; -@Getter +@Getter(AccessLevel.PUBLIC) public enum ActivitySecondaries { /** @@ -104,7 +105,7 @@ public enum ActivitySecondaries ; private final SecondaryItem[] items; - ActivitySecondaries(SecondaryItem... items) + ActivitySecondaries(final SecondaryItem... items) { this.items = items; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/banked/beans/SecondaryItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/banked/beans/SecondaryItem.java index 68f0042fbf..0cc728d0f9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/banked/beans/SecondaryItem.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/banked/beans/SecondaryItem.java @@ -24,21 +24,22 @@ */ package net.runelite.client.plugins.skillcalculator.banked.beans; +import lombok.AccessLevel; import lombok.Getter; -@Getter +@Getter(AccessLevel.PUBLIC) public class SecondaryItem { private final int id; private final int qty; - public SecondaryItem(int id, int qty) + SecondaryItem(int id, int qty) { this.id = id; this.qty = qty; } - public SecondaryItem(int id) + SecondaryItem(int id) { this(id, 1); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/banked/ui/CriticalItemPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/banked/ui/CriticalItemPanel.java index 5de2acfee0..a6af1138ef 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/banked/ui/CriticalItemPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/banked/ui/CriticalItemPanel.java @@ -40,6 +40,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import javax.imageio.ImageIO; +import javax.inject.Singleton; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; @@ -48,6 +49,7 @@ import javax.swing.SwingUtilities; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import javax.swing.border.MatteBorder; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.client.game.AsyncBufferedImage; import net.runelite.client.game.ItemManager; @@ -61,6 +63,7 @@ import net.runelite.client.ui.components.materialtabs.MaterialTabGroup; import net.runelite.client.ui.components.shadowlabel.JShadowedLabel; import net.runelite.client.util.StackFormatter; +@Singleton public class CriticalItemPanel extends JPanel { private static final Dimension ICON_SIZE = new Dimension(36, 36); @@ -93,9 +96,9 @@ public class CriticalItemPanel extends JPanel private final CriticalItem item; private final ItemManager itemManager; private double xp; - @Getter + @Getter(AccessLevel.PUBLIC) private int amount; - @Getter + @Getter(AccessLevel.PUBLIC) private double total; private Map linkedMap; private JShadowedLabel labelValue; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/beans/SkillData.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/beans/SkillData.java index 4c2d36aa68..0d5b1cad40 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/beans/SkillData.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/beans/SkillData.java @@ -24,9 +24,10 @@ */ package net.runelite.client.plugins.skillcalculator.beans; +import lombok.AccessLevel; import lombok.Getter; -@Getter +@Getter(AccessLevel.PUBLIC) public class SkillData { private SkillDataEntry[] actions; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/beans/SkillDataBonus.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/beans/SkillDataBonus.java index 675fcb51db..6cce75a62e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/beans/SkillDataBonus.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/beans/SkillDataBonus.java @@ -24,9 +24,10 @@ */ package net.runelite.client.plugins.skillcalculator.beans; +import lombok.AccessLevel; import lombok.Getter; -@Getter +@Getter(AccessLevel.PUBLIC) public class SkillDataBonus { private String name; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/beans/SkillDataEntry.java b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/beans/SkillDataEntry.java index b21188d913..05ec9c878a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/beans/SkillDataEntry.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skillcalculator/beans/SkillDataEntry.java @@ -24,9 +24,10 @@ */ package net.runelite.client.plugins.skillcalculator.beans; +import lombok.AccessLevel; import lombok.Getter; -@Getter +@Getter(AccessLevel.PUBLIC) public class SkillDataEntry { private String name; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/skybox/SkyboxPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/skybox/SkyboxPlugin.java index 55b1a37017..d91597749b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/skybox/SkyboxPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/skybox/SkyboxPlugin.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.skybox; import com.google.inject.Inject; +import com.google.inject.Singleton; import java.io.IOException; import net.runelite.api.Client; import net.runelite.api.GameState; @@ -42,6 +43,7 @@ import net.runelite.client.plugins.PluginDescriptor; enabledByDefault = false, tags = {"sky"} ) +@Singleton public class SkyboxPlugin extends Plugin { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/KnapsackSolver.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/KnapsackSolver.java index dc2afab56c..5cd41a1132 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/KnapsackSolver.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/KnapsackSolver.java @@ -26,7 +26,9 @@ package net.runelite.client.plugins.slayer; import java.util.ArrayList; import java.util.List; +import javax.inject.Singleton; +@Singleton class KnapsackSolver { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/NPCPresence.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/NPCPresence.java index cc28df5393..2877a4ad8f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/NPCPresence.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/NPCPresence.java @@ -1,5 +1,6 @@ package net.runelite.client.plugins.slayer; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.NPC; @@ -8,15 +9,15 @@ public class NPCPresence private static final int FADE_TIMER_START = 20; - @Getter + @Getter(AccessLevel.PACKAGE) private String name; - @Getter + @Getter(AccessLevel.PACKAGE) private int combatLevel; private int fadeTimer; - private NPCPresence(String name, int combatLevel) + private NPCPresence(final String name, final int combatLevel) { this.name = name; this.combatLevel = combatLevel; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/RenderStyle.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/RenderStyle.java index 409f4c2729..c3c0f372a2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/RenderStyle.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/RenderStyle.java @@ -13,7 +13,7 @@ public enum RenderStyle private final String name; - RenderStyle(String name) + RenderStyle(final String name) { this.name = name; } 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 b27925fade..52ee0770aa 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 @@ -30,12 +30,14 @@ import java.awt.Point; import java.awt.Rectangle; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.ItemID; import net.runelite.api.widgets.WidgetItem; import net.runelite.client.ui.FontManager; import net.runelite.client.ui.overlay.WidgetItemOverlay; import net.runelite.client.ui.overlay.components.TextComponent; +@Singleton class SlayerOverlay extends WidgetItemOverlay { private final static Set SLAYER_JEWELRY = ImmutableSet.of( @@ -81,14 +83,12 @@ class SlayerOverlay extends WidgetItemOverlay ItemID.SLAYER_RING_8 ); - private final SlayerConfig config; private final SlayerPlugin plugin; @Inject - private SlayerOverlay(SlayerPlugin plugin, SlayerConfig config) + private SlayerOverlay(final SlayerPlugin plugin) { this.plugin = plugin; - this.config = config; showOnInventory(); showOnEquipment(); } @@ -101,7 +101,7 @@ class SlayerOverlay extends WidgetItemOverlay return; } - if (!config.showItemOverlay()) + if (!plugin.isShowItemOverlay()) { return; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java index b805edd030..be720fa9e3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerPlugin.java @@ -45,6 +45,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import javax.inject.Inject; +import javax.inject.Singleton; import joptsimple.internal.Strings; import lombok.AccessLevel; import lombok.Getter; @@ -107,6 +108,7 @@ import net.runelite.http.api.chat.ChatClient; ) @PluginDependency(XpTrackerPlugin.class) @Slf4j +@Singleton public class SlayerPlugin extends Plugin { //Chat messages @@ -254,9 +256,39 @@ public class SlayerPlugin extends Plugin lingeringPresences.clear(); } + private boolean showInfobox; + @Getter(AccessLevel.PACKAGE) + private boolean showItemOverlay; + @Setter(AccessLevel.PACKAGE) + private boolean showSuperiorNotification; + private int statTimeout; + @Getter(AccessLevel.PACKAGE) + private boolean highlightTargets; + @Getter(AccessLevel.PACKAGE) + private RenderStyle renderStyle; + @Getter(AccessLevel.PACKAGE) + private Color getTargetColor; + @Getter(AccessLevel.PACKAGE) + private Color getSuperiorColor; + @Getter(AccessLevel.PACKAGE) + private boolean drawNames; + @Getter(AccessLevel.PACKAGE) + private boolean drawMinimapNames; + @Getter(AccessLevel.PACKAGE) + private boolean weaknessPrompt; + @Setter(AccessLevel.PACKAGE) + private boolean taskCommand; + private String taskName; + private String taskLocation; + private int amount; + private int initialAmount; + private int lastCertainAmount; + @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(overlay); overlayManager.add(targetClickboxOverlay); overlayManager.add(targetWeaknessOverlay); @@ -321,11 +353,10 @@ public class SlayerPlugin extends Plugin currentTask.setPaused(true); break; case LOGGED_IN: - if (loginTick && config.amount() != -1 - && !config.taskName().isEmpty()) + if (loginTick && this.amount != -1 + && !this.taskName.isEmpty()) { - streak = config.streak(); - setTask(config.taskName(), config.amount(), config.initialAmount(), true, config.taskLocation(), config.lastCertainAmount()); + setTask(this.taskName, this.amount, this.initialAmount, true, this.taskLocation, this.lastCertainAmount); } } } @@ -333,10 +364,20 @@ public class SlayerPlugin extends Plugin private void save() { config.amount(currentTask.getAmount()); + this.amount = currentTask.getAmount(); + config.initialAmount(currentTask.getInitialAmount()); + this.initialAmount = currentTask.getInitialAmount(); + config.taskName(currentTask.getTaskName()); + this.taskName = currentTask.getTaskName(); + config.taskLocation(currentTask.getTaskLocation()); + this.taskLocation = currentTask.getTaskLocation(); + config.lastCertainAmount(currentTask.getLastCertainAmount()); + this.lastCertainAmount = currentTask.getLastCertainAmount(); + config.streak(streak); } @@ -383,7 +424,7 @@ public class SlayerPlugin extends Plugin setPoints(client.getVar(Varbits.SLAYER_REWARD_POINTS)); - if (!config.showInfobox()) + if (!this.showInfobox) { return; } @@ -554,7 +595,7 @@ public class SlayerPlugin extends Plugin if (infoTimer != null) { Duration timeSinceInfobox = Duration.between(infoTimer, Instant.now()); - Duration statTimeout = Duration.ofMinutes(config.statTimeout()); + Duration statTimeout = Duration.ofMinutes(this.statTimeout); if (timeSinceInfobox.compareTo(statTimeout) >= 0) { @@ -610,7 +651,7 @@ public class SlayerPlugin extends Plugin return; } - if (config.showSuperiorNotification() && chatMsg.equals(CHAT_SUPERIOR_MESSAGE)) + if (this.showSuperiorNotification && chatMsg.equals(CHAT_SUPERIOR_MESSAGE)) { notifier.notify(CHAT_SUPERIOR_MESSAGE); return; @@ -728,7 +769,9 @@ public class SlayerPlugin extends Plugin return; } - if (config.showInfobox()) + updateConfig(); + + if (this.showInfobox) { clientThread.invoke(this::addCounter); } @@ -758,7 +801,7 @@ public class SlayerPlugin extends Plugin currentTask.setPaused(false); // no longer paused since xp is gained panel.updateCurrentTask(true, currentTask.isPaused(), currentTask, false); - if (!config.showInfobox()) + if (!this.showInfobox) { return; } @@ -961,7 +1004,7 @@ public class SlayerPlugin extends Plugin private void addCounter() { - if (!config.showInfobox() || counter != null || currentTask == null || Strings.isNullOrEmpty(currentTask.getTaskName())) + if (!this.showInfobox || counter != null || currentTask == null || Strings.isNullOrEmpty(currentTask.getTaskName())) { return; } @@ -1006,7 +1049,7 @@ public class SlayerPlugin extends Plugin void taskLookup(ChatMessage chatMessage, String message) { - if (!config.taskCommand()) + if (!this.taskCommand) { return; } @@ -1150,4 +1193,25 @@ public class SlayerPlugin extends Plugin this.points = points; this.cachedPoints = points; } + + private void updateConfig() + { + this.showInfobox = config.showInfobox(); + this.showItemOverlay = config.showItemOverlay(); + this.showSuperiorNotification = config.showSuperiorNotification(); + this.statTimeout = config.statTimeout(); + this.highlightTargets = config.highlightTargets(); + this.renderStyle = config.renderStyle(); + this.getTargetColor = config.getTargetColor(); + this.getSuperiorColor = config.getSuperiorColor(); + this.drawNames = config.drawNames(); + this.drawMinimapNames = config.drawMinimapNames(); + this.weaknessPrompt = config.weaknessPrompt(); + this.taskCommand = config.taskCommand(); + this.taskName = config.taskName(); + this.amount = config.amount(); + this.initialAmount = config.initialAmount(); + this.lastCertainAmount = config.lastCertainAmount(); + this.taskLocation = config.taskLocation(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerTaskPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerTaskPanel.java index 0cd238a6d3..f865237fe9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerTaskPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/SlayerTaskPanel.java @@ -8,6 +8,7 @@ import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; +import javax.inject.Singleton; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.ImageIcon; @@ -23,6 +24,7 @@ import net.runelite.client.util.ColorUtil; import net.runelite.client.util.ImageUtil; import net.runelite.client.util.StackFormatter; +@Singleton public class SlayerTaskPanel extends PluginPanel { private static final long MILLIS_PER_SECOND = 1000; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetClickboxOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetClickboxOverlay.java index 12eeac7ead..b939fbdc2a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetClickboxOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetClickboxOverlay.java @@ -32,6 +32,7 @@ import java.awt.Graphics2D; import java.awt.Polygon; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.NPC; import net.runelite.api.NPCDefinition; @@ -46,20 +47,19 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; import net.runelite.client.util.Text; +@Singleton public class TargetClickboxOverlay extends Overlay { private static final Color TRANSPARENT = new Color(0, 0, 0, 0); private final Client client; - private final SlayerConfig config; private final SlayerPlugin plugin; private final ModelOutlineRenderer modelOutliner; @Inject - TargetClickboxOverlay(Client client, SlayerConfig config, SlayerPlugin plugin, ModelOutlineRenderer modelOutlineRenderer) + TargetClickboxOverlay(final Client client, final SlayerPlugin plugin, final ModelOutlineRenderer modelOutlineRenderer) { this.client = client; - this.config = config; this.plugin = plugin; this.modelOutliner = modelOutlineRenderer; setPosition(OverlayPosition.DYNAMIC); @@ -69,7 +69,7 @@ public class TargetClickboxOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (config.highlightTargets()) + if (plugin.isHighlightTargets()) { Set targets = plugin.getHighlightedTargets(); for (NPC target : targets) @@ -79,11 +79,11 @@ public class TargetClickboxOverlay extends Overlay continue; } - Color coloration = config.getTargetColor(); + Color coloration = plugin.getGetTargetColor(); if (plugin.isSuperior(target.getName())) { - coloration = config.getSuperiorColor(); + coloration = plugin.getGetSuperiorColor(); } renderNpcOverlay(graphics, target, coloration); @@ -95,7 +95,7 @@ public class TargetClickboxOverlay extends Overlay private void renderNpcOverlay(Graphics2D graphics, NPC actor, Color color) { - switch (config.renderStyle()) + switch (plugin.getRenderStyle()) { case SOUTH_WEST_TILE: LocalPoint lp1 = LocalPoint.fromWorld(client, actor.getWorldLocation()); @@ -168,7 +168,7 @@ public class TargetClickboxOverlay extends Overlay break; } - if (config.drawNames()) + if (plugin.isDrawNames()) { String npcName = Text.removeTags(actor.getName()); Point textLocation = actor.getCanvasTextLocation(graphics, npcName, actor.getLogicalHeight() + 40); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetMinimapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetMinimapOverlay.java index ceb81e6cd2..6799c49674 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetMinimapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetMinimapOverlay.java @@ -31,6 +31,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.NPC; import net.runelite.api.Point; import net.runelite.client.ui.overlay.Overlay; @@ -38,15 +39,14 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton public class TargetMinimapOverlay extends Overlay { - private final SlayerConfig config; private final SlayerPlugin plugin; @Inject - TargetMinimapOverlay(SlayerConfig config, SlayerPlugin plugin) + TargetMinimapOverlay(final SlayerPlugin plugin) { - this.config = config; this.plugin = plugin; setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); @@ -55,7 +55,7 @@ public class TargetMinimapOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!config.highlightTargets()) + if (!plugin.isHighlightTargets()) { return null; } @@ -68,11 +68,11 @@ public class TargetMinimapOverlay extends Overlay continue; } - Color coloration = config.getTargetColor(); + Color coloration = plugin.getGetTargetColor(); if (plugin.isSuperior(target.getName())) { - coloration = config.getSuperiorColor(); + coloration = plugin.getGetSuperiorColor(); } renderTargetOverlay(graphics, target, target.getName(), coloration); @@ -88,7 +88,7 @@ public class TargetMinimapOverlay extends Overlay { OverlayUtil.renderMinimapLocation(graphics, minimapLocation, color); - if (config.drawMinimapNames()) + if (plugin.isDrawMinimapNames()) { OverlayUtil.renderTextLocation(graphics, minimapLocation, name, color); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetWeaknessOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetWeaknessOverlay.java index 7a113607ee..cdc86c6992 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetWeaknessOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TargetWeaknessOverlay.java @@ -28,6 +28,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.NPC; import net.runelite.api.Perspective; @@ -40,19 +41,18 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton class TargetWeaknessOverlay extends Overlay { private final Client client; - private final SlayerConfig config; private final SlayerPlugin plugin; private final ItemManager itemManager; private final NPCManager npcManager; @Inject - private TargetWeaknessOverlay(Client client, SlayerConfig config, SlayerPlugin plugin, ItemManager itemManager, NPCManager npcManager) + private TargetWeaknessOverlay(final Client client, final SlayerPlugin plugin, final ItemManager itemManager, final NPCManager npcManager) { this.client = client; - this.config = config; this.plugin = plugin; this.itemManager = itemManager; this.npcManager = npcManager; @@ -63,7 +63,7 @@ class TargetWeaknessOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!config.weaknessPrompt()) + if (!plugin.isWeaknessPrompt()) { return null; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/Task.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/Task.java index 5c32ba6e73..538c5326bc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/Task.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/Task.java @@ -32,11 +32,12 @@ import static java.util.Arrays.asList; import java.util.Collections; import java.util.List; import java.util.Map; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.ItemID; import net.runelite.api.NpcID; -@Getter +@Getter(AccessLevel.PACKAGE) enum Task { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TaskBox.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TaskBox.java index ff3b509898..2f8776b200 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TaskBox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TaskBox.java @@ -6,6 +6,7 @@ import java.awt.Dimension; import java.awt.image.BufferedImage; import java.text.DecimalFormat; import java.util.Collections; +import javax.inject.Singleton; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; @@ -20,6 +21,7 @@ import net.runelite.client.ui.FontManager; import net.runelite.client.ui.components.ProgressBar; import net.runelite.client.util.StackFormatter; +@Singleton class TaskBox extends JPanel { private static final long MILLIS_PER_SECOND = 1000; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TaskCounter.java b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TaskCounter.java index 01f9b03890..ae7c2c67e4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TaskCounter.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/slayer/TaskCounter.java @@ -30,7 +30,7 @@ import net.runelite.client.ui.overlay.infobox.Counter; class TaskCounter extends Counter { - TaskCounter(BufferedImage img, Plugin plugin, int amount) + TaskCounter(final BufferedImage img, final Plugin plugin, final int amount) { super(img, plugin, amount); } 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 index 9584d17c34..682f39ba2f 100644 --- 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 @@ -54,6 +54,7 @@ package net.runelite.client.plugins.slayermusiq; import com.google.common.primitives.Ints; import java.util.Arrays; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.MenuAction; @@ -75,7 +76,7 @@ import net.runelite.client.util.Text; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton @Slf4j public class SlayermusiqPlugin extends Plugin { 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 index 3e9cad459d..017aef6ddd 100644 --- 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 @@ -30,6 +30,7 @@ import java.awt.Graphics2D; import java.time.Duration; import java.time.Instant; import javax.inject.Inject; +import javax.inject.Singleton; import static net.runelite.api.AnimationID.SMITHING_CANNONBALL; import static net.runelite.api.AnimationID.SMITHING_SMELTING; import net.runelite.api.Client; @@ -45,6 +46,7 @@ import net.runelite.client.ui.overlay.components.TitleComponent; import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; +@Singleton class SmeltingOverlay extends Overlay { private static final int SMELT_TIMEOUT = 5; @@ -56,7 +58,7 @@ class SmeltingOverlay extends Overlay private final PanelComponent panelComponent = new PanelComponent(); @Inject - SmeltingOverlay(Client client, SmeltingPlugin plugin, XpTrackerService xpTrackerService) + SmeltingOverlay(final Client client, final SmeltingPlugin plugin, final XpTrackerService xpTrackerService) { super(plugin); this.client = client; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingPlugin.java index 21a3b5440b..9d821ad6ab 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingPlugin.java @@ -28,10 +28,12 @@ import com.google.inject.Provides; import java.time.Duration; import java.time.Instant; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.ChatMessageType; import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameTick; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; @@ -46,6 +48,7 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Show Smelting stats", tags = {"overlay", "skilling"} ) +@Singleton @PluginDependency(XpTrackerPlugin.class) public class SmeltingPlugin extends Plugin { @@ -61,6 +64,8 @@ public class SmeltingPlugin extends Plugin @Getter(AccessLevel.PACKAGE) private SmeltingSession session; + private int statTimeout; + @Provides SmeltingConfig getConfig(ConfigManager configManager) { @@ -70,6 +75,7 @@ public class SmeltingPlugin extends Plugin @Override protected void startUp() { + this.statTimeout = config.statTimeout(); session = null; overlayManager.add(overlay); } @@ -112,7 +118,7 @@ public class SmeltingPlugin extends Plugin { if (session != null) { - final Duration statTimeout = Duration.ofMinutes(config.statTimeout()); + final Duration statTimeout = Duration.ofMinutes(this.statTimeout); final Duration sinceCaught = Duration.between(session.getLastItemSmelted(), Instant.now()); if (sinceCaught.compareTo(statTimeout) >= 0) @@ -121,5 +127,16 @@ public class SmeltingPlugin extends Plugin } } } + + @Subscribe + private void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("smelting")) + { + return; + } + + this.statTimeout = config.statTimeout(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/spawntimer/SpawnTimerConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/spawntimer/SpawnTimerConfig.java index 299122edf5..9b14734ebd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/spawntimer/SpawnTimerConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/spawntimer/SpawnTimerConfig.java @@ -1,11 +1,10 @@ package net.runelite.client.plugins.spawntimer; +import java.awt.Color; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; -import java.awt.*; - @ConfigGroup("spawntimer") public interface SpawnTimerConfig extends Config { @@ -19,6 +18,7 @@ public interface SpawnTimerConfig extends Config { return ""; } + @ConfigItem( position = 2, keyName = "npcColor", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/spawntimer/SpawnTimerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/spawntimer/SpawnTimerOverlay.java index f823cf3308..fe00ea22af 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/spawntimer/SpawnTimerOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/spawntimer/SpawnTimerOverlay.java @@ -1,40 +1,36 @@ package net.runelite.client.plugins.spawntimer; -import net.runelite.api.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.util.List; +import javax.inject.Inject; +import javax.inject.Singleton; +import net.runelite.api.NPC; import net.runelite.api.Point; -import net.runelite.client.plugins.spawntimer.SpawnTimerPlugin; -import net.runelite.client.plugins.spawntimer.SpawnTimerConfig; 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; import net.runelite.client.util.WildcardMatcher; -import javax.inject.Inject; -import java.awt.*; -import java.util.ArrayList; -import java.util.List; - +@Singleton public class SpawnTimerOverlay extends Overlay { - private final Client client; - private final SpawnTimerConfig config; private final SpawnTimerPlugin plugin; - private List highlights = new ArrayList<>(); + @Inject - SpawnTimerOverlay(Client client, SpawnTimerConfig config, SpawnTimerPlugin plugin) + SpawnTimerOverlay(final SpawnTimerPlugin plugin) { - this.client = client; - this.config = config; this.plugin = plugin; setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); } @Override - public Dimension render(Graphics2D graphics) + public Dimension render(Graphics2D graphics) { - highlights = plugin.getHighlights(); + List highlights = plugin.getHighlights(); for (thing npc : plugin.getTicks()) { if (npc == null) @@ -56,13 +52,13 @@ public class SpawnTimerOverlay extends Overlay { int tick = plugin.getCurrentTick() - npc.getTick(); String tickString = "" + tick; - renderNpcOverlay(graphics, npc.getNpc(), tickString, config.getHighlightColor()); + renderNpcOverlay(graphics, npc.getNpc(), tickString, plugin.getGetHighlightColor()); } } } return null; } - + private void renderNpcOverlay(Graphics2D graphics, NPC actor, String name, Color color) { Point textLocation = actor.getCanvasTextLocation(graphics, name, actor.getLogicalHeight() - 40); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/spawntimer/SpawnTimerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/spawntimer/SpawnTimerPlugin.java index b98a2a2541..aa1e66efd0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/spawntimer/SpawnTimerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/spawntimer/SpawnTimerPlugin.java @@ -2,11 +2,18 @@ package net.runelite.client.plugins.spawntimer; import com.google.common.annotations.VisibleForTesting; import com.google.inject.Provides; +import java.awt.Color; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; -import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.NPC; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.NpcDespawned; @@ -19,24 +26,20 @@ import net.runelite.client.plugins.PluginType; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.util.Text; -import javax.inject.Inject; -import java.util.*; - @PluginDescriptor( - name = "Spawn Timer", - description = "Shows NPC'S time since spawned", - tags = {"highlight", "minimap", "npcs", "overlay", "spawn", "tags", "lyzrd"}, - type = PluginType.PVM, - enabledByDefault = false + name = "Spawn Timer", + description = "Shows NPC'S time since spawned", + tags = {"highlight", "minimap", "npcs", "overlay", "spawn", "tags", "lyzrd"}, + type = PluginType.PVM, + enabledByDefault = false ) - -public class SpawnTimerPlugin extends Plugin +@Singleton +public class SpawnTimerPlugin extends Plugin { @Inject private OverlayManager overlayManager; - @Getter(AccessLevel.PACKAGE) private final Set highlightedNpcs = new HashSet<>(); @@ -46,9 +49,6 @@ public class SpawnTimerPlugin extends Plugin @Inject private SpawnTimerOverlay SpawnTimerOverlay; - @Inject - private Client client; - @Inject private SpawnTimerConfig config; @@ -60,9 +60,17 @@ public class SpawnTimerPlugin extends Plugin @Getter(AccessLevel.PACKAGE) public int currentTick; + + private String getNpcToHighlight; + @Getter(AccessLevel.PACKAGE) + private Color getHighlightColor; + @Override protected void startUp() throws Exception { + this.getNpcToHighlight = config.getNpcToHighlight(); + this.getHighlightColor = config.getHighlightColor(); + currentTick = 0; overlayManager.add(SpawnTimerOverlay); } @@ -86,7 +94,7 @@ public class SpawnTimerPlugin extends Plugin public void onGameStateChanged(GameStateChanged event) { if (event.getGameState() == GameState.LOGIN_SCREEN || - event.getGameState() == GameState.HOPPING) + event.getGameState() == GameState.HOPPING) { highlightedNpcs.clear(); ticks.clear(); @@ -114,21 +122,15 @@ public class SpawnTimerPlugin extends Plugin if (highlightedNpcs.contains(npc)) { highlightedNpcs.remove(npc); - for (Iterator iterator = ticks.iterator(); iterator.hasNext();) - { - thing t = iterator.next(); - if (t.getNpc() == npc) - { - iterator.remove(); - } - //currentTick = 0; - } + //currentTick = 0; + ticks.removeIf(t -> t.getNpc() == npc); } } + @VisibleForTesting public List getHighlights() { - final String configNpcs = config.getNpcToHighlight().toLowerCase(); + final String configNpcs = this.getNpcToHighlight.toLowerCase(); if (configNpcs.isEmpty()) { @@ -137,4 +139,16 @@ public class SpawnTimerPlugin extends Plugin return Text.fromCSV(configNpcs); } + + @Subscribe + private void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("spawntimer")) + { + return; + } + + this.getNpcToHighlight = config.getNpcToHighlight(); + this.getHighlightColor = config.getHighlightColor(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/specbar/SpecBarPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/specbar/SpecBarPlugin.java index 086d3d397d..d58467d9f1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/specbar/SpecBarPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/specbar/SpecBarPlugin.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.specbar; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.events.ScriptCallbackEvent; import net.runelite.client.eventbus.Subscribe; @@ -39,7 +40,7 @@ import net.runelite.client.plugins.PluginType; type = PluginType.PVP, enabledByDefault = false ) - +@Singleton public class SpecBarPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/Boss.java b/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/Boss.java index a9b4434797..d609ed9d9b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/Boss.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/Boss.java @@ -26,11 +26,12 @@ package net.runelite.client.plugins.specialcounter; import com.google.common.collect.Sets; import java.util.Set; +import lombok.AccessLevel; import lombok.Getter; import lombok.ToString; import net.runelite.api.NpcID; -@Getter +@Getter(AccessLevel.PACKAGE) @ToString enum Boss { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialCounter.java b/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialCounter.java index 482fb45089..b752cea058 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialCounter.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialCounter.java @@ -33,15 +33,13 @@ import net.runelite.client.ui.overlay.infobox.Counter; class SpecialCounter extends Counter { - private final SpecialCounterPlugin plugin; private SpecialWeapon weapon; @Getter(AccessLevel.PACKAGE) private final Map partySpecs = new HashMap<>(); - SpecialCounter(BufferedImage image, SpecialCounterPlugin plugin, int hitValue, SpecialWeapon weapon) + SpecialCounter(final BufferedImage image, final SpecialCounterPlugin plugin, final int hitValue, final SpecialWeapon weapon) { super(image, plugin, hitValue); - this.plugin = plugin; this.weapon = weapon; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialCounterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialCounterPlugin.java index 1f056ad234..fef53c1ea8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialCounterPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialCounterPlugin.java @@ -28,6 +28,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Actor; import net.runelite.api.Client; import net.runelite.api.EquipmentInventorySlot; @@ -60,6 +61,7 @@ import org.apache.commons.lang3.ArrayUtils; tags = {"combat", "npcs", "overlay"}, enabledByDefault = false ) +@Singleton public class SpecialCounterPlugin extends Plugin { private int currentWorld = -1; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialCounterUpdate.java b/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialCounterUpdate.java index 16eff1af25..efb8b308a8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialCounterUpdate.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialCounterUpdate.java @@ -30,7 +30,7 @@ import net.runelite.http.api.ws.messages.party.PartyMemberMessage; @Value @EqualsAndHashCode(callSuper = true) -public class SpecialCounterUpdate extends PartyMemberMessage +class SpecialCounterUpdate extends PartyMemberMessage { private final int npcId; private final SpecialWeapon weapon; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialWeapon.java b/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialWeapon.java index 69d8d68193..ec581fe9e3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialWeapon.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/specialcounter/SpecialWeapon.java @@ -24,12 +24,13 @@ */ package net.runelite.client.plugins.specialcounter; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.ItemID; @AllArgsConstructor -@Getter +@Getter(AccessLevel.PACKAGE) enum SpecialWeapon { DRAGON_WARHAMMER("Dragon Warhammer", ItemID.DRAGON_WARHAMMER, false), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/Spellbook.java b/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/Spellbook.java index a0b292ca3c..eebfff8426 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/Spellbook.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/Spellbook.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.spellbook; import com.google.common.collect.ImmutableMap; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @@ -36,10 +37,10 @@ public enum Spellbook LUNAR(2, "lunar"), ARCEUUS(3, "arceuus"); - @Getter + @Getter(AccessLevel.PACKAGE) private final int id; - @Getter + @Getter(AccessLevel.PACKAGE) private final String configKey; private static final ImmutableMap map; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookConfig.java index 9bc8e243f9..cb8a187300 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookConfig.java @@ -85,51 +85,6 @@ public interface SpellbookConfig extends Config return ""; } - @ConfigItem( - keyName = "standard", - name = "", - description = "", - hidden = true - ) - default String standard() - { - return ""; - } - - - @ConfigItem( - keyName = "ancient", - name = "", - description = "", - hidden = true - ) - default String ancient() - { - return ""; - } - - @ConfigItem( - keyName = "lunar", - name = "", - description = "", - hidden = true - ) - default String lunar() - { - return ""; - } - - @ConfigItem( - keyName = "arceuus", - name = "", - description = "", - hidden = true - ) - default String arceuus() - { - return ""; - } - @ConfigItem( keyName = "canDrag", name = "", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookDragOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookDragOverlay.java index 0066f841fe..5ac75aae56 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookDragOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookDragOverlay.java @@ -46,7 +46,7 @@ public class SpellbookDragOverlay extends Overlay private SpriteManager spriteManager; @Inject - private SpellbookDragOverlay(SpellbookPlugin plugin, Client client, SpriteManager spriteManager) + private SpellbookDragOverlay(final SpellbookPlugin plugin, final Client client, final SpriteManager spriteManager) { this.plugin = plugin; this.client = client; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookMouseListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookMouseListener.java index b4416161b3..01db4f79e5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookMouseListener.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookMouseListener.java @@ -26,15 +26,17 @@ package net.runelite.client.plugins.spellbook; import java.awt.event.MouseEvent; import java.awt.event.MouseWheelEvent; +import javax.inject.Singleton; import javax.swing.SwingUtilities; import net.runelite.client.input.MouseAdapter; import net.runelite.client.input.MouseWheelListener; +@Singleton public class SpellbookMouseListener extends MouseAdapter implements MouseWheelListener { private final SpellbookPlugin plugin; - SpellbookMouseListener(SpellbookPlugin plugin) + SpellbookMouseListener(final SpellbookPlugin plugin) { this.plugin = plugin; } @@ -42,7 +44,7 @@ public class SpellbookMouseListener extends MouseAdapter implements MouseWheelLi @Override public MouseEvent mouseClicked(MouseEvent event) { - if (!plugin.isOnSpellWidget(event.getPoint())) + if (plugin.isNotOnSpellWidget(event.getPoint())) { return event; } @@ -59,7 +61,7 @@ public class SpellbookMouseListener extends MouseAdapter implements MouseWheelLi @Override public MouseEvent mousePressed(MouseEvent event) { - if (!SwingUtilities.isLeftMouseButton(event) || !plugin.isOnSpellWidget(event.getPoint()) || plugin.isDragging()) + if (!SwingUtilities.isLeftMouseButton(event) || plugin.isNotOnSpellWidget(event.getPoint()) || plugin.isDragging()) { return event; } @@ -87,7 +89,7 @@ public class SpellbookMouseListener extends MouseAdapter implements MouseWheelLi @Override public MouseWheelEvent mouseWheelMoved(MouseWheelEvent event) { - if (!plugin.isOnSpellWidget(event.getPoint())) + if (plugin.isNotOnSpellWidget(event.getPoint())) { return event; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookPlugin.java index 5f739ab8b5..fc5d766385 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/spellbook/SpellbookPlugin.java @@ -36,6 +36,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; @@ -70,7 +71,7 @@ import net.runelite.client.util.Text; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton @Slf4j public class SpellbookPlugin extends Plugin { @@ -134,6 +135,11 @@ public class SpellbookPlugin extends Plugin private Spellbook spellbook; private SpellbookMouseListener mouseListener; + private boolean enableMobile; + private boolean dragSpells; + private boolean scroll; + private int size; + private String filter; @Provides SpellbookConfig getConfig(ConfigManager configManager) @@ -144,6 +150,8 @@ public class SpellbookPlugin extends Plugin @Override protected void startUp() { + updateConfig(); + refreshMagicTabOption(); loadFilter(); mouseListener = new SpellbookMouseListener(this); @@ -177,6 +185,8 @@ public class SpellbookPlugin extends Plugin return; } + updateConfig(); + String key = event.getKey(); if ("filter".equals(key)) @@ -260,7 +270,7 @@ public class SpellbookPlugin extends Plugin mouseManager.registerMouseListener(mouseListener); tmp = new HashMap<>(); - if (config.scroll()) + if (this.scroll) { mouseManager.registerMouseWheelListener(mouseListener); } @@ -289,7 +299,7 @@ public class SpellbookPlugin extends Plugin private void refreshMagicTabOption() { clearMagicTabMenus(); - if (client.getGameState() != GameState.LOGGED_IN || !config.dragSpells()) + if (client.getGameState() != GameState.LOGGED_IN || !this.dragSpells) { return; } @@ -312,7 +322,7 @@ public class SpellbookPlugin extends Plugin public void onScriptCallbackEvent(ScriptCallbackEvent event) { if (client.getVar(Varbits.FILTER_SPELLBOOK) != 0 - || !config.enableMobile() + || !this.enableMobile || !event.getEventName().toLowerCase().contains("spell")) { return; @@ -367,7 +377,7 @@ public class SpellbookPlugin extends Plugin } else if ("resizeSpell".equals(event.getEventName())) { - int size = config.size(); + int size = this.size; int columns = clamp(FULL_WIDTH / size, 2, 3); iStack[iStackSize - 2] = size; @@ -375,7 +385,7 @@ public class SpellbookPlugin extends Plugin } else if ("setSpellAreaSize".equals(event.getEventName())) { - if (!config.dragSpells()) + if (!this.dragSpells) { return; } @@ -411,7 +421,7 @@ public class SpellbookPlugin extends Plugin } else if ("setSpellPosition".equals(event.getEventName())) { - if (!config.dragSpells()) + if (!this.dragSpells) { return; } @@ -509,7 +519,7 @@ public class SpellbookPlugin extends Plugin return WordFilterMode.CONTAINS; // but probably null soz } - boolean isOnSpellWidget(java.awt.Point point) + boolean isNotOnSpellWidget(java.awt.Point point) { Widget boundsWidget = client.getWidget(WidgetInfo.SPELLBOOK_FILTERED_BOUNDS); if (client.getVar(VarClientInt.INVENTORY_TAB) != 6 @@ -517,15 +527,15 @@ public class SpellbookPlugin extends Plugin || boundsWidget == null || !boundsWidget.getBounds().contains(point)) { - return false; + return true; } - return currentWidget(point) != null; + return currentWidget(point) == null; } private void loadFilter() { - notFilteredSpells = ImmutableSet.copyOf(Text.fromCSV(config.filter().toLowerCase())); + notFilteredSpells = ImmutableSet.copyOf(Text.fromCSV(this.filter.toLowerCase())); } void startDragging(java.awt.Point point) @@ -630,7 +640,7 @@ public class SpellbookPlugin extends Plugin { Widget clickedWidget = currentWidget(point); - if (clickedWidget == null || dragging || !config.scroll()) + if (clickedWidget == null || dragging || !this.scroll) { return; } @@ -701,6 +711,15 @@ public class SpellbookPlugin extends Plugin private int trueSize(Spell s) { - return s.getSize() * 2 + config.size(); + return s.getSize() * 2 + this.size; + } + + private void updateConfig() + { + this.enableMobile = config.enableMobile(); + this.dragSpells = config.dragSpells(); + this.scroll = config.scroll(); + this.size = config.size(); + this.filter = config.filter(); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsOverlay.java index bf2dce7138..d4d64dec42 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsOverlay.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.statusbars; import com.google.common.base.Strings; import com.google.common.primitives.Ints; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.MenuEntry; import net.runelite.api.Point; @@ -44,6 +45,7 @@ import javax.inject.Inject; import java.awt.Dimension; import java.awt.Graphics2D; +@Singleton public class StatusBarsOverlay extends Overlay { private static final int HEIGHT = 252; @@ -53,17 +55,15 @@ public class StatusBarsOverlay extends Overlay private final Client client; private final StatusBarsPlugin plugin; - private final StatusBarsConfig config; private final ItemStatChangesService itemStatService; @Inject - private StatusBarsOverlay(Client client, StatusBarsPlugin plugin, StatusBarsConfig config, ItemStatChangesService itemstatservice) + private StatusBarsOverlay(final Client client, final StatusBarsPlugin plugin, final ItemStatChangesService itemstatservice) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_WIDGETS); this.client = client; this.plugin = plugin; - this.config = config; this.itemStatService = itemstatservice; } @@ -117,8 +117,8 @@ public class StatusBarsOverlay extends Overlay offsetRightBarY = (location.getY() - offsetRight.getY()); } - BarRenderer left = plugin.getBarRenderers().get(config.leftBarMode()); - BarRenderer right = plugin.getBarRenderers().get(config.rightBarMode()); + BarRenderer left = plugin.getBarRenderers().get(plugin.getLeftBarMode()); + BarRenderer right = plugin.getBarRenderers().get(plugin.getRightBarMode()); if (left != null) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsPlugin.java index 93d6f94163..b2310a1acc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/StatusBarsPlugin.java @@ -28,6 +28,7 @@ import javax.inject.Inject; import com.google.common.collect.Maps; import com.google.inject.Provides; +import javax.inject.Singleton; import lombok.Getter; import java.time.Duration; import java.time.Instant; @@ -38,6 +39,7 @@ import net.runelite.api.Actor; import net.runelite.api.Client; import net.runelite.api.NPC; import net.runelite.api.NPCDefinition; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameTick; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; @@ -61,6 +63,7 @@ import java.util.Map; description = "Draws status bars next to players inventory showing currentValue and restore amounts", enabledByDefault = false ) +@Singleton @PluginDependency(ItemStatPlugin.class) public class StatusBarsPlugin extends Plugin { @@ -94,9 +97,24 @@ public class StatusBarsPlugin extends Plugin @Getter(AccessLevel.PACKAGE) private Instant lastCombatAction; + @Getter(AccessLevel.PUBLIC) + private boolean enableCounter; + @Getter(AccessLevel.PUBLIC) + private boolean enableSkillIcon; + @Getter(AccessLevel.PUBLIC) + private boolean enableRestorationBars; + @Getter(AccessLevel.PACKAGE) + private BarMode leftBarMode; + @Getter(AccessLevel.PACKAGE) + private BarMode rightBarMode; + private boolean toggleRestorationBars; + private int hideStatusBarDelay; + @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(overlay); barRenderers.put(BarMode.DISABLED, null); barRenderers.put(BarMode.HITPOINTS, hitPointsRenderer); @@ -105,7 +123,7 @@ public class StatusBarsPlugin extends Plugin barRenderers.put(BarMode.SPECIAL_ATTACK, specialAttackRenderer); } - void updateLastCombatAction() + private void updateLastCombatAction() { this.lastCombatAction = Instant.now(); } @@ -113,10 +131,9 @@ public class StatusBarsPlugin extends Plugin @Subscribe public void onGameTick(GameTick gameTick) { - if (!config.toggleRestorationBars()) + if (!this.toggleRestorationBars) { overlayManager.add(overlay); - return; } else { @@ -128,14 +145,14 @@ public class StatusBarsPlugin extends Plugin { final Actor interacting = client.getLocalPlayer().getInteracting(); final boolean isNpc = interacting instanceof NPC; - final int combatTimeout = config.hideStatusBarDelay(); + final int combatTimeout = this.hideStatusBarDelay; if (isNpc) { final NPC npc = (NPC) interacting; final NPCDefinition npcComposition = npc.getDefinition(); final List npcMenuActions = Arrays.asList(npcComposition.getActions()); - if (npcMenuActions.contains("Attack") && config.toggleRestorationBars()) + if (npcMenuActions.contains("Attack") && this.toggleRestorationBars) { updateLastCombatAction(); overlayManager.add(overlay); @@ -162,4 +179,26 @@ public class StatusBarsPlugin extends Plugin { return configManager.getConfig(StatusBarsConfig.class); } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!"statusbars".equals(event.getGroup())) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.enableCounter = config.enableCounter(); + this.enableSkillIcon = config.enableSkillIcon(); + this.enableRestorationBars = config.enableRestorationBars(); + this.leftBarMode = config.leftBarMode(); + this.rightBarMode = config.rightBarMode(); + this.toggleRestorationBars = config.toggleRestorationBars(); + this.hideStatusBarDelay = config.hideStatusBarDelay(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/Viewport.java b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/Viewport.java index ce4c6e86b6..ff1703e93a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/Viewport.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/Viewport.java @@ -24,12 +24,13 @@ */ package net.runelite.client.plugins.statusbars; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.Point; import net.runelite.api.widgets.WidgetInfo; -@Getter +@Getter(AccessLevel.PACKAGE) @AllArgsConstructor enum Viewport { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/config/BarMode.java b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/config/BarMode.java index 7da3d0c308..0716177fe9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/config/BarMode.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/config/BarMode.java @@ -24,10 +24,11 @@ */ package net.runelite.client.plugins.statusbars.config; +import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; -@Getter +@Getter(AccessLevel.PACKAGE) @RequiredArgsConstructor public enum BarMode { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/BarRenderer.java b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/BarRenderer.java index 21ed8fd96b..f721611b47 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/BarRenderer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/BarRenderer.java @@ -27,18 +27,17 @@ package net.runelite.client.plugins.statusbars.renderer; -import lombok.AccessLevel; -import lombok.RequiredArgsConstructor; -import net.runelite.api.Client; -import net.runelite.client.plugins.statusbars.StatusBarsConfig; -import net.runelite.client.plugins.statusbars.StatusBarsOverlay; -import net.runelite.client.ui.FontManager; -import net.runelite.client.ui.overlay.components.TextComponent; - import java.awt.Color; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Point; +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import net.runelite.api.Client; +import net.runelite.client.plugins.statusbars.StatusBarsOverlay; +import net.runelite.client.plugins.statusbars.StatusBarsPlugin; +import net.runelite.client.ui.FontManager; +import net.runelite.client.ui.overlay.components.TextComponent; @RequiredArgsConstructor(access = AccessLevel.PROTECTED) public abstract class BarRenderer @@ -56,12 +55,12 @@ public abstract class BarRenderer private static final int ICON_AND_COUNTER_OFFSET_Y = 21; private static final int OFFSET = 2; - protected final StatusBarsConfig config; - protected int maximumValue; - protected int currentValue; + protected final StatusBarsPlugin plugin; + int maximumValue; + int currentValue; protected int restore; - protected Color standardColor; - protected Color restoreColor; + Color standardColor; + Color restoreColor; protected Image icon; protected abstract void update(Client client, StatusBarsOverlay overlay); @@ -75,9 +74,9 @@ public abstract class BarRenderer final int filledHeight = getBarHeight(maximumValue, currentValue, height); graphics.setColor(standardColor); graphics.fillRect(x + PADDING, - y + PADDING + (height - filledHeight), - BAR_WIDTH - PADDING * OFFSET, - filledHeight - PADDING * OFFSET); + y + PADDING + (height - filledHeight), + BAR_WIDTH - PADDING * OFFSET, + filledHeight - PADDING * OFFSET); } private void renderIconsAndCounters(Graphics2D graphics, int x, int y) @@ -86,7 +85,7 @@ public abstract class BarRenderer final int widthOfCounter = graphics.getFontMetrics().stringWidth(counterText); final int centerText = (BAR_WIDTH - PADDING) / 2 - (widthOfCounter / 2); - if (config.enableCounter()) + if (plugin.isEnableCounter()) { graphics.setFont(FontManager.getRunescapeSmallFont()); TEXT.setText(counterText); @@ -97,7 +96,7 @@ public abstract class BarRenderer TEXT.setText(""); } - if (config.enableSkillIcon()) + if (plugin.isEnableSkillIcon()) { graphics.drawImage(icon, x + ICON_AND_COUNTER_OFFSET_X + PADDING, y + ICON_AND_COUNTER_OFFSET_Y - icon.getWidth(null), null); TEXT.setPosition(new Point(x + centerText + 1, y + SKILL_ICON_HEIGHT)); @@ -123,16 +122,16 @@ public abstract class BarRenderer filledHeight = filledHeight - overHeal + OVERHEAL_OFFSET; graphics.setColor(COLOR_OVERHEAL); graphics.fillRect(x + PADDING, - y - filledCurrentHeight + (height - filledHeight) + HEAL_OFFSET, - BAR_WIDTH - PADDING * OVERHEAL_OFFSET, - filledHeight - PADDING * OVERHEAL_OFFSET); + y - filledCurrentHeight + (height - filledHeight) + HEAL_OFFSET, + BAR_WIDTH - PADDING * OVERHEAL_OFFSET, + filledHeight - PADDING * OVERHEAL_OFFSET); } else { graphics.fillRect(x + PADDING, - y - OVERHEAL_OFFSET - filledCurrentHeight + (height - filledHeight) + HEAL_OFFSET, - BAR_WIDTH - PADDING * OVERHEAL_OFFSET, - filledHeight + OVERHEAL_OFFSET - PADDING * OVERHEAL_OFFSET); + y - OVERHEAL_OFFSET - filledCurrentHeight + (height - filledHeight) + HEAL_OFFSET, + BAR_WIDTH - PADDING * OVERHEAL_OFFSET, + filledHeight + OVERHEAL_OFFSET - PADDING * OVERHEAL_OFFSET); } } @@ -152,9 +151,13 @@ public abstract class BarRenderer { update(client, overlay); renderBar(graphics, x, y, height); - if (config.enableRestorationBars()) + if (plugin.isEnableRestorationBars()) + { renderRestore(graphics, x, y, height); - if (config.enableSkillIcon() || config.enableCounter()) + } + if (plugin.isEnableSkillIcon() || plugin.isEnableCounter()) + { renderIconsAndCounters(graphics, x, y); + } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/EnergyRenderer.java b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/EnergyRenderer.java index 127aa6b601..b3a1cd5141 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/EnergyRenderer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/EnergyRenderer.java @@ -27,23 +27,24 @@ package net.runelite.client.plugins.statusbars.renderer; +import java.awt.Color; +import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.SpriteID; import net.runelite.client.game.SpriteManager; -import net.runelite.client.plugins.statusbars.StatusBarsConfig; import net.runelite.client.plugins.statusbars.StatusBarsOverlay; +import net.runelite.client.plugins.statusbars.StatusBarsPlugin; -import javax.inject.Inject; -import java.awt.Color; - +@Singleton public class EnergyRenderer extends BarRenderer { private final SpriteManager spriteManager; @Inject - public EnergyRenderer(StatusBarsConfig config, SpriteManager spriteManager) + public EnergyRenderer(final StatusBarsPlugin plugin, final SpriteManager spriteManager) { - super(config); + super(plugin); maximumValue = 100; this.spriteManager = spriteManager; standardColor = new Color(199, 174, 0, 220); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/HitPointsRenderer.java b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/HitPointsRenderer.java index 68e1c29548..f9976ebe27 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/HitPointsRenderer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/HitPointsRenderer.java @@ -27,16 +27,17 @@ package net.runelite.client.plugins.statusbars.renderer; +import java.awt.Color; +import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Skill; import net.runelite.api.VarPlayer; import net.runelite.client.game.SkillIconManager; -import net.runelite.client.plugins.statusbars.StatusBarsConfig; import net.runelite.client.plugins.statusbars.StatusBarsOverlay; +import net.runelite.client.plugins.statusbars.StatusBarsPlugin; -import javax.inject.Inject; -import java.awt.Color; - +@Singleton public class HitPointsRenderer extends BarRenderer { private static final Color COLOR_STANDARD = new Color(225, 35, 0, 125); @@ -44,9 +45,9 @@ public class HitPointsRenderer extends BarRenderer private static final Color COLOR_VENOM = new Color(0, 65, 0, 150); @Inject - public HitPointsRenderer(StatusBarsConfig config, SkillIconManager iconManager) + public HitPointsRenderer(final StatusBarsPlugin plugin, final SkillIconManager iconManager) { - super(config); + super(plugin); icon = iconManager.getSkillImage(Skill.HITPOINTS, true); restoreColor = new Color(255, 112, 6, 150); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/PrayerRenderer.java b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/PrayerRenderer.java index 76ed6fadca..bf5eed9cf1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/PrayerRenderer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/PrayerRenderer.java @@ -27,17 +27,18 @@ package net.runelite.client.plugins.statusbars.renderer; +import java.awt.Color; +import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Skill; import net.runelite.api.Varbits; import net.runelite.client.game.SkillIconManager; -import net.runelite.client.plugins.statusbars.StatusBarsConfig; import net.runelite.client.plugins.statusbars.StatusBarsOverlay; +import net.runelite.client.plugins.statusbars.StatusBarsPlugin; import net.runelite.client.util.ImageUtil; -import javax.inject.Inject; -import java.awt.Color; - +@Singleton public class PrayerRenderer extends BarRenderer { private static final Color COLOR_STANDARD = new Color(50, 200, 200, 175); @@ -45,9 +46,9 @@ public class PrayerRenderer extends BarRenderer private static final int SIZE = 17; @Inject - public PrayerRenderer(StatusBarsConfig config, SkillIconManager iconManager) + public PrayerRenderer(final StatusBarsPlugin plugin, final SkillIconManager iconManager) { - super(config); + super(plugin); icon = ImageUtil.resizeImage(iconManager.getSkillImage(Skill.PRAYER, true), SIZE, SIZE); restoreColor = new Color(57, 255, 186, 75); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/SpecialAttackRenderer.java b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/SpecialAttackRenderer.java index a2f43f1c2e..7ffeb06d2c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/SpecialAttackRenderer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/statusbars/renderer/SpecialAttackRenderer.java @@ -27,24 +27,25 @@ package net.runelite.client.plugins.statusbars.renderer; +import java.awt.Color; +import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.SpriteID; import net.runelite.api.VarPlayer; import net.runelite.client.game.SpriteManager; -import net.runelite.client.plugins.statusbars.StatusBarsConfig; import net.runelite.client.plugins.statusbars.StatusBarsOverlay; +import net.runelite.client.plugins.statusbars.StatusBarsPlugin; -import javax.inject.Inject; -import java.awt.Color; - +@Singleton public class SpecialAttackRenderer extends BarRenderer { private final SpriteManager spriteManager; @Inject - public SpecialAttackRenderer(StatusBarsConfig config, SpriteManager spriteManager) + public SpecialAttackRenderer(final StatusBarsPlugin plugin, final SpriteManager spriteManager) { - super(config); + super(plugin); maximumValue = 100; this.spriteManager = spriteManager; standardColor = restoreColor = new Color(3, 153, 0, 195); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ItemSortTypes.java b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ItemSortTypes.java index 80ae04b20d..11680b9456 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ItemSortTypes.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ItemSortTypes.java @@ -1,9 +1,10 @@ package net.runelite.client.plugins.stonedloottracker; +import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; -@Getter +@Getter(AccessLevel.PACKAGE) @RequiredArgsConstructor public enum ItemSortTypes { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/StonedLootTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/StonedLootTrackerPlugin.java index ceb85fe365..3141db78e6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/StonedLootTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/StonedLootTrackerPlugin.java @@ -46,6 +46,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.SwingUtilities; import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; @@ -97,7 +98,7 @@ import net.runelite.client.util.Text; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton @Slf4j public class StonedLootTrackerPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/BossTab.java b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/BossTab.java index b59752f5f7..f40ca6cb94 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/BossTab.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/BossTab.java @@ -29,10 +29,11 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.TreeSet; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.ItemID; -@Getter +@Getter(AccessLevel.PUBLIC) public enum BossTab { // Chest Rewards diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/LootRecord.java b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/LootRecord.java index 5143e79591..3a8ae0a843 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/LootRecord.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/LootRecord.java @@ -27,9 +27,10 @@ package net.runelite.client.plugins.stonedloottracker.data; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import lombok.AccessLevel; import lombok.Getter; -@Getter +@Getter(AccessLevel.PUBLIC) @Deprecated public class LootRecord { @@ -39,7 +40,7 @@ public class LootRecord private final int killCount; final Collection drops; - public LootRecord(int id, String name, int level, int kc, Collection drops) + public LootRecord(final int id, final String name, final int level, final int kc, final Collection drops) { this.id = id; this.name = name; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/LootRecordCustom.java b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/LootRecordCustom.java index ec208f8615..2d098b17f3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/LootRecordCustom.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/LootRecordCustom.java @@ -28,9 +28,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Map; +import lombok.AccessLevel; import lombok.Getter; -@Getter +@Getter(AccessLevel.PUBLIC) public class LootRecordCustom { private final int id; @@ -39,7 +40,7 @@ public class LootRecordCustom private final int killCount; final Collection drops; - public LootRecordCustom(int id, String name, int level, int kc, Collection drops) + public LootRecordCustom(final int id, final String name, final int level, final int kc, final Collection drops) { this.id = id; this.name = name; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/LootTrackerItemEntry.java b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/LootTrackerItemEntry.java index c7215a4b5b..5d764ac750 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/LootTrackerItemEntry.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/LootTrackerItemEntry.java @@ -25,9 +25,10 @@ */ package net.runelite.client.plugins.stonedloottracker.data; +import lombok.AccessLevel; import lombok.Getter; -@Getter +@Getter(AccessLevel.PUBLIC) public class LootTrackerItemEntry { private final String name; @@ -39,7 +40,7 @@ public class LootTrackerItemEntry private long haTotal; private final boolean stackable; - public LootTrackerItemEntry(String name, int id, int quantity, long price, long haPrice, boolean stackable) + public LootTrackerItemEntry(final String name, final int id, final int quantity, final long price, final long haPrice, final boolean stackable) { this.name = name; this.id = id; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/Pet.java b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/Pet.java index 354ef2bd7c..35ff366e9c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/Pet.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/Pet.java @@ -2,10 +2,11 @@ package net.runelite.client.plugins.stonedloottracker.data; import java.util.HashMap; import java.util.Map; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.ItemID; -@Getter +@Getter(AccessLevel.PUBLIC) public enum Pet { // GWD Pets @@ -46,7 +47,7 @@ public enum Pet private final String[] bossNames; private static final Map byBossName = buildBossMap(); - Pet(int id, String... bossNames) + Pet(final int id, final String... bossNames) { this.petID = id; this.bossNames = bossNames; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/UniqueItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/UniqueItem.java index 959327e293..d15a980420 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/UniqueItem.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/data/UniqueItem.java @@ -30,12 +30,13 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import java.util.stream.Collectors; +import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; import net.runelite.api.ItemID; @RequiredArgsConstructor -@Getter +@Getter(AccessLevel.PUBLIC) public enum UniqueItem { // Shared "Uniques" (Dropped by multiple activities) @@ -828,7 +829,7 @@ public enum UniqueItem HERBI("Herbi", ItemID.HERBI, "Herbiboar", "Pet", -1); // Shared Unique Items - UniqueItem(String n, int id, String... activities) + UniqueItem(final String n, final int id, final String... activities) { this.name = n; this.itemID = id; @@ -838,7 +839,7 @@ public enum UniqueItem } // Non-Shared Unique Items - UniqueItem(String n, int id, String a, String set, int position) + UniqueItem(final String n, final int id, final String a, final String set, final int position) { this.name = n; this.itemID = id; @@ -886,7 +887,7 @@ public enum UniqueItem String[] activities = item.getActivities(); for (String activity : activities) { - byName.computeIfAbsent(activity.toUpperCase(), e -> new ArrayList()).add(item); + byName.computeIfAbsent(activity.toUpperCase(), e -> new ArrayList<>()).add(item); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/ItemPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/ItemPanel.java index 4199f3b44b..b7e01d00a8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/ItemPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/ItemPanel.java @@ -30,12 +30,14 @@ import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; +import javax.inject.Singleton; import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.client.game.ItemManager; import net.runelite.client.plugins.stonedloottracker.data.LootTrackerItemEntry; @@ -44,7 +46,8 @@ import net.runelite.client.ui.FontManager; import net.runelite.client.ui.components.shadowlabel.JShadowedLabel; import net.runelite.client.util.StackFormatter; -@Getter +@Singleton +@Getter(AccessLevel.PACKAGE) class ItemPanel extends JPanel { private static final GridBagLayout LAYOUT = new GridBagLayout(); @@ -57,7 +60,7 @@ class ItemPanel extends JPanel private LootTrackerItemEntry record; - ItemPanel(LootTrackerItemEntry record, ItemManager itemManager) + ItemPanel(final LootTrackerItemEntry record, final ItemManager itemManager) { this.record = record; this.setLayout(LAYOUT); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/LootGrid.java b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/LootGrid.java index b5ee9a7449..0af19c077c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/LootGrid.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/LootGrid.java @@ -28,6 +28,7 @@ import java.awt.Dimension; import java.awt.GridLayout; import java.util.ArrayList; import java.util.Arrays; +import javax.inject.Singleton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; @@ -37,6 +38,7 @@ import net.runelite.client.plugins.stonedloottracker.data.LootTrackerItemEntry; import net.runelite.client.ui.ColorScheme; import net.runelite.client.util.StackFormatter; +@Singleton class LootGrid extends JPanel { private static final int ITEMS_PER_ROW = 5; @@ -44,7 +46,7 @@ class LootGrid extends JPanel private final LootTrackerItemEntry[] itemsToDisplay; private ItemManager itemManager; - LootGrid(LootTrackerItemEntry[] itemsToDisplay, ItemManager itemManager) + LootGrid(final LootTrackerItemEntry[] itemsToDisplay, final ItemManager itemManager) { this.itemsToDisplay = itemsToDisplay; this.itemManager = itemManager; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/LootPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/LootPanel.java index c89adcaafb..089eda28d0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/LootPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/LootPanel.java @@ -35,6 +35,7 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import javax.inject.Singleton; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.border.EmptyBorder; @@ -48,6 +49,7 @@ import net.runelite.client.plugins.stonedloottracker.data.UniqueItemPrepared; import net.runelite.client.ui.ColorScheme; @Slf4j +@Singleton class LootPanel extends JPanel { private Collection records; @@ -63,7 +65,7 @@ class LootPanel extends JPanel private boolean playbackPlaying = false; private boolean cancelPlayback = false; - LootPanel(Collection records, Map> uniqueMap, boolean hideUnqiues, ItemSortTypes sort, boolean itemBreakdown, ItemManager itemManager) + LootPanel(final Collection records, final Map> uniqueMap, final boolean hideUnqiues, final ItemSortTypes sort, final boolean itemBreakdown, final ItemManager itemManager) { this.records = (records == null ? new ArrayList<>() : records); this.uniqueMap = (uniqueMap == null ? new HashMap<>() : uniqueMap); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/LootTrackerBox.java b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/LootTrackerBox.java index 1b6083505d..da69419947 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/LootTrackerBox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/LootTrackerBox.java @@ -33,6 +33,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; import javax.annotation.Nullable; +import javax.inject.Singleton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; @@ -47,7 +48,8 @@ import net.runelite.client.ui.FontManager; import net.runelite.client.util.StackFormatter; import net.runelite.client.util.Text; -@Getter +@Singleton +@Getter(AccessLevel.PACKAGE) class LootTrackerBox extends JPanel { private static final int ITEMS_PER_ROW = 5; @@ -58,7 +60,7 @@ class LootTrackerBox extends JPanel @Getter(AccessLevel.PACKAGE) private final String id; - @Getter + @Getter(AccessLevel.PACKAGE) private final List records = new ArrayList<>(); private long totalPrice; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/LootTrackerPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/LootTrackerPanel.java index 50af60e653..6ce3b3cad5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/LootTrackerPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/LootTrackerPanel.java @@ -37,6 +37,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import javax.imageio.ImageIO; +import javax.inject.Singleton; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JOptionPane; @@ -56,6 +57,7 @@ import net.runelite.client.ui.PluginPanel; import net.runelite.client.ui.components.PluginErrorPanel; @Slf4j +@Singleton public class LootTrackerPanel extends PluginPanel { private static final BufferedImage ICON_DELETE; @@ -99,7 +101,7 @@ public class LootTrackerPanel extends PluginPanel private final ItemManager itemManager; private final StonedLootTrackerPlugin plugin; - public LootTrackerPanel(final ItemManager itemManager, StonedLootTrackerPlugin plugin) + public LootTrackerPanel(final ItemManager itemManager, final StonedLootTrackerPlugin plugin) { super(false); this.itemManager = itemManager; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/SelectionPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/SelectionPanel.java index 37acb992e0..f6e9141a3b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/SelectionPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/SelectionPanel.java @@ -36,6 +36,7 @@ import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.Set; import java.util.TreeSet; +import javax.inject.Singleton; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; @@ -49,7 +50,8 @@ import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.components.materialtabs.MaterialTab; import net.runelite.client.ui.components.materialtabs.MaterialTabGroup; -public class SelectionPanel extends JPanel +@Singleton +class SelectionPanel extends JPanel { private TreeSet names; private LootTrackerPanel parent; @@ -61,7 +63,7 @@ public class SelectionPanel extends JPanel private boolean configToggle; - SelectionPanel(boolean configToggle, TreeSet names, LootTrackerPanel parent, ItemManager itemManager) + SelectionPanel(final boolean configToggle, final TreeSet names, final LootTrackerPanel parent, final ItemManager itemManager) { this.names = names == null ? new TreeSet<>() : names; this.parent = parent; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/TextPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/TextPanel.java index 38529cce86..e05caac244 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/TextPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/TextPanel.java @@ -28,17 +28,20 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; +import javax.inject.Singleton; import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.client.ui.ColorScheme; import net.runelite.client.util.StackFormatter; -@Getter +@Singleton +@Getter(AccessLevel.PACKAGE) class TextPanel extends JPanel { private static final GridBagLayout LAYOUT = new GridBagLayout(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/UniqueItemPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/UniqueItemPanel.java index e5a4c38721..0bb4824668 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/UniqueItemPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stonedloottracker/ui/UniqueItemPanel.java @@ -32,12 +32,14 @@ import java.awt.GridBagLayout; import java.awt.image.BufferedImage; import java.util.Collection; import java.util.Map; +import javax.inject.Singleton; 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.EmptyBorder; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.client.game.AsyncBufferedImage; import net.runelite.client.game.ItemManager; @@ -46,7 +48,8 @@ import net.runelite.client.ui.ColorScheme; import net.runelite.client.util.ImageUtil; import net.runelite.client.util.StackFormatter; -@Getter +@Singleton +@Getter(AccessLevel.PACKAGE) class UniqueItemPanel extends JPanel { private ItemManager itemManager; @@ -58,7 +61,7 @@ class UniqueItemPanel extends JPanel private static final Border panelBorder = new EmptyBorder(3, 0, 3, 0); private static final Color panelBackgroundColor = ColorScheme.DARK_GRAY_COLOR; - UniqueItemPanel(Collection items, Map uniqueMap, ItemManager itemManager) + UniqueItemPanel(final Collection items, final Map uniqueMap, final ItemManager itemManager) { this.itemManager = itemManager; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stretchedmode/StretchedModePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/stretchedmode/StretchedModePlugin.java index cbaceb550b..1d57cdb4ee 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stretchedmode/StretchedModePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stretchedmode/StretchedModePlugin.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.stretchedmode; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ResizeableChanged; @@ -42,6 +43,7 @@ import net.runelite.client.plugins.PluginDescriptor; tags = {"resize", "ui", "interface", "stretch", "scaling", "fixed"}, enabledByDefault = false ) +@Singleton public class StretchedModePlugin extends Plugin { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stretchedmode/TranslateMouseListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/stretchedmode/TranslateMouseListener.java index 4720dbe98f..c2093cb32b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stretchedmode/TranslateMouseListener.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stretchedmode/TranslateMouseListener.java @@ -29,15 +29,17 @@ import java.awt.Component; import java.awt.Dimension; import java.awt.event.MouseEvent; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.client.input.MouseListener; +@Singleton public class TranslateMouseListener implements MouseListener { private final Client client; @Inject - public TranslateMouseListener(Client client) + public TranslateMouseListener(final Client client) { this.client = client; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/stretchedmode/TranslateMouseWheelListener.java b/runelite-client/src/main/java/net/runelite/client/plugins/stretchedmode/TranslateMouseWheelListener.java index 2fdd39ec03..e204be23cc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/stretchedmode/TranslateMouseWheelListener.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/stretchedmode/TranslateMouseWheelListener.java @@ -29,15 +29,17 @@ import java.awt.Component; import java.awt.Dimension; import java.awt.event.MouseWheelEvent; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.client.input.MouseWheelListener; +@Singleton public class TranslateMouseWheelListener implements MouseWheelListener { private final Client client; @Inject - public TranslateMouseWheelListener(Client client) + public TranslateMouseWheelListener(final Client client) { this.client = client; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/BlowpipeDartType.java b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/BlowpipeDartType.java index 5ab1a31652..1d625ea7e3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/BlowpipeDartType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/BlowpipeDartType.java @@ -24,6 +24,7 @@ */ package net.runelite.client.plugins.suppliestracker; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import static net.runelite.api.ItemID.ADAMANT_DART; @@ -45,7 +46,7 @@ public enum BlowpipeDartType ADAMANT(ADAMANT_DART), RUNE(RUNE_DART), DRAGON(DRAGON_DART); - @Getter + @Getter(AccessLevel.PACKAGE) private int dartID; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/ItemType.java b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/ItemType.java index 56887d9837..692b8a6233 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/ItemType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/ItemType.java @@ -25,6 +25,7 @@ */ package net.runelite.client.plugins.suppliestracker; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @@ -41,7 +42,7 @@ public enum ItemType AMMO("Ammo"), TELEPORT("Teleports"); - @Getter + @Getter(AccessLevel.PACKAGE) private String label; /** diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/MenuAction.java b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/MenuAction.java index 76c83d1bb6..3decf36460 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/MenuAction.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/MenuAction.java @@ -24,6 +24,7 @@ */ package net.runelite.client.plugins.suppliestracker; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.Item; @@ -34,20 +35,20 @@ import net.runelite.api.Item; @AllArgsConstructor public class MenuAction { - @Getter + @Getter(AccessLevel.PACKAGE) private ActionType type; - @Getter + @Getter(AccessLevel.PACKAGE) private Item[] oldInventory; static class ItemAction extends MenuAction { - @Getter + @Getter(AccessLevel.PACKAGE) private int itemID; - @Getter + @Getter(AccessLevel.PACKAGE) private int slot; - ItemAction(ActionType type, Item[] oldInventory, int itemID, int slot) + ItemAction(final ActionType type, final Item[] oldInventory, final int itemID, final int slot) { super(type, oldInventory); this.itemID = itemID; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesBox.java b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesBox.java index ee4788a3ce..b5ef601ced 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesBox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesBox.java @@ -30,6 +30,7 @@ import java.awt.Color; import java.awt.GridLayout; import java.util.ArrayList; import java.util.List; +import javax.inject.Singleton; import javax.swing.JLabel; import javax.swing.JMenuItem; import javax.swing.JPanel; @@ -78,6 +79,7 @@ import net.runelite.client.util.StackFormatter; import net.runelite.client.util.Text; import net.runelite.http.api.item.ItemPrice; +@Singleton class SuppliesBox extends JPanel { private static final int ITEMS_PER_ROW = 5; @@ -91,12 +93,12 @@ class SuppliesBox extends JPanel private final SuppliesTrackerPlugin plugin; private final SuppliesTrackerPanel panel; - @Getter + @Getter(AccessLevel.PACKAGE) private final List trackedItems = new ArrayList<>(); private long totalPrice; - @Getter + @Getter(AccessLevel.PACKAGE) private final ItemType type; SuppliesBox(final ItemManager itemManager, final String id, diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerItem.java b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerItem.java index 4333d77c8f..5347945d00 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerItem.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerItem.java @@ -24,18 +24,16 @@ */ package net.runelite.client.plugins.suppliestracker; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; +@Getter(AccessLevel.PACKAGE) @AllArgsConstructor class SuppliesTrackerItem { - @Getter private int id; - @Getter private String name; - @Getter private int quantity; - @Getter private long price; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerPanel.java index da19cc4842..088d2421b5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/suppliestracker/SuppliesTrackerPanel.java @@ -31,6 +31,7 @@ import java.awt.GridLayout; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; +import javax.inject.Singleton; import javax.swing.BoxLayout; import javax.swing.ImageIcon; import javax.swing.JLabel; @@ -46,7 +47,7 @@ import net.runelite.client.ui.components.PluginErrorPanel; import net.runelite.client.util.ColorUtil; import net.runelite.client.util.StackFormatter; - +@Singleton class SuppliesTrackerPanel extends PluginPanel { private static final String HTML_LABEL_TEMPLATE = 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 3731f6df9a..3fc78a6532 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 @@ -38,6 +38,7 @@ import java.util.List; import java.util.Random; import java.util.regex.Pattern; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.SwingUtilities; import lombok.extern.slf4j.Slf4j; import static net.runelite.api.AnimationID.BLOWPIPE_ATTACK; @@ -184,7 +185,7 @@ import net.runelite.http.api.item.ItemPrice; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton @Slf4j public class SuppliesTrackerPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tarnslair/TarnsLairOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/tarnslair/TarnsLairOverlay.java index e7ed05731e..01670c2fdf 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tarnslair/TarnsLairOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tarnslair/TarnsLairOverlay.java @@ -29,6 +29,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Polygon; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.coords.LocalPoint; @@ -36,6 +37,7 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; +@Singleton @Slf4j public class TarnsLairOverlay extends Overlay { @@ -45,7 +47,7 @@ public class TarnsLairOverlay extends Overlay private final TarnsLairPlugin plugin; @Inject - public TarnsLairOverlay(Client client, TarnsLairPlugin plugin) + public TarnsLairOverlay(final Client client, final TarnsLairPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tarnslair/TarnsLairPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/tarnslair/TarnsLairPlugin.java index b6dd13f6ad..afe425a8d9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tarnslair/TarnsLairPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tarnslair/TarnsLairPlugin.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.tarnslair; import java.util.HashMap; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -54,7 +55,7 @@ import net.runelite.client.ui.overlay.OverlayManager; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton @Slf4j public class TarnsLairPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/teamcapes/TeamCapesOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/teamcapes/TeamCapesOverlay.java index 9dbd2dc861..21e4ed2606 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/teamcapes/TeamCapesOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/teamcapes/TeamCapesOverlay.java @@ -28,6 +28,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.ItemID; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.client.game.ItemManager; @@ -40,6 +41,7 @@ import net.runelite.client.ui.overlay.components.ComponentOrientation; import net.runelite.client.ui.overlay.components.ImageComponent; import net.runelite.client.ui.overlay.components.PanelComponent; +@Singleton public class TeamCapesOverlay extends Overlay { private final PanelComponent panelComponent = new PanelComponent(); @@ -48,7 +50,7 @@ public class TeamCapesOverlay extends Overlay private final ItemManager manager; @Inject - private TeamCapesOverlay(TeamCapesPlugin plugin, TeamCapesConfig config, ItemManager manager) + private TeamCapesOverlay(final TeamCapesPlugin plugin, final TeamCapesConfig config, final ItemManager manager) { super(plugin); setPosition(OverlayPosition.TOP_LEFT); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/teamcapes/TeamCapesPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/teamcapes/TeamCapesPlugin.java index 61d283cbfd..f2a25b57ad 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/teamcapes/TeamCapesPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/teamcapes/TeamCapesPlugin.java @@ -33,6 +33,7 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.Player; @@ -48,6 +49,7 @@ import net.runelite.client.ui.overlay.OverlayManager; tags = {"overlay", "players"}, enabledByDefault = false ) +@Singleton public class TeamCapesPlugin extends Plugin { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tearsofguthix/TearsOfGuthixExperienceOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/tearsofguthix/TearsOfGuthixExperienceOverlay.java index b702556f5f..9f5669f4db 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tearsofguthix/TearsOfGuthixExperienceOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tearsofguthix/TearsOfGuthixExperienceOverlay.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.tearsofguthix; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; @@ -36,6 +37,7 @@ import java.awt.Graphics2D; import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; +@Singleton class TearsOfGuthixExperienceOverlay extends Overlay { private final TearsOfGuthixPlugin plugin; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tearsofguthix/TearsOfGuthixOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/tearsofguthix/TearsOfGuthixOverlay.java index 4c1a5569fc..be546772ab 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tearsofguthix/TearsOfGuthixOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tearsofguthix/TearsOfGuthixOverlay.java @@ -30,12 +30,14 @@ import java.awt.Graphics2D; import java.time.Duration; import java.time.Instant; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Point; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.components.ProgressPieComponent; +@Singleton class TearsOfGuthixOverlay extends Overlay { private static final Color CYAN_ALPHA = new Color(Color.CYAN.getRed(), Color.CYAN.getGreen(), Color.CYAN.getBlue(), 100); @@ -43,7 +45,7 @@ class TearsOfGuthixOverlay extends Overlay private final TearsOfGuthixPlugin plugin; @Inject - private TearsOfGuthixOverlay(TearsOfGuthixPlugin plugin) + private TearsOfGuthixOverlay(final TearsOfGuthixPlugin plugin) { this.plugin = plugin; setPosition(OverlayPosition.DYNAMIC); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tearsofguthix/TearsOfGuthixPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/tearsofguthix/TearsOfGuthixPlugin.java index 9d2f1100aa..69c55e9f2f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tearsofguthix/TearsOfGuthixPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tearsofguthix/TearsOfGuthixPlugin.java @@ -28,6 +28,7 @@ import java.time.Instant; import java.util.HashMap; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Client; @@ -48,6 +49,7 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Show timers for the Tears Of Guthix streams", tags = {"minigame", "overlay", "skilling", "timers", "tog"} ) +@Singleton public class TearsOfGuthixPlugin extends Plugin { private static final int TOG_REGION = 12948; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/RoomHandler.java b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/RoomHandler.java index 3615d58f6d..0112708098 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/RoomHandler.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/RoomHandler.java @@ -5,7 +5,6 @@ import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Polygon; -import java.util.Iterator; import java.util.Map; import net.runelite.api.Client; import net.runelite.api.NPC; @@ -22,13 +21,11 @@ public abstract class RoomHandler protected final Client client; protected final TheatrePlugin plugin; - protected final TheatreConfig config; - public RoomHandler(Client client, TheatrePlugin plugin, TheatreConfig config) + public RoomHandler(final Client client, final TheatrePlugin plugin) { this.client = client; this.plugin = plugin; - this.config = config; } public abstract void onStart(); @@ -64,11 +61,8 @@ public abstract class RoomHandler protected void renderProjectiles(Graphics2D graphics, Map projectiles) { - - Iterator> itr = projectiles.entrySet().iterator(); - while (itr.hasNext()) + for (Map.Entry entry : projectiles.entrySet()) { - Map.Entry entry = itr.next(); int projectileId = entry.getKey().getId(); String text = entry.getValue(); int x = (int) entry.getKey().getX(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/TheatreOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/TheatreOverlay.java index e4dc6c2683..5237641000 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/TheatreOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/TheatreOverlay.java @@ -11,27 +11,21 @@ package net.runelite.client.plugins.theatre; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; -import net.runelite.api.Client; -import net.runelite.client.graphics.ModelOutlineRenderer; +import javax.inject.Singleton; 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 TheatreOverlay extends Overlay { - private final Client client; private final TheatrePlugin plugin; - private final TheatreConfig config; - private final ModelOutlineRenderer modelOutline; @Inject - private TheatreOverlay(Client client, TheatrePlugin plugin, TheatreConfig config, ModelOutlineRenderer modelOutline) + private TheatreOverlay(final TheatrePlugin plugin) { - this.client = client; this.plugin = plugin; - this.config = config; - this.modelOutline = modelOutline; setPosition(OverlayPosition.DYNAMIC); setPriority(OverlayPriority.HIGH); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/TheatrePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/TheatrePlugin.java index 2a08416e84..26238c416b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/TheatrePlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/TheatrePlugin.java @@ -13,6 +13,7 @@ import java.awt.Color; import java.util.LinkedList; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; @@ -54,7 +55,7 @@ import net.runelite.client.ui.overlay.OverlayManager; type = PluginType.PVM, enabledByDefault = false ) - +@Singleton @Slf4j public class TheatrePlugin extends Plugin { @@ -98,6 +99,59 @@ public class TheatrePlugin extends Plugin @Inject private ModelOutlineRenderer modelOutline; + @Getter + private boolean showMaidenBloodToss; + @Getter + private boolean showMaidenBloodSpawns; + @Getter + private boolean showNyloFreezeHighlights; + @Getter + private boolean showBloatIndicator; + @Getter + private boolean showBloatHands; + @Getter + private boolean BloatFeetIndicatorRaveEdition; + @Getter + private boolean showBloatTimer; + @Getter + private boolean showNyloPillarHealth; + @Getter + private TheatreConfig.NYLOOPTION showNylocasExplosions; + @Getter + private boolean showNylocasAmount; + @Getter + private boolean highlightNyloAgros; + @Getter + private boolean showSotetsegAttacks; + @Getter + private boolean showSotetsegMaze; + @Getter + private boolean showSotetsegSolo; + @Getter + private Color mazeTileColour; + @Getter + private boolean showXarpusHeals; + @Getter + private boolean showXarpusTick; + @Getter + private boolean showVerzikAttacks; + @Getter + private boolean showVerzikYellows; + @Getter + private boolean showCrabTargets; + @Getter + private boolean VerzikTankTile; + @Getter + private boolean verzikRangeAttacks; + @Getter + private boolean extraTimers; + @Getter + private boolean p1attacks; + @Getter + private boolean p2attacks; + @Getter + private boolean p3attacks; + @Provides TheatreConfig getConfig(ConfigManager configManager) { @@ -107,14 +161,16 @@ public class TheatrePlugin extends Plugin @Override protected void startUp() { + updateConfig(); + room = TheatreRoom.UNKNOWN; - maidenHandler = new MaidenHandler(client, this, config, modelOutline); - bloatHandler = new BloatHandler(client, this, config); - nyloHandler = new NyloHandler(client, this, config); - sotetsegHandler = new SotetsegHandler(client, this, config); - xarpusHandler = new XarpusHandler(client, this, config); - verzikHandler = new VerzikHandler(client, this, config); + maidenHandler = new MaidenHandler(client, this, modelOutline); + bloatHandler = new BloatHandler(client, this); + nyloHandler = new NyloHandler(client, this); + sotetsegHandler = new SotetsegHandler(client, this); + xarpusHandler = new XarpusHandler(client, this); + verzikHandler = new VerzikHandler(client, this); overlayManager.add(overlay); } @@ -406,6 +462,11 @@ public class TheatrePlugin extends Plugin @Subscribe public void onConfigChanged(ConfigChanged event) { + if (!event.getGroup().equals("Theatre")) + { + return; + } + if (nyloHandler != null) { nyloHandler.onConfigChanged(); @@ -439,4 +500,34 @@ public class TheatrePlugin extends Plugin verzikHandler.onProjectileMoved(event); } } + + private void updateConfig() + { + this.showMaidenBloodToss = config.showMaidenBloodToss(); + this.showMaidenBloodSpawns = config.showMaidenBloodSpawns(); + this.showNyloFreezeHighlights = config.showNyloFreezeHighlights(); + this.showBloatIndicator = config.showBloatIndicator(); + this.showBloatHands = config.showBloatHands(); + this.BloatFeetIndicatorRaveEdition = config.BloatFeetIndicatorRaveEdition(); + this.showBloatTimer = config.showBloatTimer(); + this.showNyloPillarHealth = config.showNyloPillarHealth(); + this.showNylocasExplosions = config.showNylocasExplosions(); + this.showNylocasAmount = config.showNylocasAmount(); + this.highlightNyloAgros = config.highlightNyloAgros(); + this.showSotetsegAttacks = config.showSotetsegAttacks(); + this.showSotetsegMaze = config.showSotetsegMaze(); + this.showSotetsegSolo = config.showSotetsegSolo(); + this.mazeTileColour = config.mazeTileColour(); + this.showXarpusHeals = config.showXarpusHeals(); + this.showXarpusTick = config.showXarpusTick(); + this.showVerzikAttacks = config.showVerzikAttacks(); + this.showVerzikYellows = config.showVerzikYellows(); + this.showCrabTargets = config.showCrabTargets(); + this.VerzikTankTile = config.VerzikTankTile(); + this.verzikRangeAttacks = config.verzikRangeAttacks(); + this.extraTimers = config.extraTimers(); + this.p1attacks = config.p1attacks(); + this.p2attacks = config.p2attacks(); + this.p3attacks = config.p3attacks(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/BloatHandler.java b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/BloatHandler.java index b62b979012..9bf1aaca87 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/BloatHandler.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/BloatHandler.java @@ -18,7 +18,6 @@ import net.runelite.api.events.NpcSpawned; import net.runelite.api.events.VarbitChanged; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.plugins.theatre.RoomHandler; -import net.runelite.client.plugins.theatre.TheatreConfig; import net.runelite.client.plugins.theatre.TheatrePlugin; import net.runelite.client.plugins.theatre.TheatreRoom; @@ -34,9 +33,9 @@ public class BloatHandler extends RoomHandler @Getter(AccessLevel.PUBLIC) private BloatState bloatState; - public BloatHandler(Client client, TheatrePlugin plugin, TheatreConfig config) + public BloatHandler(final Client client, final TheatrePlugin plugin) { - super(client, plugin, config); + super(client, plugin); } @Override @@ -76,7 +75,7 @@ public class BloatHandler extends RoomHandler return; } - if (config.showBloatIndicator()) + if (plugin.isShowBloatIndicator()) { switch (bloatState) { @@ -92,7 +91,7 @@ public class BloatHandler extends RoomHandler } } - if (config.showBloatHands()) + if (plugin.isShowBloatHands()) { for (GraphicsObject object : client.getGraphicsObjects()) { @@ -100,7 +99,7 @@ public class BloatHandler extends RoomHandler if (id >= 1560 && id <= 1590) { WorldPoint point = WorldPoint.fromLocal(client, object.getLocation()); - if (!config.BloatFeetIndicatorRaveEdition()) + if (!plugin.isBloatFeetIndicatorRaveEdition()) { drawTile(graphics, point, new Color(36, 248, 229), 2, 255, 10); } @@ -113,7 +112,7 @@ public class BloatHandler extends RoomHandler } } - if (config.showBloatTimer()) + if (plugin.isShowBloatTimer()) { final String tickCounter = String.valueOf(bloatTimer); int secondConversion = (int) (bloatTimer * .6); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/MaidenHandler.java b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/MaidenHandler.java index 68115623fa..d62bf8c8ea 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/MaidenHandler.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/MaidenHandler.java @@ -20,7 +20,6 @@ import net.runelite.api.events.NpcSpawned; import net.runelite.api.events.SpotAnimationChanged; import net.runelite.client.graphics.ModelOutlineRenderer; import net.runelite.client.plugins.theatre.RoomHandler; -import net.runelite.client.plugins.theatre.TheatreConfig; import net.runelite.client.plugins.theatre.TheatreConstant; import net.runelite.client.plugins.theatre.TheatrePlugin; import net.runelite.client.plugins.theatre.TheatreRoom; @@ -68,9 +67,9 @@ public class MaidenHandler extends RoomHandler private long startTime = 0; private ModelOutlineRenderer modelOutline; - public MaidenHandler(Client client, TheatrePlugin plugin, TheatreConfig config, ModelOutlineRenderer modelOutline) + public MaidenHandler(final Client client, final TheatrePlugin plugin, final ModelOutlineRenderer modelOutline) { - super(client, plugin, config); + super(client, plugin); this.modelOutline = modelOutline; } @@ -139,7 +138,7 @@ public class MaidenHandler extends RoomHandler } } - if (config.showMaidenBloodToss()) + if (plugin.isShowMaidenBloodToss()) { for (WorldPoint point : bloodThrows) { @@ -147,7 +146,7 @@ public class MaidenHandler extends RoomHandler } } - if (config.showMaidenBloodSpawns()) + if (plugin.isShowMaidenBloodSpawns()) { for (WorldPoint point : bloodSpawnLocation) { @@ -197,7 +196,7 @@ public class MaidenHandler extends RoomHandler maiden = npc; break; case "Nylocas Matomenos": - if (!config.showNyloFreezeHighlights()) + if (!plugin.isShowNyloFreezeHighlights()) { return; } @@ -327,7 +326,7 @@ public class MaidenHandler extends RoomHandler seconds = seconds % 60; int percentage = 70 - (20 * ((wave++) - 1)); - if (config.extraTimers()) + if (plugin.isExtraTimers()) { this.client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Wave 'The Maiden of Sugadinti - " + percentage + "%' completed! Duration: " + minutes + ":" + twoDigitString(seconds), null); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/Nylos.java b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/Nylos.java index 53469f3fe4..5429f016e7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/Nylos.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/Nylos.java @@ -1,5 +1,6 @@ package net.runelite.client.plugins.theatre.rooms; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; @@ -7,12 +8,12 @@ import net.runelite.api.NPC; class Nylos { - @Getter + @Getter(AccessLevel.PUBLIC) private NPC npc; - @Getter + @Getter(AccessLevel.PUBLIC) private int npcIndex; - @Getter - @Setter + @Getter(AccessLevel.PUBLIC) + @Setter(AccessLevel.PUBLIC) private SpawnLocation spawnLocation; Nylos(NPC npc, SpawnLocation spawnLocation) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/SotetsegHandler.java b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/SotetsegHandler.java index 13551b9ec4..6d0ccd8c03 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/SotetsegHandler.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/SotetsegHandler.java @@ -24,7 +24,6 @@ import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcSpawned; import net.runelite.api.events.ProjectileMoved; import net.runelite.client.plugins.theatre.RoomHandler; -import net.runelite.client.plugins.theatre.TheatreConfig; import net.runelite.client.plugins.theatre.TheatreConstant; import net.runelite.client.plugins.theatre.TheatrePlugin; import net.runelite.client.plugins.theatre.TheatreRoom; @@ -46,11 +45,10 @@ public class SotetsegHandler extends RoomHandler private List gridPath = new ArrayList<>(); private Map soteyProjectiles = new HashMap<>(); private NPC npc; - private long startTime = 0; - public SotetsegHandler(Client client, TheatrePlugin plugin, TheatreConfig config) + public SotetsegHandler(final Client client, final TheatrePlugin plugin) { - super(client, plugin, config); + super(client, plugin); } @Override @@ -76,7 +74,6 @@ public class SotetsegHandler extends RoomHandler public void reset() { - startTime = 0; npc = null; soteyProjectiles.clear(); redTiles.clear(); @@ -89,7 +86,7 @@ public class SotetsegHandler extends RoomHandler public void render(Graphics2D graphics) { - if (config.showSotetsegMaze()) + if (plugin.isShowSotetsegMaze()) { int i = 1; for (GroundObject o : redTiles.keySet()) @@ -98,7 +95,7 @@ public class SotetsegHandler extends RoomHandler if (poly != null) { - graphics.setColor(config.mazeTileColour()); + graphics.setColor(plugin.getMazeTileColour()); graphics.setStroke(new BasicStroke(2)); graphics.draw(poly); } @@ -113,15 +110,15 @@ public class SotetsegHandler extends RoomHandler } } - if (config.showSotetsegSolo()) + if (plugin.isShowSotetsegSolo()) { for (WorldPoint p : redOverworld) { - drawTile(graphics, p, config.mazeTileColour(), 2, 255, 10); + drawTile(graphics, p, plugin.getMazeTileColour(), 2, 255, 10); } } - if (config.showSotetsegAttacks()) + if (plugin.isShowSotetsegAttacks()) { Map projectileMap = new HashMap<>(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/VerzikHandler.java b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/VerzikHandler.java index 0f92345fa4..9c311a236c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/VerzikHandler.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/VerzikHandler.java @@ -25,7 +25,6 @@ import net.runelite.api.events.AnimationChanged; import net.runelite.api.events.NpcSpawned; import net.runelite.api.events.ProjectileMoved; import net.runelite.client.plugins.theatre.RoomHandler; -import net.runelite.client.plugins.theatre.TheatreConfig; import net.runelite.client.plugins.theatre.TheatreConstant; import net.runelite.client.plugins.theatre.TheatrePlugin; import net.runelite.client.plugins.theatre.TheatreRoom; @@ -43,15 +42,13 @@ public class VerzikHandler extends RoomHandler @Getter(AccessLevel.PUBLIC) private NPC npc; private int lastId = -1; - private int autosSinceYellows; private int yellows; private boolean tornados; - private int attackTick = -1; private long startTime = 0; - public VerzikHandler(Client client, TheatrePlugin plugin, TheatreConfig config) + public VerzikHandler(final Client client, final TheatrePlugin plugin) { - super(client, plugin, config); + super(client, plugin); } @Override @@ -83,7 +80,6 @@ public class VerzikHandler extends RoomHandler this.attacksLeft = 0; this.npc = null; this.yellows = 0; - this.autosSinceYellows = 0; this.lastId = -1; this.tornados = false; this.startTime = 0; @@ -97,19 +93,19 @@ public class VerzikHandler extends RoomHandler } int id = npc.getId(); - if (config.verzikRangeAttacks()) + if (plugin.isVerzikRangeAttacks()) { for (WorldPoint p : getVerzik_RangeProjectiles().values()) { drawTile(graphics, p, Color.RED, 2, 180, 50); } } - if (config.showVerzikAttacks()) + if (plugin.isShowVerzikAttacks()) { if (id == TheatreConstant.VERZIK_ID_P1) { - if (config.p1attacks()) + if (plugin.isP1attacks()) { if (this.versikCounter >= 0) { @@ -124,7 +120,7 @@ public class VerzikHandler extends RoomHandler } else if (id == TheatreConstant.VERZIK_ID_P2) { - if (config.p2attacks()) + if (plugin.isP2attacks()) { if (this.versikCounter >= 0) { @@ -140,7 +136,7 @@ public class VerzikHandler extends RoomHandler else if (id == TheatreConstant.VERZIK_ID_P3) { - if (config.p3attacks()) + if (plugin.isP3attacks()) { Model model = npc.getModel(); if (versikCounter > 0 && versikCounter < 8) @@ -156,7 +152,7 @@ public class VerzikHandler extends RoomHandler } } - if (config.VerzikTankTile()) + if (plugin.isVerzikTankTile()) { if (id == TheatreConstant.VERZIK_ID_P3) { @@ -167,7 +163,7 @@ public class VerzikHandler extends RoomHandler } - if (config.showVerzikYellows()) + if (plugin.isShowVerzikYellows()) { if (this.yellows > 0) { @@ -186,7 +182,7 @@ public class VerzikHandler extends RoomHandler } } - if (config.showCrabTargets()) + if (plugin.isShowCrabTargets()) { Player local = client.getLocalPlayer(); if (local != null && local.getName() != null) @@ -330,7 +326,6 @@ public class VerzikHandler extends RoomHandler { this.yellows = 14; // this.versikCounter = 22; - this.autosSinceYellows = 0; System.out.println("Yellows have spawned."); break; } @@ -400,7 +395,7 @@ public class VerzikHandler extends RoomHandler long minutes = seconds / 60L; seconds = seconds % 60; - if (config.extraTimers()) + if (plugin.isExtraTimers()) { this.client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Wave 'The Final Challenge - Part 1' completed! Duration: " + minutes + ":" + twoDigitString(seconds), null); } @@ -413,10 +408,10 @@ public class VerzikHandler extends RoomHandler long minutes = seconds / 60L; seconds = seconds % 60; - this.attackTick = this.client.getTickCount() - 4; + int attackTick = this.client.getTickCount() - 4; this.versikCounter = -1; this.attacksLeft = 9; - if (config.extraTimers()) + if (plugin.isExtraTimers()) { this.client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Wave 'The Final Challenge - Part 2' completed! Duration: " + minutes + ":" + twoDigitString(seconds), null); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/nylocas/NyloHandler.java b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/nylocas/NyloHandler.java index 4ff3c17ae7..46dc3bf122 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/nylocas/NyloHandler.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/nylocas/NyloHandler.java @@ -25,7 +25,6 @@ import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcSpawned; import net.runelite.client.plugins.theatre.RoomHandler; -import net.runelite.client.plugins.theatre.TheatreConfig; import net.runelite.client.plugins.theatre.TheatreConstant; import net.runelite.client.plugins.theatre.TheatrePlugin; import net.runelite.client.plugins.theatre.TheatreRoom; @@ -41,8 +40,8 @@ public class NyloHandler extends RoomHandler private Map pillars = new HashMap<>(); @Getter(AccessLevel.PUBLIC) private Map spiders = new HashMap<>(); - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private int wave = 0; private NyloOverlay overlay = null; private NyloPredictor predictor = null; @@ -50,9 +49,9 @@ public class NyloHandler extends RoomHandler private Point west = new Point(49, 56); private Point east = new Point(78, 56); - public NyloHandler(Client client, TheatrePlugin plugin, TheatreConfig config) + public NyloHandler(final Client client, final TheatrePlugin plugin) { - super(client, plugin, config); + super(client, plugin); } @Override @@ -66,9 +65,9 @@ public class NyloHandler extends RoomHandler this.reset(); this.plugin.setRoom(TheatreRoom.NYLOCAS); - if (overlay == null && config.showNylocasAmount()) + if (overlay == null && plugin.isShowNylocasAmount()) { - overlay = new NyloOverlay(client, plugin, config, this); + overlay = new NyloOverlay(client, plugin, this); plugin.getOverlayManager().add(overlay); } @@ -100,7 +99,7 @@ public class NyloHandler extends RoomHandler if (this.startTime != 0) { - if (config.extraTimers()) + if (plugin.isExtraTimers()) { this.client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Wave 'The Nylocas - Waves' completed! Duration: " + minutes + ":" + twoDigitString(seconds), null); } @@ -128,12 +127,12 @@ public class NyloHandler extends RoomHandler return; } - if (overlay == null && config.showNylocasAmount()) + if (overlay == null && plugin.isShowNylocasAmount()) { - overlay = new NyloOverlay(client, plugin, config, this); + overlay = new NyloOverlay(client, plugin, this); plugin.getOverlayManager().add(overlay); } - else if (overlay != null && !config.showNylocasAmount()) + else if (overlay != null && !plugin.isShowNylocasAmount()) { plugin.getOverlayManager().remove(overlay); overlay = null; @@ -148,14 +147,13 @@ public class NyloHandler extends RoomHandler double rMod = 130.0 * health / 100.0; double gMod = 255.0 * health / 100.0; double bMod = 125.0 * health / 100.0; - Color c = new Color((int) (255 - rMod), (int) (0 + gMod), (int) (0 + bMod)); - return c; + return new Color((int) (255 - rMod), (int) (0 + gMod), (int) (0 + bMod)); } public void render(Graphics2D graphics) { - if (config.showNyloPillarHealth()) + if (plugin.isShowNyloPillarHealth()) { for (NPC npc : pillars.keySet()) { @@ -170,7 +168,7 @@ public class NyloHandler extends RoomHandler } } - switch (config.showNylocasExplosions()) + switch (plugin.getShowNylocasExplosions()) { case TILE: for (NPC npc : spiders.keySet()) @@ -202,11 +200,11 @@ public class NyloHandler extends RoomHandler break; } - Set toHighlight = new HashSet(); + Set toHighlight = new HashSet<>(); - if (config.highlightNyloAgros()) + if (plugin.isHighlightNyloAgros()) { - for (NPC npc : new ArrayList(this.waveAgros)) + for (NPC npc : new ArrayList<>(this.waveAgros)) { try { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/nylocas/NyloOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/nylocas/NyloOverlay.java index 9c57485f26..e6cc1324eb 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/nylocas/NyloOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/nylocas/NyloOverlay.java @@ -30,7 +30,6 @@ import java.awt.Graphics2D; import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.api.NPC; -import net.runelite.client.plugins.theatre.TheatreConfig; import net.runelite.client.plugins.theatre.TheatrePlugin; import net.runelite.client.plugins.theatre.TheatreRoom; import net.runelite.client.ui.overlay.Overlay; @@ -53,7 +52,7 @@ class NyloOverlay extends Overlay private NyloHandler nylohandler; - NyloOverlay(Client client, TheatrePlugin plugin, TheatreConfig config, NyloHandler nylohandler) + NyloOverlay(final Client client, final TheatrePlugin plugin, final NyloHandler nylohandler) { super(plugin); @@ -84,17 +83,17 @@ class NyloOverlay extends Overlay String name = npc.getName(); if (name != null) { - if (name.equals("Nylocas Hagios")) + switch (name) { - hagios++; - } - else if (name.equals("Nylocas Toxobolos")) - { - toxobolos++; - } - else if (name.equals("Nylocas Ischyros")) - { - ischyros++; + case "Nylocas Hagios": + hagios++; + break; + case "Nylocas Toxobolos": + toxobolos++; + break; + case "Nylocas Ischyros": + ischyros++; + break; } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/nylocas/NyloPredictor.java b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/nylocas/NyloPredictor.java index b9d3e19b44..b0a9720e96 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/nylocas/NyloPredictor.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/nylocas/NyloPredictor.java @@ -376,8 +376,7 @@ public class NyloPredictor { if ((currentIndex + 1) < NYLOCAS_WAVES.length) { - Wave nextWave = NYLOCAS_WAVES[currentIndex + 1]; - return nextWave; + return NYLOCAS_WAVES[currentIndex + 1]; } else { @@ -393,7 +392,7 @@ public class NyloPredictor } else { - String types = ""; + StringBuilder types = new StringBuilder(); for (Nylocas nylo : wave.getSpawns()) { @@ -401,34 +400,34 @@ public class NyloPredictor { if (types.length() > 0) { - types += ", "; + types.append(", "); } switch (nylo.getType()) { case MAGE_162: - types += "Small Mage"; + types.append("Small Mage"); break; case MAGE_260: - types += "Big Mage"; + types.append("Big Mage"); break; case MELEE_162: - types += "Small Melee"; + types.append("Small Melee"); break; case MELEE_260: - types += "Big Melee"; + types.append("Big Melee"); break; case RANGE_162: - types += "Small Range"; + types.append("Small Range"); break; case RANGE_260: - types += "Big Range"; + types.append("Big Range"); break; } } } - return types.length() > 0 ? types : null; + return types.length() > 0 ? types.toString() : null; } } @@ -474,7 +473,7 @@ public class NyloPredictor @Override public boolean equals(Object object) { - if (object != null && (object instanceof Nylocas)) + if ((object instanceof Nylocas)) { Nylocas nylo = (Nylocas) object; return nylo.getType() == this.type && nylo.getSpawn() == this.spawn; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/xarpus/XarpusCounter.java b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/xarpus/XarpusCounter.java index 2be0d90109..73772c40e6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/xarpus/XarpusCounter.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/xarpus/XarpusCounter.java @@ -3,9 +3,7 @@ package net.runelite.client.plugins.theatre.rooms.xarpus; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; -import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; -import net.runelite.client.plugins.theatre.TheatreConfig; import net.runelite.client.plugins.theatre.TheatrePlugin; import net.runelite.client.ui.overlay.Overlay; import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE; @@ -18,20 +16,13 @@ import net.runelite.client.ui.overlay.components.table.TableComponent; public class XarpusCounter extends Overlay { - - private final Client client; - private final TheatrePlugin plugin; - private final TheatreConfig config; - PanelComponent panelComponent = new PanelComponent(); + private PanelComponent panelComponent = new PanelComponent(); private XarpusHandler xarpusHandler; - public XarpusCounter(Client client, TheatrePlugin plugin, TheatreConfig config, XarpusHandler xarpushandler) + XarpusCounter(final TheatrePlugin plugin, final XarpusHandler xarpushandler) { super(plugin); - this.client = client; this.xarpusHandler = xarpushandler; - this.plugin = plugin; - this.config = config; setPosition(OverlayPosition.ABOVE_CHATBOX_RIGHT); getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Theatre xarpus overlay")); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/xarpus/XarpusHandler.java b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/xarpus/XarpusHandler.java index d2c278806e..94467d34f8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/xarpus/XarpusHandler.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/rooms/xarpus/XarpusHandler.java @@ -8,6 +8,7 @@ import java.awt.Polygon; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; @@ -23,7 +24,6 @@ import net.runelite.api.events.NpcDespawned; import net.runelite.api.events.NpcSpawned; import net.runelite.api.events.VarbitChanged; import net.runelite.client.plugins.theatre.RoomHandler; -import net.runelite.client.plugins.theatre.TheatreConfig; import net.runelite.client.plugins.theatre.TheatreConstant; import net.runelite.client.plugins.theatre.TheatrePlugin; import net.runelite.client.plugins.theatre.TheatreRoom; @@ -36,21 +36,21 @@ public class XarpusHandler extends RoomHandler private boolean staring; private int ticksUntilShoot = 8; - @Getter + @Getter(AccessLevel.PUBLIC) private NPC npc; private long startTime = 0; private boolean up = false; - @Getter + @Getter(AccessLevel.PUBLIC) private int exhumesCount; private boolean xarpusFlag; private XarpusCounter overlay = null; - public XarpusHandler(Client client, TheatrePlugin plugin, TheatreConfig config) + public XarpusHandler(final Client client, final TheatrePlugin plugin) { - super(client, plugin, config); + super(client, plugin); } @Override @@ -66,7 +66,7 @@ public class XarpusHandler extends RoomHandler if (overlay == null) { - overlay = new XarpusCounter(client, plugin, config, this); + overlay = new XarpusCounter(plugin, this); plugin.getOverlayManager().add(overlay); } @@ -121,7 +121,7 @@ public class XarpusHandler extends RoomHandler seconds = seconds % 60; this.ticksUntilShoot = 8; - if (config.extraTimers()) + if (plugin.isExtraTimers()) { this.client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Wave 'Xarpus - Recovery' completed! Duration: " + minutes + ":" + twoDigitString(seconds), null); } @@ -132,7 +132,7 @@ public class XarpusHandler extends RoomHandler renderTextLocation(graphics, ticksLeftStr, 12, Font.BOLD, Color.WHITE, canvasPoint); } - if (npc.getId() == NpcID.XARPUS_8339 && config.showXarpusHeals()) + if (npc.getId() == NpcID.XARPUS_8339 && plugin.isShowXarpusHeals()) { for (GroundObject o : exhumes.keySet()) { @@ -263,7 +263,7 @@ public class XarpusHandler extends RoomHandler long minutes = seconds / 60L; seconds = seconds % 60; - if (config.extraTimers()) + if (plugin.isExtraTimers()) { this.client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Wave 'Xarpus - Acid' completed! Duration: " + minutes + ":" + twoDigitString(seconds), null); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/timers/RoomTimer.java b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/timers/RoomTimer.java index 3a9c13252f..c01b81d990 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/theatre/timers/RoomTimer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/theatre/timers/RoomTimer.java @@ -27,7 +27,7 @@ public class RoomTimer extends Overlay @Inject - public RoomTimer(Client client, TheatrePlugin plugin) + public RoomTimer(final Client client, final TheatrePlugin plugin) { super(plugin); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/thieving/ThievingOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/thieving/ThievingOverlay.java index abd408abb4..dece27f927 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/thieving/ThievingOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/thieving/ThievingOverlay.java @@ -31,6 +31,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.text.DecimalFormat; import javax.inject.Inject; +import javax.inject.Singleton; import static net.runelite.api.AnimationID.BLOCK_UNARMED; import static net.runelite.api.AnimationID.PICKPOCKET_SUCCESS; import static net.runelite.api.AnimationID.THIEVING_STALL; @@ -44,6 +45,7 @@ import net.runelite.client.ui.overlay.components.TitleComponent; import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; +@Singleton public class ThievingOverlay extends Overlay { private static final DecimalFormat FORMAT = new DecimalFormat("#.#"); @@ -54,7 +56,7 @@ public class ThievingOverlay extends Overlay private final PanelComponent panelComponent = new PanelComponent(); @Inject - private ThievingOverlay(Client client, ThievingPlugin plugin, XpTrackerService xpTrackerService) + private ThievingOverlay(final Client client, final ThievingPlugin plugin, final XpTrackerService xpTrackerService) { setPosition(OverlayPosition.TOP_LEFT); this.client = client; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/thieving/ThievingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/thieving/ThievingPlugin.java index e1babf47fd..fa73e5b00f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/thieving/ThievingPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/thieving/ThievingPlugin.java @@ -29,11 +29,13 @@ package net.runelite.client.plugins.thieving; import java.time.Duration; import java.time.Instant; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import com.google.inject.Provides; import net.runelite.api.ChatMessageType; import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameTick; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; @@ -52,7 +54,7 @@ import net.runelite.client.ui.overlay.OverlayManager; type = PluginType.SKILLING, enabledByDefault = false ) - +@Singleton @PluginDependency(XpTrackerPlugin.class) public class ThievingPlugin extends Plugin { @@ -68,6 +70,8 @@ public class ThievingPlugin extends Plugin @Getter(AccessLevel.PACKAGE) private ThievingSession session; + private int statTimeout; + @Provides ThievingConfig getConfig(ConfigManager configManager) { @@ -77,6 +81,8 @@ public class ThievingPlugin extends Plugin @Override protected void startUp() throws Exception { + this.statTimeout = config.statTimeout(); + session = null; overlayManager.add(overlay); } @@ -91,12 +97,12 @@ public class ThievingPlugin extends Plugin @Subscribe public void onGameTick(GameTick gameTick) { - if (session == null || config.statTimeout() == 0) + if (session == null || this.statTimeout == 0) { return; } - Duration statTimeout = Duration.ofMinutes(config.statTimeout()); + Duration statTimeout = Duration.ofMinutes(this.statTimeout); Duration sinceCut = Duration.between(session.getLastTheivingAction(), Instant.now()); if (sinceCut.compareTo(statTimeout) >= 0) @@ -138,5 +144,16 @@ public class ThievingPlugin extends Plugin session.hasFailed(); } } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!"thieving".equals(event.getGroup())) + { + return; + } + + this.statTimeout = config.statTimeout(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/thieving/ThievingSession.java b/runelite-client/src/main/java/net/runelite/client/plugins/thieving/ThievingSession.java index 97cf75212f..967fd60cf4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/thieving/ThievingSession.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/thieving/ThievingSession.java @@ -30,7 +30,7 @@ import java.time.Instant; import lombok.AccessLevel; import lombok.Getter; -public class ThievingSession +class ThievingSession { @Getter(AccessLevel.PACKAGE) private Instant lastTheivingAction; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ticktimers/NPCContainer.java b/runelite-client/src/main/java/net/runelite/client/plugins/ticktimers/NPCContainer.java index 6edc06cead..f7a5b6ae42 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/ticktimers/NPCContainer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ticktimers/NPCContainer.java @@ -28,6 +28,7 @@ package net.runelite.client.plugins.ticktimers; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import java.awt.Color; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -39,7 +40,7 @@ import net.runelite.api.NPCDefinition; import net.runelite.api.NpcID; import net.runelite.api.Prayer; -@Getter +@Getter(AccessLevel.PACKAGE) class NPCContainer { private NPC npc; @@ -48,14 +49,14 @@ class NPCContainer private int npcSize; private ImmutableSet animations; private int attackSpeed; - @Setter + @Setter(AccessLevel.PACKAGE) private int ticksUntilAttack; - @Setter + @Setter(AccessLevel.PACKAGE) private Actor npcInteracting; - @Setter + @Setter(AccessLevel.PACKAGE) private AttackStyle attackStyle; - NPCContainer(NPC npc, int attackSpeed) + NPCContainer(final NPC npc, final int attackSpeed) { this.npc = npc; this.npcName = npc.getName(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ticktimers/TickTimersConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/ticktimers/TickTimersConfig.java index 58b0a346cd..c61c121a2d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/ticktimers/TickTimersConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ticktimers/TickTimersConfig.java @@ -24,6 +24,7 @@ package net.runelite.client.plugins.ticktimers; import java.awt.Font; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.client.config.Config; @@ -169,7 +170,7 @@ public interface TickTimersConfig extends Config return false; } - @Getter + @Getter(AccessLevel.PACKAGE) @AllArgsConstructor enum FontStyle { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ticktimers/TickTimersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/ticktimers/TickTimersPlugin.java index 2454e42a1e..25e09e077c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/ticktimers/TickTimersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ticktimers/TickTimersPlugin.java @@ -28,6 +28,7 @@ import java.util.Arrays; import java.util.HashSet; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -35,6 +36,7 @@ import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.NPC; import net.runelite.api.NpcID; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.NpcDespawned; @@ -54,7 +56,7 @@ import net.runelite.client.ui.overlay.OverlayManager; enabledByDefault = false, type = PluginType.PVM ) - +@Singleton @Slf4j public class TickTimersPlugin extends Plugin { @@ -78,6 +80,21 @@ public class TickTimersPlugin extends Plugin private Set npcContainer = new HashSet<>(); private boolean validRegion; + @Getter(AccessLevel.PACKAGE) + private boolean showPrayerWidgetHelper; + @Getter(AccessLevel.PACKAGE) + private boolean showHitSquares; + @Getter(AccessLevel.PACKAGE) + private boolean changeTickColor; + private boolean gwd; + private boolean dks; + @Getter(AccessLevel.PACKAGE) + private TickTimersConfig.FontStyle fontStyle; + @Getter(AccessLevel.PACKAGE) + private int textSize; + @Getter(AccessLevel.PACKAGE) + private boolean shadows; + @Provides TickTimersConfig getConfig(ConfigManager configManager) { @@ -87,6 +104,7 @@ public class TickTimersPlugin extends Plugin @Override public void startUp() { + updateConfig(); npcContainer.clear(); } @@ -147,7 +165,7 @@ public class TickTimersPlugin extends Plugin case NpcID.FLOCKLEADER_GEERIN: case NpcID.WINGMAN_SKREE: case NpcID.KREEARRA: - if (config.gwd()) + if (this.gwd) { npcContainer.add(new NPCContainer(npc, npcManager.getAttackSpeed(npc.getId()))); } @@ -155,7 +173,7 @@ public class TickTimersPlugin extends Plugin case NpcID.DAGANNOTH_REX: case NpcID.DAGANNOTH_SUPREME: case NpcID.DAGANNOTH_PRIME: - if (config.dks()) + if (this.dks) { npcContainer.add(new NPCContainer(npc, npcManager.getAttackSpeed(npc.getId()))); } @@ -238,4 +256,27 @@ public class TickTimersPlugin extends Plugin x -> x == ARMA_REGION || x == GENERAL_REGION || x == ZAMMY_REGION || x == SARA_REGION || x == WATERBITH_REGION ); } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!"TickTimers".equals(event.getGroup())) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.showPrayerWidgetHelper = config.showPrayerWidgetHelper(); + this.showHitSquares = config.showHitSquares(); + this.changeTickColor = config.changeTickColor(); + this.gwd = config.gwd(); + this.dks = config.dks(); + this.fontStyle = config.fontStyle(); + this.textSize = config.textSize(); + this.shadows = config.shadows(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/ticktimers/TimersOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/ticktimers/TimersOverlay.java index a07cf1bede..1b07158e7d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/ticktimers/TimersOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/ticktimers/TimersOverlay.java @@ -31,6 +31,7 @@ import java.awt.Graphics2D; import java.awt.Rectangle; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Point; import net.runelite.api.coords.WorldArea; @@ -41,18 +42,17 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton public class TimersOverlay extends Overlay { private TickTimersPlugin plugin; private Client client; - private TickTimersConfig config; @Inject - TimersOverlay(TickTimersPlugin plugin, Client client, TickTimersConfig config) + TimersOverlay(final TickTimersPlugin plugin, final Client client) { this.plugin = plugin; this.client = client; - this.config = config; setPosition(OverlayPosition.DYNAMIC); setPriority(OverlayPriority.HIGHEST); setLayer(OverlayLayer.ALWAYS_ON_TOP); @@ -72,7 +72,7 @@ public class TimersOverlay extends Overlay final List hitSquares = getHitSquares(npc.getNpc().getWorldLocation(), npc.getNpcSize(), 1, false); final NPCContainer.AttackStyle attackStyle = npc.getAttackStyle(); - if (config.showHitSquares() && attackStyle.getName().equals("Melee")) + if (plugin.isShowHitSquares() && attackStyle.getName().equals("Melee")) { for (WorldPoint p : hitSquares) { @@ -86,26 +86,26 @@ public class TimersOverlay extends Overlay } final String ticksLeftStr = String.valueOf(ticksLeft); - final int font = config.fontStyle().getFont(); - final boolean shadows = config.shadows(); + final int font = plugin.getFontStyle().getFont(); + final boolean shadows = plugin.isShadows(); Color color = (ticksLeft <= 1 ? Color.WHITE : attackStyle.getColor()); - if (!config.changeTickColor()) + if (!plugin.isChangeTickColor()) { color = attackStyle.getColor(); } final Point canvasPoint = npc.getNpc().getCanvasTextLocation(graphics, Integer.toString(ticksLeft), 0); - OverlayUtil.renderTextLocation(graphics, ticksLeftStr, config.textSize(), font, color, canvasPoint, shadows, 0); + OverlayUtil.renderTextLocation(graphics, ticksLeftStr, plugin.getTextSize(), font, color, canvasPoint, shadows, 0); - if (config.showPrayerWidgetHelper() && attackStyle.getPrayer() != null) + if (plugin.isShowPrayerWidgetHelper() && attackStyle.getPrayer() != null) { Rectangle bounds = OverlayUtil.renderPrayerOverlay(graphics, client, attackStyle.getPrayer(), color); if (bounds != null) { - renderTextLocation(graphics, ticksLeftStr, 16, config.fontStyle().getFont(), color, centerPoint(bounds), shadows); + renderTextLocation(graphics, ticksLeftStr, 16, plugin.getFontStyle().getFont(), color, centerPoint(bounds), shadows); } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tileindicators/TileIndicatorsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/tileindicators/TileIndicatorsConfig.java index 0d1022d92f..03bea0d0c1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tileindicators/TileIndicatorsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tileindicators/TileIndicatorsConfig.java @@ -35,9 +35,9 @@ public interface TileIndicatorsConfig extends Config { @Alpha @ConfigItem( - keyName = "highlightDestinationColor", - name = "Color of current destination highlighting", - description = "Configures the highlight color of current destination" + keyName = "highlightDestinationColor", + name = "Color of current destination highlighting", + description = "Configures the highlight color of current destination" ) default Color highlightDestinationColor() { @@ -45,9 +45,9 @@ public interface TileIndicatorsConfig extends Config } @ConfigItem( - keyName = "highlightDestinationTile", - name = "Highlight destination tile", - description = "Highlights tile player is walking to" + keyName = "highlightDestinationTile", + name = "Highlight destination tile", + description = "Highlights tile player is walking to" ) default boolean highlightDestinationTile() { @@ -56,9 +56,9 @@ public interface TileIndicatorsConfig extends Config @Alpha @ConfigItem( - keyName = "highlightCurrentColor", - name = "Color of current tile highlighting", - description = "Configures the highlight color of current tile position" + keyName = "highlightCurrentColor", + name = "Color of current tile highlighting", + description = "Configures the highlight color of current tile position" ) default Color highlightCurrentColor() { @@ -66,9 +66,9 @@ public interface TileIndicatorsConfig extends Config } @ConfigItem( - keyName = "highlightCurrentTile", - name = "Highlight current tile", - description = "Highlights tile player is on" + keyName = "highlightCurrentTile", + name = "Highlight current tile", + description = "Highlights tile player is on" ) default boolean highlightCurrentTile() { @@ -77,9 +77,9 @@ public interface TileIndicatorsConfig extends Config @Alpha @ConfigItem( - keyName = "highlightHoveredColor", - name = "Color of current hovered highlighting", - description = "Configures the highlight color of hovered tile" + keyName = "highlightHoveredColor", + name = "Color of current hovered highlighting", + description = "Configures the highlight color of hovered tile" ) default Color highlightHoveredColor() { @@ -87,9 +87,9 @@ public interface TileIndicatorsConfig extends Config } @ConfigItem( - keyName = "highlightHoveredTile", - name = "Highlight hovered tile", - description = "Highlights tile player is hovering with mouse" + keyName = "highlightHoveredTile", + name = "Highlight hovered tile", + description = "Highlights tile player is hovering with mouse" ) default boolean highlightHoveredTile() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tileindicators/TileIndicatorsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/tileindicators/TileIndicatorsOverlay.java index 938a842088..b7df67dd1a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tileindicators/TileIndicatorsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tileindicators/TileIndicatorsOverlay.java @@ -29,6 +29,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Polygon; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.coords.LocalPoint; @@ -39,16 +40,17 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton public class TileIndicatorsOverlay extends Overlay { private final Client client; - private final TileIndicatorsConfig config; + private final TileIndicatorsPlugin plugin; @Inject - private TileIndicatorsOverlay(Client client, TileIndicatorsConfig config) + private TileIndicatorsOverlay(final Client client, final TileIndicatorsPlugin plugin) { this.client = client; - this.config = config; + this.plugin = plugin; setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); setPriority(OverlayPriority.MED); @@ -57,21 +59,21 @@ public class TileIndicatorsOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (config.highlightHoveredTile()) + if (plugin.isHighlightHoveredTile()) { // If we have tile "selected" render it if (client.getSelectedSceneTile() != null) { - renderTile(graphics, client.getSelectedSceneTile().getLocalLocation(), config.highlightHoveredColor()); + renderTile(graphics, client.getSelectedSceneTile().getLocalLocation(), plugin.getHighlightHoveredColor()); } } - if (config.highlightDestinationTile()) + if (plugin.isHighlightDestinationTile()) { - renderTile(graphics, client.getLocalDestinationLocation(), config.highlightDestinationColor()); + renderTile(graphics, client.getLocalDestinationLocation(), plugin.getHighlightDestinationColor()); } - if (config.highlightCurrentTile()) + if (plugin.isHighlightCurrentTile()) { final WorldPoint playerPos = client.getLocalPlayer().getWorldLocation(); if (playerPos == null) @@ -85,7 +87,7 @@ public class TileIndicatorsOverlay extends Overlay return null; } - renderTile(graphics, playerPosLocal, config.highlightCurrentColor()); + renderTile(graphics, playerPosLocal, plugin.getHighlightCurrentColor()); } return null; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tileindicators/TileIndicatorsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/tileindicators/TileIndicatorsPlugin.java index 7347c8611e..9a41a6a35b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tileindicators/TileIndicatorsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tileindicators/TileIndicatorsPlugin.java @@ -25,8 +25,14 @@ package net.runelite.client.plugins.tileindicators; import com.google.inject.Provides; +import java.awt.Color; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; +import net.runelite.api.events.ConfigChanged; 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; @@ -37,6 +43,7 @@ import net.runelite.client.ui.overlay.OverlayManager; tags = {"highlight", "overlay"}, enabledByDefault = false ) +@Singleton public class TileIndicatorsPlugin extends Plugin { @Inject @@ -45,6 +52,22 @@ public class TileIndicatorsPlugin extends Plugin @Inject private TileIndicatorsOverlay overlay; + @Inject + private TileIndicatorsConfig config; + + @Getter(AccessLevel.PACKAGE) + private Color highlightDestinationColor; + @Getter(AccessLevel.PACKAGE) + private boolean highlightDestinationTile; + @Getter(AccessLevel.PACKAGE) + private Color highlightCurrentColor; + @Getter(AccessLevel.PACKAGE) + private boolean highlightCurrentTile; + @Getter(AccessLevel.PACKAGE) + private Color highlightHoveredColor; + @Getter(AccessLevel.PACKAGE) + private boolean highlightHoveredTile; + @Provides TileIndicatorsConfig provideConfig(ConfigManager configManager) { @@ -54,6 +77,7 @@ public class TileIndicatorsPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); overlayManager.add(overlay); } @@ -62,4 +86,25 @@ public class TileIndicatorsPlugin extends Plugin { overlayManager.remove(overlay); } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!"tileindicators".equals(event.getGroup())) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.highlightDestinationColor = config.highlightDestinationColor(); + this.highlightDestinationTile = config.highlightDestinationTile(); + this.highlightCurrentColor = config.highlightCurrentColor(); + this.highlightCurrentTile = config.highlightCurrentTile(); + this.highlightHoveredColor = config.highlightHoveredColor(); + this.highlightHoveredTile = config.highlightHoveredTile(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameIndicator.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameIndicator.java index b91f8c7080..6434ad8203 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameIndicator.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/GameIndicator.java @@ -45,7 +45,7 @@ enum GameIndicator private final int imageId; private final GameTimerImageType imageType; - GameIndicator(int imageId, GameTimerImageType idType, String description, String text, Color textColor) + GameIndicator(final int imageId, final GameTimerImageType idType, final String description, final String text, final Color textColor) { this.imageId = imageId; this.imageType = idType; @@ -54,7 +54,7 @@ enum GameIndicator this.textColor = textColor; } - GameIndicator(int imageId, GameTimerImageType idType, String description) + GameIndicator(final int imageId, final GameTimerImageType idType, final String description) { this(imageId, idType, description, "", null); } 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 dcd739fad6..53d957dcf3 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 @@ -30,6 +30,7 @@ package net.runelite.client.plugins.timers; import java.awt.image.BufferedImage; import java.time.Duration; import java.time.temporal.ChronoUnit; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.GraphicID; import net.runelite.api.ItemID; @@ -75,19 +76,19 @@ enum GameTimer ANTIPOISON(ItemID.ANTIPOISON4, GameTimerImageType.ITEM, "Antipoison"), ANTIVENOM(ItemID.ANTIVENOM4, GameTimerImageType.ITEM, "Anti-venom"); - @Getter + @Getter(AccessLevel.PACKAGE) private final Duration duration; - @Getter + @Getter(AccessLevel.PACKAGE) private final Integer graphicId; - @Getter + @Getter(AccessLevel.PACKAGE) private final String description; - @Getter + @Getter(AccessLevel.PACKAGE) private final boolean removedOnDeath; private final int imageId; private final GameTimerImageType imageType; - GameTimer(int imageId, GameTimerImageType idType, String description, Integer graphicId, long time, ChronoUnit unit, boolean removedOnDeath) + GameTimer(final int imageId, final GameTimerImageType idType, final String description, final Integer graphicId, final long time, final ChronoUnit unit, final boolean removedOnDeath) { this.description = description; this.graphicId = graphicId; @@ -97,22 +98,22 @@ enum GameTimer this.removedOnDeath = removedOnDeath; } - GameTimer(int imageId, GameTimerImageType idType, String description, long time, ChronoUnit unit, boolean removeOnDeath) + GameTimer(final int imageId, final GameTimerImageType idType, final String description, final long time, final ChronoUnit unit, final boolean removeOnDeath) { this(imageId, idType, description, null, time, unit, removeOnDeath); } - GameTimer(int imageId, GameTimerImageType idType, String description, Integer graphicId, long time, ChronoUnit unit) + GameTimer(final int imageId, final GameTimerImageType idType, final String description, final Integer graphicId, final long time, final ChronoUnit unit) { this(imageId, idType, description, graphicId, time, unit, false); } - GameTimer(int imageId, GameTimerImageType idType, String description, long time, ChronoUnit unit) + GameTimer(final int imageId, final GameTimerImageType idType, final String description, final long time, final ChronoUnit unit) { this(imageId, idType, description, null, time, unit, false); } - GameTimer(int imageId, GameTimerImageType idType, String description) + GameTimer(final int imageId, final GameTimerImageType idType, final String description) { this(imageId, idType, description, null, 1, ChronoUnit.MILLIS, false); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/IndicatorIndicator.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/IndicatorIndicator.java index 9af1716f4d..395fd7ba74 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/IndicatorIndicator.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/IndicatorIndicator.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.timers; import java.awt.Color; import java.awt.Image; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.client.plugins.Plugin; import net.runelite.client.ui.overlay.infobox.InfoBox; @@ -33,10 +34,10 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxPriority; public class IndicatorIndicator extends InfoBox { - @Getter + @Getter(AccessLevel.PACKAGE) private final GameIndicator indicator; - IndicatorIndicator(GameIndicator indicator, Image image, Plugin plugin) + IndicatorIndicator(final GameIndicator indicator, final Image image, final Plugin plugin) { super(image, plugin); this.indicator = indicator; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimerTimer.java b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimerTimer.java index 0a648a43f5..5d7ffa5762 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimerTimer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timers/TimerTimer.java @@ -35,14 +35,14 @@ class TimerTimer extends Timer { private final GameTimer timer; - TimerTimer(GameTimer timer, Plugin plugin, BufferedImage image) + TimerTimer(final GameTimer timer, final Plugin plugin, final BufferedImage image) { super(timer.getDuration().toMillis(), ChronoUnit.MILLIS, image, plugin); this.timer = timer; setPriority(InfoBoxPriority.MED); } - TimerTimer(GameTimer timer, int amount, Plugin plugin, BufferedImage image) + TimerTimer(final GameTimer timer, final int amount, final Plugin plugin, final BufferedImage image) { super(timer.getDuration().toMillis() * amount, ChronoUnit.MILLIS, image, plugin); this.timer = timer; 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 8ddf85f6a9..36071cacf2 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 @@ -30,6 +30,9 @@ import com.google.inject.Provides; import java.awt.image.BufferedImage; import java.util.regex.Pattern; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Actor; import net.runelite.api.AnimationID; @@ -118,6 +121,7 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager; tags = {"combat", "items", "magic", "potions", "prayer", "overlay", "abyssal", "sire"} ) @Slf4j +@Singleton public class TimersPlugin extends Plugin { private static final String ANTIFIRE_DRINK_MESSAGE = "You drink some of your antifire potion."; @@ -180,6 +184,26 @@ public class TimersPlugin extends Plugin @Inject private InfoBoxManager infoBoxManager; + + private boolean showHomeMinigameTeleports; + private boolean showAntiPoison; + private boolean showAntiFire; + private boolean showStamina; + private boolean showOverload; + private boolean showPrayerEnhance; + private boolean showCannon; + private boolean showMagicImbue; + private boolean showCharge; + private boolean showImbuedHeart; + private boolean showVengeance; + private boolean showVengeanceActive; + @Setter(AccessLevel.PACKAGE) + private boolean showTeleblock; + private boolean showFreezes; + private boolean showGodWarsAltar; + private boolean showSkull; + private boolean showStaffOfTheDead; + private boolean showAbyssalSireStun; @Provides TimersConfig getConfig(ConfigManager configManager) @@ -187,6 +211,12 @@ public class TimersPlugin extends Plugin return configManager.getConfig(TimersConfig.class); } + @Override + protected void startUp() throws Exception + { + updateConfig(); + } + @Override protected void shutDown() throws Exception { @@ -217,7 +247,7 @@ public class TimersPlugin extends Plugin lastRaidVarb = raidVarb; } - if (lastVengCooldownVarb != vengCooldownVarb && config.showVengeance()) + if (lastVengCooldownVarb != vengCooldownVarb && this.showVengeance) { if (vengCooldownVarb == 1) { @@ -231,7 +261,7 @@ public class TimersPlugin extends Plugin lastVengCooldownVarb = vengCooldownVarb; } - if (lastIsVengeancedVarb != isVengeancedVarb && config.showVengeanceActive()) + if (lastIsVengeancedVarb != isVengeancedVarb && this.showVengeanceActive) { if (isVengeancedVarb == 1) { @@ -261,7 +291,7 @@ public class TimersPlugin extends Plugin lastWildernessVarb = inWilderness; } - if (lastPoisonVarp != poisonVarp && config.showAntiPoison()) + if (lastPoisonVarp != poisonVarp && this.showAntiPoison) { if (nextPoisonTick - client.getTickCount() <= 0 || lastPoisonVarp == 0) { @@ -304,76 +334,83 @@ public class TimersPlugin extends Plugin @Subscribe public void onConfigChanged(ConfigChanged event) { - if (!config.showHomeMinigameTeleports()) + if (!event.getGroup().equals("timers")) + { + return; + } + + updateConfig(); + + if (!this.showHomeMinigameTeleports) { removeGameTimer(HOME_TELEPORT); removeGameTimer(MINIGAME_TELEPORT); } - if (!config.showAntiFire()) + if (!this.showAntiFire) { removeGameTimer(ANTIFIRE); removeGameTimer(EXANTIFIRE); removeGameTimer(SUPERANTIFIRE); } - if (!config.showStamina()) + if (!this.showStamina) { removeGameTimer(STAMINA); } - if (!config.showOverload()) + if (!this.showOverload) { removeGameTimer(OVERLOAD); removeGameTimer(OVERLOAD_RAID); } - if (!config.showPrayerEnhance()) + if (!this.showPrayerEnhance) { removeGameTimer(PRAYER_ENHANCE); } - if (!config.showCannon()) + if (!this.showCannon) { removeGameTimer(CANNON); } - if (!config.showMagicImbue()) + if (!this.showMagicImbue) { removeGameTimer(MAGICIMBUE); } - if (!config.showCharge()) + if (!this.showCharge) { removeGameTimer(CHARGE); } - if (!config.showImbuedHeart()) + if (!this.showImbuedHeart) { removeGameTimer(IMBUEDHEART); } - if (!config.showStaffOfTheDead()) + if (!this.showStaffOfTheDead) { removeGameTimer(STAFF_OF_THE_DEAD); } - if (!config.showVengeance()) + if (!this.showVengeance) { removeGameTimer(VENGEANCE); } - if (!config.showVengeanceActive()) + if (!this.showVengeanceActive) { removeGameIndicator(VENGEANCE_ACTIVE); } - if (!config.showTeleblock()) + if (!this.showTeleblock) { removeTbTimers(); } - if (!config.showFreezes()) + if (!this.showFreezes) { removeGameTimer(BIND); removeGameTimer(HALFBIND); @@ -397,7 +434,7 @@ public class TimersPlugin extends Plugin @Subscribe public void onMenuOptionClicked(MenuOptionClicked event) { - if (config.showStamina() + if (this.showStamina && event.getOption().contains("Drink") && (event.getIdentifier() == ItemID.STAMINA_MIX1 || event.getIdentifier() == ItemID.STAMINA_MIX2)) @@ -407,7 +444,7 @@ public class TimersPlugin extends Plugin return; } - if (config.showAntiFire() + if (this.showAntiFire && event.getOption().contains("Drink") && (event.getIdentifier() == ItemID.ANTIFIRE_MIX1 || event.getIdentifier() == ItemID.ANTIFIRE_MIX2)) @@ -417,7 +454,7 @@ public class TimersPlugin extends Plugin return; } - if (config.showAntiFire() + if (this.showAntiFire && event.getOption().contains("Drink") && (event.getIdentifier() == ItemID.EXTENDED_ANTIFIRE_MIX1 || event.getIdentifier() == ItemID.EXTENDED_ANTIFIRE_MIX2)) @@ -427,7 +464,7 @@ public class TimersPlugin extends Plugin return; } - if (config.showAntiFire() + if (this.showAntiFire && event.getOption().contains("Drink") && (event.getIdentifier() == ItemID.SUPER_ANTIFIRE_MIX1 || event.getIdentifier() == ItemID.SUPER_ANTIFIRE_MIX2)) @@ -437,7 +474,7 @@ public class TimersPlugin extends Plugin return; } - if (config.showAntiFire() + if (this.showAntiFire && event.getOption().contains("Drink") && (event.getIdentifier() == ItemID.EXTENDED_SUPER_ANTIFIRE_MIX1 || event.getIdentifier() == ItemID.EXTENDED_SUPER_ANTIFIRE_MIX2)) @@ -453,7 +490,7 @@ public class TimersPlugin extends Plugin lastTeleportClicked = teleportWidget; } - if (config.showImbuedHeart() + if (this.showImbuedHeart && event.getOption().contains("Invigorate")) { // Needs a hook as there's a few cases where potions boost the same amount as the heart @@ -469,44 +506,44 @@ public class TimersPlugin extends Plugin return; } - if (config.showStamina() && (event.getMessage().equals(STAMINA_DRINK_MESSAGE) || event.getMessage().equals(STAMINA_SHARED_DRINK_MESSAGE))) + if (this.showStamina && (event.getMessage().equals(STAMINA_DRINK_MESSAGE) || event.getMessage().equals(STAMINA_SHARED_DRINK_MESSAGE))) { createGameTimer(STAMINA); } - if (config.showStamina() && event.getMessage().equals(STAMINA_EXPIRED_MESSAGE)) + if (this.showStamina && event.getMessage().equals(STAMINA_EXPIRED_MESSAGE)) { removeGameTimer(STAMINA); } - if (config.showAntiFire() && event.getMessage().equals(ANTIFIRE_DRINK_MESSAGE)) + if (this.showAntiFire && event.getMessage().equals(ANTIFIRE_DRINK_MESSAGE)) { createGameTimer(ANTIFIRE); } - if (config.showAntiFire() && event.getMessage().equals(EXTENDED_ANTIFIRE_DRINK_MESSAGE)) + if (this.showAntiFire && event.getMessage().equals(EXTENDED_ANTIFIRE_DRINK_MESSAGE)) { createGameTimer(EXANTIFIRE); } - if (config.showGodWarsAltar() && event.getMessage().equalsIgnoreCase(GOD_WARS_ALTAR_MESSAGE))//Normal altars are "You recharge your Prayer points." while gwd is "You recharge your Prayer." + if (this.showGodWarsAltar && event.getMessage().equalsIgnoreCase(GOD_WARS_ALTAR_MESSAGE))//Normal altars are "You recharge your Prayer points." while gwd is "You recharge your Prayer." { createGameTimer(GOD_WARS_ALTAR); } - if (config.showAntiFire() && event.getMessage().equals(EXTENDED_SUPER_ANTIFIRE_DRINK_MESSAGE)) + if (this.showAntiFire && event.getMessage().equals(EXTENDED_SUPER_ANTIFIRE_DRINK_MESSAGE)) { createGameTimer(EXSUPERANTIFIRE); } - if (config.showAntiFire() && event.getMessage().equals(ANTIFIRE_EXPIRED_MESSAGE)) + if (this.showAntiFire && event.getMessage().equals(ANTIFIRE_EXPIRED_MESSAGE)) { //they have the same expired message removeGameTimer(ANTIFIRE); removeGameTimer(EXANTIFIRE); } - if (config.showOverload() && event.getMessage().startsWith("You drink some of your") && event.getMessage().contains("overload")) + if (this.showOverload && event.getMessage().startsWith("You drink some of your") && event.getMessage().contains("overload")) { if (client.getVar(Varbits.IN_RAID) == 1) { @@ -519,17 +556,17 @@ public class TimersPlugin extends Plugin } - if (config.showCannon() && (event.getMessage().equals(CANNON_FURNACE_MESSAGE) || event.getMessage().contains(CANNON_REPAIR_MESSAGE))) + if (this.showCannon && (event.getMessage().equals(CANNON_FURNACE_MESSAGE) || event.getMessage().contains(CANNON_REPAIR_MESSAGE))) { createGameTimer(CANNON); } - if (config.showCannon() && event.getMessage().equals(CANNON_PICKUP_MESSAGE)) + if (this.showCannon && event.getMessage().equals(CANNON_PICKUP_MESSAGE)) { removeGameTimer(CANNON); } - if (config.showMagicImbue() && event.getMessage().equals(MAGIC_IMBUE_MESSAGE)) + if (this.showMagicImbue && event.getMessage().equals(MAGIC_IMBUE_MESSAGE)) { createGameTimer(MAGICIMBUE); } @@ -539,7 +576,7 @@ public class TimersPlugin extends Plugin removeGameTimer(MAGICIMBUE); } - if (config.showTeleblock()) + if (this.showTeleblock) { if (FULL_TELEBLOCK_PATTERN.matcher(event.getMessage()).find()) { @@ -564,53 +601,53 @@ public class TimersPlugin extends Plugin } } - if (config.showAntiFire() && event.getMessage().contains(SUPER_ANTIFIRE_DRINK_MESSAGE)) + if (this.showAntiFire && event.getMessage().contains(SUPER_ANTIFIRE_DRINK_MESSAGE)) { createGameTimer(SUPERANTIFIRE); } - if (config.showAntiFire() && event.getMessage().equals(SUPER_ANTIFIRE_EXPIRED_MESSAGE)) + if (this.showAntiFire && event.getMessage().equals(SUPER_ANTIFIRE_EXPIRED_MESSAGE)) { removeGameTimer(SUPERANTIFIRE); } - if (config.showImbuedHeart() && event.getMessage().contains(IMBUED_HEART_NOTREADY_MESSAGE)) + if (this.showImbuedHeart && event.getMessage().contains(IMBUED_HEART_NOTREADY_MESSAGE)) { imbuedHeartClicked = false; return; } - if (config.showImbuedHeart() && event.getMessage().equals(IMBUED_HEART_READY_MESSAGE)) + if (this.showImbuedHeart && event.getMessage().equals(IMBUED_HEART_READY_MESSAGE)) { removeGameTimer(IMBUEDHEART); } - if (config.showPrayerEnhance() && event.getMessage().startsWith("You drink some of your") && event.getMessage().contains("prayer enhance")) + if (this.showPrayerEnhance && event.getMessage().startsWith("You drink some of your") && event.getMessage().contains("prayer enhance")) { createGameTimer(PRAYER_ENHANCE); } - if (config.showCharge() && event.getMessage().equals(CHARGE_MESSAGE)) + if (this.showCharge && event.getMessage().equals(CHARGE_MESSAGE)) { createGameTimer(CHARGE); } - if (config.showCharge() && event.getMessage().equals(CHARGE_EXPIRED_MESSAGE)) + if (this.showCharge && event.getMessage().equals(CHARGE_EXPIRED_MESSAGE)) { removeGameTimer(CHARGE); } - if (config.showStaffOfTheDead() && event.getMessage().contains(STAFF_OF_THE_DEAD_SPEC_MESSAGE)) + if (this.showStaffOfTheDead && event.getMessage().contains(STAFF_OF_THE_DEAD_SPEC_MESSAGE)) { createGameTimer(STAFF_OF_THE_DEAD); } - if (config.showStaffOfTheDead() && event.getMessage().contains(STAFF_OF_THE_DEAD_SPEC_EXPIRED_MESSAGE)) + if (this.showStaffOfTheDead && event.getMessage().contains(STAFF_OF_THE_DEAD_SPEC_EXPIRED_MESSAGE)) { removeGameTimer(STAFF_OF_THE_DEAD); } - if (config.showFreezes() && event.getMessage().equals(FROZEN_MESSAGE)) + if (this.showFreezes && event.getMessage().equals(FROZEN_MESSAGE)) { freezeTimer = createGameTimer(ICEBARRAGE); freezeTime = client.getTickCount(); @@ -627,7 +664,7 @@ public class TimersPlugin extends Plugin final boolean isSkulled = player.getSkullIcon() != null && player.getSkullIcon() != SkullIcon.SKULL_FIGHT_PIT; - if (isSkulled != skulledLastTick && config.showSkull()) + if (isSkulled != skulledLastTick && this.showSkull) { skulledLastTick = isSkulled; if (isSkulled) @@ -689,7 +726,7 @@ public class TimersPlugin extends Plugin { Actor actor = event.getActor(); - if (config.showAbyssalSireStun() + if (this.showAbyssalSireStun && actor instanceof NPC) { int npcId = ((NPC) actor).getId(); @@ -720,7 +757,7 @@ public class TimersPlugin extends Plugin return; } - if (config.showHomeMinigameTeleports() + if (this.showHomeMinigameTeleports && client.getLocalPlayer().getAnimation() == AnimationID.IDLE && (lastAnimation == AnimationID.BOOK_HOME_TELEPORT_5 || lastAnimation == AnimationID.COW_HOME_TELEPORT_6)) @@ -748,12 +785,12 @@ public class TimersPlugin extends Plugin return; } - if (config.showImbuedHeart() && actor.getSpotAnimation() == IMBUEDHEART.getGraphicId()) + if (this.showImbuedHeart && actor.getSpotAnimation() == IMBUEDHEART.getGraphicId()) { createGameTimer(IMBUEDHEART); } - if (config.showFreezes()) + if (this.showFreezes) { if (actor.getSpotAnimation() == BIND.getGraphicId()) { @@ -891,7 +928,7 @@ public class TimersPlugin extends Plugin { Skill skill = event.getSkill(); - if (skill != Skill.MAGIC || !config.showImbuedHeart() || !imbuedHeartClicked) + if (skill != Skill.MAGIC || !this.showImbuedHeart || !imbuedHeartClicked) { return; } @@ -960,4 +997,26 @@ public class TimersPlugin extends Plugin removeGameTimer(DMM_FULLTB); removeGameTimer(DMM_HALFTB); } + + private void updateConfig() + { + this.showHomeMinigameTeleports = config.showHomeMinigameTeleports(); + this.showAntiPoison = config.showAntiPoison(); + this.showAntiFire = config.showAntiFire(); + this.showStamina = config.showStamina(); + this.showOverload = config.showOverload(); + this.showPrayerEnhance = config.showPrayerEnhance(); + this.showCannon = config.showCannon(); + this.showMagicImbue = config.showMagicImbue(); + this.showCharge = config.showCharge(); + this.showImbuedHeart = config.showImbuedHeart(); + this.showVengeance = config.showVengeance(); + this.showVengeanceActive = config.showVengeanceActive(); + this.showTeleblock = config.showTeleblock(); + this.showFreezes = config.showFreezes(); + this.showGodWarsAltar = config.showGodWarsAltar(); + this.showSkull = config.showSkull(); + this.showStaffOfTheDead = config.showStaffOfTheDead(); + this.showAbyssalSireStun = config.showAbyssalSireStun(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/timestamp/TimestampPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/timestamp/TimestampPlugin.java index 4379d37844..516fb5eb94 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/timestamp/TimestampPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/timestamp/TimestampPlugin.java @@ -33,6 +33,7 @@ import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.Date; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.MessageNode; @@ -51,6 +52,7 @@ import net.runelite.client.util.ColorUtil; tags = {"timestamp"}, enabledByDefault = false ) +@Singleton public class TimestampPlugin extends Plugin { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlant.java b/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlant.java index f7dce4fbfc..0488514d89 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlant.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlant.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.tithefarm; import java.time.Duration; import java.time.Instant; +import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import net.runelite.api.GameObject; @@ -35,23 +36,23 @@ class TitheFarmPlant { private static final Duration PLANT_TIME = Duration.ofMinutes(1); - @Getter - @Setter + @Getter(AccessLevel.PACKAGE) + @Setter(AccessLevel.PACKAGE) private Instant planted; - @Getter + @Getter(AccessLevel.PACKAGE) private final TitheFarmPlantState state; - @Getter + @Getter(AccessLevel.PACKAGE) private final TitheFarmPlantType type; - @Getter + @Getter(AccessLevel.PACKAGE) private final GameObject gameObject; - @Getter + @Getter(AccessLevel.PACKAGE) private final WorldPoint worldLocation; - TitheFarmPlant(TitheFarmPlantState state, TitheFarmPlantType type, GameObject gameObject) + TitheFarmPlant(final TitheFarmPlantState state, final TitheFarmPlantType type, final GameObject gameObject) { this.planted = Instant.now(); this.state = state; @@ -60,7 +61,7 @@ class TitheFarmPlant this.worldLocation = gameObject.getWorldLocation(); } - public double getPlantTimeRelative() + double getPlantTimeRelative() { Duration duration = Duration.between(planted, Instant.now()); return duration.compareTo(PLANT_TIME) < 0 ? (double) duration.toMillis() / PLANT_TIME.toMillis() : 1; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlantOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlantOverlay.java index 5e39d3b452..0cf673b2dd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlantOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlantOverlay.java @@ -30,6 +30,7 @@ import java.awt.Graphics2D; import java.util.HashMap; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.Point; @@ -40,21 +41,20 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.components.ProgressPieComponent; +@Singleton public class TitheFarmPlantOverlay extends Overlay { private final Client client; private final TitheFarmPlugin plugin; - private final TitheFarmPluginConfig config; private final Map borders = new HashMap<>(); private final Map fills = new HashMap<>(); @Inject - TitheFarmPlantOverlay(Client client, TitheFarmPlugin plugin, TitheFarmPluginConfig config) + TitheFarmPlantOverlay(final Client client, final TitheFarmPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); this.plugin = plugin; - this.config = config; this.client = client; } @@ -66,17 +66,17 @@ public class TitheFarmPlantOverlay extends Overlay borders.clear(); fills.clear(); - final Color colorUnwateredBorder = config.getColorUnwatered(); + final Color colorUnwateredBorder = plugin.getGetColorUnwatered(); final Color colorUnwatered = new Color(colorUnwateredBorder.getRed(), colorUnwateredBorder.getGreen(), colorUnwateredBorder.getBlue(), 100); borders.put(TitheFarmPlantState.UNWATERED, colorUnwateredBorder); fills.put(TitheFarmPlantState.UNWATERED, colorUnwatered); - final Color colorWateredBorder = config.getColorWatered(); + final Color colorWateredBorder = plugin.getGetColorWatered(); final Color colorWatered = new Color(colorWateredBorder.getRed(), colorWateredBorder.getGreen(), colorWateredBorder.getBlue(), 100); borders.put(TitheFarmPlantState.WATERED, colorWateredBorder); fills.put(TitheFarmPlantState.WATERED, colorWatered); - final Color colorGrownBorder = config.getColorGrown(); + final Color colorGrownBorder = plugin.getGetColorGrown(); final Color colorGrown = new Color(colorGrownBorder.getRed(), colorGrownBorder.getGreen(), colorGrownBorder.getBlue(), 100); borders.put(TitheFarmPlantState.GROWN, colorGrownBorder); fills.put(TitheFarmPlantState.GROWN, colorGrown); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlantType.java b/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlantType.java index 04a48e6eb3..61e131aa22 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlantType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlantType.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.tithefarm; import com.google.common.collect.ImmutableMap; import java.util.Map; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.ObjectID; @@ -53,11 +54,11 @@ public enum TitheFarmPlantType ObjectID.LOGAVANO_PLANT_27415, ObjectID.BLIGHTED_LOGAVANO_PLANT_27416 ); - @Getter + @Getter(AccessLevel.PACKAGE) private final String name; - @Getter + @Getter(AccessLevel.PACKAGE) private final int baseId; - @Getter + @Getter(AccessLevel.PACKAGE) private final int[] objectIds; private static final Map plantTypes; @@ -77,7 +78,7 @@ public enum TitheFarmPlantType plantTypes = builder.build(); } - TitheFarmPlantType(String name, int baseId, int... objectIds) + TitheFarmPlantType(final String name, final int baseId, final int... objectIds) { this.name = name; this.baseId = baseId; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlugin.java index ae3ee54894..bc69f169fe 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tithefarm/TitheFarmPlugin.java @@ -25,9 +25,12 @@ package net.runelite.client.plugins.tithefarm; import com.google.inject.Provides; +import java.awt.Color; import java.util.HashSet; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.GameObject; @@ -47,6 +50,7 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Show timers for the farming patches within the Tithe Farm minigame", tags = {"farming", "minigame", "overlay", "skilling", "timers"} ) +@Singleton public class TitheFarmPlugin extends Plugin { @Inject @@ -55,9 +59,19 @@ public class TitheFarmPlugin extends Plugin @Inject private TitheFarmPlantOverlay titheFarmOverlay; - @Getter + @Inject + private TitheFarmPluginConfig config; + + @Getter(AccessLevel.PACKAGE) private final Set plants = new HashSet<>(); + @Getter(AccessLevel.PACKAGE) + private Color getColorUnwatered; + @Getter(AccessLevel.PACKAGE) + private Color getColorWatered; + @Getter(AccessLevel.PACKAGE) + private Color getColorGrown; + @Provides TitheFarmPluginConfig getConfig(ConfigManager configManager) { @@ -67,6 +81,7 @@ public class TitheFarmPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); overlayManager.add(titheFarmOverlay); titheFarmOverlay.updateConfig(); } @@ -82,6 +97,8 @@ public class TitheFarmPlugin extends Plugin { if (event.getGroup().equals("tithefarmplugin")) { + updateConfig(); + titheFarmOverlay.updateConfig(); } } @@ -152,4 +169,11 @@ public class TitheFarmPlugin extends Plugin } return null; } + + private void updateConfig() + { + this.getColorUnwatered = config.getColorUnwatered(); + this.getColorWatered = config.getColorWatered(); + this.getColorGrown = config.getColorGrown(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/tmorph/TMorph.java b/runelite-client/src/main/java/net/runelite/client/plugins/tmorph/TMorph.java index e7795025b3..133636aa77 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/tmorph/TMorph.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/tmorph/TMorph.java @@ -25,10 +25,12 @@ package net.runelite.client.plugins.tmorph; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.GameState; import net.runelite.api.Player; import net.runelite.api.events.AnimationChanged; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameTick; import net.runelite.api.kit.KitType; import net.runelite.api.widgets.WidgetInfo; @@ -46,7 +48,7 @@ import org.apache.commons.lang3.ObjectUtils; type = PluginType.UTILITY, enabledByDefault = false ) - +@Singleton public class TMorph extends Plugin { @Inject @@ -55,27 +57,103 @@ public class TMorph extends Plugin @Inject private TMorphConfig config; + private boolean mageSwap; + private boolean rangeSwap; + private boolean meleeSwap; + private int globalAnimSwap; + private int animationSwap; + private int animationTarget; + private int MainhandMage; + private int targetMainhandMage; + private int OffhandMage; + private int targetOffhandMage; + private int HelmetMage; + private int targetHelmetMage; + private int CapeMage; + private int targetCapeMage; + private int NeckMage; + private int targetNeckMage; + private int BodyMage; + private int targetBodyMage; + private int LegsMage; + private int targetLegsMage; + private int BootsMage; + private int targetBootsMage; + private int GlovesMage; + private int targetGlovesMage; + private int MainhandRange; + private int targetMainhandRange; + private int OffhandRange; + private int targetOffhandRange; + private int HelmetRange; + private int targetHelmetRange; + private int CapeRange; + private int targetCapeRange; + private int NeckRange; + private int targetNeckRange; + private int BodyRange; + private int targetBodyRange; + private int LegsRange; + private int targetLegsRange; + private int BootsRange; + private int targetBootsRange; + private int GlovesRange; + private int targetGlovesRange; + private int MainhandMelee; + private int targetMainhandMelee; + private int OffhandMelee; + private int targetOffhandMelee; + private int HelmetMelee; + private int targetHelmetMelee; + private int CapeMelee; + private int targetCapeMelee; + private int NeckMelee; + private int targetNeckMelee; + private int BodyMelee; + private int targetBodyMelee; + private int LegsMelee; + private int targetLegsMelee; + private int BootsMelee; + private int targetBootsMelee; + private int GlovesMelee; + private int targetGlovesMelee; + @Provides TMorphConfig provideConfig(ConfigManager configManager) { return configManager.getConfig(TMorphConfig.class); } + @Override + protected void startUp() throws Exception + { + updateConfig(); + } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("TMorph")) + { + updateConfig(); + } + } + @Subscribe public void onAnimationChanged(AnimationChanged event) { - if (config.animationTarget() <= 0 && config.animationSwap() <= 0 && config.globalAnimSwap() > 0) + if (this.animationTarget <= 0 && this.animationSwap <= 0 && this.globalAnimSwap > 0) { if (event.getActor().getAnimation() != -1) { - event.getActor().setAnimation(config.globalAnimSwap()); + event.getActor().setAnimation(this.globalAnimSwap); } } - if (config.animationTarget() > 0 && config.animationSwap() > 0) + if (this.animationTarget > 0 && this.animationSwap > 0) { - if (event.getActor().getAnimation() == config.animationTarget()) + if (event.getActor().getAnimation() == this.animationTarget) { - event.getActor().setAnimation(config.animationSwap()); + event.getActor().setAnimation(this.animationSwap); } } } @@ -121,285 +199,349 @@ public class TMorph extends Plugin final int glovesID = ObjectUtils.defaultIfNull(player.getPlayerAppearance(). getEquipmentId(KitType.HANDS), 0); - if (config.mageSwap()) + if (this.mageSwap) { - if (config.MainhandMage() > 0) + if (this.MainhandMage > 0) { - if (config.targetMainhandMage() > 0) + if (this.targetMainhandMage > 0) { - if (mainhandID == config.targetMainhandMage()) + if (mainhandID == this.targetMainhandMage) { - player.getPlayerAppearance().getEquipmentIds()[KitType.WEAPON.getIndex()] = config.MainhandMage() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.WEAPON.getIndex()] = this.MainhandMage + 512; } } } - if (config.OffhandMage() > 0) + if (this.OffhandMage > 0) { - if (config.targetOffhandMage() > 0) + if (this.targetOffhandMage > 0) { - if (offhandID == config.targetOffhandMage()) + if (offhandID == this.targetOffhandMage) { - player.getPlayerAppearance().getEquipmentIds()[KitType.SHIELD.getIndex()] = config.OffhandMage() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.SHIELD.getIndex()] = this.OffhandMage + 512; } } } - if (config.HelmetMage() > 0) + if (this.HelmetMage > 0) { - if (config.targetHelmetMage() > 0) + if (this.targetHelmetMage > 0) { - if (helmetID == config.targetHelmetMage()) + if (helmetID == this.targetHelmetMage) { - player.getPlayerAppearance().getEquipmentIds()[KitType.HELMET.getIndex()] = config.HelmetMage() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.HELMET.getIndex()] = this.HelmetMage + 512; } } } - if (config.CapeMage() > 0) + if (this.CapeMage > 0) { - if (config.targetCapeMage() > 0) + if (this.targetCapeMage > 0) { - if (capeID == config.targetCapeMage()) + if (capeID == this.targetCapeMage) { - player.getPlayerAppearance().getEquipmentIds()[KitType.CAPE.getIndex()] = config.CapeMage() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.CAPE.getIndex()] = this.CapeMage + 512; } } } - if (config.NeckMage() > 0) + if (this.NeckMage > 0) { - if (config.targetNeckMage() > 0) + if (this.targetNeckMage > 0) { - if (neckID == config.targetNeckMage()) + if (neckID == this.targetNeckMage) { - player.getPlayerAppearance().getEquipmentIds()[KitType.AMULET.getIndex()] = config.NeckMage() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.AMULET.getIndex()] = this.NeckMage + 512; } } } - if (config.BodyMage() > 0) + if (this.BodyMage > 0) { - if (config.targetBodyMage() > 0) + if (this.targetBodyMage > 0) { - if (bodyID == config.targetBodyMage()) + if (bodyID == this.targetBodyMage) { - player.getPlayerAppearance().getEquipmentIds()[KitType.TORSO.getIndex()] = config.BodyMage() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.TORSO.getIndex()] = this.BodyMage + 512; } } } - if (config.LegsMage() > 0) + if (this.LegsMage > 0) { - if (config.targetLegsMage() > 0) + if (this.targetLegsMage > 0) { - if (legsID == config.targetLegsMage()) + if (legsID == this.targetLegsMage) { - player.getPlayerAppearance().getEquipmentIds()[KitType.LEGS.getIndex()] = config.LegsMage() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.LEGS.getIndex()] = this.LegsMage + 512; } } } - if (config.BootsMage() > 0) + if (this.BootsMage > 0) { - if (config.targetBootsMage() > 0) + if (this.targetBootsMage > 0) { - if (bootsID == config.targetBootsMage()) + if (bootsID == this.targetBootsMage) { - player.getPlayerAppearance().getEquipmentIds()[KitType.BOOTS.getIndex()] = config.BootsMage() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.BOOTS.getIndex()] = this.BootsMage + 512; } } } - if (config.GlovesMage() > 0) + if (this.GlovesMage > 0) { - if (config.targetGlovesMage() > 0) + if (this.targetGlovesMage > 0) { - if (glovesID == config.targetGlovesMage()) + if (glovesID == this.targetGlovesMage) { - player.getPlayerAppearance().getEquipmentIds()[KitType.HANDS.getIndex()] = config.GlovesMage() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.HANDS.getIndex()] = this.GlovesMage + 512; } } } } - if (config.rangeSwap()) + if (this.rangeSwap) { - if (config.MainhandRange() > 0) + if (this.MainhandRange > 0) { - if (config.targetMainhandRange() > 0) + if (this.targetMainhandRange > 0) { - if (mainhandID == config.targetMainhandRange()) + if (mainhandID == this.targetMainhandRange) { - player.getPlayerAppearance().getEquipmentIds()[KitType.WEAPON.getIndex()] = config.MainhandRange() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.WEAPON.getIndex()] = this.MainhandRange + 512; } } } - if (config.OffhandRange() > 0) + if (this.OffhandRange > 0) { - if (config.targetOffhandRange() > 0) + if (this.targetOffhandRange > 0) { - if (offhandID == config.targetOffhandRange()) + if (offhandID == this.targetOffhandRange) { - player.getPlayerAppearance().getEquipmentIds()[KitType.SHIELD.getIndex()] = config.OffhandRange() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.SHIELD.getIndex()] = this.OffhandRange + 512; } } } - if (config.HelmetRange() > 0) + if (this.HelmetRange > 0) { - if (config.targetHelmetRange() > 0) + if (this.targetHelmetRange > 0) { - if (helmetID == config.targetHelmetRange()) + if (helmetID == this.targetHelmetRange) { - player.getPlayerAppearance().getEquipmentIds()[KitType.HELMET.getIndex()] = config.HelmetRange() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.HELMET.getIndex()] = this.HelmetRange + 512; } } } - if (config.CapeRange() > 0) + if (this.CapeRange > 0) { - if (config.targetCapeRange() > 0) + if (this.targetCapeRange > 0) { - if (capeID == config.targetCapeRange()) + if (capeID == this.targetCapeRange) { - player.getPlayerAppearance().getEquipmentIds()[KitType.CAPE.getIndex()] = config.CapeRange() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.CAPE.getIndex()] = this.CapeRange + 512; } } } - if (config.NeckRange() > 0) + if (this.NeckRange > 0) { - if (config.targetNeckRange() > 0) + if (this.targetNeckRange > 0) { - if (neckID == config.targetNeckRange()) + if (neckID == this.targetNeckRange) { - player.getPlayerAppearance().getEquipmentIds()[KitType.AMULET.getIndex()] = config.NeckRange() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.AMULET.getIndex()] = this.NeckRange + 512; } } } - if (config.BodyRange() > 0) + if (this.BodyRange > 0) { - if (config.targetBodyRange() > 0) + if (this.targetBodyRange > 0) { - if (bodyID == config.targetBodyRange()) + if (bodyID == this.targetBodyRange) { - player.getPlayerAppearance().getEquipmentIds()[KitType.TORSO.getIndex()] = config.BodyRange() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.TORSO.getIndex()] = this.BodyRange + 512; } } } - if (config.LegsRange() > 0) + if (this.LegsRange > 0) { - if (config.targetLegsRange() > 0) + if (this.targetLegsRange > 0) { - if (legsID == config.targetLegsRange()) + if (legsID == this.targetLegsRange) { - player.getPlayerAppearance().getEquipmentIds()[KitType.LEGS.getIndex()] = config.LegsRange() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.LEGS.getIndex()] = this.LegsRange + 512; } } } - if (config.BootsRange() > 0) + if (this.BootsRange > 0) { - if (config.targetBootsRange() > 0) + if (this.targetBootsRange > 0) { - if (bootsID == config.targetBootsRange()) + if (bootsID == this.targetBootsRange) { - player.getPlayerAppearance().getEquipmentIds()[KitType.BOOTS.getIndex()] = config.BootsRange() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.BOOTS.getIndex()] = this.BootsRange + 512; } } } - if (config.GlovesRange() > 0) + if (this.GlovesRange > 0) { - if (config.targetGlovesRange() > 0) + if (this.targetGlovesRange > 0) { - if (glovesID == config.targetGlovesRange()) + if (glovesID == this.targetGlovesRange) { - player.getPlayerAppearance().getEquipmentIds()[KitType.HANDS.getIndex()] = config.GlovesRange() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.HANDS.getIndex()] = this.GlovesRange + 512; } } } } - if (config.meleeSwap()) + if (this.meleeSwap) { - if (config.MainhandMelee() > 0) + if (this.MainhandMelee > 0) { - if (config.targetMainhandMelee() > 0) + if (this.targetMainhandMelee > 0) { - if (mainhandID == config.targetMainhandMelee()) + if (mainhandID == this.targetMainhandMelee) { - player.getPlayerAppearance().getEquipmentIds()[KitType.WEAPON.getIndex()] = config.MainhandMelee() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.WEAPON.getIndex()] = this.MainhandMelee + 512; } } } - if (config.OffhandMelee() > 0) + if (this.OffhandMelee > 0) { - if (config.targetOffhandMelee() > 0) + if (this.targetOffhandMelee > 0) { - if (offhandID == config.targetOffhandMelee()) + if (offhandID == this.targetOffhandMelee) { - player.getPlayerAppearance().getEquipmentIds()[KitType.SHIELD.getIndex()] = config.OffhandMelee() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.SHIELD.getIndex()] = this.OffhandMelee + 512; } } } - if (config.HelmetMelee() > 0) + if (this.HelmetMelee > 0) { - if (config.targetHelmetMelee() > 0) + if (this.targetHelmetMelee > 0) { - if (helmetID == config.targetHelmetMelee()) + if (helmetID == this.targetHelmetMelee) { - player.getPlayerAppearance().getEquipmentIds()[KitType.HELMET.getIndex()] = config.HelmetMelee() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.HELMET.getIndex()] = this.HelmetMelee + 512; } } } - if (config.CapeMelee() > 0) + if (this.CapeMelee > 0) { - if (config.targetCapeMelee() > 0) + if (this.targetCapeMelee > 0) { - if (capeID == config.targetCapeMelee()) + if (capeID == this.targetCapeMelee) { - player.getPlayerAppearance().getEquipmentIds()[KitType.CAPE.getIndex()] = config.CapeMelee() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.CAPE.getIndex()] = this.CapeMelee + 512; } } } - if (config.NeckMelee() > 0) + if (this.NeckMelee > 0) { - if (config.targetNeckMelee() > 0) + if (this.targetNeckMelee > 0) { - if (neckID == config.targetNeckMelee()) + if (neckID == this.targetNeckMelee) { - player.getPlayerAppearance().getEquipmentIds()[KitType.AMULET.getIndex()] = config.NeckMelee() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.AMULET.getIndex()] = this.NeckMelee + 512; } } } - if (config.BodyMelee() > 0) + if (this.BodyMelee > 0) { - if (config.targetBodyMelee() > 0) + if (this.targetBodyMelee > 0) { - if (bodyID == config.targetBodyMelee()) + if (bodyID == this.targetBodyMelee) { - player.getPlayerAppearance().getEquipmentIds()[KitType.TORSO.getIndex()] = config.BodyMelee() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.TORSO.getIndex()] = this.BodyMelee + 512; } } } - if (config.LegsMelee() > 0) + if (this.LegsMelee > 0) { - if (config.targetLegsMelee() > 0) + if (this.targetLegsMelee > 0) { - if (legsID == config.targetLegsMelee()) + if (legsID == this.targetLegsMelee) { - player.getPlayerAppearance().getEquipmentIds()[KitType.LEGS.getIndex()] = config.LegsMelee() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.LEGS.getIndex()] = this.LegsMelee + 512; } } } - if (config.BootsMelee() > 0) + if (this.BootsMelee > 0) { - if (config.targetBootsMelee() > 0) + if (this.targetBootsMelee > 0) { - if (bootsID == config.targetBootsMelee()) + if (bootsID == this.targetBootsMelee) { - player.getPlayerAppearance().getEquipmentIds()[KitType.BOOTS.getIndex()] = config.BootsMelee() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.BOOTS.getIndex()] = this.BootsMelee + 512; } } } - if (config.GlovesMelee() > 0) + if (this.GlovesMelee > 0) { - if (config.targetGlovesMelee() > 0) + if (this.targetGlovesMelee > 0) { - if (glovesID == config.targetGlovesMelee()) + if (glovesID == this.targetGlovesMelee) { - player.getPlayerAppearance().getEquipmentIds()[KitType.HANDS.getIndex()] = config.GlovesMelee() + 512; + player.getPlayerAppearance().getEquipmentIds()[KitType.HANDS.getIndex()] = this.GlovesMelee + 512; } } } } player.getPlayerAppearance().setHash(); } + + private void updateConfig() + { + this.mageSwap = config.mageSwap(); + this.rangeSwap = config.rangeSwap(); + this.meleeSwap = config.meleeSwap(); + this.globalAnimSwap = config.globalAnimSwap(); + this.animationSwap = config.animationSwap(); + this.animationTarget = config.animationTarget(); + this.MainhandMage = config.MainhandMage(); + this.targetMainhandMage = config.targetMainhandMage(); + this.OffhandMage = config.OffhandMage(); + this.targetOffhandMage = config.targetOffhandMage(); + this.HelmetMage = config.HelmetMage(); + this.targetHelmetMage = config.targetHelmetMage(); + this.CapeMage = config.CapeMage(); + this.targetCapeMage = config.targetCapeMage(); + this.NeckMage = config.NeckMage(); + this.targetNeckMage = config.targetNeckMage(); + this.BodyMage = config.BodyMage(); + this.targetBodyMage = config.targetBodyMage(); + this.LegsMage = config.LegsMage(); + this.targetLegsMage = config.targetLegsMage(); + this.BootsMage = config.BootsMage(); + this.targetBootsMage = config.targetBootsMage(); + this.GlovesMage = config.GlovesMage(); + this.targetGlovesMage = config.targetGlovesMage(); + this.MainhandRange = config.MainhandRange(); + this.targetMainhandRange = config.targetMainhandRange(); + this.OffhandRange = config.OffhandRange(); + this.targetOffhandRange = config.targetOffhandRange(); + this.HelmetRange = config.HelmetRange(); + this.targetHelmetRange = config.targetHelmetRange(); + this.CapeRange = config.CapeRange(); + this.targetCapeRange = config.targetCapeRange(); + this.NeckRange = config.NeckRange(); + this.targetNeckRange = config.targetNeckRange(); + this.BodyRange = config.BodyRange(); + this.targetBodyRange = config.targetBodyRange(); + this.LegsRange = config.LegsRange(); + this.targetLegsRange = config.targetLegsRange(); + this.BootsRange = config.BootsRange(); + this.targetBootsRange = config.targetBootsRange(); + this.GlovesRange = config.GlovesRange(); + this.targetGlovesRange = config.targetGlovesRange(); + this.MainhandMelee = config.MainhandMelee(); + this.targetMainhandMelee = config.targetMainhandMelee(); + this.OffhandMelee = config.OffhandMelee(); + this.targetOffhandMelee = config.targetOffhandMelee(); + this.HelmetMelee = config.HelmetMelee(); + this.targetHelmetMelee = config.targetHelmetMelee(); + this.CapeMelee = config.CapeMelee(); + this.targetCapeMelee = config.targetCapeMelee(); + this.NeckMelee = config.NeckMelee(); + this.targetNeckMelee = config.targetNeckMelee(); + this.BodyMelee = config.BodyMelee(); + this.targetBodyMelee = config.targetBodyMelee(); + this.LegsMelee = config.LegsMelee(); + this.targetLegsMelee = config.targetLegsMelee(); + this.BootsMelee = config.BootsMelee(); + this.targetBootsMelee = config.targetBootsMelee(); + this.GlovesMelee = config.GlovesMelee(); + this.targetGlovesMelee = config.targetGlovesMelee(); + } } 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 2cb2ff0de8..1202e4466b 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 @@ -27,6 +27,7 @@ package net.runelite.client.plugins.tobdamagecount; import java.text.DecimalFormat; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Actor; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; @@ -59,7 +60,7 @@ import net.runelite.client.plugins.PluginType; type = PluginType.PVM, enabledByDefault = false ) - +@Singleton public class DamageCounterPlugin extends Plugin { private int currentWorld = -1; @@ -329,10 +330,10 @@ public class DamageCounterPlugin extends Plugin String DeathMessage = "You have died! You did " + DAMAGEFORMAT.format(DamageCount) + " damage to " + BossName + "!"; String MessageTaken = "You have taken " + DAMAGEFORMAT.format(DamageTaken) + " damage from this fight!"; - for (int i = 0; i < ToB_Region.length; i++) + for (int value : ToB_Region) { if (WorldPoint.fromLocalInstance(client, - client.getLocalPlayer().getLocalLocation()).getRegionID() == ToB_Region[i]) + client.getLocalPlayer().getLocalLocation()).getRegionID() == value) { sendChatMessage(DeathMessage); sendChatMessage(MessageTaken); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/twitch/TwitchPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/twitch/TwitchPlugin.java index ce7b25acb3..62923981a9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/twitch/TwitchPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/twitch/TwitchPlugin.java @@ -29,6 +29,7 @@ import com.google.inject.Provides; import java.time.temporal.ChronoUnit; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; @@ -56,6 +57,7 @@ import net.runelite.client.task.Schedule; enabledByDefault = false ) @Slf4j +@Singleton public class TwitchPlugin extends Plugin implements TwitchListener, ChatboxInputListener { @Inject diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/twitch/irc/Message.java b/runelite-client/src/main/java/net/runelite/client/plugins/twitch/irc/Message.java index fe990331cc..fb7945f17e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/twitch/irc/Message.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/twitch/irc/Message.java @@ -28,9 +28,10 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import lombok.AccessLevel; import lombok.Getter; -@Getter +@Getter(AccessLevel.PACKAGE) class Message { private final Map tags = new HashMap<>(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/twitch/irc/TwitchIRCClient.java b/runelite-client/src/main/java/net/runelite/client/plugins/twitch/irc/TwitchIRCClient.java index f76ddcaa3c..a51a38a433 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/twitch/irc/TwitchIRCClient.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/twitch/irc/TwitchIRCClient.java @@ -52,7 +52,7 @@ public class TwitchIRCClient extends Thread implements AutoCloseable private long last; private boolean pingSent; - public TwitchIRCClient(TwitchListener twitchListener, String username, String password, String channel) + public TwitchIRCClient(final TwitchListener twitchListener, final String username, final String password, final String channel) { setName("Twitch"); this.twitchListener = twitchListener; 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 7f4ccff362..9d3179c68c 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 @@ -28,6 +28,7 @@ import java.time.Instant; import java.util.HashMap; import java.util.Map; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.Getter; import net.runelite.api.Actor; import net.runelite.api.AnimationID; @@ -45,7 +46,7 @@ import net.runelite.client.ui.overlay.OverlayManager; type = PluginType.PVM, enabledByDefault = false ) - +@Singleton public class VetionPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/virtuallevels/VirtualLevelsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/virtuallevels/VirtualLevelsPlugin.java index 7be76a31b4..c9f3bb462f 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/virtuallevels/VirtualLevelsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/virtuallevels/VirtualLevelsPlugin.java @@ -27,6 +27,7 @@ package net.runelite.client.plugins.virtuallevels; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Experience; import net.runelite.api.Skill; @@ -45,6 +46,7 @@ import net.runelite.client.plugins.PluginDescriptor; tags = {"skill", "total", "max"}, enabledByDefault = false ) +@Singleton public class VirtualLevelsPlugin extends Plugin { private static final String TOTAL_LEVEL_TEXT_PREFIX = "Total level:
"; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/Vorkath.java b/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/Vorkath.java index 2691f4991d..02ae424527 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/Vorkath.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/Vorkath.java @@ -70,7 +70,7 @@ public class Vorkath * * @param newPhase the new phase Vorkath is current on */ - public void updatePhase(Phase newPhase) + void updatePhase(Phase newPhase) { Phase oldLastPhase = this.lastPhase; Phase oldCurrentPhase = this.currentPhase; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/VorkathAttack.java b/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/VorkathAttack.java index 8e1b20daae..6a2479c57b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/VorkathAttack.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/VorkathAttack.java @@ -27,13 +27,14 @@ package net.runelite.client.plugins.vorkath; import com.google.common.collect.ImmutableMap; import java.util.Map; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import net.runelite.api.AnimationID; import net.runelite.api.ProjectileID; @AllArgsConstructor -@Getter +@Getter(AccessLevel.PACKAGE) public enum VorkathAttack { /** diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/VorkathOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/VorkathOverlay.java index 3b94cefe7b..af8635f8af 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/VorkathOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/VorkathOverlay.java @@ -33,6 +33,7 @@ import java.awt.Graphics2D; import java.awt.geom.Arc2D; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Perspective; import net.runelite.api.Point; @@ -41,6 +42,7 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; +@Singleton public class VorkathOverlay extends Overlay { private static final Color COLOR_ICON_BACKGROUND = new Color(0, 0, 0, 128); @@ -53,7 +55,7 @@ public class VorkathOverlay extends Overlay private VorkathPlugin plugin; @Inject - public VorkathOverlay(Client client, VorkathPlugin plugin) + public VorkathOverlay(final Client client, final VorkathPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); 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 a694be9826..58cefc7efe 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 @@ -27,6 +27,7 @@ package net.runelite.client.plugins.vorkath; import com.google.inject.Inject; +import com.google.inject.Singleton; import java.awt.image.BufferedImage; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -52,6 +53,7 @@ import org.apache.commons.lang3.ArrayUtils; type = PluginType.PVM, enabledByDefault = false ) +@Singleton @Slf4j public class VorkathPlugin extends Plugin { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/ZombifiedSpawnOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/ZombifiedSpawnOverlay.java index 50fb185532..145eb2602d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/ZombifiedSpawnOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/vorkath/ZombifiedSpawnOverlay.java @@ -28,17 +28,19 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; 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; +@Singleton public class ZombifiedSpawnOverlay extends Overlay { private VorkathPlugin plugin; @Inject - public ZombifiedSpawnOverlay(VorkathPlugin plugin) + public ZombifiedSpawnOverlay(final VorkathPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); setLayer(OverlayLayer.ABOVE_SCENE); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorConfig.java index dca6ba47b3..226286ff19 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorConfig.java @@ -97,7 +97,6 @@ public interface WarIndicatorConfig extends Config ) void setActiveCallers(String key); - @ConfigItem( position = 6, keyName = "highlightSnipes", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorMiniMapOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorMiniMapOverlay.java index d7fa0cc92a..3e278405e5 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorMiniMapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorMiniMapOverlay.java @@ -41,12 +41,12 @@ import org.apache.commons.lang3.ArrayUtils; public class WarIndicatorMiniMapOverlay extends Overlay { private final WarIndicatorService warIndicatorService; - private final WarIndicatorConfig config; + private final WarIndicatorPlugin plugin; @Inject - private WarIndicatorMiniMapOverlay(WarIndicatorConfig config, WarIndicatorService warIndicatorService) + private WarIndicatorMiniMapOverlay(final WarIndicatorPlugin plugin, final WarIndicatorService warIndicatorService) { - this.config = config; + this.plugin = plugin; this.warIndicatorService = warIndicatorService; setLayer(OverlayLayer.ABOVE_WIDGETS); setPosition(OverlayPosition.DYNAMIC); @@ -65,10 +65,10 @@ public class WarIndicatorMiniMapOverlay extends Overlay final String name = actor.getName().replace('\u00A0', ' '); final net.runelite.api.Point minimapLocation = actor.getMinimapLocation(); - String[] callers = config.getActiveCallers().split(", "); - String[] targets = config.getTargetedSnipes().split(", "); + String[] callers = plugin.getGetActiveCallers().split(", "); + String[] targets = plugin.getGetTargetedSnipes().split(", "); - if (config.callerMinimap() && ArrayUtils.contains(callers, actor.getName())) + if (plugin.isCallerMinimap() && ArrayUtils.contains(callers, actor.getName())) { if (minimapLocation != null) { @@ -76,7 +76,7 @@ public class WarIndicatorMiniMapOverlay extends Overlay } } - if (config.snipeMinimap() && ArrayUtils.contains(targets, actor.getName())) + if (plugin.isSnipeMinimap() && ArrayUtils.contains(targets, actor.getName())) { if (minimapLocation != null) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorOverlay.java index 3eb4c463de..4d24401d7d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorOverlay.java @@ -43,12 +43,12 @@ import org.apache.commons.lang3.ArrayUtils; public class WarIndicatorOverlay extends Overlay { private final WarIndicatorService warIndicatorService; - private final WarIndicatorConfig config; + private final WarIndicatorPlugin plugin; @Inject - private WarIndicatorOverlay(WarIndicatorConfig config, WarIndicatorService warIndicatorService) + private WarIndicatorOverlay(final WarIndicatorPlugin plugin, final WarIndicatorService warIndicatorService) { - this.config = config; + this.plugin = plugin; this.warIndicatorService = warIndicatorService; setLayer(OverlayLayer.ABOVE_SCENE); setPosition(OverlayPosition.DYNAMIC); @@ -64,16 +64,16 @@ public class WarIndicatorOverlay extends Overlay private void renderPlayerOverlay(Graphics2D graphics, Player actor, Color color) { - if (!config.highlightSnipes() && !config.highLightCallers()) + if (!plugin.isHighlightSnipes() && !plugin.isHighLightCallers()) { return; } Polygon poly = actor.getCanvasTilePoly(); - String[] callers = config.getActiveCallers().split(", "); - String[] targets = config.getTargetedSnipes().split(", "); + String[] callers = plugin.getGetActiveCallers().split(", "); + String[] targets = plugin.getGetTargetedSnipes().split(", "); - if (config.callerTile() && ArrayUtils.contains(callers, actor.getName())) + if (plugin.isCallerTile() && ArrayUtils.contains(callers, actor.getName())) { if (poly != null) { @@ -81,7 +81,7 @@ public class WarIndicatorOverlay extends Overlay } } - if (config.snipeTile() && ArrayUtils.contains(targets, actor.getName())) + if (plugin.isSnipeTile() && ArrayUtils.contains(targets, actor.getName())) { if (poly != null) { 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 6e6d80a476..e3ca95d45a 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 @@ -27,6 +27,9 @@ package net.runelite.client.plugins.warindicators; import com.google.inject.Provides; import java.awt.Color; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; +import lombok.Getter; import net.runelite.api.Client; import static net.runelite.api.MenuAction.FOLLOW; import static net.runelite.api.MenuAction.ITEM_USE_ON_PLAYER; @@ -42,6 +45,7 @@ import static net.runelite.api.MenuAction.SPELL_CAST_ON_PLAYER; import static net.runelite.api.MenuAction.TRADE; import net.runelite.api.MenuEntry; import net.runelite.api.Player; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.MenuEntryAdded; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; @@ -58,7 +62,7 @@ import org.apache.commons.lang3.ArrayUtils; type = PluginType.PVP, enabledByDefault = false ) - +@Singleton public class WarIndicatorPlugin extends Plugin { @Inject @@ -76,6 +80,27 @@ public class WarIndicatorPlugin extends Plugin @Inject private Client client; + @Getter(AccessLevel.PACKAGE) + private boolean highLightCallers; + @Getter(AccessLevel.PACKAGE) + private Color getCallerColor; + @Getter(AccessLevel.PACKAGE) + private boolean callerMinimap; + @Getter(AccessLevel.PACKAGE) + private boolean callerTile; + @Getter(AccessLevel.PACKAGE) + private String getActiveCallers; + @Getter(AccessLevel.PACKAGE) + private boolean highlightSnipes; + @Getter(AccessLevel.PACKAGE) + private Color getSnipeColor; + @Getter(AccessLevel.PACKAGE) + private boolean snipeMinimap; + @Getter(AccessLevel.PACKAGE) + private boolean snipeTile; + @Getter(AccessLevel.PACKAGE) + private String getTargetedSnipes; + @Provides WarIndicatorConfig provideConfig(ConfigManager configManager) { @@ -85,6 +110,8 @@ public class WarIndicatorPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(warIndicatorOverlay); overlayManager.add(warIndicatorMiniMapOverlay); } @@ -123,8 +150,8 @@ public class WarIndicatorPlugin extends Plugin Player player = null; String player2 = null; - String[] callers = config.getActiveCallers().split(", "); - String[] targets = config.getTargetedSnipes().split(", "); + String[] callers = this.getActiveCallers.split(", "); + String[] targets = this.getTargetedSnipes.split(", "); if (identifier >= 0 && identifier < players.length) { @@ -139,14 +166,14 @@ public class WarIndicatorPlugin extends Plugin Color color = null; - if (config.highLightCallers() && ArrayUtils.contains(callers, player2)) + if (this.highLightCallers && ArrayUtils.contains(callers, player2)) { - color = config.getCallerColor(); + color = this.getCallerColor; } - if (config.highlightSnipes() && ArrayUtils.contains(targets, player2)) + if (this.highlightSnipes && ArrayUtils.contains(targets, player2)) { - color = config.getSnipeColor(); + color = this.getSnipeColor; } if (color != null) @@ -167,4 +194,27 @@ public class WarIndicatorPlugin extends Plugin } } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("warIndicators")) + { + updateConfig(); + } + } + + private void updateConfig() + { + this.highLightCallers = config.highLightCallers(); + this.getCallerColor = config.getCallerColor(); + this.callerMinimap = config.callerMinimap(); + this.callerTile = config.callerTile(); + this.getActiveCallers = config.getActiveCallers(); + this.highlightSnipes = config.highlightSnipes(); + this.getSnipeColor = config.getSnipeColor(); + this.snipeMinimap = config.snipeMinimap(); + this.snipeTile = config.snipeTile(); + this.getTargetedSnipes = config.getTargetedSnipes(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorService.java b/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorService.java index 1188dc6a12..630cbb4a47 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorService.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/warindicators/WarIndicatorService.java @@ -35,23 +35,23 @@ import net.runelite.api.Player; public class WarIndicatorService { private final Client client; - private final WarIndicatorConfig config; + private final WarIndicatorPlugin plugin; @Inject - private WarIndicatorService(Client client, WarIndicatorConfig config) + private WarIndicatorService(final Client client, final WarIndicatorPlugin plugin) { - this.config = config; + this.plugin = plugin; this.client = client; } public void forEachPlayer(final BiConsumer consumer) { - if (!config.highlightSnipes() && !config.highLightCallers()) + if (!plugin.isHighlightSnipes() && !plugin.isHighLightCallers()) { return; } - if (config.highlightSnipes()) + if (plugin.isHighlightSnipes()) { for (Player player : client.getPlayers()) { @@ -60,19 +60,19 @@ public class WarIndicatorService continue; } - String[] targets = config.getTargetedSnipes().split(", "); + String[] targets = plugin.getGetTargetedSnipes().split(", "); for (String target : targets) { if (player.getName().equalsIgnoreCase(target)) { - consumer.accept(player, config.getSnipeColor()); + consumer.accept(player, plugin.getGetSnipeColor()); } } } } - if (config.highLightCallers()) + if (plugin.isHighLightCallers()) { for (Player player : client.getPlayers()) { @@ -81,13 +81,13 @@ public class WarIndicatorService continue; } - String[] callers = config.getActiveCallers().split(", "); + String[] callers = plugin.getGetActiveCallers().split(", "); for (String caller : callers) { if (player.getName().equalsIgnoreCase(caller)) { - consumer.accept(player, config.getCallerColor()); + consumer.accept(player, plugin.getGetCallerColor()); } } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersGloryOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersGloryOverlay.java index b15b87c431..d5b9d32afa 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersGloryOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersGloryOverlay.java @@ -13,7 +13,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; -import net.runelite.api.Client; +import javax.inject.Singleton; import net.runelite.api.ItemID; import net.runelite.client.game.AsyncBufferedImage; import net.runelite.client.game.ItemManager; @@ -25,10 +25,9 @@ import net.runelite.client.ui.overlay.components.ImageComponent; import net.runelite.client.ui.overlay.components.PanelComponent; import net.runelite.client.ui.overlay.components.TitleComponent; +@Singleton public class WhaleWatchersGloryOverlay extends Overlay { - private Client client; - private final WhaleWatchersConfig config; private WhaleWatchersPlugin plugin; private PanelComponent panelComponent; @@ -36,10 +35,8 @@ public class WhaleWatchersGloryOverlay extends Overlay private ItemManager itemManager; @Inject - public WhaleWatchersGloryOverlay(WhaleWatchersConfig config, Client client, WhaleWatchersPlugin plugin) + public WhaleWatchersGloryOverlay(final WhaleWatchersPlugin plugin) { - this.client = client; - this.config = config; this.plugin = plugin; setLayer(OverlayLayer.ABOVE_WIDGETS); setPriority(OverlayPriority.HIGH); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersOverlay.java index 5ea462699b..a915399cab 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersOverlay.java @@ -12,6 +12,7 @@ package net.runelite.client.plugins.whalewatchers; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.MenuAction; import net.runelite.client.ui.overlay.Overlay; @@ -27,23 +28,22 @@ import net.runelite.client.ui.overlay.components.TitleComponent; * The overlay for the Damage Counter */ +@Singleton public class WhaleWatchersOverlay extends Overlay { private Client client; - private final WhaleWatchersConfig config; private WhaleWatchersPlugin plugin; private PanelComponent panelComponent; private String lastOpponent = "-"; - private final OverlayMenuEntry resetMenuEntry = new OverlayMenuEntry(MenuAction.RUNELITE_OVERLAY, - "Reset", "Damage Counter"); @Inject - public WhaleWatchersOverlay(WhaleWatchersConfig config, Client client, WhaleWatchersPlugin plugin) + public WhaleWatchersOverlay(final Client client, final WhaleWatchersPlugin plugin) { + OverlayMenuEntry resetMenuEntry = new OverlayMenuEntry(MenuAction.RUNELITE_OVERLAY, + "Reset", "Damage Counter"); this.getMenuEntries().add(resetMenuEntry); this.client = client; - this.config = config; this.plugin = plugin; setLayer(OverlayLayer.ABOVE_WIDGETS); setPriority(OverlayPriority.HIGHEST); @@ -57,14 +57,13 @@ public class WhaleWatchersOverlay extends Overlay { panelComponent.getChildren().clear(); - if (plugin.inCombat && config.showDamageCounter()) + if (plugin.inCombat && plugin.isShowDamageCounter()) { panelComponent.setOrientation(ComponentOrientation.HORIZONTAL); panelComponent.setWrapping(5); - String opp = client.getLocalPlayer().getInteracting() != null ? - client.getLocalPlayer().getInteracting().getName() : lastOpponent; - lastOpponent = opp; + lastOpponent = client.getLocalPlayer().getInteracting() != null ? + client.getLocalPlayer().getInteracting().getName() : lastOpponent; String damageTaken = "Damage Taken: " + plugin.damageTaken; String damageDealt = "Damage Dealt: " + plugin.damageDone; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersPlugin.java index 4d554fee56..a35c9fe846 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersPlugin.java @@ -16,6 +16,8 @@ import com.google.inject.Provides; import java.util.EnumSet; import java.util.Objects; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.InventoryID; @@ -50,16 +52,16 @@ import org.apache.commons.lang3.ObjectUtils; type = PluginType.PVP, enabledByDefault = false ) - +@Singleton public class WhaleWatchersPlugin extends Plugin { private static final String CONFIG_GROUP_NAME = "WhaleWatchers"; - public boolean protectItemOverlay = false; - public int damageDone = 0; - public int damageTaken = 0; - public boolean inCombat = false; + boolean protectItemOverlay = false; + int damageDone = 0; + int damageTaken = 0; + boolean inCombat = false; @Inject private Client client; @Inject @@ -75,11 +77,18 @@ public class WhaleWatchersPlugin extends Plugin @Inject private OverlayManager overlayManager; private int tickCountdown = 0; - @Getter + @Getter(AccessLevel.PACKAGE) private boolean displaySmiteOverlay; - @Getter + @Getter(AccessLevel.PACKAGE) private boolean displayGloryOverlay; + @Getter(AccessLevel.PACKAGE) + private boolean protectItemWarning; + @Getter(AccessLevel.PACKAGE) + private boolean showDamageCounter; + private boolean smiteableWarning; + private boolean gloryWarning; + @Provides WhaleWatchersConfig getConfig(ConfigManager configManager) { @@ -101,6 +110,7 @@ public class WhaleWatchersPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); overlayManager.add(overlay); overlayManager.add(whaleWatchersProtOverlay); @@ -126,15 +136,17 @@ public class WhaleWatchersPlugin extends Plugin return; } - if (!config.protectItemWarning()) + updateConfig(); + + if (!this.protectItemWarning) { protectItemOverlay = false; } - if (!config.gloryWarning()) + if (!this.gloryWarning) { displayGloryOverlay = false; } - if (!config.smiteableWarning()) + if (!this.smiteableWarning) { displaySmiteOverlay = false; } @@ -144,7 +156,7 @@ public class WhaleWatchersPlugin extends Plugin @Subscribe public void onHitsplatApplied(HitsplatApplied event) { - if (config.showDamageCounter()) + if (this.showDamageCounter) { if (!(event.getActor() == client.getLocalPlayer() || event.getActor() == client.getLocalPlayer().getInteracting())) @@ -170,7 +182,7 @@ public class WhaleWatchersPlugin extends Plugin @Subscribe public void onItemContainerChanged(ItemContainerChanged event) { - if (config.gloryWarning() && event.getItemContainer() == client.getItemContainer(InventoryID.EQUIPMENT)) + if (this.gloryWarning && event.getItemContainer() == client.getItemContainer(InventoryID.EQUIPMENT)) { final int amuletID = ObjectUtils.defaultIfNull(client.getLocalPlayer() .getPlayerAppearance().getEquipmentId(KitType.AMULET), 0); @@ -186,7 +198,7 @@ public class WhaleWatchersPlugin extends Plugin @Subscribe public void onMenuOptionClicked(MenuOptionClicked event) { - if (config.showDamageCounter() && event.getMenuAction().equals(MenuAction.SPELL_CAST_ON_PLAYER)) + if (this.showDamageCounter && event.getMenuAction().equals(MenuAction.SPELL_CAST_ON_PLAYER)) { inCombat = true; } @@ -195,7 +207,7 @@ public class WhaleWatchersPlugin extends Plugin @Subscribe public void onVarbitChanged(VarbitChanged event) { - if (config.showDamageCounter()) + if (this.showDamageCounter) { if (client.getVar(VarPlayer.ATTACKING_PLAYER) == -1) { @@ -206,12 +218,12 @@ public class WhaleWatchersPlugin extends Plugin } } - if (config.protectItemWarning()) + if (this.protectItemWarning) { try { final SkullIcon skullIcon = Objects.requireNonNull(client.getLocalPlayer().getSkullIcon()); - final EnumSet worldTypes = client.getWorldType(); + final EnumSet worldTypes = client.getWorldType(); if (WorldType.isHighRiskWorld(worldTypes)) { protectItemOverlay = false; @@ -242,7 +254,7 @@ public class WhaleWatchersPlugin extends Plugin @Subscribe public void onGameTick(GameTick event) { - if (config.showDamageCounter()) + if (this.showDamageCounter) { if (tickCountdown > 0 && tickCountdown < 11) { @@ -255,7 +267,7 @@ public class WhaleWatchersPlugin extends Plugin } } } - if (config.smiteableWarning() && (client.getVar(Varbits.IN_WILDERNESS) == 1 || isPvpWorld(client.getWorldType()))) + if (this.smiteableWarning && (client.getVar(Varbits.IN_WILDERNESS) == 1 || isPvpWorld(client.getWorldType()))) { if (client.getLocalPlayer().getSkullIcon() != null && client.getLocalPlayer().getSkullIcon().equals(SkullIcon.SKULL)) { @@ -294,5 +306,13 @@ public class WhaleWatchersPlugin extends Plugin damageTaken = 0; damageDone = 0; } + + private void updateConfig() + { + this.protectItemWarning = config.protectItemWarning(); + this.showDamageCounter = config.showDamageCounter(); + this.smiteableWarning = config.smiteableWarning(); + this.gloryWarning = config.gloryWarning(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersProtOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersProtOverlay.java index b0d7dc7cac..17de8ac9b8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersProtOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersProtOverlay.java @@ -20,6 +20,7 @@ import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.Stroke; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Point; import net.runelite.client.ui.FontManager; @@ -29,19 +30,17 @@ import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; import net.runelite.client.ui.overlay.OverlayUtil; - +@Singleton public class WhaleWatchersProtOverlay extends Overlay { private Client client; - private final WhaleWatchersConfig config; private WhaleWatchersPlugin plugin; @Inject - public WhaleWatchersProtOverlay(WhaleWatchersConfig config, Client client, WhaleWatchersPlugin plugin) + public WhaleWatchersProtOverlay(final Client client, final WhaleWatchersPlugin plugin) { this.client = client; - this.config = config; this.plugin = plugin; setLayer(OverlayLayer.ABOVE_WIDGETS); setPriority(OverlayPriority.HIGH); @@ -51,7 +50,7 @@ public class WhaleWatchersProtOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (plugin.protectItemOverlay && config.protectItemWarning()) + if (plugin.protectItemOverlay && plugin.isProtectItemWarning()) { Rectangle rectangle = new Rectangle(); rectangle.setBounds(client.getCanvas().getBounds()); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersSmiteableOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersSmiteableOverlay.java index 4be28dce80..0d2cd567e9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersSmiteableOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/whalewatchers/WhaleWatchersSmiteableOverlay.java @@ -14,6 +14,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; @@ -24,6 +25,7 @@ import net.runelite.client.ui.overlay.components.TitleComponent; /** * The overlay for the smiteable warning */ +@Singleton public class WhaleWatchersSmiteableOverlay extends Overlay { private WhaleWatchersPlugin plugin; @@ -31,7 +33,7 @@ public class WhaleWatchersSmiteableOverlay extends Overlay @Inject - public WhaleWatchersSmiteableOverlay(WhaleWatchersPlugin plugin) + public WhaleWatchersSmiteableOverlay(final WhaleWatchersPlugin plugin) { this.plugin = plugin; setLayer(OverlayLayer.ABOVE_WIDGETS); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiPlugin.java index 8ff438b68f..b07ea0bad0 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiPlugin.java @@ -30,6 +30,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.inject.Inject; import javax.inject.Provider; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.MenuAction; @@ -64,6 +65,7 @@ import okhttp3.HttpUrl; name = "Wiki", description = "Adds a Wiki button that takes you to the OSRS Wiki" ) +@Singleton public class WikiPlugin extends Plugin { private static final int[] QUESTLIST_WIDGET_IDS = new int[] diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSearchChatboxTextInput.java b/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSearchChatboxTextInput.java index 96ebec1479..0753c24338 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSearchChatboxTextInput.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSearchChatboxTextInput.java @@ -75,8 +75,7 @@ public class WikiSearchChatboxTextInput extends ChatboxTextInput private String offPrediction = null; @Inject - public WikiSearchChatboxTextInput(ChatboxPanelManager chatboxPanelManager, ClientThread clientThread, - ScheduledExecutorService scheduledExecutorService, @Named("developerMode") final boolean developerMode) + public WikiSearchChatboxTextInput(final ChatboxPanelManager chatboxPanelManager, final ClientThread clientThread, final ScheduledExecutorService scheduledExecutorService, @Named("developerMode") final boolean developerMode) { super(chatboxPanelManager, clientThread); this.chatboxPanelManager = chatboxPanelManager; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSprite.java b/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSprite.java index 188d54837b..b470dc2212 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSprite.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/wiki/WikiSprite.java @@ -24,6 +24,7 @@ */ package net.runelite.client.plugins.wiki; +import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; import net.runelite.api.SpriteID; @@ -36,9 +37,9 @@ public enum WikiSprite implements SpriteOverride WIKI_SELECTED_ICON(-301, "wiki_selected.png"), FIXED_MODE_MINIMAP_CLICKMASK(SpriteID.MINIMAP_CLICK_MASK, "fixed_mode_minimap_clickmask.png"); - @Getter + @Getter(AccessLevel.PUBLIC) private final int spriteId; - @Getter + @Getter(AccessLevel.PUBLIC) private final String fileName; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wildernesslocations/WildernessLocationsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/wildernesslocations/WildernessLocationsOverlay.java index 41ad66e7d2..921ed916b6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wildernesslocations/WildernessLocationsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/wildernesslocations/WildernessLocationsOverlay.java @@ -12,22 +12,21 @@ package net.runelite.client.plugins.wildernesslocations; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; 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.TextComponent; +@Singleton public class WildernessLocationsOverlay extends Overlay { private final WildernessLocationsPlugin plugin; private TextComponent textComponent; @Inject - private WildernessLocationsConfig wildyConfig; - - @Inject - public WildernessLocationsOverlay(WildernessLocationsPlugin plugin) + public WildernessLocationsOverlay(final WildernessLocationsPlugin plugin) { this.plugin = plugin; setLayer(OverlayLayer.ABOVE_WIDGETS); @@ -39,7 +38,7 @@ public class WildernessLocationsOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (plugin.isRenderLocation() && wildyConfig.drawOverlay()) + if (plugin.isRenderLocation() && plugin.isDrawOverlay()) { textComponent.setText(plugin.getLocationString()); return textComponent.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 ba776475ed..b051211fc6 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 @@ -16,6 +16,8 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; @@ -24,11 +26,13 @@ import net.runelite.api.VarClientStr; import net.runelite.api.Varbits; import net.runelite.api.coords.WorldArea; import net.runelite.api.coords.WorldPoint; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.VarClientStrChanged; import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ConfigManager; +import net.runelite.client.config.Keybind; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.input.KeyManager; import net.runelite.client.plugins.Plugin; @@ -46,7 +50,7 @@ import net.runelite.client.util.WildernessLocation; type = PluginType.PVP, enabledByDefault = false ) - +@Singleton public class WildernessLocationsPlugin extends Plugin { @@ -79,7 +83,7 @@ public class WildernessLocationsPlugin extends Plugin private WorldPoint worldPoint = null; private final HashMap wildLocs = getLocationMap(); - private final HotkeyListener hotkeyListener = new HotkeyListener(() -> wildyConfig.keybind()) + private final HotkeyListener hotkeyListener = new HotkeyListener(() -> this.keybind) { @Override public void hotkeyPressed() @@ -88,6 +92,10 @@ public class WildernessLocationsPlugin extends Plugin } }; + @Getter(AccessLevel.PACKAGE) + private boolean drawOverlay; + private Keybind keybind; + @Provides WildernessLocationsConfig getConfig(ConfigManager configManager) { @@ -97,10 +105,25 @@ public class WildernessLocationsPlugin extends Plugin @Override protected void startUp() throws Exception { + this.drawOverlay = wildyConfig.drawOverlay(); + this.keybind = wildyConfig.keybind(); + overlayManager.add(overlay); keyManager.registerKeyListener(hotkeyListener); } + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("wildernesslocations")) + { + return; + } + + this.drawOverlay = wildyConfig.drawOverlay(); + this.keybind = wildyConfig.keybind(); + } + @Override protected void shutDown() throws Exception { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtActivity.java b/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtActivity.java index dadca4137b..bf81e101be 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtActivity.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtActivity.java @@ -25,11 +25,12 @@ */ package net.runelite.client.plugins.wintertodt; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @AllArgsConstructor -@Getter +@Getter(AccessLevel.PACKAGE) enum WintertodtActivity { IDLE("IDLE"), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtInterruptType.java b/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtInterruptType.java index db7fe0d416..582cf55ed6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtInterruptType.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtInterruptType.java @@ -25,11 +25,12 @@ */ package net.runelite.client.plugins.wintertodt; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @AllArgsConstructor -@Getter +@Getter(AccessLevel.PACKAGE) enum WintertodtInterruptType { COLD("Damaged by Wintertodt Cold"), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtOverlay.java index 95dc4a7e42..edf894b549 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtOverlay.java @@ -29,6 +29,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.api.Skill; @@ -44,6 +45,7 @@ import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; import net.runelite.client.util.ColorUtil; +@Singleton class WintertodtOverlay extends Overlay { @Inject @@ -53,7 +55,7 @@ class WintertodtOverlay extends Overlay private final PanelComponent panelComponent = new PanelComponent(); @Inject - private WintertodtOverlay(WintertodtPlugin plugin) + private WintertodtOverlay(final WintertodtPlugin plugin) { super(plugin); this.plugin = plugin; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtPlugin.java index 0ad69971f7..a27565a015 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/WintertodtPlugin.java @@ -26,9 +26,11 @@ package net.runelite.client.plugins.wintertodt; import com.google.inject.Provides; +import java.awt.Color; import java.time.Duration; import java.time.Instant; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -44,6 +46,7 @@ import net.runelite.api.MessageNode; import net.runelite.api.Player; import net.runelite.api.events.AnimationChanged; import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.GameTick; import net.runelite.api.events.ItemContainerChanged; import net.runelite.client.Notifier; @@ -52,6 +55,7 @@ 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.wintertodt.config.WintertodtNotifyMode; import net.runelite.client.ui.overlay.OverlayManager; import net.runelite.client.util.ColorUtil; @@ -61,6 +65,7 @@ import net.runelite.client.util.ColorUtil; tags = {"minigame", "firemaking", "boss"} ) @Slf4j +@Singleton public class WintertodtPlugin extends Plugin { private static final int WINTERTODT_REGION = 6462; @@ -100,6 +105,9 @@ public class WintertodtPlugin extends Plugin private Instant lastActionTime; + private WintertodtNotifyMode notifyCondition; + private Color damageNotificationColor; + @Provides WintertodtConfig getConfig(ConfigManager configManager) { @@ -109,6 +117,9 @@ public class WintertodtPlugin extends Plugin @Override protected void startUp() throws Exception { + this.notifyCondition = config.notifyCondition(); + this.damageNotificationColor = config.damageNotificationColor(); + reset(); overlayManager.add(overlay); } @@ -120,6 +131,18 @@ public class WintertodtPlugin extends Plugin reset(); } + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("wintertodt")) + { + return; + } + + this.notifyCondition = config.notifyCondition(); + this.damageNotificationColor = config.damageNotificationColor(); + } + private void reset() { numRoots = 0; @@ -253,7 +276,7 @@ public class WintertodtPlugin extends Plugin wasDamaged = true; // Recolor message for damage notification - messageNode.setRuneLiteFormatMessage(ColorUtil.wrapWithColorTag(messageNode.getValue(), config.damageNotificationColor())); + messageNode.setRuneLiteFormatMessage(ColorUtil.wrapWithColorTag(messageNode.getValue(), this.damageNotificationColor)); chatMessageManager.update(messageNode); client.refreshChat(); @@ -280,7 +303,7 @@ public class WintertodtPlugin extends Plugin { boolean shouldNotify = false; - switch (config.notifyCondition()) + switch (this.notifyCondition) { case ONLY_WHEN_INTERRUPTED: if (wasInterrupted) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/config/WintertodtNotifyMode.java b/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/config/WintertodtNotifyMode.java index c5a3b114fd..e5c54b7be6 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/config/WintertodtNotifyMode.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/wintertodt/config/WintertodtNotifyMode.java @@ -25,10 +25,11 @@ */ package net.runelite.client.plugins.wintertodt.config; +import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; -@Getter +@Getter(AccessLevel.PACKAGE) @RequiredArgsConstructor public enum WintertodtNotifyMode { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/Axe.java b/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/Axe.java index 7b8a5c5f4e..709ea85378 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/Axe.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/Axe.java @@ -26,6 +26,7 @@ package net.runelite.client.plugins.woodcutting; import com.google.common.collect.ImmutableMap; import java.util.Map; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import static net.runelite.api.AnimationID.WOODCUTTING_3A_AXE; @@ -50,7 +51,7 @@ import static net.runelite.api.ItemID.STEEL_AXE; import static net.runelite.api.ItemID._3RD_AGE_AXE; @AllArgsConstructor -@Getter +@Getter(AccessLevel.PACKAGE) enum Axe { BRONZE(WOODCUTTING_BRONZE, BRONZE_AXE), diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/Tree.java b/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/Tree.java index befc78df8c..dfb670ac5a 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/Tree.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/Tree.java @@ -26,18 +26,19 @@ package net.runelite.client.plugins.woodcutting; import com.google.common.collect.ImmutableMap; import java.util.Map; +import lombok.AccessLevel; import lombok.Getter; import static net.runelite.api.ObjectID.REDWOOD; import static net.runelite.api.ObjectID.REDWOOD_29670; -@Getter +@Getter(AccessLevel.PACKAGE) enum Tree { REDWOOD_TREE_SPAWN(REDWOOD, REDWOOD_29670); private final int[] treeIds; - Tree(int... treeIds) + Tree(final int... treeIds) { this.treeIds = treeIds; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/WoodcuttingOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/WoodcuttingOverlay.java index 497d9695b4..0aa27918d7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/WoodcuttingOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/WoodcuttingOverlay.java @@ -28,6 +28,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.api.Skill; @@ -41,22 +42,21 @@ import net.runelite.client.ui.overlay.components.TitleComponent; import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; +@Singleton class WoodcuttingOverlay extends Overlay { private final Client client; private final WoodcuttingPlugin plugin; - private final WoodcuttingConfig config; private final XpTrackerService xpTrackerService; private final PanelComponent panelComponent = new PanelComponent(); @Inject - private WoodcuttingOverlay(Client client, WoodcuttingPlugin plugin, WoodcuttingConfig config, XpTrackerService xpTrackerService) + private WoodcuttingOverlay(final Client client, final WoodcuttingPlugin plugin, final 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, "Woodcutting overlay")); } @@ -64,7 +64,7 @@ class WoodcuttingOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (!config.showWoodcuttingStats()) + if (!plugin.isShowWoodcuttingStats()) { return null; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/WoodcuttingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/WoodcuttingPlugin.java index 28547b8921..996a13cb30 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/WoodcuttingPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/WoodcuttingPlugin.java @@ -30,6 +30,8 @@ import java.time.Instant; import java.util.HashSet; import java.util.Set; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; @@ -38,6 +40,7 @@ import net.runelite.api.GameState; import net.runelite.api.Player; import net.runelite.api.events.AnimationChanged; 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; @@ -57,6 +60,7 @@ import net.runelite.client.ui.overlay.OverlayManager; description = "Show woodcutting statistics and/or bird nest notifications", tags = {"birds", "nest", "notifications", "overlay", "skilling", "wc"} ) +@Singleton @PluginDependency(XpTrackerPlugin.class) public class WoodcuttingPlugin extends Plugin { @@ -78,15 +82,22 @@ public class WoodcuttingPlugin extends Plugin @Inject private WoodcuttingConfig config; - @Getter + @Getter(AccessLevel.PACKAGE) private WoodcuttingSession session; - @Getter + @Getter(AccessLevel.PACKAGE) private Axe axe; - @Getter + @Getter(AccessLevel.PACKAGE) private final Set treeObjects = new HashSet<>(); + private int statTimeout; + private boolean showNestNotification; + @Getter(AccessLevel.PACKAGE) + private boolean showWoodcuttingStats; + @Getter(AccessLevel.PACKAGE) + private boolean showRedwoodTrees; + @Provides WoodcuttingConfig getConfig(ConfigManager configManager) { @@ -96,6 +107,8 @@ public class WoodcuttingPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + overlayManager.add(overlay); overlayManager.add(treesOverlay); } @@ -118,7 +131,7 @@ public class WoodcuttingPlugin extends Plugin return; } - Duration statTimeout = Duration.ofMinutes(config.statTimeout()); + Duration statTimeout = Duration.ofMinutes(this.statTimeout); Duration sinceCut = Duration.between(session.getLastLogCut(), Instant.now()); if (sinceCut.compareTo(statTimeout) >= 0) @@ -143,7 +156,7 @@ public class WoodcuttingPlugin extends Plugin session.setLastLogCut(); } - if (event.getMessage().contains("A bird's nest falls out of the tree") && config.showNestNotification()) + if (event.getMessage().contains("A bird's nest falls out of the tree") && this.showNestNotification) { notifier.notify("A bird nest has spawned!"); } @@ -200,4 +213,23 @@ public class WoodcuttingPlugin extends Plugin this.axe = axe; } } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("woodcutting")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.statTimeout = config.statTimeout(); + this.showNestNotification = config.showNestNotification(); + this.showWoodcuttingStats = config.showWoodcuttingStats(); + this.showRedwoodTrees = config.showRedwoodTrees(); + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/WoodcuttingSession.java b/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/WoodcuttingSession.java index ac5d66130e..aaf2919c01 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/WoodcuttingSession.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/WoodcuttingSession.java @@ -26,16 +26,16 @@ package net.runelite.client.plugins.woodcutting; import java.time.Instant; -public class WoodcuttingSession +class WoodcuttingSession { private Instant lastLogCut; - public void setLastLogCut() + void setLastLogCut() { lastLogCut = Instant.now(); } - public Instant getLastLogCut() + Instant getLastLogCut() { return lastLogCut; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/WoodcuttingTreesOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/WoodcuttingTreesOverlay.java index 2415d17f7a..cf25150169 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/WoodcuttingTreesOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/woodcutting/WoodcuttingTreesOverlay.java @@ -28,6 +28,7 @@ package net.runelite.client.plugins.woodcutting; import java.awt.Dimension; import java.awt.Graphics2D; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.GameObject; import net.runelite.client.game.ItemManager; @@ -36,18 +37,17 @@ import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayUtil; +@Singleton class WoodcuttingTreesOverlay extends Overlay { private final Client client; - private final WoodcuttingConfig config; private final ItemManager itemManager; private final WoodcuttingPlugin plugin; @Inject - private WoodcuttingTreesOverlay(final Client client, final WoodcuttingConfig config, final ItemManager itemManager, final WoodcuttingPlugin plugin) + private WoodcuttingTreesOverlay(final Client client, final ItemManager itemManager, final WoodcuttingPlugin plugin) { this.client = client; - this.config = config; this.itemManager = itemManager; this.plugin = plugin; setLayer(OverlayLayer.ABOVE_SCENE); @@ -57,7 +57,7 @@ class WoodcuttingTreesOverlay extends Overlay @Override public Dimension render(Graphics2D graphics) { - if (plugin.getSession() == null || !config.showRedwoodTrees()) + if (plugin.getSession() == null || !plugin.isShowRedwoodTrees()) { return null; } 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 84abfcf9f5..1ee270ed2c 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 @@ -44,6 +44,7 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import javax.imageio.ImageIO; import javax.inject.Inject; +import javax.inject.Singleton; import javax.swing.SwingUtilities; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -65,12 +66,12 @@ import net.runelite.api.events.PlayerMenuOptionClicked; import net.runelite.api.events.VarbitChanged; import net.runelite.api.events.WorldListLoad; import net.runelite.api.widgets.WidgetInfo; -import net.runelite.client.callback.ClientThread; 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.config.ConfigManager; +import net.runelite.client.config.Keybind; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.input.KeyManager; import net.runelite.client.plugins.Plugin; @@ -93,6 +94,7 @@ import org.apache.commons.lang3.ArrayUtils; description = "Allows you to quickly hop worlds" ) @Slf4j +@Singleton public class WorldHopperPlugin extends Plugin { private static final int WORLD_FETCH_TIMER = 10; @@ -110,9 +112,6 @@ public class WorldHopperPlugin extends Plugin @Inject private Client client; - @Inject - private ClientThread clientThread; - @Inject private ConfigManager configManager; @@ -149,7 +148,15 @@ public class WorldHopperPlugin extends Plugin private Instant lastFetch; private boolean firstRun; - private final HotkeyListener previousKeyListener = new HotkeyListener(() -> config.previousKey()) + private Keybind previousKey; + private Keybind nextKey; + private boolean quickhopOutOfDanger; + private boolean showSidebar; + private boolean ping; + private boolean showWorldHopMessage; + private SubscriptionFilterMode subscriptionFilter; + + private final HotkeyListener previousKeyListener = new HotkeyListener(() -> this.previousKey) { @Override public void hotkeyPressed() @@ -157,7 +164,7 @@ public class WorldHopperPlugin extends Plugin hop(true); } }; - private final HotkeyListener nextKeyListener = new HotkeyListener(() -> config.nextKey()) + private final HotkeyListener nextKeyListener = new HotkeyListener(() -> this.nextKey) { @Override public void hotkeyPressed() @@ -175,6 +182,8 @@ public class WorldHopperPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); + firstRun = true; keyManager.registerKeyListener(previousKeyListener); @@ -195,12 +204,12 @@ public class WorldHopperPlugin extends Plugin .panel(panel) .build(); - if (config.showSidebar()) + if (this.showSidebar) { clientToolbar.addNavigation(navButton); } - panel.setFilterMode(config.subscriptionFilter()); + panel.setFilterMode(this.subscriptionFilter); worldResultFuture = executorService.scheduleAtFixedRate(this::tick, 0, WORLD_FETCH_TIMER, TimeUnit.MINUTES); hopperExecutorService = new ExecutorServiceExceptionLogger(Executors.newSingleThreadScheduledExecutor()); @@ -232,10 +241,12 @@ public class WorldHopperPlugin extends Plugin { if (event.getGroup().equals(WorldHopperConfig.GROUP)) { + updateConfig(); + switch (event.getKey()) { case "showSidebar": - if (config.showSidebar()) + if (this.showSidebar) { clientToolbar.addNavigation(navButton); } @@ -245,7 +256,7 @@ public class WorldHopperPlugin extends Plugin } break; case "ping": - if (config.ping()) + if (this.ping) { SwingUtilities.invokeLater(() -> panel.showPing()); } @@ -255,7 +266,7 @@ public class WorldHopperPlugin extends Plugin } break; case "subscriptionFilter": - panel.setFilterMode(config.subscriptionFilter()); + panel.setFilterMode(this.subscriptionFilter); updateList(); break; } @@ -409,7 +420,7 @@ public class WorldHopperPlugin extends Plugin public void onGameStateChanged(GameStateChanged gameStateChanged) { // If the player has disabled the side bar plugin panel, do not update the UI - if (config.showSidebar() && gameStateChanged.getGameState() == GameState.LOGGED_IN) + if (this.showSidebar && gameStateChanged.getGameState() == GameState.LOGGED_IN) { if (lastWorld != client.getWorld()) { @@ -423,7 +434,7 @@ public class WorldHopperPlugin extends Plugin @Subscribe public void onWorldListLoad(WorldListLoad worldListLoad) { - if (!config.showSidebar()) + if (!this.showSidebar) { return; } @@ -516,7 +527,7 @@ public class WorldHopperPlugin extends Plugin EnumSet currentWorldTypes = currentWorld.getTypes().clone(); // Make it so you always hop out of PVP and high risk worlds - if (config.quickhopOutOfDanger()) + if (this.quickhopOutOfDanger) { currentWorldTypes.remove(WorldType.PVP); currentWorldTypes.remove(WorldType.HIGH_RISK); @@ -634,7 +645,7 @@ public class WorldHopperPlugin extends Plugin return; } - if (config.showWorldHopMessage()) + if (this.showWorldHopMessage) { String chatMessage = new ChatMessageBuilder() .append(ChatColorType.NORMAL) @@ -752,7 +763,7 @@ public class WorldHopperPlugin extends Plugin private void pingWorlds() { - if (worldResult == null || !config.showSidebar() || !config.ping()) + if (worldResult == null || !this.showSidebar || !this.ping) { return; } @@ -769,4 +780,15 @@ public class WorldHopperPlugin extends Plugin log.debug("Done pinging worlds in {}", stopwatch.elapsed()); } + + private void updateConfig() + { + this.previousKey = config.previousKey(); + this.nextKey = config.nextKey(); + this.quickhopOutOfDanger = config.quickhopOutOfDanger(); + this.showSidebar = config.showSidebar(); + this.ping = config.ping(); + this.showWorldHopMessage = config.showWorldHopMessage(); + this.subscriptionFilter = config.subscriptionFilter(); + } } 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 27eb29b321..bb5fbda991 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 @@ -33,6 +33,7 @@ import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.List; import java.util.Map; +import javax.inject.Singleton; import javax.swing.JPanel; import javax.swing.SwingUtilities; import lombok.AccessLevel; @@ -45,6 +46,7 @@ import net.runelite.http.api.worlds.World; import net.runelite.http.api.worlds.WorldType; @Slf4j +@Singleton class WorldSwitcherPanel extends PluginPanel { private static final Color ODD_ROW = new Color(44, 44, 44); 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 25d0cc9f9a..a1ad1e76b7 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,6 +31,7 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.image.BufferedImage; import javax.annotation.Nonnull; +import javax.inject.Singleton; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JLabel; @@ -43,6 +44,7 @@ import net.runelite.client.ui.ColorScheme; import net.runelite.client.ui.FontManager; import net.runelite.client.util.ImageUtil; +@Singleton class WorldTableHeader extends JPanel { private static final ImageIcon ARROW_UP; 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 3133a81a4f..7aa7eb12b1 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 @@ -32,6 +32,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.function.BiConsumer; import java.util.function.Consumer; +import javax.inject.Singleton; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JMenuItem; @@ -45,6 +46,7 @@ import net.runelite.client.util.ImageUtil; import net.runelite.http.api.worlds.World; import net.runelite.http.api.worlds.WorldType; +@Singleton class WorldTableRow extends JPanel { private static final ImageIcon FLAG_AUS; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/ping/IcmpEchoReply.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/ping/IcmpEchoReply.java index 0e1cc198a3..75a7e4226c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/ping/IcmpEchoReply.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/ping/IcmpEchoReply.java @@ -47,7 +47,7 @@ public class IcmpEchoReply extends Structure public WinDef.UCHAR optionsSize; public WinDef.PVOID optionsData; - IcmpEchoReply(Pointer p) + IcmpEchoReply(final Pointer p) { super(p); } 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 d5be4c8591..7f8a0ec744 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 @@ -127,6 +127,24 @@ public class WorldMapPlugin extends Plugin private int agilityLevel = 0; private int woodcuttingLevel = 0; + private boolean fairyRingTooltips; + private boolean fairyRingIcon; + private boolean agilityShortcutTooltips; + private boolean agilityShortcutLevelIcon; + private boolean normalTeleportIcon; + private boolean minigameTooltip; + private boolean ancientTeleportIcon; + private boolean lunarTeleportIcon; + private boolean arceuusTeleportIcon; + private boolean jewelleryTeleportIcon; + private boolean scrollTeleportIcon; + private boolean miscellaneousTeleportIcon; + private boolean questStartTooltips; + private boolean farmingPatchTooltips; + private boolean rareTreeTooltips; + private boolean rareTreeLevelIcon; + private boolean transportationTeleportTooltips; + @Provides WorldMapConfig provideConfig(ConfigManager configManager) { @@ -136,6 +154,7 @@ public class WorldMapPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); agilityLevel = client.getRealSkillLevel(Skill.AGILITY); woodcuttingLevel = client.getRealSkillLevel(Skill.WOODCUTTING); updateShownIcons(); @@ -164,6 +183,7 @@ public class WorldMapPlugin extends Plugin return; } + updateConfig(); updateShownIcons(); } @@ -206,13 +226,13 @@ public class WorldMapPlugin extends Plugin { worldMapPointManager.removeIf(AgilityShortcutPoint.class::isInstance); - if (config.agilityShortcutLevelIcon() || config.agilityShortcutTooltips()) + if (this.agilityShortcutLevelIcon || this.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())) + agilityLevel > 0 && this.agilityShortcutLevelIcon && value.getLevel() > agilityLevel ? NOPE_ICON : BLANK_ICON, + this.agilityShortcutTooltips)) .forEach(worldMapPointManager::add); } } @@ -221,15 +241,15 @@ public class WorldMapPlugin extends Plugin { worldMapPointManager.removeIf(RareTreePoint.class::isInstance); - if (config.rareTreeLevelIcon() || config.rareTreeTooltips()) + if (this.rareTreeLevelIcon || this.rareTreeTooltips) { Arrays.stream(RareTreeLocation.values()).forEach(rareTree -> Arrays.stream(rareTree.getLocations()) .map(point -> new RareTreePoint(point, rareTree.getTooltip(), - woodcuttingLevel > 0 && config.rareTreeLevelIcon() && + woodcuttingLevel > 0 && this.rareTreeLevelIcon && rareTree.getLevelReq() > woodcuttingLevel ? NOPE_ICON : BLANK_ICON, - config.rareTreeTooltips())) + this.rareTreeTooltips)) .forEach(worldMapPointManager::add)); } } @@ -241,17 +261,17 @@ public class WorldMapPlugin extends Plugin updateQuestStartPointIcons(); worldMapPointManager.removeIf(FairyRingPoint.class::isInstance); - if (config.fairyRingIcon() || config.fairyRingTooltips()) + if (this.fairyRingIcon || this.fairyRingTooltips) { Arrays.stream(FairyRingLocation.values()) .map(value -> new FairyRingPoint(value, - config.fairyRingIcon() ? FAIRY_TRAVEL_ICON : BLANK_ICON, - config.fairyRingTooltips())) + this.fairyRingIcon ? FAIRY_TRAVEL_ICON : BLANK_ICON, + this.fairyRingTooltips)) .forEach(worldMapPointManager::add); } worldMapPointManager.removeIf(MinigamePoint.class::isInstance); - if (config.minigameTooltip()) + if (this.minigameTooltip) { Arrays.stream(MinigameLocation.values()) .map(value -> new MinigamePoint(value, BLANK_ICON)) @@ -259,7 +279,7 @@ public class WorldMapPlugin extends Plugin } worldMapPointManager.removeIf(TransportationPoint.class::isInstance); - if (config.transportationTeleportTooltips()) + if (this.transportationTeleportTooltips) { Arrays.stream(TransportationPointLocation.values()) .map(value -> new TransportationPoint(value, BLANK_ICON)) @@ -267,7 +287,7 @@ public class WorldMapPlugin extends Plugin } worldMapPointManager.removeIf(FarmingPatchPoint.class::isInstance); - if (config.farmingPatchTooltips()) + if (this.farmingPatchTooltips) { Arrays.stream(FarmingPatchLocation.values()).forEach(location -> Arrays.stream(location.getLocations()) @@ -283,19 +303,19 @@ public class WorldMapPlugin extends Plugin switch (data.getType()) { case NORMAL_MAGIC: - return config.normalTeleportIcon(); + return this.normalTeleportIcon; case ANCIENT_MAGICKS: - return config.ancientTeleportIcon(); + return this.ancientTeleportIcon; case LUNAR_MAGIC: - return config.lunarTeleportIcon(); + return this.lunarTeleportIcon; case ARCEUUS_MAGIC: - return config.arceuusTeleportIcon(); + return this.arceuusTeleportIcon; case JEWELLERY: - return config.jewelleryTeleportIcon(); + return this.jewelleryTeleportIcon; case SCROLL: - return config.scrollTeleportIcon(); + return this.scrollTeleportIcon; case OTHER: - return config.miscellaneousTeleportIcon(); + return this.miscellaneousTeleportIcon; default: return false; } @@ -307,7 +327,7 @@ public class WorldMapPlugin extends Plugin { worldMapPointManager.removeIf(QuestStartPoint.class::isInstance); - if (!config.questStartTooltips()) + if (!this.questStartTooltips) { return; } @@ -333,11 +353,11 @@ public class WorldMapPlugin extends Plugin // Get first uncompleted quest. Else, return the last quest. Quest quest = null; - for (int i = 0; i < quests.length; i++) + for (Quest value : quests) { - if (quests[i].getState(client) != QuestState.FINISHED) + if (value.getState(client) != QuestState.FINISHED) { - quest = quests[i]; + quest = value; break; } } @@ -370,4 +390,25 @@ public class WorldMapPlugin extends Plugin return new QuestStartPoint(data.getLocation(), icon, tooltip); } + + private void updateConfig() + { + this.fairyRingTooltips = config.fairyRingTooltips(); + this.fairyRingIcon = config.fairyRingIcon(); + this.agilityShortcutTooltips = config.agilityShortcutTooltips(); + this.agilityShortcutLevelIcon = config.agilityShortcutLevelIcon(); + this.normalTeleportIcon = config.normalTeleportIcon(); + this.minigameTooltip = config.minigameTooltip(); + this.ancientTeleportIcon = config.ancientTeleportIcon(); + this.lunarTeleportIcon = config.lunarTeleportIcon(); + this.arceuusTeleportIcon = config.arceuusTeleportIcon(); + this.jewelleryTeleportIcon = config.jewelleryTeleportIcon(); + this.scrollTeleportIcon = config.scrollTeleportIcon(); + this.miscellaneousTeleportIcon = config.miscellaneousTeleportIcon(); + this.questStartTooltips = config.questStartTooltips(); + this.farmingPatchTooltips = config.farmingPatchTooltips(); + this.rareTreeTooltips = config.rareTreeTooltips(); + this.rareTreeLevelIcon = config.rareTreeLevelIcon(); + this.transportationTeleportTooltips = config.transportationTeleportTooltips(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobe.java b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobe.java index 51d0e1328d..68ffee0499 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobe.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobe.java @@ -25,13 +25,14 @@ package net.runelite.client.plugins.xpglobes; import java.time.Instant; +import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import net.runelite.api.Skill; -@Getter -@Setter +@Getter(AccessLevel.PACKAGE) +@Setter(AccessLevel.PACKAGE) @AllArgsConstructor class XpGlobe { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java index 942ccd2988..4d6d53ad36 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesOverlay.java @@ -37,8 +37,10 @@ import java.awt.geom.Ellipse2D; import java.awt.image.BufferedImage; import java.text.DecimalFormat; import java.time.Instant; +import java.util.Comparator; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.api.Client; import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG; import net.runelite.api.Point; @@ -56,6 +58,7 @@ import net.runelite.client.ui.overlay.components.table.TableAlignment; import net.runelite.client.ui.overlay.components.table.TableComponent; import net.runelite.client.util.ColorUtil; +@Singleton public class XpGlobesOverlay extends Overlay { private static final int MINIMUM_STEP = 10; @@ -66,24 +69,22 @@ public class XpGlobesOverlay extends Overlay private final Client client; private final XpGlobesPlugin plugin; - private final XpGlobesConfig config; private final XpTrackerService xpTrackerService; private final PanelComponent xpTooltip = new PanelComponent(); private final SkillIconManager iconManager; @Inject private XpGlobesOverlay( - Client client, - XpGlobesPlugin plugin, - XpGlobesConfig config, - XpTrackerService xpTrackerService, - SkillIconManager iconManager) + final Client client, + final XpGlobesPlugin plugin, + final XpTrackerService xpTrackerService, + final SkillIconManager iconManager) { super(plugin); this.iconManager = iconManager; this.client = client; this.plugin = plugin; - this.config = config; + this.xpTrackerService = xpTrackerService; setPosition(OverlayPosition.TOP_CENTER); getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "XP Globes overlay")); @@ -99,7 +100,7 @@ public class XpGlobesOverlay extends Overlay } final List sortedXpGlobes = plugin.getXpGlobes(); - sortedXpGlobes.sort((a, b) -> a.getSkill().compareTo(b.getSkill())); + sortedXpGlobes.sort(Comparator.comparing(XpGlobe::getSkill)); int curDrawX = 0; for (final XpGlobe xpGlobe : sortedXpGlobes) @@ -107,12 +108,12 @@ public class XpGlobesOverlay extends Overlay int startXp = xpTrackerService.getStartGoalXp(xpGlobe.getSkill()); int goalXp = xpTrackerService.getEndGoalXp(xpGlobe.getSkill()); renderProgressCircle(graphics, xpGlobe, startXp, goalXp, curDrawX, 0, getBounds()); - curDrawX += MINIMUM_STEP + config.xpOrbSize(); + curDrawX += MINIMUM_STEP + plugin.getXpOrbSize(); } // Get width of markers - final int markersLength = (queueSize * (config.xpOrbSize())) + ((MINIMUM_STEP) * (queueSize - 1)); - return new Dimension(markersLength, config.xpOrbSize()); + final int markersLength = (queueSize * (plugin.getXpOrbSize())) + ((MINIMUM_STEP) * (queueSize - 1)); + return new Dimension(markersLength, plugin.getXpOrbSize()); } private double getSkillProgress(int startXp, int currentXp, int goalXp) @@ -150,7 +151,7 @@ public class XpGlobesOverlay extends Overlay drawProgressLabel(graphics, skillToDraw, startXp, goalXp, x, y); - if (config.enableTooltips()) + if (plugin.isEnableTooltips()) { drawTooltip(graphics, skillToDraw, goalXp, backgroundCircle); } @@ -161,18 +162,18 @@ public class XpGlobesOverlay extends Overlay drawProgressArc( graphics, x, y, - config.xpOrbSize(), config.xpOrbSize(), + plugin.getXpOrbSize(), plugin.getXpOrbSize(), PROGRESS_RADIUS_REMAINDER, radiusToGoalXp, 5, - config.progressOrbOutLineColor() + plugin.getProgressOrbOutLineColor() ); drawProgressArc( graphics, x, y, - config.xpOrbSize(), config.xpOrbSize(), + plugin.getXpOrbSize(), plugin.getXpOrbSize(), PROGRESS_RADIUS_START, radiusCurrentXp, - config.progressArcStrokeWidth(), - config.enableCustomArcColor() ? config.progressArcColor() : SkillColor.find(skillToDraw.getSkill()).getColor()); + plugin.getProgressArcStrokeWidth(), + plugin.isEnableCustomArcColor() ? plugin.getProgressArcColor() : SkillColor.find(skillToDraw.getSkill()).getColor()); } private void drawProgressLabel(Graphics2D graphics, XpGlobe globe, int startXp, int goalXp, int x, int y) @@ -186,8 +187,8 @@ public class XpGlobesOverlay extends Overlay String progress = (int) (getSkillProgress(startXp, globe.getCurrentXp(), goalXp)) + "%"; final FontMetrics metrics = graphics.getFontMetrics(); - int drawX = x + (config.xpOrbSize() / 2) - (metrics.stringWidth(progress) / 2); - int drawY = y + (config.xpOrbSize() / 2) + (metrics.getHeight() / 2) - metrics.getMaxDescent(); + int drawX = x + (plugin.getXpOrbSize() / 2) - (metrics.stringWidth(progress) / 2); + int drawY = y + (plugin.getXpOrbSize() / 2) + (metrics.getHeight() / 2) - metrics.getMaxDescent(); OverlayUtil.renderTextLocation(graphics, new Point(drawX, drawY), progress, Color.WHITE); } @@ -207,8 +208,8 @@ public class XpGlobesOverlay extends Overlay private Ellipse2D drawEllipse(Graphics2D graphics, int x, int y) { - graphics.setColor(config.progressOrbBackgroundColor()); - Ellipse2D ellipse = new Ellipse2D.Double(x, y, config.xpOrbSize(), config.xpOrbSize()); + graphics.setColor(plugin.getProgressOrbBackgroundColor()); + Ellipse2D ellipse = new Ellipse2D.Double(x, y, plugin.getXpOrbSize(), plugin.getXpOrbSize()); graphics.fill(ellipse); graphics.draw(ellipse); return ellipse; @@ -225,8 +226,8 @@ public class XpGlobesOverlay extends Overlay graphics.drawImage( skillImage, - x + (config.xpOrbSize() / 2) - (skillImage.getWidth() / 2), - y + (config.xpOrbSize() / 2) - (skillImage.getHeight() / 2), + x + (plugin.getXpOrbSize() / 2) - (skillImage.getWidth() / 2), + y + (plugin.getXpOrbSize() / 2) - (skillImage.getHeight() / 2), null ); } @@ -234,8 +235,8 @@ public class XpGlobesOverlay extends Overlay private void drawTooltip(Graphics2D graphics, XpGlobe mouseOverSkill, int goalXp, Ellipse2D drawnGlobe) { //draw tooltip under the globe of the mouse location - int x = (int) drawnGlobe.getX() - (TOOLTIP_RECT_SIZE_X / 2) + (config.xpOrbSize() / 2); - int y = (int) drawnGlobe.getY() + config.xpOrbSize() + 10; + int x = (int) drawnGlobe.getX() - (TOOLTIP_RECT_SIZE_X / 2) + (plugin.getXpOrbSize() / 2); + int y = (int) drawnGlobe.getY() + plugin.getXpOrbSize() + 10; // reset the timer on XpGlobe to prevent it from disappearing while hovered over it mouseOverSkill.setTime(Instant.now()); @@ -279,7 +280,7 @@ public class XpGlobesOverlay extends Overlay tableComponent.addRow(ColorUtil.prependColorTag("XP per hour:", Color.ORANGE), xpHrString); } - if (config.enableTimeToLevel()) + if (plugin.isEnableTimeToLevel()) { String timeLeft = xpTrackerService.getTimeTillGoal(mouseOverSkill.getSkill()); tableComponent.addRow(ColorUtil.prependColorTag("TimeLeft:", Color.ORANGE), timeLeft); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesPlugin.java index 2771c986f5..591543e137 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xpglobes/XpGlobesPlugin.java @@ -25,16 +25,20 @@ package net.runelite.client.plugins.xpglobes; import com.google.inject.Provides; +import java.awt.Color; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import net.runelite.api.Client; import net.runelite.api.Experience; import net.runelite.api.Skill; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ExperienceChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.client.config.ConfigManager; @@ -52,6 +56,7 @@ import net.runelite.client.ui.overlay.OverlayManager; tags = {"experience", "levels", "overlay"}, enabledByDefault = false ) +@Singleton @PluginDependency(XpTrackerPlugin.class) public class XpGlobesPlugin extends Plugin { @@ -74,6 +79,25 @@ public class XpGlobesPlugin extends Plugin @Inject private XpGlobesOverlay overlay; + @Getter(AccessLevel.PACKAGE) + private boolean enableTooltips; + private boolean hideMaxed; + @Getter(AccessLevel.PACKAGE) + private boolean enableTimeToLevel; + @Getter(AccessLevel.PACKAGE) + private boolean enableCustomArcColor; + @Getter(AccessLevel.PACKAGE) + private Color progressArcColor; + @Getter(AccessLevel.PACKAGE) + private Color progressOrbOutLineColor; + @Getter(AccessLevel.PACKAGE) + private Color progressOrbBackgroundColor; + @Getter(AccessLevel.PACKAGE) + private int progressArcStrokeWidth; + @Getter(AccessLevel.PACKAGE) + private int xpOrbSize; + private int xpOrbDuration; + @Provides XpGlobesConfig getConfig(ConfigManager configManager) { @@ -83,6 +107,7 @@ public class XpGlobesPlugin extends Plugin @Override protected void startUp() throws Exception { + updateConfig(); overlayManager.add(overlay); } @@ -107,7 +132,7 @@ public class XpGlobesPlugin extends Plugin return; } - if (config.hideMaxed() && currentLevel >= Experience.MAX_REAL_LEVEL) + if (this.hideMaxed && currentLevel >= Experience.MAX_REAL_LEVEL) { return; } @@ -156,7 +181,7 @@ public class XpGlobesPlugin extends Plugin { XpGlobe globe = it.next(); Instant globeCreationTime = globe.getTime(); - if (currentTime.isBefore(globeCreationTime.plusSeconds(config.xpOrbDuration()))) + if (currentTime.isBefore(globeCreationTime.plusSeconds(this.xpOrbDuration))) { //if a globe is not expired, stop checking newer globes return; @@ -184,4 +209,31 @@ public class XpGlobesPlugin extends Plugin } } + + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("xpglobes")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.enableTooltips = config.enableTooltips(); + this.hideMaxed = config.hideMaxed(); + this.enableTimeToLevel = config.enableTimeToLevel(); + this.enableCustomArcColor = config.enableCustomArcColor(); + this.progressArcColor = config.progressArcColor(); + this.progressOrbOutLineColor = config.progressOrbOutLineColor(); + this.progressOrbBackgroundColor = config.progressOrbBackgroundColor(); + this.progressArcStrokeWidth = config.progressArcStrokeWidth(); + this.xpOrbSize = config.xpOrbSize(); + this.xpOrbDuration = config.xpOrbDuration(); + + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBox.java b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBox.java index d0d157c480..4b6142b1d8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBox.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBox.java @@ -75,6 +75,7 @@ class XpInfoBox extends JPanel // Instance members private final JPanel panel; + private final XpTrackerPlugin plugin; @Getter(AccessLevel.PACKAGE) private final Skill skill; @@ -98,8 +99,6 @@ class XpInfoBox extends JPanel private final JMenuItem pauseSkill = new JMenuItem("Pause"); private final JMenuItem canvasItem = new JMenuItem(ADD_STATE); - private final XpTrackerConfig xpTrackerConfig; - private boolean paused = false; private Style style = Style.FULL; @@ -110,9 +109,9 @@ class XpInfoBox extends JPanel SIMPLE } - XpInfoBox(XpTrackerPlugin xpTrackerPlugin, XpTrackerConfig xpTrackerConfig, Client client, JPanel panel, Skill skill, SkillIconManager iconManager) + XpInfoBox(XpTrackerPlugin xpTrackerPlugin, Client client, JPanel panel, Skill skill, SkillIconManager iconManager) { - this.xpTrackerConfig = xpTrackerConfig; + this.plugin = xpTrackerPlugin; this.panel = panel; this.skill = skill; @@ -276,7 +275,7 @@ class XpInfoBox extends JPanel : "Lvl. " + xpSnapshotSingle.getEndLevel()); // Add intermediate level positions to progressBar - if (xpTrackerConfig.showIntermediateLevels() && xpSnapshotSingle.getEndLevel() - xpSnapshotSingle.getStartLevel() > 1) + if (plugin.isShowIntermediateLevels() && xpSnapshotSingle.getEndLevel() - xpSnapshotSingle.getStartLevel() > 1) { final List positions = new ArrayList<>(); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBoxOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBoxOverlay.java index 2f07d07389..e31fa0a13b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBoxOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBoxOverlay.java @@ -59,7 +59,6 @@ class XpInfoBoxOverlay extends Overlay private final PanelComponent panel = new PanelComponent(); private final PanelComponent iconXpSplitPanel = new PanelComponent(); private final XpTrackerPlugin plugin; - private final XpTrackerConfig config; @Getter(AccessLevel.PACKAGE) private final Skill skill; @@ -67,13 +66,11 @@ class XpInfoBoxOverlay extends Overlay XpInfoBoxOverlay( XpTrackerPlugin plugin, - XpTrackerConfig config, Skill skill, BufferedImage icon) { super(plugin); this.plugin = plugin; - this.config = config; this.skill = skill; this.icon = icon; panel.setBorder(new Rectangle(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE)); @@ -99,7 +96,7 @@ class XpInfoBoxOverlay extends Overlay final String leftStr; final int rightNum; - switch (config.onScreenDisplayMode()) + switch (plugin.getOnScreenDisplayMode()) { case ACTIONS_DONE: leftStr = snapshot.getActionType().getLabel() + " Done"; @@ -128,7 +125,7 @@ class XpInfoBoxOverlay extends Overlay final String bottemLeftStr; final int bottomRightNum; - switch (config.onScreenDisplayModeBottom()) + switch (plugin.getOnScreenDisplayModeBottom()) { case ACTIONS_HOUR: bottemLeftStr = snapshot.getActionType().getLabel() + "/Hour"; diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpPanel.java index d716f12630..f456958292 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpPanel.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpPanel.java @@ -62,7 +62,7 @@ class XpPanel extends PluginPanel /* This displays the "No exp gained" text */ private final PluginErrorPanel errorPanel = new PluginErrorPanel(); - XpPanel(XpTrackerPlugin xpTrackerPlugin, XpTrackerConfig xpTrackerConfig, Client client, SkillIconManager iconManager) + XpPanel(XpTrackerPlugin xpTrackerPlugin, Client client, SkillIconManager iconManager) { super(); @@ -134,7 +134,7 @@ class XpPanel extends PluginPanel { break; } - infoBoxes.put(skill, new XpInfoBox(xpTrackerPlugin, xpTrackerConfig, client, infoBoxPanel, skill, iconManager)); + infoBoxes.put(skill, new XpInfoBox(xpTrackerPlugin, client, infoBoxPanel, skill, iconManager)); } errorPanel.setContent("Exp trackers", "You have not gained experience yet."); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerPlugin.java index 68663a896f..f592cdc166 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerPlugin.java @@ -35,6 +35,8 @@ import java.util.EnumSet; import java.util.List; import java.util.Objects; import javax.inject.Inject; +import lombok.AccessLevel; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Actor; import net.runelite.api.Client; @@ -45,6 +47,7 @@ import net.runelite.api.Player; import net.runelite.api.Skill; import net.runelite.api.VarPlayer; import net.runelite.api.WorldType; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.ExperienceChanged; import net.runelite.api.events.GameStateChanged; import net.runelite.api.events.GameTick; @@ -114,6 +117,16 @@ public class XpTrackerPlugin extends Plugin private final XpState xpState = new XpState(); private final XpPauseState xpPauseState = new XpPauseState(); + private boolean hideMaxed; + private boolean pauseOnLogout; + @Getter(AccessLevel.PACKAGE) + private boolean showIntermediateLevels; + private int pauseSkillAfter; + @Getter(AccessLevel.PACKAGE) + private XpTrackerConfig.OnScreenDisplayMode onScreenDisplayMode; + @Getter(AccessLevel.PACKAGE) + private XpTrackerConfig.OnScreenDisplayModeBottom onScreenDisplayModeBottom; + @Provides XpTrackerConfig provideConfig(ConfigManager configManager) { @@ -129,7 +142,9 @@ public class XpTrackerPlugin extends Plugin @Override protected void startUp() throws Exception { - xpPanel = new XpPanel(this, xpTrackerConfig, client, skillIconManager); + updateConfig(); + + xpPanel = new XpPanel(this, client, skillIconManager); final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "/skill_icons/overall.png"); @@ -221,7 +236,7 @@ public class XpTrackerPlugin extends Plugin void addOverlay(Skill skill) { removeOverlay(skill); - overlayManager.add(new XpInfoBoxOverlay(this, xpTrackerConfig, skill, skillIconManager.getSkillImage(skill))); + overlayManager.add(new XpInfoBoxOverlay(this, skill, skillIconManager.getSkillImage(skill))); } /** @@ -314,7 +329,7 @@ public class XpTrackerPlugin extends Plugin final int startGoalXp = startGoal != null ? client.getVar(startGoal) : -1; final int endGoalXp = endGoal != null ? client.getVar(endGoal) : -1; - if (xpTrackerConfig.hideMaxed() && currentLevel >= Experience.MAX_REAL_LEVEL) + if (this.hideMaxed && currentLevel >= Experience.MAX_REAL_LEVEL) { return; } @@ -511,10 +526,10 @@ public class XpTrackerPlugin extends Plugin skillExperience = client.getSkillExperience(skill); } - xpPauseState.tickXp(skill, skillExperience, xpTrackerConfig.pauseSkillAfter()); + xpPauseState.tickXp(skill, skillExperience, this.pauseSkillAfter); } - xpPauseState.tickLogout(xpTrackerConfig.pauseOnLogout(), !GameState.LOGIN_SCREEN.equals(client.getGameState())); + xpPauseState.tickLogout(this.pauseOnLogout, !GameState.LOGIN_SCREEN.equals(client.getGameState())); if (lastTickMillis == 0) { @@ -563,4 +578,25 @@ public class XpTrackerPlugin extends Plugin pauseSkill(skill, pause); } } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (!event.getGroup().equals("xpTracker")) + { + return; + } + + updateConfig(); + } + + private void updateConfig() + { + this.hideMaxed = xpTrackerConfig.hideMaxed(); + this.pauseOnLogout = xpTrackerConfig.pauseOnLogout(); + this.showIntermediateLevels = xpTrackerConfig.showIntermediateLevels(); + this.pauseSkillAfter = xpTrackerConfig.pauseSkillAfter(); + this.onScreenDisplayMode = xpTrackerConfig.onScreenDisplayMode(); + this.onScreenDisplayModeBottom = xpTrackerConfig.onScreenDisplayModeBottom(); + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ImagePanelComponent.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ImagePanelComponent.java index dae0a1e354..bb7bf6a80e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ImagePanelComponent.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ImagePanelComponent.java @@ -36,10 +36,13 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.image.BufferedImage; import javax.annotation.Nullable; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Setter; import net.runelite.client.ui.overlay.RenderableEntity; import net.runelite.client.ui.overlay.components.BackgroundComponent; +@Singleton public class ImagePanelComponent implements RenderableEntity { private static final int TOP_BORDER = 3; @@ -47,20 +50,20 @@ public class ImagePanelComponent implements RenderableEntity private static final int BOTTOM_BORDER = 6; private static final int SEPARATOR = 4; - @Setter + @Setter(AccessLevel.PUBLIC) @Nullable private String title; - @Setter + @Setter(AccessLevel.PACKAGE) private Color titleColor = Color.WHITE; - @Setter + @Setter(AccessLevel.PUBLIC) private Color backgroundColor = new Color(70, 61, 50, 156); - @Setter + @Setter(AccessLevel.PUBLIC) private BufferedImage image; - @Setter + @Setter(AccessLevel.PACKAGE) private Point position = new Point(); @Override diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/TextComponent.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/TextComponent.java index 043916c147..ed0e737ef2 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/TextComponent.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/TextComponent.java @@ -32,18 +32,19 @@ import java.awt.Dimension; import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.Point; +import lombok.AccessLevel; import lombok.Setter; import net.runelite.client.ui.overlay.RenderableEntity; public class TextComponent implements RenderableEntity { - @Setter + @Setter(AccessLevel.PACKAGE) private String text; - @Setter + @Setter(AccessLevel.PACKAGE) private Point position = new Point(); - @Setter + @Setter(AccessLevel.PACKAGE) private Color color = Color.WHITE; @Override diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahConfig.java index 2911317a38..539a15cbc8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahConfig.java @@ -36,19 +36,9 @@ import net.runelite.client.config.ConfigItem; public interface ZulrahConfig extends Config { @ConfigItem( - keyName = "enabled", - name = "Enabled", - description = "Configures whether or not zulrah overlays are displayed" - ) - default boolean enabled() - { - return true; - } - - @ConfigItem( - keyName = "sounds", - name = "Sounds Enabled", - description = "Configures whether client sounds are enabled for zulrah" + keyName = "sounds", + name = "Sounds Enabled", + description = "Configures whether client sounds are enabled for zulrah" ) default boolean sounds() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahInstance.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahInstance.java index e701cd65f6..fdbff52358 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahInstance.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/ZulrahInstance.java @@ -65,7 +65,7 @@ public class ZulrahInstance private int stage; private ZulrahPhase phase; - public ZulrahInstance(NPC zulrah) + ZulrahInstance(final NPC zulrah) { this.startLocation = zulrah.getLocalLocation(); } @@ -85,12 +85,12 @@ public class ZulrahInstance this.pattern = pattern; } - public int getStage() + int getStage() { return stage; } - public void nextStage() + void nextStage() { ++stage; } 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 366d636e94..c8551b1d0f 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 @@ -29,6 +29,8 @@ package net.runelite.client.plugins.zulrah; import com.google.inject.Provides; import javax.inject.Inject; +import javax.inject.Singleton; +import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Actor; @@ -68,6 +70,7 @@ import net.runelite.client.ui.overlay.OverlayManager; enabledByDefault = false ) @Slf4j +@Singleton public class ZulrahPlugin extends Plugin { private static final ZulrahPattern[] patterns = new ZulrahPattern[] @@ -77,7 +80,7 @@ public class ZulrahPlugin extends Plugin new ZulrahPatternC(), new ZulrahPatternD() }; - @Getter + @Getter(AccessLevel.PACKAGE) private NPC zulrah; @Inject private Client client; @@ -126,7 +129,7 @@ public class ZulrahPlugin extends Plugin @Subscribe public void onGameTick(GameTick event) { - if (!config.enabled() || client.getGameState() != GameState.LOGGED_IN) + if (client.getGameState() != GameState.LOGGED_IN) { return; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahCurrentPhaseOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahCurrentPhaseOverlay.java index 2d7bbbcff1..26c37887e8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahCurrentPhaseOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahCurrentPhaseOverlay.java @@ -31,6 +31,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.client.plugins.zulrah.ImagePanelComponent; import net.runelite.client.plugins.zulrah.ZulrahInstance; import net.runelite.client.plugins.zulrah.ZulrahPlugin; @@ -38,15 +39,14 @@ import net.runelite.client.plugins.zulrah.phase.ZulrahPhase; 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.PanelComponent; +@Singleton public class ZulrahCurrentPhaseOverlay extends Overlay { private final ZulrahPlugin plugin; - private final PanelComponent imagePanelComponent = new PanelComponent(); @Inject - ZulrahCurrentPhaseOverlay(ZulrahPlugin plugin) + ZulrahCurrentPhaseOverlay(final ZulrahPlugin plugin) { setPosition(OverlayPosition.BOTTOM_RIGHT); setPriority(OverlayPriority.HIGH); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahImageManager.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahImageManager.java index c64736c352..b181acc041 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahImageManager.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahImageManager.java @@ -34,13 +34,13 @@ import net.runelite.client.plugins.zulrah.phase.ZulrahType; import net.runelite.client.util.ImageUtil; @Slf4j -public class ZulrahImageManager +class ZulrahImageManager { private static final BufferedImage[] zulrahBufferedImages = new BufferedImage[3]; private static final BufferedImage[] smallZulrahBufferedImages = new BufferedImage[3]; private static final BufferedImage[] prayerBufferedImages = new BufferedImage[2]; - public static BufferedImage getZulrahBufferedImage(ZulrahType type) + static BufferedImage getZulrahBufferedImage(ZulrahType type) { switch (type) { @@ -66,7 +66,7 @@ public class ZulrahImageManager return null; } - public static BufferedImage getSmallZulrahBufferedImage(ZulrahType type) + static BufferedImage getSmallZulrahBufferedImage(ZulrahType type) { switch (type) { @@ -92,7 +92,7 @@ public class ZulrahImageManager return null; } - public static BufferedImage getProtectionPrayerBufferedImage(Prayer prayer) + static BufferedImage getProtectionPrayerBufferedImage(Prayer prayer) { switch (prayer) { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahNextPhaseOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahNextPhaseOverlay.java index 509631e9b8..ca9903302d 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahNextPhaseOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahNextPhaseOverlay.java @@ -31,6 +31,7 @@ import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.inject.Inject; +import javax.inject.Singleton; import net.runelite.client.plugins.zulrah.ImagePanelComponent; import net.runelite.client.plugins.zulrah.ZulrahInstance; import net.runelite.client.plugins.zulrah.ZulrahPlugin; @@ -39,12 +40,13 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; +@Singleton public class ZulrahNextPhaseOverlay extends Overlay { private final ZulrahPlugin plugin; @Inject - ZulrahNextPhaseOverlay(ZulrahPlugin plugin) + ZulrahNextPhaseOverlay(final ZulrahPlugin plugin) { setPosition(OverlayPosition.BOTTOM_RIGHT); setPriority(OverlayPriority.HIGH); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahOverlay.java index 93ce00d4bc..db8136ac24 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahOverlay.java @@ -31,11 +31,11 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.FontMetrics; import java.awt.Graphics2D; -import java.awt.Image; import java.awt.Polygon; import java.awt.image.BufferedImage; import javax.annotation.Nullable; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.Perspective; @@ -48,6 +48,7 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; @Slf4j +@Singleton public class ZulrahOverlay extends Overlay { private static final Color TILE_BORDER_COLOR = new Color(0, 0, 0, 100); @@ -57,7 +58,7 @@ public class ZulrahOverlay extends Overlay private final ZulrahPlugin plugin; @Inject - ZulrahOverlay(@Nullable Client client, ZulrahPlugin plugin) + ZulrahOverlay(final @Nullable Client client, final ZulrahPlugin plugin) { setPosition(OverlayPosition.DYNAMIC); this.client = client; @@ -121,10 +122,10 @@ public class ZulrahOverlay extends Overlay } if (nextPhase.isJad()) { - Image jadPrayerImg = ZulrahImageManager.getProtectionPrayerBufferedImage(nextPhase.getPrayer()); + BufferedImage jadPrayerImg = ZulrahImageManager.getProtectionPrayerBufferedImage(nextPhase.getPrayer()); if (jadPrayerImg != null) { - Point imageLoc = Perspective.getCanvasImageLocation(client, localTile, (BufferedImage) jadPrayerImg, 0); + Point imageLoc = Perspective.getCanvasImageLocation(client, localTile, jadPrayerImg, 0); if (imageLoc != null) { graphics.drawImage(jadPrayerImg, imageLoc.getX(), imageLoc.getY(), null); @@ -165,10 +166,10 @@ public class ZulrahOverlay extends Overlay if (phase.isJad()) { - Image jadPrayerImg = ZulrahImageManager.getProtectionPrayerBufferedImage(phase.getPrayer()); + BufferedImage jadPrayerImg = ZulrahImageManager.getProtectionPrayerBufferedImage(phase.getPrayer()); if (jadPrayerImg != null) { - Point imageLoc = Perspective.getCanvasImageLocation(client, localTile, (BufferedImage) jadPrayerImg, 0); + Point imageLoc = Perspective.getCanvasImageLocation(client, localTile, jadPrayerImg, 0); if (imageLoc != null) { graphics.drawImage(jadPrayerImg, imageLoc.getX(), imageLoc.getY(), null); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahPrayerOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahPrayerOverlay.java index abcd234034..cd3315f1fe 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahPrayerOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/overlays/ZulrahPrayerOverlay.java @@ -31,6 +31,7 @@ import java.awt.Graphics2D; import java.awt.image.BufferedImage; import javax.annotation.Nullable; import javax.inject.Inject; +import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.api.Prayer; @@ -42,6 +43,7 @@ import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayPosition; import net.runelite.client.ui.overlay.OverlayPriority; +@Singleton @Slf4j public class ZulrahPrayerOverlay extends Overlay { @@ -49,7 +51,7 @@ public class ZulrahPrayerOverlay extends Overlay private final ZulrahPlugin plugin; @Inject - ZulrahPrayerOverlay(@Nullable Client client, ZulrahPlugin plugin) + ZulrahPrayerOverlay(final @Nullable Client client, final ZulrahPlugin plugin) { setPosition(OverlayPosition.BOTTOM_RIGHT); setPriority(OverlayPriority.MED); diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPattern.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPattern.java index 04cd35e278..caf6bcf575 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPattern.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/patterns/ZulrahPattern.java @@ -44,7 +44,7 @@ public abstract class ZulrahPattern add(loc, type, standLocation, false, prayer); } - protected final void addJad(ZulrahLocation loc, ZulrahType type, StandLocation standLocation, Prayer prayer) + final void addJad(ZulrahLocation loc, ZulrahType type, StandLocation standLocation, Prayer prayer) { add(loc, type, standLocation, true, prayer); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/phase/ZulrahPhase.java b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/phase/ZulrahPhase.java index c1fc54b7da..fdc9b2b4b3 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/phase/ZulrahPhase.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/zulrah/phase/ZulrahPhase.java @@ -124,11 +124,6 @@ public class ZulrahPhase return startTile; } - public ZulrahLocation getZulrahLocation() - { - return zulrahLocation; - } - public ZulrahType getType() { return type; diff --git a/runelite-client/src/main/java/net/runelite/client/ui/ContainableFrame.java b/runelite-client/src/main/java/net/runelite/client/ui/ContainableFrame.java index 0e60a97e13..6b61a6a78f 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/ContainableFrame.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/ContainableFrame.java @@ -39,6 +39,17 @@ public class ContainableFrame extends JFrame private boolean containedInScreen; private boolean expandedClientOppositeDirection; + ContainableFrame() + { + addWindowStateListener(windowEvent -> + { + if (windowEvent.getNewState() == Frame.NORMAL) + { + revalidateMinimumSize(); + } + }); + } + public void setContainedInScreen(boolean value) { this.containedInScreen = value; diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java index 38677410f2..41a3b9329a 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/OverlayRenderer.java @@ -27,6 +27,7 @@ package net.runelite.client.ui.overlay; import com.google.common.base.MoreObjects; import java.awt.Color; import java.awt.Dimension; +import java.awt.Font; import java.awt.Graphics2D; import java.awt.Point; import java.awt.Rectangle; @@ -44,6 +45,7 @@ import net.runelite.api.MenuAction; import net.runelite.api.MenuEntry; import net.runelite.api.events.BeforeRender; import net.runelite.api.events.ClientTick; +import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.FocusChanged; import net.runelite.api.widgets.Widget; import net.runelite.api.widgets.WidgetInfo; @@ -89,6 +91,12 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener private boolean isResizeable; private OverlayBounds snapCorners; + // Overlay Fonts + private Font clientFont; + private Font standardFont; + private Font tooltipFont; + private Font interfaceFont; + @Inject private OverlayRenderer( final Client client, @@ -100,10 +108,28 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener this.client = client; this.overlayManager = overlayManager; this.runeLiteConfig = runeLiteConfig; + this.updateConfig(); keyManager.registerKeyListener(this); mouseManager.registerMouseListener(this); } + private void updateConfig() + { + this.clientFont = runeLiteConfig.clientFont(); + this.standardFont = FontManager.getFontFromType(this.clientFont, runeLiteConfig.fontType()); + this.tooltipFont = FontManager.getFontFromType(this.clientFont, runeLiteConfig.tooltipFontType()); + this.interfaceFont = FontManager.getFontFromType(this.clientFont, runeLiteConfig.interfaceFontType()); + } + + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("runelite")) + { + updateConfig(); + } + } + @Subscribe public void onFocusChanged(FocusChanged event) { @@ -457,15 +483,15 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener // Set font based on configuration if (position == OverlayPosition.DYNAMIC || position == OverlayPosition.DETACHED) { - subGraphics.setFont(FontManager.getFontFromType(runeLiteConfig.clientFont(), runeLiteConfig.fontType())); + subGraphics.setFont(this.standardFont); } else if (position == OverlayPosition.TOOLTIP) { - subGraphics.setFont(FontManager.getFontFromType(runeLiteConfig.clientFont(), runeLiteConfig.tooltipFontType())); + subGraphics.setFont(this.tooltipFont); } else { - subGraphics.setFont(FontManager.getFontFromType(runeLiteConfig.clientFont(), runeLiteConfig.interfaceFontType())); + subGraphics.setFont(this.interfaceFont); } subGraphics.translate(point.x, point.y); diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/bank/BankCalculationTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/bank/BankCalculationTest.java index af690525c3..2736c133a5 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/bank/BankCalculationTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/bank/BankCalculationTest.java @@ -61,7 +61,7 @@ public class BankCalculationTest private BankConfig bankConfig; @Inject - private BankCalculation bankCalculation; + private BankPlugin bankplugin; @Before public void before() @@ -107,6 +107,7 @@ public class BankCalculationTest when(itemManager.getItemDefinition(ItemID.ABYSSAL_WHIP)) .thenReturn(whipComp); + BankCalculation bankCalculation = new BankCalculation(itemManager, bankplugin, client); bankCalculation.calculate(); long value = bankCalculation.getHaPrice(); diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/cerberus/CerberusPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/cerberus/CerberusPluginTest.java index 4f35f7b174..daac7907de 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/cerberus/CerberusPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/cerberus/CerberusPluginTest.java @@ -71,7 +71,7 @@ public class CerberusPluginTest mockNpc(new LocalPoint(2, 5)), mockNpc(new LocalPoint(1, 5)) )); - cerberusPlugin.onGameTick(new GameTick()); + cerberusPlugin.onGameTick(GameTick.INSTANCE); // Expected sort is by lowest y first, then by lowest x assertEquals(ghosts.get(0).getLocalLocation(), new LocalPoint(0, 0)); diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/chatfilter/ChatFilterPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/chatfilter/ChatFilterPluginTest.java index a12a8b257b..26348cbd16 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/chatfilter/ChatFilterPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/chatfilter/ChatFilterPluginTest.java @@ -65,16 +65,17 @@ public class ChatFilterPluginTest { Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this); - when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.CENSOR_WORDS); - when(chatFilterConfig.filteredWords()).thenReturn(""); - when(chatFilterConfig.filteredRegex()).thenReturn(""); + chatFilterPlugin.setFilterType(ChatFilterType.CENSOR_WORDS); + chatFilterPlugin.setFilteredWords(""); + chatFilterPlugin.setFilteredRegex(""); + when(client.getLocalPlayer()).thenReturn(localPlayer); } @Test public void testCensorWords() { - when(chatFilterConfig.filteredWords()).thenReturn("hat"); + chatFilterPlugin.setFilteredWords("hat"); chatFilterPlugin.updateFilteredPatterns(); assertEquals("w***s up", chatFilterPlugin.censorMessage("whats up")); @@ -83,8 +84,8 @@ public class ChatFilterPluginTest @Test public void testCensorRegex() { - when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.REMOVE_MESSAGE); - when(chatFilterConfig.filteredRegex()).thenReturn("5[0-9]x2\n("); + chatFilterPlugin.setFilterType(ChatFilterType.REMOVE_MESSAGE); + chatFilterPlugin.setFilteredRegex("5[0-9]x2\n("); chatFilterPlugin.updateFilteredPatterns(); assertNull(chatFilterPlugin.censorMessage("55X2 Dicing | Trusted Ranks | Huge Pay Outs!")); @@ -93,7 +94,7 @@ public class ChatFilterPluginTest @Test public void testBrokenRegex() { - when(chatFilterConfig.filteredRegex()).thenReturn("Test\n)\n73"); + chatFilterPlugin.setFilteredRegex("Test\n)\n73"); chatFilterPlugin.updateFilteredPatterns(); assertEquals("** isn't funny", chatFilterPlugin.censorMessage("73 isn't funny")); @@ -102,8 +103,8 @@ public class ChatFilterPluginTest @Test public void testCaseSensitivity() { - when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.CENSOR_MESSAGE); - when(chatFilterConfig.filteredWords()).thenReturn("ReGeX!!!"); + chatFilterPlugin.setFilterType(ChatFilterType.CENSOR_MESSAGE); + chatFilterPlugin.setFilteredWords("ReGeX!!!"); chatFilterPlugin.updateFilteredPatterns(); assertEquals("Hey, everyone, I just tried to say something very silly!", @@ -113,8 +114,8 @@ public class ChatFilterPluginTest @Test public void testNonPrintableCharacters() { - when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.REMOVE_MESSAGE); - when(chatFilterConfig.filteredWords()).thenReturn("test"); + chatFilterPlugin.setFilterType(ChatFilterType.REMOVE_MESSAGE); + chatFilterPlugin.setFilteredWords("test"); chatFilterPlugin.updateFilteredPatterns(); assertNull(chatFilterPlugin.censorMessage("te\u008Cst")); @@ -124,7 +125,7 @@ public class ChatFilterPluginTest public void testMessageFromFriendIsFiltered() { when(client.isFriended("Iron Mammal", false)).thenReturn(true); - when(chatFilterConfig.filterFriends()).thenReturn(true); + chatFilterPlugin.setFilterFriends(true); assertTrue(chatFilterPlugin.shouldFilterPlayerMessage("Iron Mammal")); } @@ -132,7 +133,7 @@ public class ChatFilterPluginTest public void testMessageFromFriendIsNotFiltered() { when(client.isFriended("Iron Mammal", false)).thenReturn(true); - when(chatFilterConfig.filterFriends()).thenReturn(false); + chatFilterPlugin.setFilterFriends(false); assertFalse(chatFilterPlugin.shouldFilterPlayerMessage("Iron Mammal")); } @@ -140,7 +141,7 @@ public class ChatFilterPluginTest public void testMessageFromClanIsFiltered() { when(client.isClanMember("B0aty")).thenReturn(true); - when(chatFilterConfig.filterClan()).thenReturn(true); + chatFilterPlugin.setFilterClan(true); assertTrue(chatFilterPlugin.shouldFilterPlayerMessage("B0aty")); } @@ -148,7 +149,7 @@ public class ChatFilterPluginTest public void testMessageFromClanIsNotFiltered() { when(client.isClanMember("B0aty")).thenReturn(true); - when(chatFilterConfig.filterClan()).thenReturn(false); + chatFilterPlugin.setFilterClan(false); assertFalse(chatFilterPlugin.shouldFilterPlayerMessage("B0aty")); } diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/cooking/CookingPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/cooking/CookingPluginTest.java index 6b8334e99d..5c5d4dd176 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/cooking/CookingPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/cooking/CookingPluginTest.java @@ -115,7 +115,8 @@ public class CookingPluginTest Player player = mock(Player.class); when(player.getSpotAnimation()).thenReturn(GraphicID.WINE_MAKE); - when(config.fermentTimer()).thenReturn(true); + cookingPlugin.setFermentTimer(true); + when(client.getLocalPlayer()).thenReturn(player); SpotAnimationChanged graphicChanged = new SpotAnimationChanged(); diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPluginTest.java index 51dc7842e0..508a396e97 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/idlenotifier/IdleNotifierPluginTest.java @@ -114,12 +114,12 @@ public class IdleNotifierPluginTest when(client.getLocalPlayer()).thenReturn(player); // Mock config - when(config.logoutIdle()).thenReturn(true); - when(config.animationIdle()).thenReturn(true); - when(config.interactionIdle()).thenReturn(true); - when(config.getIdleNotificationDelay()).thenReturn(0); - when(config.getHitpointsThreshold()).thenReturn(42); - when(config.getPrayerThreshold()).thenReturn(42); + plugin.setLogoutIdle(true); + plugin.setAnimationIdle(true); + plugin.setInteractionIdle(true); + plugin.setGetIdleNotificationDelay(0); + plugin.setGetHitpointsThreshold(42); + plugin.setGetPrayerThreshold(42); // Mock client when(client.getGameState()).thenReturn(GameState.LOGGED_IN); @@ -135,10 +135,10 @@ public class IdleNotifierPluginTest AnimationChanged animationChanged = new AnimationChanged(); animationChanged.setActor(player); plugin.onAnimationChanged(animationChanged); - plugin.onGameTick(new GameTick()); + plugin.onGameTick(GameTick.INSTANCE); when(player.getAnimation()).thenReturn(AnimationID.IDLE); plugin.onAnimationChanged(animationChanged); - plugin.onGameTick(new GameTick()); + plugin.onGameTick(GameTick.INSTANCE); verify(notifier).notify("[" + PLAYER_NAME + "] is now idle!"); } @@ -149,13 +149,13 @@ public class IdleNotifierPluginTest AnimationChanged animationChanged = new AnimationChanged(); animationChanged.setActor(player); plugin.onAnimationChanged(animationChanged); - plugin.onGameTick(new GameTick()); + plugin.onGameTick(GameTick.INSTANCE); when(player.getAnimation()).thenReturn(AnimationID.LOOKING_INTO); plugin.onAnimationChanged(animationChanged); - plugin.onGameTick(new GameTick()); + plugin.onGameTick(GameTick.INSTANCE); when(player.getAnimation()).thenReturn(AnimationID.IDLE); plugin.onAnimationChanged(animationChanged); - plugin.onGameTick(new GameTick()); + plugin.onGameTick(GameTick.INSTANCE); verify(notifier, times(0)).notify(any()); } @@ -166,7 +166,7 @@ public class IdleNotifierPluginTest AnimationChanged animationChanged = new AnimationChanged(); animationChanged.setActor(player); plugin.onAnimationChanged(animationChanged); - plugin.onGameTick(new GameTick()); + plugin.onGameTick(GameTick.INSTANCE); // Logout when(client.getGameState()).thenReturn(GameState.LOGIN_SCREEN); @@ -182,7 +182,7 @@ public class IdleNotifierPluginTest // Tick when(player.getAnimation()).thenReturn(AnimationID.IDLE); plugin.onAnimationChanged(animationChanged); - plugin.onGameTick(new GameTick()); + plugin.onGameTick(GameTick.INSTANCE); verify(notifier, times(0)).notify(any()); } @@ -191,10 +191,10 @@ public class IdleNotifierPluginTest { when(player.getInteracting()).thenReturn(monster); plugin.onInteractingChanged(new InteractingChanged(player, monster)); - plugin.onGameTick(new GameTick()); + plugin.onGameTick(GameTick.INSTANCE); when(player.getInteracting()).thenReturn(null); plugin.onInteractingChanged(new InteractingChanged(player, null)); - plugin.onGameTick(new GameTick()); + plugin.onGameTick(GameTick.INSTANCE); verify(notifier).notify("[" + PLAYER_NAME + "] is now out of combat!"); } @@ -203,13 +203,13 @@ public class IdleNotifierPluginTest { when(player.getInteracting()).thenReturn(monster); plugin.onInteractingChanged(new InteractingChanged(player, monster)); - plugin.onGameTick(new GameTick()); + plugin.onGameTick(GameTick.INSTANCE); when(player.getInteracting()).thenReturn(randomEvent); plugin.onInteractingChanged(new InteractingChanged(player, randomEvent)); - plugin.onGameTick(new GameTick()); + plugin.onGameTick(GameTick.INSTANCE); when(player.getInteracting()).thenReturn(null); plugin.onInteractingChanged(new InteractingChanged(player, null)); - plugin.onGameTick(new GameTick()); + plugin.onGameTick(GameTick.INSTANCE); verify(notifier, times(0)).notify(any()); } @@ -218,7 +218,7 @@ public class IdleNotifierPluginTest { plugin.onInteractingChanged(new InteractingChanged(player, monster)); when(player.getInteracting()).thenReturn(monster); - plugin.onGameTick(new GameTick()); + plugin.onGameTick(GameTick.INSTANCE); // Logout when(client.getGameState()).thenReturn(GameState.LOGIN_SCREEN); @@ -234,7 +234,7 @@ public class IdleNotifierPluginTest // Tick when(player.getInteracting()).thenReturn(null); plugin.onInteractingChanged(new InteractingChanged(player, null)); - plugin.onGameTick(new GameTick()); + plugin.onGameTick(GameTick.INSTANCE); verify(notifier, times(0)).notify(any()); } @@ -249,7 +249,7 @@ public class IdleNotifierPluginTest hitsplatApplied.setActor(player); hitsplatApplied.setHitsplat(new Hitsplat(Hitsplat.HitsplatType.DAMAGE, 0, 0)); plugin.onHitsplatApplied(hitsplatApplied); - plugin.onGameTick(new GameTick()); + plugin.onGameTick(GameTick.INSTANCE); verify(notifier, times(0)).notify(any()); } @@ -262,22 +262,22 @@ public class IdleNotifierPluginTest when(client.getKeyboardIdleTicks()).thenReturn(80_000); when(client.getMouseIdleTicks()).thenReturn(14_500); - plugin.onGameTick(new GameTick()); - plugin.onGameTick(new GameTick()); + plugin.onGameTick(GameTick.INSTANCE); + plugin.onGameTick(GameTick.INSTANCE); verify(notifier, times(1)).notify(any()); } @Test public void testSpecRegen() { - when(config.getSpecEnergyThreshold()).thenReturn(50); + plugin.setGetSpecEnergyThreshold(50); when(client.getVar(Matchers.eq(VarPlayer.SPECIAL_ATTACK_PERCENT))).thenReturn(400); // 40% - plugin.onGameTick(new GameTick()); // once to set lastSpecEnergy to 400 + plugin.onGameTick(GameTick.INSTANCE); // once to set lastSpecEnergy to 400 verify(notifier, never()).notify(any()); when(client.getVar(Matchers.eq(VarPlayer.SPECIAL_ATTACK_PERCENT))).thenReturn(500); // 50% - plugin.onGameTick(new GameTick()); + plugin.onGameTick(GameTick.INSTANCE); verify(notifier).notify(Matchers.eq("[" + PLAYER_NAME + "] has restored spec energy!")); } } \ No newline at end of file diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java index 87f69cceb3..fb5b92810d 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPluginTest.java @@ -37,7 +37,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import static org.mockito.Mockito.when; import org.mockito.runners.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) @@ -67,7 +66,7 @@ public class NpcIndicatorsPluginTest @Test public void getHighlights() { - when(npcIndicatorsConfig.getNpcToHighlight()).thenReturn("goblin, , zulrah , *wyvern, ,"); + npcIndicatorsPlugin.setGetNpcToHighlight("goblin, , zulrah , *wyvern, ,"); final List highlightedNpcs = npcIndicatorsPlugin.getHighlights(); assertEquals("Length of parsed NPCs is incorrect", 3, highlightedNpcs.size()); diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/screenshot/ScreenshotPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/screenshot/ScreenshotPluginTest.java index 9aff61c346..4a34a86712 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/screenshot/ScreenshotPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/screenshot/ScreenshotPluginTest.java @@ -101,10 +101,10 @@ public class ScreenshotPluginTest public void before() { Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this); - when(screenshotConfig.screenshotRewards()).thenReturn(true); - when(screenshotConfig.screenshotLevels()).thenReturn(true); - when(screenshotConfig.screenshotValuableDrop()).thenReturn(true); - when(screenshotConfig.screenshotUntradeableDrop()).thenReturn(true); + screenshotPlugin.setScreenshotRewards(true); + screenshotPlugin.setScreenshotLevels(true); + screenshotPlugin.setScreenshotValuableDrop(true); + screenshotPlugin.setScreenshotUntradeableDrop(true); } @Test @@ -179,7 +179,7 @@ public class ScreenshotPluginTest event.setGroupId(LEVEL_UP_GROUP_ID); screenshotPlugin.onWidgetLoaded(event); - GameTick tick = new GameTick(); + GameTick tick = GameTick.INSTANCE; screenshotPlugin.onGameTick(tick); verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class)); @@ -202,7 +202,7 @@ public class ScreenshotPluginTest event.setGroupId(LEVEL_UP_GROUP_ID); screenshotPlugin.onWidgetLoaded(event); - GameTick tick = new GameTick(); + GameTick tick = GameTick.INSTANCE; screenshotPlugin.onGameTick(tick); verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class)); @@ -225,7 +225,7 @@ public class ScreenshotPluginTest event.setGroupId(LEVEL_UP_GROUP_ID); screenshotPlugin.onWidgetLoaded(event); - GameTick tick = new GameTick(); + GameTick tick = GameTick.INSTANCE; screenshotPlugin.onGameTick(tick); verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class)); @@ -248,7 +248,7 @@ public class ScreenshotPluginTest event.setGroupId(DIALOG_SPRITE_GROUP_ID); screenshotPlugin.onWidgetLoaded(event); - GameTick tick = new GameTick(); + GameTick tick = GameTick.INSTANCE; screenshotPlugin.onGameTick(tick); verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class)); diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java index 099a76d19b..169caac2a9 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/slayer/SlayerPluginTest.java @@ -155,7 +155,7 @@ public class SlayerPluginTest Widget npcDialog = mock(Widget.class); when(npcDialog.getText()).thenReturn(TASK_NEW); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); - slayerPlugin.onGameTick(new GameTick()); + slayerPlugin.onGameTick(GameTick.INSTANCE); assertEquals("Suqahs", slayerPlugin.getCurrentTask().getTaskName()); assertEquals(231, slayerPlugin.getCurrentTask().getAmount()); @@ -167,7 +167,7 @@ public class SlayerPluginTest Widget npcDialog = mock(Widget.class); when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); - slayerPlugin.onGameTick(new GameTick()); + slayerPlugin.onGameTick(GameTick.INSTANCE); assertEquals("Wyrms", slayerPlugin.getCurrentTask().getTaskName()); assertEquals(147, slayerPlugin.getCurrentTask().getAmount()); @@ -180,7 +180,7 @@ public class SlayerPluginTest Widget npcDialog = mock(Widget.class); when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR_2); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); - slayerPlugin.onGameTick(new GameTick()); + slayerPlugin.onGameTick(GameTick.INSTANCE); assertEquals("Hellhounds", slayerPlugin.getCurrentTask().getTaskName()); assertEquals(142, slayerPlugin.getCurrentTask().getAmount()); @@ -193,7 +193,7 @@ public class SlayerPluginTest Widget npcDialog = mock(Widget.class); when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR_3); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); - slayerPlugin.onGameTick(new GameTick()); + slayerPlugin.onGameTick(GameTick.INSTANCE); assertEquals("Trolls", slayerPlugin.getCurrentTask().getTaskName()); assertEquals(135, slayerPlugin.getCurrentTask().getAmount()); @@ -206,7 +206,7 @@ public class SlayerPluginTest Widget npcDialog = mock(Widget.class); when(npcDialog.getText()).thenReturn(TASK_NEW_FIRST); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); - slayerPlugin.onGameTick(new GameTick()); + slayerPlugin.onGameTick(GameTick.INSTANCE); assertEquals("goblins", slayerPlugin.getCurrentTask().getTaskName()); assertEquals(17, slayerPlugin.getCurrentTask().getAmount()); @@ -218,7 +218,7 @@ public class SlayerPluginTest Widget npcDialog = mock(Widget.class); when(npcDialog.getText()).thenReturn(TASK_NEW_NPC_CONTACT); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); - slayerPlugin.onGameTick(new GameTick()); + slayerPlugin.onGameTick(GameTick.INSTANCE); assertEquals("Suqahs", slayerPlugin.getCurrentTask().getTaskName()); assertEquals(211, slayerPlugin.getCurrentTask().getAmount()); @@ -230,7 +230,7 @@ public class SlayerPluginTest Widget npcDialog = mock(Widget.class); when(npcDialog.getText()).thenReturn(TASK_BOSS_NEW); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); - slayerPlugin.onGameTick(new GameTick()); + slayerPlugin.onGameTick(GameTick.INSTANCE); assertEquals("Vet'ion", slayerPlugin.getCurrentTask().getTaskName()); assertEquals(3, slayerPlugin.getCurrentTask().getAmount()); @@ -243,7 +243,7 @@ public class SlayerPluginTest Widget npcDialog = mock(Widget.class); when(npcDialog.getText()).thenReturn(TASK_BOSS_NEW_THE); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); - slayerPlugin.onGameTick(new GameTick()); + slayerPlugin.onGameTick(GameTick.INSTANCE); assertEquals("Chaos Elemental", slayerPlugin.getCurrentTask().getTaskName()); assertEquals(3, slayerPlugin.getCurrentTask().getAmount()); @@ -296,7 +296,7 @@ public class SlayerPluginTest Widget npcDialog = mock(Widget.class); when(npcDialog.getText()).thenReturn(TASK_EXISTING); when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog); - slayerPlugin.onGameTick(new GameTick()); + slayerPlugin.onGameTick(GameTick.INSTANCE); assertEquals("suqahs", slayerPlugin.getCurrentTask().getTaskName()); assertEquals(222, slayerPlugin.getCurrentTask().getAmount()); @@ -387,11 +387,11 @@ public class SlayerPluginTest { ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Superior", SUPERIOR_MESSAGE, null, 0); - when(slayerConfig.showSuperiorNotification()).thenReturn(true); + slayerPlugin.setShowSuperiorNotification(true); slayerPlugin.onChatMessage(chatMessageEvent); verify(notifier).notify(SUPERIOR_MESSAGE); - when(slayerConfig.showSuperiorNotification()).thenReturn(false); + slayerPlugin.setShowSuperiorNotification(false); slayerPlugin.onChatMessage(chatMessageEvent); verifyNoMoreInteractions(notifier); } @@ -405,7 +405,7 @@ public class SlayerPluginTest task.setAmount(42); task.setInitialAmount(42); - when(slayerConfig.taskCommand()).thenReturn(true); + slayerPlugin.setTaskCommand(true); when(chatClient.getTask(anyString())).thenReturn(task); ChatMessage setMessage = new ChatMessage(); diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/timers/TimersPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/timers/TimersPluginTest.java index f9ba35154d..378f062de2 100644 --- a/runelite-client/src/test/java/net/runelite/client/plugins/timers/TimersPluginTest.java +++ b/runelite-client/src/test/java/net/runelite/client/plugins/timers/TimersPluginTest.java @@ -86,7 +86,7 @@ public class TimersPluginTest @Test public void testHalfTeleblock() { - when(timersConfig.showTeleblock()).thenReturn(true); + timersPlugin.setShowTeleblock(true); when(client.getWorldType()).thenReturn(EnumSet.of(WorldType.MEMBERS)); ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", HALF_TELEBLOCK_MESSAGE, "", 0); timersPlugin.onChatMessage(chatMessage); @@ -100,7 +100,7 @@ public class TimersPluginTest @Test public void testFullTeleblock() { - when(timersConfig.showTeleblock()).thenReturn(true); + timersPlugin.setShowTeleblock(true); ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", FULL_TELEBLOCK_MESSAGE, "", 0); timersPlugin.onChatMessage(chatMessage); @@ -113,7 +113,7 @@ public class TimersPluginTest @Test public void testDmmHalfTb() { - when(timersConfig.showTeleblock()).thenReturn(true); + timersPlugin.setShowTeleblock(true); when(client.getWorldType()).thenReturn(EnumSet.of(WorldType.DEADMAN)); ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", DMM_HALF_TELEBLOCK_MESSAGE, "", 0); timersPlugin.onChatMessage(chatMessage); @@ -127,7 +127,7 @@ public class TimersPluginTest @Test public void testDmmFullTb() { - when(timersConfig.showTeleblock()).thenReturn(true); + timersPlugin.setShowTeleblock(true); when(client.getWorldType()).thenReturn(EnumSet.of(WorldType.DEADMAN)); ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", HALF_TELEBLOCK_MESSAGE, "", 0); timersPlugin.onChatMessage(chatMessage); 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 f25c98e263..65951bc9c5 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSActorMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSActorMixin.java @@ -251,7 +251,7 @@ public abstract class RSActorMixin implements RSActor { client.getLogger().debug("You died!"); - LocalPlayerDeath event = new LocalPlayerDeath(); + LocalPlayerDeath event = LocalPlayerDeath.INSTANCE; client.getCallbacks().post(event); } else if (this instanceof RSNPC) 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 ee569abca0..1df5621284 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSClientMixin.java @@ -1094,14 +1094,14 @@ public abstract class RSClientMixin implements RSClient @Inject public static void canvasWidthChanged(int idx) { - client.getCallbacks().post(new CanvasSizeChanged()); + client.getCallbacks().post(CanvasSizeChanged.INSTANCE); } @FieldHook("canvasHeight") @Inject public static void canvasHeightChanged(int idx) { - client.getCallbacks().post(new CanvasSizeChanged()); + client.getCallbacks().post(CanvasSizeChanged.INSTANCE); } @Inject @@ -1272,7 +1272,7 @@ public abstract class RSClientMixin implements RSClient @Inject public static void onUsernameChanged(int idx) { - client.getCallbacks().post(new UsernameChanged()); + client.getCallbacks().post(UsernameChanged.INSTANCE); } @Override @@ -1515,7 +1515,7 @@ public abstract class RSClientMixin implements RSClient @FieldHook("cycleCntr") public static void onCycleCntrChanged(int idx) { - client.getCallbacks().post(new ClientTick()); + client.getCallbacks().post(ClientTick.INSTANCE); } @Copy("shouldLeftClickOpenMenu") 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 4c59a88e53..208c813667 100644 --- a/runelite-mixins/src/main/java/net/runelite/mixins/RSWidgetMixin.java +++ b/runelite-mixins/src/main/java/net/runelite/mixins/RSWidgetMixin.java @@ -496,7 +496,7 @@ public abstract class RSWidgetMixin implements RSWidget client.getLogger().trace("Posting widget position changed"); - WidgetPositioned widgetPositioned = new WidgetPositioned(); + WidgetPositioned widgetPositioned = WidgetPositioned.INSTANCE; client.getCallbacks().postDeferred(widgetPositioned); }