diff options
| author | Roman / Linnea Gräf <nea@nea.moe> | 2023-03-19 17:58:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-19 17:58:54 +0100 |
| commit | 86d6cc6bf29172fb13ed6aab2ca0676631336da9 (patch) | |
| tree | d5e0fc0aa6a556c44f497d818f36e674a0f2e317 /src/main/java/at/hannibal2/skyhanni/data | |
| parent | 4d3e68e8777ac174b938ad63c3367a20e99e06ac (diff) | |
| parent | 6913b635b9d20cc6736aef64bad9f5d517a2f644 (diff) | |
| download | SkyHanni-yaw_snapping.tar.gz SkyHanni-yaw_snapping.tar.bz2 SkyHanni-yaw_snapping.zip | |
Merge branch 'beta' into yaw_snappingyaw_snapping
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
7 files changed, 74 insertions, 24 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt b/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt index 17cb04d35..71a5a66b8 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt @@ -107,7 +107,7 @@ class ApiDataLoader { } private fun findApiCandidatesFromOtherMods(): Map<String, String> { - LorenzUtils.consoleLog("Trying to find the API Key from the config of other mods..") + LorenzUtils.consoleLog("Trying to find the api key from the config of other mods..") val candidates = mutableMapOf<String, String>() for (mod in OtherMod.values()) { val modName = mod.modName @@ -116,6 +116,10 @@ class ApiDataLoader { val reader = APIUtil.readFile(file) try { val key = mod.readKey(reader).replace("\n", "").replace(" ", "") + if (key == "") { + LorenzUtils.consoleLog("- $modName: no api key set!") + continue + } UUID.fromString(key) candidates[modName] = key } catch (e: Throwable) { @@ -123,7 +127,7 @@ class ApiDataLoader { continue } } else { - LorenzUtils.consoleLog("- $modName: no config found!") + LorenzUtils.consoleLog("- $modName: no mod/config found!") } } return candidates diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt index 95572c213..b55840b39 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt @@ -43,7 +43,9 @@ class ChatManager { if (message.startsWith("§f{\"server\":\"")) return val chatEvent = LorenzChatEvent(message, original) - chatEvent.postAndCatch() + if (!event.message.toString().contains("(held item preview from soopy using [hand])")) { + chatEvent.postAndCatch() + } val blockReason = chatEvent.blockedReason.uppercase() if (blockReason != "") { diff --git a/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt index 2893e67a4..b98664a2a 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HyPixelData.kt @@ -26,7 +26,7 @@ class HyPixelData { var stranded = false var bingo = false - var profile = "" + var profileName = "" fun readSkyBlockArea(): String { return ScoreboardData.sidebarLinesFormatted @@ -64,13 +64,13 @@ class HyPixelData { val message = event.message.removeColor().lowercase() if (message.startsWith("your profile was changed to:")) { val newProfile = message.replace("your profile was changed to:", "").replace("(co-op)", "").trim() - profile = newProfile + profileName = newProfile ProfileJoinEvent(newProfile).postAndCatch() } if (message.startsWith("you are playing on profile:")) { val newProfile = message.replace("you are playing on profile:", "").replace("(co-op)", "").trim() - if (profile == newProfile) return - profile = newProfile + if (profileName == newProfile) return + profileName = newProfile ProfileJoinEvent(newProfile).postAndCatch() } } @@ -112,8 +112,6 @@ class HyPixelData { bingo = true } - // TODO implemennt stranded check - " §7♲ §7Ironman" -> { ironman = true } @@ -139,14 +137,7 @@ class HyPixelData { } } - var islandType = IslandType.getBySidebarName(newIsland) - - if (islandType == IslandType.PRIVATE_ISLAND) { - if (guesting) { - islandType = IslandType.PRIVATE_ISLAND_GUEST - } - } - + val islandType = getIslandType(newIsland, guesting) if (skyBlockIsland != islandType) { IslandChangeEvent(islandType, skyBlockIsland).postAndCatch() if (islandType == IslandType.UNKNOWN) { @@ -159,6 +150,15 @@ class HyPixelData { } } + private fun getIslandType(newIsland: String, guesting: Boolean): IslandType { + val islandType = IslandType.getBySidebarName(newIsland) + if (guesting) { + if (islandType == IslandType.PRIVATE_ISLAND) return IslandType.PRIVATE_ISLAND_GUEST + if (islandType == IslandType.GARDEN) return IslandType.GARDEN_GUEST + } + return islandType + } + private fun checkScoreboard(): Boolean { val minecraft = Minecraft.getMinecraft() val world = minecraft.theWorld ?: return false diff --git a/src/main/java/at/hannibal2/skyhanni/data/InventoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/InventoryData.kt index 0f372269a..d3630c159 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/InventoryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/InventoryData.kt @@ -1,17 +1,16 @@ package at.hannibal2.skyhanni.data -import at.hannibal2.skyhanni.events.GuiContainerEvent -import at.hannibal2.skyhanni.events.InventoryCloseEvent -import at.hannibal2.skyhanni.events.InventoryOpenEvent -import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.events.* import net.minecraft.item.ItemStack import net.minecraft.network.play.server.S2DPacketOpenWindow import net.minecraft.network.play.server.S2FPacketSetSlot import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent class InventoryData { private var currentInventory: Inventory? = null private var acceptItems = false + private var lateEvent: LateInventoryOpenEvent? = null @SubscribeEvent fun onCloseWindow(event: GuiContainerEvent.CloseWindowEvent) { @@ -26,6 +25,15 @@ class InventoryData { } @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + if (event.phase != TickEvent.Phase.START) return + lateEvent?.let { + it.postAndCatch() + lateEvent = null + } + } + + @SubscribeEvent fun onChatPacket(event: PacketEvent.ReceiveEvent) { val packet = event.packet @@ -40,7 +48,21 @@ class InventoryData { } if (packet is S2FPacketSetSlot) { - if (!acceptItems) return + if (!acceptItems) { + currentInventory?.let { + if (it.windowId != packet.func_149175_c()) return + + val slot = packet.func_149173_d() + if (slot < it.slotCount) { + val itemStack = packet.func_149174_e() + if (itemStack != null) { + it.items[slot] = itemStack + lateEvent = LateInventoryOpenEvent(it) + } + } + } + return + } currentInventory?.let { if (it.windowId != packet.func_149175_c()) return @@ -71,6 +93,6 @@ class InventoryData { val windowId: Int, val title: String, val slotCount: Int, - val items: MutableMap<Int, ItemStack> = mutableMapOf() + val items: MutableMap<Int, ItemStack> = mutableMapOf(), ) }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt index 74081a5c4..aa6a02b13 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/IslandType.kt @@ -16,6 +16,7 @@ enum class IslandType(val displayName: String, val apiName: String = "null") { DEEP_CAVERNS("Deep Caverns", "deep_caverns"), GOLD_MINES("Gold Mine", "gold_mine"),//TODO confirm GARDEN("Garden"), + GARDEN_GUEST("Garden Guest"), NONE(""), UNKNOWN("???"), diff --git a/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt b/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt index d135c78cc..e80551dec 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt @@ -50,7 +50,7 @@ class SkillExperience { } @SubscribeEvent - fun onTick(event: InventoryOpenEvent) { + fun onInventoryOpen(event: InventoryOpenEvent) { if (event.inventoryName != "Your Skills") return for ((_, stack) in event.inventoryItems) { diff --git a/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt b/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt new file mode 100644 index 000000000..70ed2ead6 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt @@ -0,0 +1,21 @@ +package at.hannibal2.skyhanni.data + +import at.hannibal2.skyhanni.events.LorenzToolTipEvent +import net.minecraft.inventory.Slot +import net.minecraftforge.event.entity.player.ItemTooltipEvent +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class ToolTipData { + + @SubscribeEvent(priority = EventPriority.LOWEST) + fun onTooltip(event: ItemTooltipEvent) { + val toolTip = event.toolTip ?: return + val slot = lastSlot ?: return + LorenzToolTipEvent(slot, event.itemStack, toolTip).postAndCatch() + } + + companion object { + var lastSlot: Slot? = null + } +}
\ No newline at end of file |
