aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2022-12-29 23:08:53 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2022-12-29 23:08:53 +0100
commite50d8d3b7d3f2682744b5b9ee98d248ea5f0ce5b (patch)
treef9c0cca9a01e8e50615173721f6e73a46e6cd3f3
parentf175e24a431d67bae406ffcd45e88c82f93ec8fd (diff)
downloadskyhanni-e50d8d3b7d3f2682744b5b9ee98d248ea5f0ce5b.tar.gz
skyhanni-e50d8d3b7d3f2682744b5b9ee98d248ea5f0ce5b.tar.bz2
skyhanni-e50d8d3b7d3f2682744b5b9ee98d248ea5f0ce5b.zip
Saves missing items from cancelled buy orders to clipboard for faster re-entry.
-rw-r--r--CHANGELOG.md1
-rw-r--r--FEATURES.md1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Bazaar.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarCancelledBuyOrderClipboard.kt58
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt18
6 files changed, 79 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8652ad54c..006f81fd6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@
+ Add two more chat filter categories: Powder Mining and Winter Gifts.
+ Add catacombs class level color to party finder.
+ Add wishing compass uses amount display.
++ Saves missing items from cancelled buy orders to clipboard for faster re-entry.
### Removals
- Removed additional settings for the chat design, like channel prefix and skyblock level
diff --git a/FEATURES.md b/FEATURES.md
index 21b9853d2..f4e99dec6 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -88,6 +88,7 @@
## Bazaar
- Showing colors in the order inventory for outbid or fully bought/sold items.
- Best Sell Method (Calculating the difference between instant-selling or using sell order for a selected bazaar item)
+- Saves missing items from cancelled buy orders to clipboard for faster re-entry.
## Fishing
- Trophy Counter (After fishing a new trophy fish, showing you in chat how many more trophies you have collected in total)
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index afb2793d5..0af68df64 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.features.*;
import at.hannibal2.skyhanni.features.anvil.AnvilCombineHelper;
import at.hannibal2.skyhanni.features.bazaar.BazaarApi;
import at.hannibal2.skyhanni.features.bazaar.BazaarBestSellMethod;
+import at.hannibal2.skyhanni.features.bazaar.BazaarCancelledBuyOrderClipboard;
import at.hannibal2.skyhanni.features.bazaar.BazaarOrderHelper;
import at.hannibal2.skyhanni.features.chat.ChatFilter;
import at.hannibal2.skyhanni.features.chat.PlayerDeathMessages;
@@ -164,6 +165,7 @@ public class SkyHanniMod {
registerEvent(new BurrowWarpHelper());
registerEvent(new HighlightBonzoMasks());
registerEvent(new DungeonLevelColor());
+ registerEvent(new BazaarCancelledBuyOrderClipboard());
Commands.INSTANCE.init();
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Bazaar.java b/src/main/java/at/hannibal2/skyhanni/config/features/Bazaar.java
index 614568903..890d21313 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Bazaar.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Bazaar.java
@@ -22,4 +22,9 @@ public class Bazaar {
@ConfigOption(name = "Best Sell Method Position", desc = "")
@ConfigEditorButton(runnableId = "bestSellMethod", buttonText = "Edit")
public Position bestSellMethodPos = new Position(10, 10, false, true);
+
+ @Expose
+ @ConfigOption(name = "Cancelled Buy Order Clipboard", desc = "Saves missing items from cancelled buy orders to clipboard for faster re-entry.")
+ @ConfigEditorBoolean
+ public boolean cancelledBuyOrderClipboard = true;
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarCancelledBuyOrderClipboard.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarCancelledBuyOrderClipboard.kt
new file mode 100644
index 000000000..3943e7d44
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarCancelledBuyOrderClipboard.kt
@@ -0,0 +1,58 @@
+package at.hannibal2.skyhanni.features.bazaar
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.ItemUtils.name
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.OSUtils
+import net.minecraftforge.event.entity.player.ItemTooltipEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.util.regex.Pattern
+
+class BazaarCancelledBuyOrderClipboard {
+
+ private val patternLastAmount = Pattern.compile("§a(.*)§7x")
+ private val patternCancelledMessage =
+ Pattern.compile("§6\\[Bazaar] §r§7§r§cCancelled! §r§7Refunded §r§6(.*) coins §r§7from cancelling Buy Order!")
+
+ private var latestAmount: String? = null
+
+ @SubscribeEvent
+ fun onTooltip(event: ItemTooltipEvent) {
+ if (!isEnabled()) return
+
+ val stack = event.itemStack ?: return
+ val name = stack.name ?: return
+ if (!name.contains("Cancel Order")) return
+
+ for (line in stack.getLore()) {
+ val matcher = patternLastAmount.matcher(line)
+ if (matcher.find()) {
+ latestAmount = matcher.group(1)
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onChat(event: LorenzChatEvent) {
+ if (!isEnabled()) return
+
+ val message = event.message
+
+ val matcher = patternCancelledMessage.matcher(message)
+ if (matcher.matches()) {
+ event.blockedReason = "bazaar cancelled buy order clipbaord"
+ val coins = matcher.group(1)
+
+ LorenzUtils.chat("§e[SkyHanni] Bazaar buy order cancelled. $latestAmount saved to clipboard. ($coins coins)")
+
+ latestAmount?.let { OSUtils.copyToClipboard(it.replace(",", "")) }
+ latestAmount = null
+ }
+ }
+
+ fun isEnabled(): Boolean {
+ return LorenzUtils.inSkyblock && SkyHanniMod.feature.bazaar.cancelledBuyOrderClipboard
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
index c82048e8c..8f0c4cc2c 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
@@ -83,19 +83,25 @@ class LorenzTest {
emptyList()
}
- val listenerClasses = SkyHanniMod.listenerClasses
- for (any in listenerClasses) {
- val simpleName = any.javaClass.simpleName
- MinecraftForge.EVENT_BUS.unregister(any)
+ val listeners = SkyHanniMod.listenerClasses
+ for (oldListener in listeners.toMutableList()) {
+ val javaClass = oldListener.javaClass
+ val simpleName = javaClass.simpleName
+ MinecraftForge.EVENT_BUS.unregister(oldListener)
println("Unregistered listener $simpleName")
+
if (simpleName !in blockedFeatures) {
- MinecraftForge.EVENT_BUS.register(any)
+ listeners.remove(oldListener)
+ val newListener = javaClass.newInstance()
+ listeners.add(newListener)
+
+ MinecraftForge.EVENT_BUS.register(newListener)
println("Registered listener $simpleName")
} else {
println("Skipped registering listener $simpleName")
}
}
- LorenzUtils.chat("§e[SkyHanni] reloaded ${listenerClasses.size} listener classes.")
+ LorenzUtils.chat("§e[SkyHanni] reloaded ${listeners.size} listener classes.")
}
}