diff options
Diffstat (limited to 'src/main/java')
3 files changed, 13 insertions, 17 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt index 32d53e2c3..4b4d9e732 100644 --- a/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt @@ -4,13 +4,10 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.bazaar.BazaarApi import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent -import at.hannibal2.skyhanni.utils.ItemUtils +import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.ItemUtils.cleanName import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.LorenzColor -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.removeColorCodes -import at.hannibal2.skyhanni.utils.MultiFilter import at.hannibal2.skyhanni.utils.RenderUtils.highlight import com.google.gson.JsonObject import net.minecraft.client.Minecraft @@ -34,6 +31,7 @@ class HideNotClickableItems { private val hideInStorageList = MultiFilter() private val tradeNpcList = MultiFilter() private val itemsToSalvage = mutableListOf<String>() + private val hidePlayerTradeFilter = MultiFilter() @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { @@ -47,6 +45,8 @@ class HideNotClickableItems { updateSalvageList(hideNotClickableItems) + hidePlayerTradeFilter.load(hideNotClickableItems["hide_player_trade"].asJsonObject) + } catch (e: Exception) { e.printStackTrace() LorenzUtils.error("error in RepositoryReloadEvent") @@ -174,7 +174,7 @@ class HideNotClickableItems { hideNpcSell(chestName, stack) -> true hideInStorage(chestName, stack) -> true hideSalvage(chestName, stack) -> true - hideTrade(chestName, stack) -> true + hidePlayerTrade(chestName, stack) -> true hideBazaarOrAH(chestName, stack) -> true hideAccessoryBag(chestName, stack) -> true hideSackOfSacks(chestName, stack) -> true @@ -237,7 +237,7 @@ class HideNotClickableItems { return true } - private fun hideTrade(chestName: String, stack: ItemStack): Boolean { + private fun hidePlayerTrade(chestName: String, stack: ItemStack): Boolean { if (!chestName.startsWith("You ")) return false if (ItemUtils.isSoulBound(stack)) { @@ -257,15 +257,8 @@ class HideNotClickableItems { return true } - val result = when { - name.contains("Personal Deletor") -> true - name.contains("Day Crystal") -> true - name.contains("Night Crystal") -> true - name.contains("Cat Talisman") -> true - name.contains("Lynx Talisman") -> true - name.contains("Cheetah Talisman") -> true - else -> false - } + val result = hidePlayerTradeFilter.match(name) + LorenzDebug.log("hidePlayerTradeList filter result for '$name': $result") if (result) hideReason = "This item cannot be traded!" return result diff --git a/src/main/java/at/hannibal2/skyhanni/repo/RepoManager.kt b/src/main/java/at/hannibal2/skyhanni/repo/RepoManager.kt index 11f27a368..eea0f83bd 100644 --- a/src/main/java/at/hannibal2/skyhanni/repo/RepoManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/repo/RepoManager.kt @@ -20,8 +20,8 @@ class RepoManager(private val configLocation: File) { private val repoLocation: File = File(configLocation, "repo") fun loadRepoInformation() { + atomicShouldManuallyReload.set(true) if (SkyHanniMod.feature.apiData.repoAutoUpdate) { - atomicShouldManuallyReload.set(true) fetchRepository().thenRun(this::reloadRepository) } else { reloadRepository() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/MultiFilter.kt b/src/main/java/at/hannibal2/skyhanni/utils/MultiFilter.kt index 39b2a012e..5786cb9e7 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/MultiFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/MultiFilter.kt @@ -7,15 +7,18 @@ class MultiFilter { val equals = mutableListOf<String>() val startsWith = mutableListOf<String>() val endsWith = mutableListOf<String>() + val contains = mutableListOf<String>() fun load(hideNpcSell: JsonObject) { equals.clear() startsWith.clear() endsWith.clear() + contains.clear() fill(hideNpcSell, "equals", equals) fill(hideNpcSell, "startsWith", startsWith) fill(hideNpcSell, "endsWith", endsWith) + fill(hideNpcSell, "contains", contains) } private fun fill(jsonObject: JsonObject, key: String, list: MutableList<String>) { @@ -26,9 +29,9 @@ class MultiFilter { fun match(name: String): Boolean { if (equals.contains(name)) return true - if (startsWith.any { name.startsWith(it) }) return true if (endsWith.any { name.endsWith(it) }) return true + if (contains.any { name.contains(it) }) return true return false } |