From b91aa3724f9364d32a11e1d052b36600106293ba Mon Sep 17 00:00:00 2001 From: Leandro Date: Sun, 4 Jul 2021 22:57:40 -0300 Subject: [PATCH] Code legibility change. --- .../tsp/headdb/inventory/InventoryUtils.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/tsp/headdb/inventory/InventoryUtils.java b/src/main/java/tsp/headdb/inventory/InventoryUtils.java index 0f0de21..afd068a 100644 --- a/src/main/java/tsp/headdb/inventory/InventoryUtils.java +++ b/src/main/java/tsp/headdb/inventory/InventoryUtils.java @@ -27,19 +27,22 @@ public class InventoryUtils { private static final Map uiItem = new HashMap<>(); public static int uiGetLocation(String category, int slot) { - // Try to use the cached value first; then the config; then the given default. - if (!uiLocation.containsKey(category)) { - if (HeadDB.getInstance().getCfg().contains("ui.category." + category + ".location")) { - uiLocation.put(category, HeadDB.getInstance().getCfg().getInt("ui.category." + category + ".location")); - } else { - uiLocation.put(category, slot); - } + // Try to use the cached value first. + if (uiLocation.containsKey(category)) return uiLocation.get(category); + + // Try to get the value from the config file. + if (HeadDB.getInstance().getCfg().contains("ui.category." + category + ".location")) { + uiLocation.put(category, HeadDB.getInstance().getCfg().getInt("ui.category." + category + ".location")); + uiLocation.get(category); } - return uiLocation.get(category); + + // No valid value in the config file, return the given default. + uiLocation.put(category, slot); + return slot; } public static ItemStack uiGetItem(String category, ItemStack item) { - // Try to use the cached value first. + // Try to use the cached item first. if (uiItem.containsKey(category)) return uiItem.get(category); // Try to get a head from the config file.