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
This commit is contained in:
sdburns1998
2019-07-05 01:11:31 +02:00
committed by Lucwousin
parent 8f05c01618
commit 22914889aa
694 changed files with 9824 additions and 4525 deletions

View File

@@ -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<Integer, GameState> 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);
}
}

View File

@@ -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(

View File

@@ -29,4 +29,10 @@ package net.runelite.api.events;
*/
public class BeforeRender
{
public static final BeforeRender INSTANCE = new BeforeRender();
private BeforeRender()
{
// noop
}
}

View File

@@ -29,4 +29,10 @@ package net.runelite.api.events;
*/
public class CannonballFired
{
public static final CannonballFired INSTANCE = new CannonballFired();
private CannonballFired()
{
// noop
}
}

View File

@@ -29,4 +29,10 @@ package net.runelite.api.events;
*/
public class CanvasSizeChanged
{
public static final CanvasSizeChanged INSTANCE = new CanvasSizeChanged();
private CanvasSizeChanged()
{
// noop
}
}

View File

@@ -29,4 +29,10 @@ package net.runelite.api.events;
*/
public class ClientTick
{
public static final ClientTick INSTANCE = new ClientTick();
private ClientTick()
{
// noop
}
}

View File

@@ -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
}
}

View File

@@ -29,4 +29,10 @@ package net.runelite.api.events;
*/
public class LocalPlayerDeath
{
public static final LocalPlayerDeath INSTANCE = new LocalPlayerDeath();
private LocalPlayerDeath()
{
// noop
}
}

View File

@@ -32,4 +32,10 @@ package net.runelite.api.events;
*/
public class UsernameChanged
{
public static final UsernameChanged INSTANCE = new UsernameChanged();
private UsernameChanged()
{
// noop
}
}

View File

@@ -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
}
}