client: use immutablemap for maps built in class initializers

This commit is contained in:
Adam
2019-05-12 11:57:40 -04:00
committed by Adam
parent 4d85b49b6c
commit 7d22663756
23 changed files with 223 additions and 125 deletions

View File

@@ -25,12 +25,12 @@
package net.runelite.client.game; package net.runelite.client.game;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
@@ -39,7 +39,7 @@ import java.util.Map;
*/ */
public class ItemVariationMapping public class ItemVariationMapping
{ {
private static final Map<Integer, Integer> MAPPINGS = new HashMap<>(); private static final Map<Integer, Integer> MAPPINGS;
static static
{ {
@@ -51,6 +51,7 @@ public class ItemVariationMapping
final InputStream geLimitData = ItemVariationMapping.class.getResourceAsStream("/item_variations.json"); final InputStream geLimitData = ItemVariationMapping.class.getResourceAsStream("/item_variations.json");
final Map<String, Collection<Integer>> itemVariations = gson.fromJson(new InputStreamReader(geLimitData), typeToken.getType()); final Map<String, Collection<Integer>> itemVariations = gson.fromJson(new InputStreamReader(geLimitData), typeToken.getType());
ImmutableMap.Builder<Integer, Integer> builder = new ImmutableMap.Builder<>();
for (Collection<Integer> value : itemVariations.values()) for (Collection<Integer> value : itemVariations.values())
{ {
final Iterator<Integer> iterator = value.iterator(); final Iterator<Integer> iterator = value.iterator();
@@ -58,9 +59,10 @@ public class ItemVariationMapping
while (iterator.hasNext()) while (iterator.hasNext())
{ {
MAPPINGS.put(iterator.next(), base); builder.put(iterator.next(), base);
} }
} }
MAPPINGS = builder.build();
} }
/** /**

View File

@@ -24,7 +24,7 @@
*/ */
package net.runelite.client.plugins.agility; package net.runelite.client.plugins.agility;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import lombok.Getter; import lombok.Getter;
import net.runelite.api.coords.WorldPoint; import net.runelite.api.coords.WorldPoint;
@@ -48,7 +48,7 @@ enum Courses
RELLEKA(780.0, 475, 10553), RELLEKA(780.0, 475, 10553),
ARDOUGNE(793.0, 529, 10547); ARDOUGNE(793.0, 529, 10547);
private final static Map<Integer, Courses> coursesByRegion = new HashMap<>(); private final static Map<Integer, Courses> coursesByRegion;
@Getter @Getter
private final double totalXp; private final double totalXp;
@@ -64,10 +64,14 @@ enum Courses
static static
{ {
ImmutableMap.Builder<Integer, Courses> builder = new ImmutableMap.Builder<>();
for (Courses course : values()) for (Courses course : values())
{ {
coursesByRegion.put(course.regionId, course); builder.put(course.regionId, course);
} }
coursesByRegion = builder.build();
} }
Courses(double totalXp, int lastObstacleXp, int regionId, WorldPoint... courseEndWorldPoints) Courses(double totalXp, int lastObstacleXp, int regionId, WorldPoint... courseEndWorldPoints)

View File

@@ -24,9 +24,17 @@
*/ */
package net.runelite.client.plugins.attackstyles; package net.runelite.client.plugins.attackstyles;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import static net.runelite.client.plugins.attackstyles.AttackStyle.*; import static net.runelite.client.plugins.attackstyles.AttackStyle.ACCURATE;
import static net.runelite.client.plugins.attackstyles.AttackStyle.AGGRESSIVE;
import static net.runelite.client.plugins.attackstyles.AttackStyle.CASTING;
import static net.runelite.client.plugins.attackstyles.AttackStyle.CONTROLLED;
import static net.runelite.client.plugins.attackstyles.AttackStyle.DEFENSIVE;
import static net.runelite.client.plugins.attackstyles.AttackStyle.DEFENSIVE_CASTING;
import static net.runelite.client.plugins.attackstyles.AttackStyle.LONGRANGE;
import static net.runelite.client.plugins.attackstyles.AttackStyle.OTHER;
import static net.runelite.client.plugins.attackstyles.AttackStyle.RANGING;
enum WeaponType enum WeaponType
{ {
@@ -59,16 +67,20 @@ enum WeaponType
TYPE_26(AGGRESSIVE, AGGRESSIVE, null, AGGRESSIVE), TYPE_26(AGGRESSIVE, AGGRESSIVE, null, AGGRESSIVE),
TYPE_27(ACCURATE, null, null, OTHER); TYPE_27(ACCURATE, null, null, OTHER);
private static final Map<Integer, WeaponType> weaponTypes = new HashMap<>();
private final AttackStyle[] attackStyles; private final AttackStyle[] attackStyles;
private static final Map<Integer, WeaponType> weaponTypes;
static static
{ {
ImmutableMap.Builder<Integer, WeaponType> builder = new ImmutableMap.Builder<>();
for (WeaponType weaponType : values()) for (WeaponType weaponType : values())
{ {
weaponTypes.put(weaponType.ordinal(), weaponType); builder.put(weaponType.ordinal(), weaponType);
} }
weaponTypes = builder.build();
} }
WeaponType(AttackStyle... attackStyles) WeaponType(AttackStyle... attackStyles)

View File

@@ -24,7 +24,7 @@
*/ */
package net.runelite.client.plugins.blastfurnace; package net.runelite.client.plugins.blastfurnace;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import lombok.Getter; import lombok.Getter;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
@@ -50,14 +50,18 @@ public enum BarsOres
SILVER_BAR(Varbits.BLAST_FURNACE_SILVER_BAR, ItemID.SILVER_BAR), SILVER_BAR(Varbits.BLAST_FURNACE_SILVER_BAR, ItemID.SILVER_BAR),
GOLD_BAR(Varbits.BLAST_FURNACE_GOLD_BAR, ItemID.GOLD_BAR); GOLD_BAR(Varbits.BLAST_FURNACE_GOLD_BAR, ItemID.GOLD_BAR);
private static final Map<Varbits, BarsOres> VARBIT = new HashMap<>(); private static final Map<Varbits, BarsOres> VARBIT;
static static
{ {
ImmutableMap.Builder<Varbits, BarsOres> builder = new ImmutableMap.Builder<>();
for (BarsOres s : values()) for (BarsOres s : values())
{ {
VARBIT.put(s.getVarbit(), s); builder.put(s.getVarbit(), s);
} }
VARBIT = builder.build();
} }
@Getter @Getter

View File

@@ -24,7 +24,7 @@
*/ */
package net.runelite.client.plugins.blastmine; package net.runelite.client.plugins.blastmine;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import lombok.Getter; import lombok.Getter;
import net.runelite.api.ObjectID; import net.runelite.api.ObjectID;
@@ -37,17 +37,21 @@ public enum BlastMineRockType
LIT(ObjectID.POT_OF_DYNAMITE_28585, ObjectID.POT_OF_DYNAMITE_28586), LIT(ObjectID.POT_OF_DYNAMITE_28585, ObjectID.POT_OF_DYNAMITE_28586),
EXPLODED(ObjectID.SHATTERED_ROCKFACE, ObjectID.SHATTERED_ROCKFACE_28588); EXPLODED(ObjectID.SHATTERED_ROCKFACE, ObjectID.SHATTERED_ROCKFACE_28588);
private static final Map<Integer, BlastMineRockType> rockTypes = new HashMap<>(); private static final Map<Integer, BlastMineRockType> rockTypes;
static static
{ {
ImmutableMap.Builder<Integer, BlastMineRockType> builder = new ImmutableMap.Builder<>();
for (BlastMineRockType type : values()) for (BlastMineRockType type : values())
{ {
for (int spotId : type.getObjectIds()) for (int spotId : type.getObjectIds())
{ {
rockTypes.put(spotId, type); builder.put(spotId, type);
} }
} }
rockTypes = builder.build();
} }
@Getter @Getter

View File

@@ -25,9 +25,9 @@
*/ */
package net.runelite.client.plugins.bosstimer; package net.runelite.client.plugins.bosstimer;
import com.google.common.collect.ImmutableMap;
import java.time.Duration; import java.time.Duration;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
import net.runelite.api.NpcID; import net.runelite.api.NpcID;
@@ -59,7 +59,7 @@ enum Boss
DUSK(NpcID.DUSK_7889, 2, ChronoUnit.MINUTES, ItemID.NOON), DUSK(NpcID.DUSK_7889, 2, ChronoUnit.MINUTES, ItemID.NOON),
ALCHEMICAL_HYDRA(NpcID.ALCHEMICAL_HYDRA_8622, 25200, ChronoUnit.MILLIS, ItemID.IKKLE_HYDRA); ALCHEMICAL_HYDRA(NpcID.ALCHEMICAL_HYDRA_8622, 25200, ChronoUnit.MILLIS, ItemID.IKKLE_HYDRA);
private static final Map<Integer, Boss> bosses = new HashMap<>(); private static final Map<Integer, Boss> bosses;
private final int id; private final int id;
private final Duration spawnTime; private final Duration spawnTime;
@@ -67,10 +67,14 @@ enum Boss
static static
{ {
ImmutableMap.Builder<Integer, Boss> builder = new ImmutableMap.Builder<>();
for (Boss boss : values()) for (Boss boss : values())
{ {
bosses.put(boss.getId(), boss); builder.put(boss.getId(), boss);
} }
bosses = builder.build();
} }
private Boss(int id, long period, ChronoUnit unit, int itemSpriteId) private Boss(int id, long period, ChronoUnit unit, int itemSpriteId)

View File

@@ -24,7 +24,7 @@
*/ */
package net.runelite.client.plugins.cerberus; package net.runelite.client.plugins.cerberus;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import lombok.Getter; import lombok.Getter;
@@ -41,18 +41,21 @@ public enum CerberusGhost
MAGE(NpcID.SUMMONED_SOUL_5868, Skill.MAGIC), MAGE(NpcID.SUMMONED_SOUL_5868, Skill.MAGIC),
MELEE(NpcID.SUMMONED_SOUL_5869, Skill.ATTACK); MELEE(NpcID.SUMMONED_SOUL_5869, Skill.ATTACK);
private static final Map<Integer, CerberusGhost> MAP = new HashMap<>();
private final int npcId; private final int npcId;
private final Skill type; private final Skill type;
private static final Map<Integer, CerberusGhost> MAP;
static static
{ {
final CerberusGhost[] values = CerberusGhost.values(); ImmutableMap.Builder<Integer, CerberusGhost> builder = new ImmutableMap.Builder<>();
for (final CerberusGhost ghost : values) for (final CerberusGhost ghost : values())
{ {
MAP.put(ghost.getNpcId(), ghost); builder.put(ghost.getNpcId(), ghost);
} }
MAP = builder.build();
} }
/** /**

View File

@@ -24,56 +24,58 @@
*/ */
package net.runelite.client.plugins.chatcommands; package net.runelite.client.plugins.chatcommands;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import net.runelite.api.Skill; import net.runelite.api.Skill;
class SkillAbbreviations class SkillAbbreviations
{ {
private static final Map<String, String> MAP = new HashMap<>(); private static final Map<String, String> MAP;
static static
{ {
MAP.put("ATK", Skill.ATTACK.getName()); ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<>();
MAP.put("ATT", Skill.ATTACK.getName()); builder.put("ATK", Skill.ATTACK.getName());
MAP.put("DEF", Skill.DEFENCE.getName()); builder.put("ATT", Skill.ATTACK.getName());
MAP.put("STR", Skill.STRENGTH.getName()); builder.put("DEF", Skill.DEFENCE.getName());
MAP.put("HEALTH", Skill.HITPOINTS.getName()); builder.put("STR", Skill.STRENGTH.getName());
MAP.put("HIT", Skill.HITPOINTS.getName()); builder.put("HEALTH", Skill.HITPOINTS.getName());
MAP.put("HITPOINT", Skill.HITPOINTS.getName()); builder.put("HIT", Skill.HITPOINTS.getName());
MAP.put("HP", Skill.HITPOINTS.getName()); builder.put("HITPOINT", Skill.HITPOINTS.getName());
MAP.put("RANGE", Skill.RANGED.getName()); builder.put("HP", Skill.HITPOINTS.getName());
MAP.put("RANGING", Skill.RANGED.getName()); builder.put("RANGE", Skill.RANGED.getName());
MAP.put("RNG", Skill.RANGED.getName()); builder.put("RANGING", Skill.RANGED.getName());
MAP.put("PRAY", Skill.PRAYER.getName()); builder.put("RNG", Skill.RANGED.getName());
MAP.put("MAG", Skill.MAGIC.getName()); builder.put("PRAY", Skill.PRAYER.getName());
MAP.put("MAGE", Skill.MAGIC.getName()); builder.put("MAG", Skill.MAGIC.getName());
MAP.put("COOK", Skill.COOKING.getName()); builder.put("MAGE", Skill.MAGIC.getName());
MAP.put("WC", Skill.WOODCUTTING.getName()); builder.put("COOK", Skill.COOKING.getName());
MAP.put("WOOD", Skill.WOODCUTTING.getName()); builder.put("WC", Skill.WOODCUTTING.getName());
MAP.put("WOODCUT", Skill.WOODCUTTING.getName()); builder.put("WOOD", Skill.WOODCUTTING.getName());
MAP.put("FLETCH", Skill.FLETCHING.getName()); builder.put("WOODCUT", Skill.WOODCUTTING.getName());
MAP.put("FISH", Skill.FISHING.getName()); builder.put("FLETCH", Skill.FLETCHING.getName());
MAP.put("FM", Skill.FIREMAKING.getName()); builder.put("FISH", Skill.FISHING.getName());
MAP.put("FIRE", Skill.FIREMAKING.getName()); builder.put("FM", Skill.FIREMAKING.getName());
MAP.put("CRAFT", Skill.CRAFTING.getName()); builder.put("FIRE", Skill.FIREMAKING.getName());
MAP.put("SMITH", Skill.SMITHING.getName()); builder.put("CRAFT", Skill.CRAFTING.getName());
MAP.put("MINE", Skill.MINING.getName()); builder.put("SMITH", Skill.SMITHING.getName());
MAP.put("HL", Skill.HERBLORE.getName()); builder.put("MINE", Skill.MINING.getName());
MAP.put("HERB", Skill.HERBLORE.getName()); builder.put("HL", Skill.HERBLORE.getName());
MAP.put("AGI", Skill.AGILITY.getName()); builder.put("HERB", Skill.HERBLORE.getName());
MAP.put("AGIL", Skill.AGILITY.getName()); builder.put("AGI", Skill.AGILITY.getName());
MAP.put("THIEF", Skill.THIEVING.getName()); builder.put("AGIL", Skill.AGILITY.getName());
MAP.put("SLAY", Skill.SLAYER.getName()); builder.put("THIEF", Skill.THIEVING.getName());
MAP.put("FARM", Skill.FARMING.getName()); builder.put("SLAY", Skill.SLAYER.getName());
MAP.put("RC", Skill.RUNECRAFT.getName()); builder.put("FARM", Skill.FARMING.getName());
MAP.put("RUNE", Skill.RUNECRAFT.getName()); builder.put("RC", Skill.RUNECRAFT.getName());
MAP.put("RUNECRAFTING", Skill.RUNECRAFT.getName()); builder.put("RUNE", Skill.RUNECRAFT.getName());
MAP.put("HUNT", Skill.HUNTER.getName()); builder.put("RUNECRAFTING", Skill.RUNECRAFT.getName());
MAP.put("CON", Skill.CONSTRUCTION.getName()); builder.put("HUNT", Skill.HUNTER.getName());
MAP.put("CONSTRUCT", Skill.CONSTRUCTION.getName()); builder.put("CON", Skill.CONSTRUCTION.getName());
MAP.put("ALL", Skill.OVERALL.getName()); builder.put("CONSTRUCT", Skill.CONSTRUCTION.getName());
MAP.put("TOTAL", Skill.OVERALL.getName()); builder.put("ALL", Skill.OVERALL.getName());
builder.put("TOTAL", Skill.OVERALL.getName());
MAP = builder.build();
} }
/** /**

View File

@@ -25,8 +25,8 @@
*/ */
package net.runelite.client.plugins.discord; package net.runelite.client.plugins.discord;
import java.util.ArrayList; import com.google.common.collect.ImmutableList;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -250,16 +250,18 @@ enum DiscordGameEventType
RAIDS_CHAMBERS_OF_XERIC("Chambers of Xeric", DiscordAreaType.RAIDS, Varbits.IN_RAID), RAIDS_CHAMBERS_OF_XERIC("Chambers of Xeric", DiscordAreaType.RAIDS, Varbits.IN_RAID),
RAIDS_THEATRE_OF_BLOOD("Theatre of Blood", DiscordAreaType.RAIDS, Varbits.THEATRE_OF_BLOOD); RAIDS_THEATRE_OF_BLOOD("Theatre of Blood", DiscordAreaType.RAIDS, Varbits.THEATRE_OF_BLOOD);
private static final Map<Integer, DiscordGameEventType> FROM_REGION = new HashMap<>(); private static final Map<Integer, DiscordGameEventType> FROM_REGION;
private static final List<DiscordGameEventType> FROM_VARBITS = new ArrayList<>(); private static final List<DiscordGameEventType> FROM_VARBITS;
static static
{ {
ImmutableMap.Builder<Integer, DiscordGameEventType> regionMapBuilder = new ImmutableMap.Builder<>();
ImmutableList.Builder<DiscordGameEventType> fromVarbitsBuilder = ImmutableList.builder();
for (DiscordGameEventType discordGameEventType : DiscordGameEventType.values()) for (DiscordGameEventType discordGameEventType : DiscordGameEventType.values())
{ {
if (discordGameEventType.getVarbits() != null) if (discordGameEventType.getVarbits() != null)
{ {
FROM_VARBITS.add(discordGameEventType); fromVarbitsBuilder.add(discordGameEventType);
continue; continue;
} }
@@ -270,10 +272,11 @@ enum DiscordGameEventType
for (int region : discordGameEventType.getRegionIds()) for (int region : discordGameEventType.getRegionIds())
{ {
assert !FROM_REGION.containsKey(region); regionMapBuilder.put(region, discordGameEventType);
FROM_REGION.put(region, discordGameEventType);
} }
} }
FROM_REGION = regionMapBuilder.build();
FROM_VARBITS = fromVarbitsBuilder.build();
} }
private String imageKey; private String imageKey;

View File

@@ -24,7 +24,7 @@
*/ */
package net.runelite.client.plugins.fishing; package net.runelite.client.plugins.fishing;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import lombok.Getter; import lombok.Getter;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
@@ -160,7 +160,7 @@ enum FishingSpot
FISHING_SPOT_8523); FISHING_SPOT_8523);
@Getter @Getter
private static final Map<Integer, FishingSpot> SPOTS = new HashMap<>(); private static final Map<Integer, FishingSpot> SPOTS;
private final String name; private final String name;
private final int fishSpriteId; private final int fishSpriteId;
@@ -168,15 +168,17 @@ enum FishingSpot
static static
{ {
FishingSpot[] spots = values(); ImmutableMap.Builder<Integer, FishingSpot> builder = new ImmutableMap.Builder<>();
for (FishingSpot spot : spots) for (FishingSpot spot : values())
{ {
for (int spotId : spot.getIds()) for (int spotId : spot.getIds())
{ {
SPOTS.put(spotId, spot); builder.put(spotId, spot);
} }
} }
SPOTS = builder.build();
} }
FishingSpot(String spot, int fishSpriteId, int... ids) FishingSpot(String spot, int fishSpriteId, int... ids)

View File

@@ -24,7 +24,7 @@
*/ */
package net.runelite.client.plugins.implings; package net.runelite.client.plugins.implings;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
@@ -70,14 +70,18 @@ enum Impling
private ImplingType implingType; private ImplingType implingType;
private final int npcId; private final int npcId;
private static final Map<Integer, Impling> IMPLINGS = new HashMap<>(); private static final Map<Integer, Impling> IMPLINGS;
static static
{ {
ImmutableMap.Builder<Integer, Impling> builder = new ImmutableMap.Builder<>();
for (Impling impling : values()) for (Impling impling : values())
{ {
IMPLINGS.put(impling.npcId, impling); builder.put(impling.npcId, impling);
} }
IMPLINGS = builder.build();
} }
static Impling findImpling(int npcId) static Impling findImpling(int npcId)

View File

@@ -24,13 +24,19 @@
*/ */
package net.runelite.client.plugins.itemcharges; package net.runelite.client.plugins.itemcharges;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import static net.runelite.api.ItemID.*; import static net.runelite.api.ItemID.*;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.*; import static net.runelite.client.plugins.itemcharges.ItemChargeType.ABYSSAL_BRACELET;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.BELLOWS;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.FUNGICIDE_SPRAY;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.IMPBOX;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.TELEPORT;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERCAN;
import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERSKIN;
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter
@@ -168,14 +174,18 @@ enum ItemWithCharge
private final int id; private final int id;
private final int charges; private final int charges;
private static final Map<Integer, ItemWithCharge> ID_MAP = new HashMap<>(); private static final Map<Integer, ItemWithCharge> ID_MAP;
static static
{ {
ImmutableMap.Builder<Integer, ItemWithCharge> builder = new ImmutableMap.Builder<>();
for (ItemWithCharge itemCharge : values()) for (ItemWithCharge itemCharge : values())
{ {
ID_MAP.put(itemCharge.getId(), itemCharge); builder.put(itemCharge.getId(), itemCharge);
} }
ID_MAP = builder.build();
} }
@Nullable @Nullable

View File

@@ -24,7 +24,7 @@
*/ */
package net.runelite.client.plugins.itemidentification; package net.runelite.client.plugins.itemidentification;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
@@ -100,17 +100,21 @@ enum ItemIdentification
this.itemIDs = ids; this.itemIDs = ids;
} }
private static final Map<Integer, ItemIdentification> itemIdentifications = new HashMap<>(); private static final Map<Integer, ItemIdentification> itemIdentifications;
static static
{ {
ImmutableMap.Builder<Integer, ItemIdentification> builder = new ImmutableMap.Builder<>();
for (ItemIdentification i : values()) for (ItemIdentification i : values())
{ {
for (int id : i.itemIDs) for (int id : i.itemIDs)
{ {
itemIdentifications.put(id, i); builder.put(id, i);
} }
} }
itemIdentifications = builder.build();
} }
static ItemIdentification get(int id) static ItemIdentification get(int id)

View File

@@ -24,12 +24,22 @@
*/ */
package net.runelite.client.plugins.poh; package net.runelite.client.plugins.poh;
import com.google.common.collect.ImmutableMap;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import lombok.Getter; import lombok.Getter;
import static net.runelite.api.NullObjectID.NULL_13615;
import static net.runelite.api.NullObjectID.NULL_13618;
import static net.runelite.api.NullObjectID.NULL_13620;
import static net.runelite.api.NullObjectID.NULL_13622;
import static net.runelite.api.NullObjectID.NULL_13625;
import static net.runelite.api.NullObjectID.NULL_13627;
import static net.runelite.api.NullObjectID.NULL_13629;
import static net.runelite.api.NullObjectID.NULL_13632;
import static net.runelite.api.NullObjectID.NULL_13634;
import static net.runelite.api.NullObjectID.NULL_29228;
import static net.runelite.api.NullObjectID.NULL_29229;
import static net.runelite.api.ObjectID.*; import static net.runelite.api.ObjectID.*;
import static net.runelite.api.NullObjectID.*;
import net.runelite.client.util.ImageUtil; import net.runelite.client.util.ImageUtil;
public enum PohIcons public enum PohIcons
@@ -56,7 +66,7 @@ public enum PohIcons
ALTAR("altar", ALTAR("altar",
ALTAR_13179, ALTAR_13180, ALTAR_13181, ALTAR_13182, ALTAR_13183, ALTAR_13184, ALTAR_13185, ALTAR_13186, ALTAR_13179, ALTAR_13180, ALTAR_13181, ALTAR_13182, ALTAR_13183, ALTAR_13184, ALTAR_13185, ALTAR_13186,
ALTAR_13187, ALTAR_13188, ALTAR_13189, ALTAR_13190, ALTAR_13191, ALTAR_13192, ALTAR_13193, ALTAR_13194, ALTAR_13187, ALTAR_13188, ALTAR_13189, ALTAR_13190, ALTAR_13191, ALTAR_13192, ALTAR_13193, ALTAR_13194,
ALTAR_13194, ALTAR_13196, ALTAR_13197, ALTAR_13198, ALTAR_13199 ALTAR_13196, ALTAR_13197, ALTAR_13198, ALTAR_13199
), ),
POOLS("pool", POOL_OF_RESTORATION, POOL_OF_REVITALISATION, POOL_OF_REJUVENATION, FANCY_REJUVENATION_POOL, ORNATE_REJUVENATION_POOL), POOLS("pool", POOL_OF_RESTORATION, POOL_OF_REVITALISATION, POOL_OF_REJUVENATION, FANCY_REJUVENATION_POOL, ORNATE_REJUVENATION_POOL),
GLORY("glory", AMULET_OF_GLORY), GLORY("glory", AMULET_OF_GLORY),
@@ -83,7 +93,7 @@ public enum PohIcons
DIGSITE_PENDANT, DIGSITE_PENDANT_33417, DIGSITE_PENDANT_33418, DIGSITE_PENDANT_33420 DIGSITE_PENDANT, DIGSITE_PENDANT_33417, DIGSITE_PENDANT_33418, DIGSITE_PENDANT_33420
); );
private static final Map<Integer, PohIcons> minimapIcons = new HashMap<>(); private static final Map<Integer, PohIcons> minimapIcons;
@Getter @Getter
private final String imageResource; private final String imageResource;
@@ -94,15 +104,17 @@ public enum PohIcons
static static
{ {
PohIcons[] icons = values(); ImmutableMap.Builder<Integer, PohIcons> builder = new ImmutableMap.Builder<>();
for (PohIcons icon : icons) for (PohIcons icon : values())
{ {
for (Integer spotId : icon.getIds()) for (Integer spotId : icon.getIds())
{ {
minimapIcons.put(spotId, icon); builder.put(spotId, icon);
} }
} }
minimapIcons = builder.build();
} }
PohIcons(String imageResource, int... ids) PohIcons(String imageResource, int... ids)

