aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Features.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Bazaar.java10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/BazaarUpdateEvent.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarData.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataGrabber.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarUpdateTimer.kt45
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/misc/CompactBingoChat.kt)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt14
10 files changed, 91 insertions, 14 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
index f6190fb10..ef768b6ef 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java
@@ -6,10 +6,8 @@ import at.hannibal2.skyhanni.config.commands.Commands;
import at.hannibal2.skyhanni.data.*;
import at.hannibal2.skyhanni.data.repo.RepoManager;
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.bazaar.*;
+import at.hannibal2.skyhanni.features.bingo.CompactBingoChat;
import at.hannibal2.skyhanni.features.chat.ChatFilter;
import at.hannibal2.skyhanni.features.chat.PlayerDeathMessages;
import at.hannibal2.skyhanni.features.chat.playerchat.PlayerChatFilter;
@@ -62,7 +60,7 @@ import java.util.List;
public class SkyHanniMod {
public static final String MODID = "skyhanni";
- public static final String VERSION = "0.14";
+ public static final String VERSION = "0.14.1";
public static Features feature;
@@ -171,6 +169,7 @@ public class SkyHanniMod {
loadModule(new CroesusUnopenedChestTracker());
loadModule(new CompactBingoChat());
loadModule(new BrewingStandOverlay());
+ loadModule(new BazaarUpdateTimer());
Commands.INSTANCE.init();
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java
index 39d20d74b..0f3b52c2a 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Features.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java
@@ -106,6 +106,11 @@ public class Features extends Config {
editOverlay(activeConfigCategory, 200, 16, misc.nonGodPotEffectPos);
return;
}
+
+ if (runnableId.equals("bazzarUpdateTimer")) {
+ editOverlay(activeConfigCategory, 200, 16, bazaar.updateTimerPos);
+ return;
+ }
}
@Expose
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 890d21313..2e3ea2195 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Bazaar.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Bazaar.java
@@ -27,4 +27,14 @@ public class Bazaar {
@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;
+
+ @Expose
+ @ConfigOption(name = "Update Timer", desc = "A countdown timer for upcoming Bazzar data update.")
+ @ConfigEditorBoolean
+ public boolean updateTimer = false;
+
+ @Expose
+ @ConfigOption(name = "Update timer Position", desc = "")
+ @ConfigEditorButton(runnableId = "bazzarUpdateTimer", buttonText = "Edit")
+ public Position updateTimerPos = new Position(10, 10, false, true);
}
diff --git a/src/main/java/at/hannibal2/skyhanni/events/BazaarUpdateEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/BazaarUpdateEvent.kt
new file mode 100644
index 000000000..4d415d920
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/BazaarUpdateEvent.kt
@@ -0,0 +1,5 @@
+package at.hannibal2.skyhanni.events
+
+import at.hannibal2.skyhanni.features.bazaar.BazaarData
+
+class BazaarUpdateEvent(val bazaarMap: MutableMap<String, BazaarData>): LorenzEvent() \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarData.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarData.kt
index b43cb1eb3..b4f00f248 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarData.kt
@@ -1,3 +1,3 @@
package at.hannibal2.skyhanni.features.bazaar
-data class BazaarData(val apiName: String, val itemName: String, val sellPrice: Double, val buyPrice: Double) \ No newline at end of file
+data class BazaarData(val apiName: String, val itemName: String, val sellPrice: Double, val buyPrice: Double, val buyMovingWeek: Int, val sellMovingWeek: Int) \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataGrabber.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataGrabber.kt
index bcf1b3e48..c2f5fb5a7 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataGrabber.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarDataGrabber.kt
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.features.bazaar
+import at.hannibal2.skyhanni.events.BazaarUpdateEvent
import at.hannibal2.skyhanni.utils.APIUtil
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.round
@@ -97,6 +98,8 @@ internal class BazaarDataGrabber(private var bazaarMap: MutableMap<String, Bazaa
continue
}
+ val sellMovingWeek = itemData["quick_status"].asJsonObject["sellMovingWeek"].asInt
+ val buyMovingWeek = itemData["quick_status"].asJsonObject["buyMovingWeek"].asInt
//parse bazaar api format into internal name format
if (apiName.startsWith("ENCHANTMENT_")) {
val split = apiName.split("_")
@@ -106,9 +109,10 @@ internal class BazaarDataGrabber(private var bazaarMap: MutableMap<String, Bazaa
apiName = text
}
- val data = BazaarData(apiName, itemName, sellPrice, buyPrice)
+ val data = BazaarData(apiName, itemName, sellPrice, buyPrice, buyMovingWeek, sellMovingWeek)
bazaarMap[itemName] = data
}
+ BazaarUpdateEvent(bazaarMap).postAndCatch()
}
private fun getItemName(apiName: String): String? {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarUpdateTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarUpdateTimer.kt
new file mode 100644
index 000000000..0a99f942a
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarUpdateTimer.kt
@@ -0,0 +1,45 @@
+package at.hannibal2.skyhanni.features.bazaar
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.BazaarUpdateEvent
+import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
+import net.minecraftforge.client.event.GuiScreenEvent
+import net.minecraftforge.fml.common.eventhandler.EventPriority
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.text.DecimalFormat
+
+class BazaarUpdateTimer {
+ private var lastBazaarUpdateTime = 0L
+
+ @SubscribeEvent
+ fun onBazaarUpdate(event: BazaarUpdateEvent) {
+ if (!isEnabled()) return
+ lastBazaarUpdateTime = System.currentTimeMillis()
+ }
+
+ @SubscribeEvent(priority = EventPriority.LOWEST)
+ fun renderOverlay(event: GuiScreenEvent.BackgroundDrawnEvent) {
+ if (!isEnabled()) return
+ if (!BazaarApi.isBazaarInventory(InventoryUtils.openInventoryName())) return
+
+ val duration = System.currentTimeMillis() - lastBazaarUpdateTime
+ val durationSeconds = duration.toDouble() / 1000
+ val nextUpdateIn = 10 - durationSeconds
+ val format = if (nextUpdateIn < 0) {
+ "Updating"
+ } else {
+ DecimalFormat("0.0").format(nextUpdateIn)
+ }
+
+ val list = mutableListOf<String>()
+ list.add("Next update in:")
+ list.add(format)
+ SkyHanniMod.feature.bazaar.updateTimerPos.renderStrings(list, center = true)
+ }
+
+ private fun isEnabled(): Boolean {
+ return LorenzUtils.inSkyBlock && SkyHanniMod.feature.bazaar.updateTimer
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CompactBingoChat.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt
index a4becd8c4..db4989621 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/CompactBingoChat.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/CompactBingoChat.kt
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.features.misc
+package at.hannibal2.skyhanni.features.bingo
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzChatEvent
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt
index 545c5c17a..0a4334bce 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt
@@ -103,7 +103,11 @@ class ChatFilter {
private fun uselessDrop(message: String): Boolean {
when {
+ // TODO check if this is still necessary
message.matchRegex("§6§lRARE DROP! §r§aEnchanted Ender Pearl (.*)") -> return true
+ message == "§6§lRARE DROP! §r§aEnchanted Ender Pearl" -> return true
+ message == "§6§lRARE DROP! §r§aEnchanted End Stone" -> return true
+ message == "§6§lRARE DROP! §r§5Crystal Fragment" -> return true
message.matchRegex("§6§lRARE DROP! §r§fCarrot (.*)") -> return true
message.matchRegex("§6§lRARE DROP! §r§fPotato (.*)") -> return true
@@ -175,7 +179,7 @@ class ChatFilter {
//Enderman
if (message.matchRegex("§b§lRARE DROP! §r§7\\(§r§f§r§7(.*)x §r§f§r§aTwilight Arrow Poison§r§7\\) (.*)")) return true
- if (message.matchRegex("§9§lVERY RARE DROP! §r§7\\(§r§fMana Steal I§r§7\\) (.*)")) return true
+ if (message.matchRegex("§5§lVERY RARE DROP! §r§7\\(§r§fMana Steal I§r§7\\) (.*)")) return true
if (message.matchRegex("§5§lVERY RARE DROP! §r§7\\(§r§f§r§5Sinful Dice§r§7\\) (.*)")) return true
if (message.matchRegex("§9§lVERY RARE DROP! §r§7\\(§r§f§r§9Null Atom§r§7\\) (.*)")) return true
if (message.matchRegex("§9§lVERY RARE DROP! §r§7\\(§r§f§r§5Transmission Tuner§r§7\\) (.*)")) return true
@@ -183,6 +187,7 @@ class ChatFilter {
if (message.matchRegex("§9§lVERY RARE DROP! §r§7\\(§r§f§r§5◆ Endersnake Rune I§r§7\\) (.*)")) return true
if (message.matchRegex("§d§lCRAZY RARE DROP! §r§7\\(§r§f§r§fPocket Espresso Machine§r§7\\) (.*)")) return true
if (message.matchRegex("§5§lVERY RARE DROP! §r§7\\(§r§f§r§5◆ End Rune I§r§7\\) (.*)")) return true
+ if (message.matchRegex("§5§lVERY RARE DROP! §r§7\\(§r§f§r§6Hazmat Enderman§r§7\\) .*")) return true
//Blaze
if (message.matchRegex("§9§lVERY RARE DROP! §r§7\\(§r§f§r§fWisp's Ice-Flavored Water I Splash Potion§r§7\\) (.*)")) return true
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
index ff28c52ab..e3052874f 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt
@@ -424,7 +424,7 @@ object RenderUtils {
return lastValue + (currentValue - lastValue) * multiplier
}
- fun Position.renderString(string: String?, offsetY: Int = 0) {
+ fun Position.renderString(string: String?, offsetY: Int = 0, center: Boolean = true) {
val minecraft = Minecraft.getMinecraft()
if (minecraft.gameSettings.keyBindPlayerList.isKeyDown) return
@@ -437,7 +437,11 @@ object RenderUtils {
val renderer = minecraft.renderManager.fontRenderer ?: return
- val offsetX = (200 - renderer.getStringWidth(display.removeColor())) / 2
+ val offsetX = if (center) {
+ (200 - renderer.getStringWidth(display.removeColor())) / 2
+ } else {
+ 0
+ }
val x = getAbsX(resolution, 200) + offsetX
val y = getAbsY(resolution, 16) + offsetY
@@ -448,13 +452,13 @@ object RenderUtils {
GlStateManager.popMatrix()
}
- fun Position.renderStrings(list: List<String>) {
+ fun Position.renderStrings(list: List<String>, extraSpace: Int = 0, center: Boolean = false) {
if (list.isEmpty()) return
var offsetY = 0
for (s in list) {
- renderString(s, offsetY)
- offsetY += 14
+ renderString(s, offsetY, center = center)
+ offsetY += 10 + extraSpace
}
}