From 975cbf0bf8fe32976d5ca64e60b683be3c3ddad4 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 14 May 2013 12:46:04 -0400 Subject: [PATCH] The cache should be here, not in the manager. --- .../java/com/gmail/nossr50/skills/fishing/Fishing.java | 5 +++++ .../com/gmail/nossr50/skills/fishing/FishingManager.java | 8 +++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java index 11b1bb576..2fd4c7130 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java @@ -1,7 +1,10 @@ package com.gmail.nossr50.skills.fishing; +import java.util.HashMap; import java.util.List; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; import org.bukkit.inventory.ItemStack; @@ -49,6 +52,8 @@ public final class Fishing { abstract protected int getVanillaXPBoostModifier(); } + protected static final HashMap> enchantableCache = new HashMap>(); + public static int fishermansDietRankLevel1 = AdvancedConfig.getInstance().getFishermanDietRankChange(); public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2; public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5; diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index 96c26f90a..7517692b7 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.fishing; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.List; import org.bukkit.ChatColor; @@ -49,7 +48,6 @@ import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.SkillUtils; public class FishingManager extends SkillManager { - private final HashMap> enchantableCache = new HashMap>(); private final long FISHING_COOLDOWN_SECONDS = 1000L; private int fishingTries = 0; @@ -438,8 +436,8 @@ public class FishingManager extends SkillManager { private List getPossibleEnchantments(ItemStack treasureDrop) { Material dropType = treasureDrop.getType(); - if (enchantableCache.containsKey(dropType)) { - return enchantableCache.get(dropType); + if (Fishing.enchantableCache.containsKey(dropType)) { + return Fishing.enchantableCache.get(dropType); } List possibleEnchantments = new ArrayList(); @@ -450,7 +448,7 @@ public class FishingManager extends SkillManager { } } - enchantableCache.put(dropType, possibleEnchantments); + Fishing.enchantableCache.put(dropType, possibleEnchantments); return possibleEnchantments; }