Skip to content

Commit

Permalink
ADDED MAXWELLAPI WOOO I AM PROUD OF MYSELF
Browse files Browse the repository at this point in the history
  • Loading branch information
j10a1n15 committed Nov 2, 2023
1 parent 311ffb8 commit 12aca2f
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import at.hannibal2.skyhanni.data.HypixelData
import at.hannibal2.skyhanni.data.ItemClickData
import at.hannibal2.skyhanni.data.ItemRenderBackground
import at.hannibal2.skyhanni.data.ItemTipHelper
import at.hannibal2.skyhanni.data.MaxwellAPI
import at.hannibal2.skyhanni.data.MayorElection
import at.hannibal2.skyhanni.data.MinecraftData
import at.hannibal2.skyhanni.data.OtherInventoryData
Expand Down Expand Up @@ -384,6 +385,7 @@ class SkyHanniMod {
loadModule(RiftAPI)
loadModule(SackAPI)
loadModule(BingoAPI)
loadModule(MaxwellAPI)

// features
loadModule(BazaarOrderHelper())
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/at/hannibal2/skyhanni/config/Storage.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.config;

import at.hannibal2.skyhanni.data.Powers;
import at.hannibal2.skyhanni.data.model.ComposterUpgrade;
import at.hannibal2.skyhanni.features.dungeon.DungeonAPI;
import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity;
Expand Down Expand Up @@ -72,6 +73,9 @@ public static class ProfileSpecific {
@Expose
public String currentPet = "";

@Expose
public Powers currentPower = null;

@Expose
public Map<LorenzVec, MinionConfig> minions = new HashMap<>();

Expand Down Expand Up @@ -457,4 +461,4 @@ public static class DungeonStorage {
public Map<DungeonAPI.DungeonFloor, Integer> bosses = new HashMap<>();
}
}
}
}
91 changes: 91 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/data/MaxwellAPI.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package at.hannibal2.skyhanni.data

import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.regex.Pattern


// TODO USE SH-REPO
enum class Powers (val power: String, val pattern: Pattern) {
// Standard
FORTUITOUS("Fortuitous", "§r§eYou(?:r selected power was set to)? §r§aFortuitous§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
PRETTY("Pretty", "§r§eYou(?:r selected power was set to)? §r§aPretty§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
PROTECTED("Protected", "§r§eYou(?:r selected power was set to)? §r§aProtected§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
SIMPLE("Simple", "§r§eYou(?:r selected power was set to)? §r§aSimple§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
WARRIOR("Warrior", "§r§eYou(?:r selected power was set to)? §r§aWarrior§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
COMMANDO("Commando", "§r§eYou(?:r selected power was set to)? §r§aCommando§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
DISCIPLINED("Disciplined", "§r§eYou(?:r selected power was set to)? §r§aDisciplined§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
INSPIRED("Inspired", "§r§eYou(?:r selected power was set to)? §r§aInspired§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
OMINOUS("Ominous", "§r§eYou(?:r selected power was set to)? §r§aOminous§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
PREPARED("Prepared", "§r§eYou(?:r selected power was set to)? §r§aPrepared§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),

// Unlockable
SILKY("Silky", "§r§eYou(?:r selected power was set to)? §r§aSilky§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
SWEET("Sweet", "§r§eYou(?:r selected power was set to)? §r§aSweet§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
BLOODY("Bloody", "§r§eYou(?:r selected power was set to)? §r§aBloody§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
ITCHY("Itchy", "§r§eYou(?:r selected power was set to)? §r§aItchy§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
SIGHTED("Sighted", "§r§eYou(?:r selected power was set to)? §r§aSighted§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
ADEPT("Adept", "§r§eYou(?:r selected power was set to)? §r§aAdept§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
MYTHICAL("Mythical", "§r§eYou(?:r selected power was set to)? §r§aMythical§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
FORCEFUL("Forceful", "§r§eYou(?:r selected power was set to)? §r§aForceful§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
SHADED("Shaded", "§r§eYou(?:r selected power was set to)? §r§aShaded§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
STRONG("Strong", "§r§eYou(?:r selected power was set to)? §r§aStrong§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
DEMONIC("Demonic", "§r§eYou(?:r selected power was set to)? §r§aDemonic§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
PLEASANT("Pleasant", "§r§eYou(?:r selected power was set to)? §r§aPleasant§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
HURTFUL("Hurtful", "§r§eYou(?:r selected power was set to)? §r§aHurtful§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
BIZARRE("Bizarre", "§r§eYou(?:r selected power was set to)? §r§aBizarre§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
HEALTHY("Healthy", "§r§eYou(?:r selected power was set to)? §r§aHealthy§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
SLENDER("Slender", "§r§eYou(?:r selected power was set to)? §r§aSlender§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
SCORCHING("Scorching", "§r§eYou(?:r selected power was set to)? §r§aScorching§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
CRUMBLY("Crumbly", "§r§eYou(?:r selected power was set to)? §r§aCrumbly§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
BUBBA("Bubba", "§r§eYou(?:r selected power was set to)? §r§aBubba§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() ),
SANGUISUGE("Sanguisuge", "§r§eYou(?:r selected power was set to)? §r§aSanguisuge§r§e(?:!§r| power for your §r§aAccessory Bag§r§e!§r)".toPattern() );
}
object MaxwellAPI {
var currentPower : Powers? = null

@SubscribeEvent
fun onConfigLoad(event: ConfigLoadEvent) {
val config = ProfileStorageData.profileSpecific ?: return
currentPower = config.currentPower ?: return
}

@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
for (power in Powers.entries) {
if (power.pattern.matcher(event.message).matches()) {
currentPower = power
savePower(power)
}
}
}

@SubscribeEvent
fun onInventoryFullyLoaded(event: InventoryFullyOpenedEvent) {
if (!LorenzUtils.inSkyBlock) return
if (!InventoryUtils.openInventoryName().contains("Accessory Bag Thaumaturgy")) return

val stacks = event.inventoryItems
val selectedPower = stacks.values.find { it.getLore().isNotEmpty() && it.getLore().last() == "§aPower is selected!" } ?: return

currentPower = Powers.entries.find { selectedPower.displayName.contains(it.power) }
savePower(currentPower!!)
}

@SubscribeEvent
fun onProfileJoin(event: ProfileJoinEvent) {
val config = ProfileStorageData.profileSpecific ?: return
currentPower = config.currentPower ?: return
}

private fun savePower(power: Powers) {
val config = ProfileStorageData.profileSpecific ?: return
config.currentPower = power
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.BingoAPI
import at.hannibal2.skyhanni.data.HypixelData
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.MaxwellAPI
import at.hannibal2.skyhanni.data.MayorElection
import at.hannibal2.skyhanni.data.PartyAPI
import at.hannibal2.skyhanni.data.PurseAPI
Expand Down Expand Up @@ -278,7 +279,17 @@ enum class CustomScoreboardElements (
19
),
MAXWELL(
{ listOf("§7Maxwell Power") },
{
when (MaxwellAPI.currentPower == null) {
true -> listOf("§c§lPlease visit Maxwell!")
false ->
when (config.displayNumbersFirst)
{
true -> listOf("§e${MaxwellAPI.currentPower?.power} Power")
false -> listOf("Power: §e${MaxwellAPI.currentPower?.power}")
}
}
},
listOf(IslandType.THE_RIFT),
1,
20
Expand Down

0 comments on commit 12aca2f

Please sign in to comment.