forked from hannibal002/SkyHanni
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send Mining Island Events (hannibal002#969)
Added sending mining events to Soopy's API to test for new Mining Event feature. hannibal002#969
- Loading branch information
Showing
15 changed files
with
431 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningEventConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/main/java/at/hannibal2/skyhanni/events/BossbarUpdateEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
26 changes: 26 additions & 0 deletions
26
src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() } | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
Oops, something went wrong.