View File

@@ -24,7 +24,7 @@
*/ */
package net.runelite.client.plugins.prayer; package net.runelite.client.plugins.prayer;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
@@ -453,17 +453,19 @@ enum PrayerItems
DAMAGED_BOOK_3841(ItemID.DAMAGED_BOOK_3841, 5), DAMAGED_BOOK_3841(ItemID.DAMAGED_BOOK_3841, 5),
FALADOR_SHIELD_4(ItemID.FALADOR_SHIELD_4, 5); FALADOR_SHIELD_4(ItemID.FALADOR_SHIELD_4, 5);
private static final Map<Integer, Integer> prayerBonuses = new HashMap<>(); private static final Map<Integer, Integer> prayerBonuses;
private final int itemId; private final int itemId;
private final int prayerBonus; private final int prayerBonus;
static static
{ {
ImmutableMap.Builder<Integer, Integer> builder = new ImmutableMap.Builder<>();
for (PrayerItems item : values()) for (PrayerItems item : values())
{ {
prayerBonuses.put(item.getItemId(), item.getPrayerBonus()); builder.put(item.getItemId(), item.getPrayerBonus());
} }
prayerBonuses = builder.build();
} }
static int getItemPrayerBonus(int itemId) static int getItemPrayerBonus(int itemId)

