aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-05-01 08:56:07 +0200
committerGitHub <noreply@github.com>2024-05-01 16:56:07 +1000
commitff5287258aee4e39b6ab0ba92ab17afde2de07d9 (patch)
treefe5813cf8024d7812bd4c77decb495cdbe108c7c /src/main/java
parentdad2c5b0156aee4fd84cf641fae8b08d2e97ff67 (diff)
downloadskyhanni-ff5287258aee4e39b6ab0ba92ab17afde2de07d9.tar.gz
skyhanni-ff5287258aee4e39b6ab0ba92ab17afde2de07d9.tar.bz2
skyhanni-ff5287258aee4e39b6ab0ba92ab17afde2de07d9.zip
Feature: Chocolate change leaderboard (#1602)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStats.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolatePositionChange.kt40
5 files changed, 72 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java
index 96386bf76..773fe7fcf 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java
@@ -130,6 +130,15 @@ public class ChocolateFactoryConfig {
public Position hoppityStatsPosition = new Position(163, 160, false, true);
@Expose
+ @ConfigOption(name = "Leaderboard Change",
+ desc = "Show the change of your chocolate leaderboard over time in chat. " +
+ "This updates every time you first open the /cf menu on a new server."
+ )
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean leaderboardChange = false;
+
+ @Expose
@ConfigOption(name = "Hoppity Menu Shortcut", desc = "Add a Chocolate Factory button in the SkyBlock Menu that runs /chocolatefactory on click.")
@ConfigEditorBoolean
@FeatureToggle
diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java
index 472f1e8af..ba60712e9 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java
@@ -94,6 +94,20 @@ public class ProfileSpecificStorage {
@Expose
public long lastDataSave = 0;
+
+ @Expose
+ public PositionChange positionChange = new PositionChange();
+
+ public static class PositionChange {
+ @Expose
+ public Long lastTime = null;
+
+ @Expose
+ public int lastPosition = -1;
+
+ @Expose
+ public String lastLeaderboard = null;
+ }
}
@Expose
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt
index 37ddb9a8e..5780b4d24 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt
@@ -36,6 +36,7 @@ import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object ChocolateFactoryAPI {
+
val config: ChocolateFactoryConfig get() = SkyHanniMod.feature.inventory.chocolateFactory
val profileStorage: ChocolateFactoryStorage? get() = ProfileStorageData.profileSpecific?.chocolateFactory
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStats.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStats.kt
index cbf38db46..a30848d43 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStats.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStats.kt
@@ -41,8 +41,13 @@ object ChocolateFactoryStats {
val perMinute = perSecond * 60
val perHour = perMinute * 60
val perDay = perHour * 24
- val position = ChocolateFactoryAPI.leaderboardPosition?.addSeparators() ?: "???"
+
+ val position = ChocolateFactoryAPI.leaderboardPosition
+ val positionText = position?.addSeparators() ?: "???"
val percentile = ChocolateFactoryAPI.leaderboardPercentile?.let { "§7Top §a$it%" } ?: ""
+ val leaderboard = "#$positionText $percentile"
+ ChocolatePositionChange.update(position, leaderboard)
+
val timeTowerInfo = if (ChocolateFactoryTimeTowerManager.timeTowerActive()) {
"§d§lActive"
} else {
@@ -66,7 +71,7 @@ object ChocolateFactoryStats {
put(ChocolateFactoryStat.MULTIPLIER, "§eChocolate Multiplier: §6${profileStorage.chocolateMultiplier}")
put(ChocolateFactoryStat.BARN, "§eBarn: §6${ChocolateFactoryBarnManager.barnStatus()}")
- put(ChocolateFactoryStat.LEADERBOARD_POS, "§ePosition: §7#§b$position $percentile")
+ put(ChocolateFactoryStat.LEADERBOARD_POS, "§ePosition: §b$leaderboard")
put(ChocolateFactoryStat.EMPTY, "")
put(ChocolateFactoryStat.EMPTY_2, "")
@@ -120,7 +125,7 @@ object ChocolateFactoryStats {
PER_DAY("§ePer Day: §6326,654,208"),
MULTIPLIER("§eChocolate Multiplier: §61.77"),
BARN("§eBarn: §6171/190 Rabbits"),
- LEADERBOARD_POS("§ePosition: §7#§b103 §7Top §a0.87%"),
+ LEADERBOARD_POS("§ePosition: §b#103 §7Top §a0.87%"),
EMPTY(""),
EMPTY_2(""),
EMPTY_3(""),
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolatePositionChange.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolatePositionChange.kt
new file mode 100644
index 000000000..0868f5bd2
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolatePositionChange.kt
@@ -0,0 +1,40 @@
+package at.hannibal2.skyhanni.features.inventory.chocolatefactory
+
+import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import at.hannibal2.skyhanni.utils.TimeUtils.format
+
+object ChocolatePositionChange {
+
+ private val config get() = ChocolateFactoryAPI.config
+ private val storage get() = ChocolateFactoryAPI.profileStorage?.positionChange
+
+ fun update(position: Int?, leaderboard: String) {
+ position ?: return
+ val storage = storage ?: return
+ val lastTime = storage.lastTime?.let { SimpleTimeMark(it) }
+ val lastPosition = storage.lastPosition
+ val lastLeaderboard = storage.lastLeaderboard
+
+ if (lastLeaderboard == leaderboard) return
+
+ lastLeaderboard?.let { lastLb ->
+ var message = "$lastLb §c-> $leaderboard"
+ val change = lastPosition - position
+ val color = if (change > 0) "§a+" else "§c"
+ message += "\n §7Changed by $color${change.addSeparators()} spots"
+
+ lastTime?.let {
+ message += " §7in §b${it.passedSince().format(maxUnits = 2)}"
+ }
+ if (config.leaderboardChange && lastPosition != -1) {
+ ChatUtils.chat(" \n §6Chocolate Leaderboard Change: §7(SkyHanni)\n $message\n ", prefix = false)
+ }
+ }
+
+ storage.lastTime = SimpleTimeMark.now().toMillis()
+ storage.lastLeaderboard = leaderboard
+ storage.lastPosition = position
+ }
+}