From 845ca463d5f0be2fcee156f04fe1737d8fe5a0c8 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 14 Jul 2021 22:52:51 -0400 Subject: [PATCH] item identification: clean up config enabled checks --- .../ItemIdentification.java | 33 ++++--- .../ItemIdentificationOverlay.java | 90 +------------------ 2 files changed, 20 insertions(+), 103 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentification.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentification.java index e80f55d281..934a0d1116 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentification.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentification.java @@ -26,6 +26,8 @@ package net.runelite.client.plugins.itemidentification; import com.google.common.collect.ImmutableMap; import java.util.Map; +import java.util.function.Predicate; +import lombok.AllArgsConstructor; import net.runelite.api.ItemID; enum ItemIdentification @@ -419,21 +421,24 @@ enum ItemIdentification return itemIdentifications.get(id); } + @AllArgsConstructor enum Type { - SEED, - SACK, - HERB, - LOGS, - PLANK, - SAPLING, - COMPOST, - ORE, - BAR, - GEM, - POTION, - IMPLING_JAR, - TABLET, - SCROLL + SEED(ItemIdentificationConfig::showSeeds), + SACK(ItemIdentificationConfig::showSacks), + HERB(ItemIdentificationConfig::showHerbs), + LOGS(ItemIdentificationConfig::showLogs), + PLANK(ItemIdentificationConfig::showPlanks), + SAPLING(ItemIdentificationConfig::showSaplings), + COMPOST(ItemIdentificationConfig::showComposts), + ORE(ItemIdentificationConfig::showOres), + BAR(ItemIdentificationConfig::showBars), + GEM(ItemIdentificationConfig::showGems), + POTION(ItemIdentificationConfig::showPotions), + IMPLING_JAR(ItemIdentificationConfig::showImplingJars), + TABLET(ItemIdentificationConfig::showTablets), + SCROLL(ItemIdentificationConfig::showTeleportScrolls); + + final Predicate enabled; } } 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 969b7d45d6..8ac2125237 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 @@ -58,99 +58,11 @@ class ItemIdentificationOverlay extends WidgetItemOverlay public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem widgetItem) { ItemIdentification iden = findItemIdentification(itemId); - if (iden == null) + if (iden == null || !iden.type.enabled.test(config)) { return; } - switch (iden.type) - { - case SEED: - if (!config.showSeeds()) - { - return; - } - break; - case SACK: - if (!config.showSacks()) - { - return; - } - break; - case HERB: - if (!config.showHerbs()) - { - return; - } - break; - case LOGS: - if (!config.showLogs()) - { - return; - } - break; - case PLANK: - if (!config.showPlanks()) - { - return; - } - break; - case SAPLING: - if (!config.showSaplings()) - { - return; - } - break; - case COMPOST: - if (!config.showComposts()) - { - return; - } - break; - case ORE: - if (!config.showOres()) - { - return; - } - break; - case BAR: - if (!config.showBars()) - { - return; - } - break; - case GEM: - if (!config.showGems()) - { - return; - } - break; - case POTION: - if (!config.showPotions()) - { - return; - } - break; - case IMPLING_JAR: - if (!config.showImplingJars()) - { - return; - } - break; - case TABLET: - if (!config.showTablets()) - { - return; - } - break; - case SCROLL: - if (!config.showTeleportScrolls()) - { - return; - } - break; - } - graphics.setFont(FontManager.getRunescapeSmallFont()); renderText(graphics, widgetItem.getCanvasBounds(), iden); }