From 0b8f9ad8514db62f8ef7bdb30537b44dcc20b193 Mon Sep 17 00:00:00 2001 From: Phong Date: Thu, 25 Jul 2024 09:01:35 +0700 Subject: [PATCH] refactor: Replace HashMap with Map in GameConstants & CombineManager --- src/main/java/emu/grasscutter/GameConstants.java | 4 ++-- .../java/emu/grasscutter/game/combine/CombineManger.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/emu/grasscutter/GameConstants.java b/src/main/java/emu/grasscutter/GameConstants.java index 9189478cb..0411fae7c 100644 --- a/src/main/java/emu/grasscutter/GameConstants.java +++ b/src/main/java/emu/grasscutter/GameConstants.java @@ -59,7 +59,7 @@ public final class GameConstants { public static final int[] DEFAULT_ABILITY_HASHES = Arrays.stream(DEFAULT_ABILITY_STRINGS).mapToInt(Utils::abilityHash).toArray(); public static final int DEFAULT_ABILITY_NAME = Utils.abilityHash("Default"); - public static final HashMap YAE_MIKO_ITEM_TO_REGION_COMBINE_BONUS = new HashMap<>() {{ + public static final Map YAE_MIKO_ITEM_TO_REGION_COMBINE_BONUS = new HashMap<>() {{ put(104304, 1); put(104307, 1); put(104310, 2); @@ -72,7 +72,7 @@ public final class GameConstants { put(104332, 4); put(104335, 4); }}; - public static final HashMap> YAE_MIKO_REGION_TO_ITEM_COMBINE_BONUS = new HashMap<>() {{ + public static final Map> YAE_MIKO_REGION_TO_ITEM_COMBINE_BONUS = new HashMap<>() {{ put(1, List.of(104304, 104307)); put(2, List.of(104310, 104313, 104316)); put(3, List.of(104320, 104323, 104326)); diff --git a/src/main/java/emu/grasscutter/game/combine/CombineManger.java b/src/main/java/emu/grasscutter/game/combine/CombineManger.java index 8f7c27098..cd2ef1507 100644 --- a/src/main/java/emu/grasscutter/game/combine/CombineManger.java +++ b/src/main/java/emu/grasscutter/game/combine/CombineManger.java @@ -128,7 +128,7 @@ public class CombineManger extends BaseGameSystem { player.getInventory().addItem(combineBack); result.getBack().add(combineBack); } else { - HashMap mapIdCount = new HashMap<>(); + Map mapIdCount = new HashMap<>(); for (int i = 0; i < luckyCount; i++) { var randomId = combineData .getMaterialItems() @@ -152,10 +152,10 @@ public class CombineManger extends BaseGameSystem { // material excluded) when crafting. The rarity is that of the base material." // from wiki // map of material id to region id - HashMap itemToRegion = GameConstants.YAE_MIKO_ITEM_TO_REGION_COMBINE_BONUS; + Map itemToRegion = GameConstants.YAE_MIKO_ITEM_TO_REGION_COMBINE_BONUS; // get list of material id with every region - HashMap> regionToId = GameConstants.YAE_MIKO_REGION_TO_ITEM_COMBINE_BONUS; + Map> regionToId = GameConstants.YAE_MIKO_REGION_TO_ITEM_COMBINE_BONUS; // check material id in itemToRegion int itemId = combineData.getMaterialItems().get(0).getItemId();