View File

@@ -24,7 +24,7 @@
*/ */
package net.runelite.client.plugins.prayer; package net.runelite.client.plugins.prayer;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
@@ -36,7 +36,7 @@ enum PrayerRestoreType
HOLYWRENCH(ItemID.PRAYER_CAPE, ItemID.PRAYER_CAPET, ItemID.PRAYER_CAPE_10643, ItemID.MAX_CAPE, ItemID.MAX_CAPE_13282, HOLYWRENCH(ItemID.PRAYER_CAPE, ItemID.PRAYER_CAPET, ItemID.PRAYER_CAPE_10643, ItemID.MAX_CAPE, ItemID.MAX_CAPE_13282,
ItemID.MAX_CAPE_13342, ItemID.HOLY_WRENCH, ItemID.RING_OF_THE_GODS_I); ItemID.MAX_CAPE_13342, ItemID.HOLY_WRENCH, ItemID.RING_OF_THE_GODS_I);
private static final Map<Integer, PrayerRestoreType> prayerRestores = new HashMap<>(); private static final Map<Integer, PrayerRestoreType> prayerRestores;
private final int[] items; private final int[] items;
@@ -47,13 +47,15 @@ enum PrayerRestoreType
static static
{ {
ImmutableMap.Builder<Integer, PrayerRestoreType> builder = new ImmutableMap.Builder<>();
for (PrayerRestoreType prayerRestoreType : values()) for (PrayerRestoreType prayerRestoreType : values())
{ {
for (int itemId : prayerRestoreType.items) for (int itemId : prayerRestoreType.items)
{ {
prayerRestores.put(itemId, prayerRestoreType); builder.put(itemId, prayerRestoreType);
} }
} }
prayerRestores = builder.build();
} }
static PrayerRestoreType getType(final int itemId) static PrayerRestoreType getType(final int itemId)

