Skip to content

Commit

Permalink
Send Mining Island Events (hannibal002#969)
Browse files Browse the repository at this point in the history
Added sending mining events to Soopy's API to test for new Mining Event feature. hannibal002#969
  • Loading branch information
CalMWolfs authored Feb 5, 2024
1 parent ab43b19 commit 6ed8185
Show file tree
Hide file tree
Showing 15 changed files with 431 additions and 16 deletions.
4 changes: 4 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.config.SackData
import at.hannibal2.skyhanni.config.commands.Commands.init
import at.hannibal2.skyhanni.data.ActionBarStatsData
import at.hannibal2.skyhanni.data.BlockData
import at.hannibal2.skyhanni.data.BossbarData
import at.hannibal2.skyhanni.data.ChatManager
import at.hannibal2.skyhanni.data.CropAccessoryData
import at.hannibal2.skyhanni.data.EntityData
Expand Down Expand Up @@ -228,6 +229,7 @@ import at.hannibal2.skyhanni.features.mining.DeepCavernsParkour
import at.hannibal2.skyhanni.features.mining.HighlightMiningCommissionMobs
import at.hannibal2.skyhanni.features.mining.KingTalismanHelper
import at.hannibal2.skyhanni.features.mining.crystalhollows.CrystalHollowsNamesInCore
import at.hannibal2.skyhanni.features.mining.eventtracker.MiningEventTracker
import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker
import at.hannibal2.skyhanni.features.minion.MinionCollectLogic
import at.hannibal2.skyhanni.features.minion.MinionFeatures
Expand Down Expand Up @@ -443,6 +445,7 @@ class SkyHanniMod {
loadModule(TrackerManager)
loadModule(UtilsPatterns)
loadModule(PetAPI)
loadModule(BossbarData)

// APIs
loadModule(BazaarApi())
Expand Down Expand Up @@ -725,6 +728,7 @@ class SkyHanniMod {
loadModule(SprayDisplay())
loadModule(HighlightPlaceableNpcs())
loadModule(PresentWaypoints())
loadModule(MiningEventTracker())
loadModule(JyrreTimer())
loadModule(NewYearCakeReminder())
loadModule(SulphurSkitterBox())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import at.hannibal2.skyhanni.test.SkyHanniConfigSearchResetCommand
import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests
import at.hannibal2.skyhanni.test.TestBingo
import at.hannibal2.skyhanni.test.WorldEdit
import at.hannibal2.skyhanni.test.command.CopyBossbarCommand
import at.hannibal2.skyhanni.test.command.CopyItemCommand
import at.hannibal2.skyhanni.test.command.CopyNearbyEntitiesCommand
import at.hannibal2.skyhanni.test.command.CopyNearbyParticlesCommand
Expand Down Expand Up @@ -355,6 +356,10 @@ object Commands {
"shcopyscoreboard",
"Copies the scoreboard data to the clipboard"
) { CopyScoreboardCommand.command(it) }
registerCommand(
"shcopybossbar",
"Copies the name of the bossbar to the clipboard, including formatting codes"
) { CopyBossbarCommand.command(it) }
registerCommand(
"shcopyitem",
"Copies information about the item in hand to the clipboard"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
import at.hannibal2.skyhanni.config.FeatureToggle;
import com.google.gson.annotations.Expose;
import io.github.moulberry.moulconfig.annotations.Accordion;
import io.github.moulberry.moulconfig.annotations.Category;
import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
import io.github.moulberry.moulconfig.annotations.ConfigOption;

public class MiningConfig {

@Expose
@Category(name = "Mining Event Tracker", desc = "Settings for the Mining Event Tracker")
public MiningEventConfig miningEvent = new MiningEventConfig();

@Expose
@ConfigOption(name = "Powder Tracker", desc = "")
@Accordion
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package at.hannibal2.skyhanni.config.features.mining;

import at.hannibal2.skyhanni.config.FeatureToggle;
import com.google.gson.annotations.Expose;
import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
import io.github.moulberry.moulconfig.annotations.ConfigOption;

public class MiningEventConfig {

// @Expose
// @ConfigOption(name = "Enabled", desc = "Show information about upcoming Dwarven Mines and Crystal Hollows mining events, also enables you sending data.")
// @ConfigEditorBoolean
// @FeatureToggle
// public boolean enabled = true;
//
// @Expose
// @ConfigOption(name = "Show Outside Mining Islands", desc = "Shows the event tracker when you are not inside of the Dwarven Mines or Crystal Hollows.")
// @ConfigEditorBoolean
// public boolean outsideMining = true;
//
// @Expose
// @ConfigOption(name = "What to Show", desc = "Choose which island's events are shown in the gui.")
// @ConfigEditorDropdown
// public ShowType showType = ShowType.BOTH;
//
// @Expose
// @ConfigOption(name = "Show Warnings For Events", desc = "Shows the warnings when select mining events are about to start.")
// @ConfigEditorBoolean
// @FeatureToggle
// public boolean showWarnings = false;

//todo remove when released
@Expose
@ConfigOption(name = "Send Test data", desc = "Sends test data to make sure the api works.")
@ConfigEditorBoolean
@FeatureToggle
public boolean sendData = true;

// @Expose
// @ConfigOption(name = "Events to Warn for", desc = "Choose which mining events you get warned about.")
// @ConfigEditorDraggableList
// public List<MiningEvent> eventsToWarn = new ArrayList<>(Collections.singletonList(MiningEvent.DOUBLE_POWDER));

public enum ShowType {
BOTH("Both Mining Islands"),
CRYSTAL("Crystal Hollows Only"),
DWARVEN("Dwarven Mines Only")
;

private final String str;

ShowType(String str) {
this.str = str;
}

@Override
public String toString() {
return str;
}
}
}
33 changes: 33 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/data/BossbarData.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package at.hannibal2.skyhanni.data

import at.hannibal2.skyhanni.events.BossbarUpdateEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import net.minecraft.entity.boss.BossStatus
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

object BossbarData {
private var bossbar: String? = null
private var previousServerBossbar = ""

fun getBossbar() = bossbar ?: ""

@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
val oldBossbar = bossbar ?: return
previousServerBossbar = oldBossbar
bossbar = null
}

@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
val bossbarLine = BossStatus.bossName ?: return
if (bossbarLine.isBlank() || bossbarLine.isEmpty()) return
if (bossbarLine == bossbar) return
if (bossbarLine == previousServerBossbar) return
if (previousServerBossbar.isNotEmpty()) previousServerBossbar = ""

bossbar = bossbarLine
BossbarUpdateEvent(bossbarLine).postAndCatch()
}
}
47 changes: 43 additions & 4 deletions src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,40 @@ import net.minecraftforge.fml.common.network.FMLNetworkEvent
import kotlin.concurrent.thread

class HypixelData {
private val group = RepoPattern.group("data.hypixeldata")
private val tabListProfilePattern by group.pattern("tablistprofile", "§e§lProfile: §r§a(?<profile>.*)")
private val lobbyTypePattern by group.pattern("lobbytype", "(?<lobbyType>.*lobby)\\d+")
private val islandNamePattern by group.pattern("islandname", "(?:§.)*(Area|Dungeon): (?:§.)*(?<island>.*)")
private val patternGroup = RepoPattern.group("data.hypixeldata")
private val tabListProfilePattern by patternGroup.pattern(
"tablistprofile",
"§e§lProfile: §r§a(?<profile>.*)"
)
private val lobbyTypePattern by patternGroup.pattern(
"lobbytype",
"(?<lobbyType>.*lobby)\\d+"
)
private val islandNamePattern by patternGroup.pattern(
"islandname",
"(?:§.)*(Area|Dungeon): (?:§.)*(?<island>.*)"
)

private var lastLocRaw = 0L

companion object {
private val patternGroup = RepoPattern.group("data.hypixeldata")
private val serverIdScoreboardPattern by patternGroup.pattern(
"serverid.scoreboard",
"§7\\d+/\\d+/\\d+ §8(?<servertype>[mM])(?<serverid>\\S+)"
)
private val serverIdTablistPattern by patternGroup.pattern(
"serverid.tablist",
" Server: §r§8(?<serverid>\\S+)"
)

var hypixelLive = false
var hypixelAlpha = false
var inLobby = false
var inLimbo = false
var skyBlock = false
var skyBlockIsland = IslandType.UNKNOWN
var serverId: String? = null

//Ironman, Stranded and Bingo
var noTrade = false
Expand Down Expand Up @@ -70,6 +90,24 @@ class HypixelData {
val lobbyType get() = locraw["lobbytype"] ?: ""
val mode get() = locraw["mode"] ?: ""
val map get() = locraw["map"] ?: ""

fun getCurrentServerId(): String? {
if (!LorenzUtils.inSkyBlock) return null
if (serverId != null) return serverId

ScoreboardData.sidebarLinesFormatted.forEach { serverIdScoreboardPattern.matchMatcher(it) {
val serverType = if (group("servertype") == "M") "mega" else "mini"
serverId = "$serverType${group("serverid")}"
return serverId
} }

TabListData.getTabList().forEach { serverIdTablistPattern.matchMatcher(it) {
serverId = group("serverid")
return serverId
} }

return serverId
}
}

private var loggerIslandChange = LorenzLogger("debug/island_change")
Expand All @@ -82,6 +120,7 @@ class HypixelData {
inLobby = false
locraw.forEach { locraw[it.key] = "" }
joinedWorld = System.currentTimeMillis()
serverId = null
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package at.hannibal2.skyhanni.events

class BossbarUpdateEvent(val bossbar: String) : LorenzEvent()
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package at.hannibal2.skyhanni.features.mining.eventtracker

import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import kotlin.time.Duration
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds

enum class MiningEvent(val eventName: String, val defaultLength: Duration, private val colourCode: Char) {
GONE_WITH_THE_WIND("GONE WITH THE WIND", 18.minutes, '9'),
DOUBLE_POWDER("2X POWDER", 15.minutes, 'b'),
GOBLIN_RAID("GOBLIN RAID", 5.minutes, 'c'),
BETTER_TOGETHER("BETTER TOGETHER", 18.minutes, 'd'),
RAFFLE("RAFFLE", 160.seconds, '6'),
MITHRIL_GOURMAND("MITHRIL GOURMAND", 10.minutes, 'b'),
;

override fun toString(): String {
return "§$colourCode$eventName"
}

companion object {
fun fromBossbarName(bossbarName: String): MiningEvent? {
return MiningEvent.entries.find { it.eventName == bossbarName.removeColor() }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package at.hannibal2.skyhanni.features.mining.eventtracker

import at.hannibal2.skyhanni.data.IslandType
import com.google.gson.annotations.Expose
import com.google.gson.annotations.SerializedName

data class MiningEventData(
@Expose @SerializedName("server_type") val serverType: IslandType,
@Expose @SerializedName("server_id") val serverId: String,
@Expose val event: MiningEvent,
@Expose @SerializedName("time_left") val timeRemaining: Long,
@Expose @SerializedName("reporter_uuid") val uuid: String
)
Loading

0 comments on commit 6ed8185

Please sign in to comment.