aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-05 13:34:19 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-05 13:34:19 +0100
commit940095657152c8a0323f1c261c1454b8035bea61 (patch)
tree4b8a262299b974c901f52a16a7e358a1f6977fcc /src/main/java/at
parent1aed35c84c55688222818d2333059f9790db3c36 (diff)
downloadskyhanni-940095657152c8a0323f1c261c1454b8035bea61.tar.gz
skyhanni-940095657152c8a0323f1c261c1454b8035bea61.tar.bz2
skyhanni-940095657152c8a0323f1c261c1454b8035bea61.zip
code cleanup
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt82
1 files changed, 42 insertions, 40 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt
index 6a9d53e15..1f1b10143 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorDropStatistics.kt
@@ -73,37 +73,37 @@ object GardenVisitorDropStatistics {
if (!ProfileStorageData.loaded) return
if (lastAccept - System.currentTimeMillis() <= 0 && lastAccept - System.currentTimeMillis() > -1000) {
val message = event.message.removeColor().trim()
- val hidden = GardenAPI.config?.visitorDrops ?: return
+ val storage = GardenAPI.config?.visitorDrops ?: return
copperPattern.matchMatcher(message) {
val amount = group("amount").formatNumber().toInt()
- hidden.copper += amount
+ storage.copper += amount
saveAndUpdate()
}
farmingExpPattern.matchMatcher(message) {
val amount = group("amount").formatNumber()
- hidden.farmingExp += amount
+ storage.farmingExp += amount
saveAndUpdate()
}
gardenExpPattern.matchMatcher(message) {
val amount = group("amount").formatNumber().toInt()
if (amount > 80) return // some of the low visitor milestones will get through but will be minimal
- hidden.gardenExp += amount
+ storage.gardenExp += amount
saveAndUpdate()
}
bitsPattern.matchMatcher(message) {
val amount = group("amount").formatNumber().toInt()
- hidden.bits += amount
+ storage.bits += amount
saveAndUpdate()
}
mithrilPowderPattern.matchMatcher(message) {
val amount = group("amount").formatNumber().toInt()
- hidden.mithrilPowder += amount
+ storage.mithrilPowder += amount
saveAndUpdate()
}
gemstonePowderPattern.matchMatcher(message) {
val amount = group("amount").formatNumber().toInt()
- hidden.gemstonePowder += amount
+ storage.gemstonePowder += amount
saveAndUpdate()
}
acceptPattern.matchMatcher(message) {
@@ -122,19 +122,19 @@ object GardenVisitorDropStatistics {
saveAndUpdate()
}
- private fun drawDisplay(hidden: Storage.ProfileSpecific.GardenStorage.VisitorDrops) = buildList<List<Any>> {
+ private fun drawDisplay(storage: Storage.ProfileSpecific.GardenStorage.VisitorDrops) = buildList<List<Any>> {
//0
addAsSingletonList("§e§lVisitor Statistics")
//1
addAsSingletonList(format(totalVisitors, "Total", "§e", ""))
//2
- val visitorRarities = hidden.visitorRarities
+ val visitorRarities = storage.visitorRarities
if (visitorRarities.isNotEmpty()) {
addAsSingletonList(
"§a${visitorRarities[0].addSeparators()}§f-" +
- "§9${visitorRarities[1].addSeparators()}§f-" +
- "§6${visitorRarities[2].addSeparators()}§f-" +
- "§c${visitorRarities[3].addSeparators()}"
+ "§9${visitorRarities[1].addSeparators()}§f-" +
+ "§6${visitorRarities[2].addSeparators()}§f-" +
+ "§c${visitorRarities[3].addSeparators()}"
)
} else {
addAsSingletonList("§c?")
@@ -150,9 +150,9 @@ object GardenVisitorDropStatistics {
//5
addAsSingletonList("")
//6
- addAsSingletonList(format(hidden.copper, "Copper", "§c", ""))
+ addAsSingletonList(format(storage.copper, "Copper", "§c", ""))
//7
- addAsSingletonList(format(hidden.farmingExp, "Farming EXP", "§3", "§7"))
+ addAsSingletonList(format(storage.farmingExp, "Farming EXP", "§3", "§7"))
//8
addAsSingletonList(format(coinsSpent, "Coins Spent", "§6", ""))
@@ -171,13 +171,13 @@ object GardenVisitorDropStatistics {
//17
addAsSingletonList("")
//18
- addAsSingletonList(format(hidden.gardenExp, "Garden EXP", "§2", "§7"))
+ addAsSingletonList(format(storage.gardenExp, "Garden EXP", "§2", "§7"))
//19
- addAsSingletonList(format(hidden.bits, "Bits", "§b", "§b"))
+ addAsSingletonList(format(storage.bits, "Bits", "§b", "§b"))
//20
- addAsSingletonList(format(hidden.mithrilPowder, "Mithril Powder", "§2", "§2"))
+ addAsSingletonList(format(storage.mithrilPowder, "Mithril Powder", "§2", "§2"))
//21
- addAsSingletonList(format(hidden.gemstonePowder, "Gemstone Powder", "§d", "§d"))
+ addAsSingletonList(format(storage.gemstonePowder, "Gemstone Powder", "§d", "§d"))
}
fun format(amount: Number, name: String, color: String, amountColor: String = color) =
@@ -194,29 +194,29 @@ object GardenVisitorDropStatistics {
fun saveAndUpdate() {
if (!GardenAPI.inGarden()) return
- val hidden = GardenAPI.config?.visitorDrops ?: return
- hidden.acceptedVisitors = acceptedVisitors
- hidden.deniedVisitors = deniedVisitors
+ val storage = GardenAPI.config?.visitorDrops ?: return
+ storage.acceptedVisitors = acceptedVisitors
+ storage.deniedVisitors = deniedVisitors
totalVisitors = acceptedVisitors + deniedVisitors
- hidden.coinsSpent = coinsSpent
- hidden.rewardsCount = rewardsCount
- display = formatDisplay(drawDisplay(hidden))
+ storage.coinsSpent = coinsSpent
+ storage.rewardsCount = rewardsCount
+ display = formatDisplay(drawDisplay(storage))
}
@SubscribeEvent
fun onConfigLoad(event: ConfigLoadEvent) {
- val hidden = GardenAPI.config?.visitorDrops ?: return
- if (hidden.visitorRarities.size == 0) {
- hidden.visitorRarities.add(0)
- hidden.visitorRarities.add(0)
- hidden.visitorRarities.add(0)
- hidden.visitorRarities.add(0)
+ val storage = GardenAPI.config?.visitorDrops ?: return
+ if (storage.visitorRarities.size == 0) {
+ storage.visitorRarities.add(0)
+ storage.visitorRarities.add(0)
+ storage.visitorRarities.add(0)
+ storage.visitorRarities.add(0)
}
- acceptedVisitors = hidden.acceptedVisitors
- deniedVisitors = hidden.deniedVisitors
+ acceptedVisitors = storage.acceptedVisitors
+ deniedVisitors = storage.deniedVisitors
totalVisitors = acceptedVisitors + deniedVisitors
- coinsSpent = hidden.coinsSpent
- rewardsCount = hidden.rewardsCount
+ coinsSpent = storage.coinsSpent
+ rewardsCount = storage.rewardsCount
saveAndUpdate()
}
@@ -231,12 +231,14 @@ object GardenVisitorDropStatistics {
@SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
- event.move(3, "garden.visitorDropsStatistics.enabled", "garden.visitors.dropsStatistics.enabled")
- event.move(3, "garden.visitorDropsStatistics.textFormat", "garden.visitors.dropsStatistics.textFormat")
- event.move(3, "garden.visitorDropsStatistics.displayNumbersFirst", "garden.visitors.dropsStatistics.displayNumbersFirst")
- event.move(3, "garden.visitorDropsStatistics.displayIcons", "garden.visitors.dropsStatistics.displayIcons")
- event.move(3, "garden.visitorDropsStatistics.onlyOnBarn", "garden.visitors.dropsStatistics.onlyOnBarn")
- event.move(3, "garden.visitorDropsStatistics.visitorDropPos", "garden.visitors.dropsStatistics.pos")
+ val originalPrefix = "garden.visitorDropsStatistics."
+ val newPrefix = "garden.visitors.dropsStatistics."
+ event.move(3, "${originalPrefix}enabled", "${newPrefix}enabled")
+ event.move(3, "${originalPrefix}textFormat", "${newPrefix}textFormat")
+ event.move(3, "${originalPrefix}displayNumbersFirst", "${newPrefix}displayNumbersFirst")
+ event.move(3, "${originalPrefix}displayIcons", "${newPrefix}displayIcons")
+ event.move(3, "${originalPrefix}onlyOnBarn", "${newPrefix}onlyOnBarn")
+ event.move(3, "${originalPrefix}visitorDropPos", "${newPrefix}pos")
}
}