View File

@@ -25,7 +25,7 @@
*/ */
package net.runelite.client.plugins.puzzlesolver; package net.runelite.client.plugins.puzzlesolver;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -135,14 +135,18 @@ enum VarrockMuseumAnswer
LEECH_5("What is special about Morytanian leeches?", "They attack by jumping."), LEECH_5("What is special about Morytanian leeches?", "They attack by jumping."),
LEECH_6("How does a leech change when it feeds?", "It doubles in size."); LEECH_6("How does a leech change when it feeds?", "It doubles in size.");
private static final Map<String, String> MATCHES = new HashMap<>(); private static final Map<String, String> MATCHES;
static static
{ {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<>();
for (VarrockMuseumAnswer varrockMuseumAnswer : VarrockMuseumAnswer.values()) for (VarrockMuseumAnswer varrockMuseumAnswer : VarrockMuseumAnswer.values())
{ {
MATCHES.put(varrockMuseumAnswer.question, varrockMuseumAnswer.answer); builder.put(varrockMuseumAnswer.question, varrockMuseumAnswer.answer);
} }
MATCHES = builder.build();
} }
private final String question; private final String question;

View File

@@ -24,7 +24,7 @@
*/ */
package net.runelite.client.plugins.runecraft; package net.runelite.client.plugins.runecraft;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import lombok.Getter; import lombok.Getter;
import static net.runelite.api.ItemID.AIR_RUNE; import static net.runelite.api.ItemID.AIR_RUNE;
@@ -64,14 +64,18 @@ public enum AbyssRifts
@Getter @Getter
private final int itemId; private final int itemId;
private static final Map<Integer, AbyssRifts> rifts = new HashMap<>(); private static final Map<Integer, AbyssRifts> rifts;
static static
{ {
ImmutableMap.Builder<Integer, AbyssRifts> builder = new ImmutableMap.Builder<>();
for (AbyssRifts s : values()) for (AbyssRifts s : values())
{ {
rifts.put(s.getObjectId(), s); builder.put(s.getObjectId(), s);
} }
rifts = builder.build();
} }
AbyssRifts(int objectId, int itemId) AbyssRifts(int objectId, int itemId)

View File

@@ -25,8 +25,8 @@
package net.runelite.client.plugins.runepouch; package net.runelite.client.plugins.runepouch;
import com.google.common.collect.ImmutableMap;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@@ -85,14 +85,16 @@ public enum Runes
@Setter @Setter
private BufferedImage image; private BufferedImage image;
private static final Map<Integer, Runes> runes = new HashMap<>(); private static final Map<Integer, Runes> runes;
static static
{ {
ImmutableMap.Builder<Integer, Runes> builder = new ImmutableMap.Builder<>();
for (Runes rune : values()) for (Runes rune : values())
{ {
runes.put(rune.getId(), rune); builder.put(rune.getId(), rune);
} }
runes = builder.build();
} }
Runes(int id, int itemId) Runes(int id, int itemId)

View File

@@ -26,7 +26,7 @@
package net.runelite.client.plugins.slayer; package net.runelite.client.plugins.slayer;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import lombok.Getter; import lombok.Getter;
import net.runelite.api.ItemID; import net.runelite.api.ItemID;
@@ -174,7 +174,7 @@ enum Task
ZUK("TzKal-Zuk", ItemID.TZREKZUK); ZUK("TzKal-Zuk", ItemID.TZREKZUK);
//</editor-fold> //</editor-fold>
private static final Map<String, Task> tasks = new HashMap<>(); private static final Map<String, Task> tasks;
private final String name; private final String name;
private final int itemSpriteId; private final int itemSpriteId;
@@ -184,10 +184,14 @@ enum Task
static static
{ {
ImmutableMap.Builder<String, Task> builder = new ImmutableMap.Builder<>();
for (Task task : values()) for (Task task : values())
{ {
tasks.put(task.getName().toLowerCase(), task); builder.put(task.getName().toLowerCase(), task);
} }
tasks = builder.build();
} }
Task(String name, int itemSpriteId, String... targetNames) Task(String name, int itemSpriteId, String... targetNames)

View File

@@ -24,7 +24,7 @@
*/ */
package net.runelite.client.plugins.tithefarm; package net.runelite.client.plugins.tithefarm;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import lombok.Getter; import lombok.Getter;
import net.runelite.api.ObjectID; import net.runelite.api.ObjectID;
@@ -60,19 +60,21 @@ public enum TitheFarmPlantType
@Getter @Getter
private final int[] objectIds; private final int[] objectIds;
private static final Map<Integer, TitheFarmPlantType> plantTypes = new HashMap<>(); private static final Map<Integer, TitheFarmPlantType> plantTypes;
static static
{ {
TitheFarmPlantType[] types = values(); ImmutableMap.Builder<Integer, TitheFarmPlantType> builder = new ImmutableMap.Builder<>();
for (TitheFarmPlantType type : types) for (TitheFarmPlantType type : values())
{ {
for (int spotId : type.getObjectIds()) for (int spotId : type.getObjectIds())
{ {
plantTypes.put(spotId, type); builder.put(spotId, type);
} }
} }
plantTypes = builder.build();
} }
TitheFarmPlantType(String name, int baseId, int... objectIds) TitheFarmPlantType(String name, int baseId, int... objectIds)

View File

@@ -24,7 +24,7 @@
*/ */
package net.runelite.client.plugins.woodcutting; package net.runelite.client.plugins.woodcutting;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
@@ -67,14 +67,18 @@ enum Axe
private final Integer animId; private final Integer animId;
private final Integer itemId; private final Integer itemId;
private static final Map<Integer, Axe> AXE_ANIM_IDS = new HashMap<>(); private static final Map<Integer, Axe> AXE_ANIM_IDS;
static static
{ {
ImmutableMap.Builder<Integer, Axe> builder = new ImmutableMap.Builder<>();
for (Axe axe : values()) for (Axe axe : values())
{ {
AXE_ANIM_IDS.put(axe.animId, axe); builder.put(axe.animId, axe);
} }
AXE_ANIM_IDS = builder.build();
} }
static Axe findAxeByAnimId(int animId) static Axe findAxeByAnimId(int animId)

View File

@@ -24,7 +24,7 @@
*/ */
package net.runelite.client.plugins.woodcutting; package net.runelite.client.plugins.woodcutting;
import java.util.HashMap; import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
import lombok.Getter; import lombok.Getter;
import static net.runelite.api.ObjectID.REDWOOD; import static net.runelite.api.ObjectID.REDWOOD;
@@ -42,17 +42,21 @@ enum Tree
this.treeIds = treeIds; this.treeIds = treeIds;
} }
private static final Map<Integer, Tree> TREES = new HashMap<>(); private static final Map<Integer, Tree> TREES;
static static
{ {
ImmutableMap.Builder<Integer, Tree> builder = new ImmutableMap.Builder<>();
for (Tree tree : values()) for (Tree tree : values())
{ {
for (int treeId : tree.treeIds) for (int treeId : tree.treeIds)
{ {
TREES.put(treeId, tree); builder.put(treeId, tree);
} }
} }
TREES = builder.build();
} }
static Tree findTree(int objectId) static Tree findTree(int objectId)