Skip to content

Commit

Permalink
Merge branch 'beta' into backend/commands
Browse files Browse the repository at this point in the history
  • Loading branch information
j10a1n15 authored Dec 13, 2024
2 parents 34a0617 + bd58e6d commit 9f804b0
Show file tree
Hide file tree
Showing 73 changed files with 904 additions and 419 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ for more information and usages.
- When updating a config option variable, use the `ConfigUpdaterMigrator.ConfigFixEvent` with event.move() when moving a value, and event.transform() when updating a value. [For Example](https://github.com/hannibal002/SkyHanni/blob/e88f416c48f9659f89b7047d7629cd9a1d1535bc/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt#L276).
- Use American English spelling conventions (e.g., "color" not "colour").
- When creating/updating a command, move it out of the `Commands.kt` class, if it isn't already, into the class that it belongs to.
- Avoid direct function imports. Always access functions or members through their respective namespaces or parent classes to improve readability and maintain encapsulation.

## Additional Useful Development Tools

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ object CollectionAPI {

/**
* REGEX-TEST: §7Total collected: §e261,390
* REGEX-TEST: §7Total Collected: §e2,012,418
*/
private val singleCounterPattern by patternGroup.pattern(
"singlecounter",
"§7Total collected: §e(?<amount>.*)",
"§7Total [c|C]ollected: §e(?<amount>.*)",
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ public class GUIConfig {
@ConfigEditorBoolean
public boolean realTimeFormatToggle = false;

@Expose
@ConfigOption(name = "Real Time Show Seconds", desc = "Include the current seconds in the Real Time display.")
@ConfigEditorBoolean
public boolean realTimeShowSeconds = true;

@Expose
@ConfigLink(owner = GUIConfig.class, field = "realTime")
public Position realTimePosition = new Position(10, 10, false, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ public class ChocolateFactoryConfig {
));

@Expose
@ConfigOption(name = "Rabbit Warning", desc = "")
@ConfigOption(name = "Stray Rabbit Warning", desc = "")
@Accordion
public ChocolateFactoryRabbitWarningConfig rabbitWarning = new ChocolateFactoryRabbitWarningConfig();
public ChocolateFactoryStrayRabbitWarningConfig rabbitWarning = new ChocolateFactoryStrayRabbitWarningConfig();

@Expose
@ConfigOption(name = "Upgrade Warnings", desc = "")
@Accordion
public ChocolateUpgradeWarningsConfig chocolateUpgradeWarnings = new ChocolateUpgradeWarningsConfig();
public ChocolateFactoryUpgradeWarningsConfig chocolateUpgradeWarnings = new ChocolateFactoryUpgradeWarningsConfig();

@Expose
@ConfigOption(name = "Chocolate Shop Price", desc = "")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
package at.hannibal2.skyhanni.config.features.inventory.chocolatefactory;

import at.hannibal2.skyhanni.utils.LorenzColor;
import at.hannibal2.skyhanni.utils.OSUtils;
import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorButton;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorColour;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDropdown;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorText;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
import io.github.notenoughupdates.moulconfig.observer.Property;
import org.jetbrains.annotations.NotNull;

public class ChocolateFactoryRabbitWarningConfig {
public class ChocolateFactoryStrayRabbitWarningConfig {

@Expose
@ConfigOption(name = "Rabbit Warning", desc = "Warn when stray rabbits of a certain tier appear.")
@ConfigOption(name = "Warning Level", desc = "Warn when stray rabbits of a certain tier appear.")
@ConfigEditorDropdown
public StrayTypeEntry rabbitWarningLevel = StrayTypeEntry.ALL;

@Expose
@ConfigOption(name = "Highlight Color", desc = "Choose the color that stray rabbits should be highlighted as.")
@ConfigEditorColour
public String inventoryHighlightColor = LorenzColor.RED.toConfigColor();

@Expose
@ConfigOption(name = "Warning Sound", desc = "The sound that plays for a special rabbit.\n" +
"§eYou can use custom sounds, put it in the §bskyhanni/sounds §efolder in your resource pack.\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
import io.github.notenoughupdates.moulconfig.observer.Property;

public class ChocolateUpgradeWarningsConfig {
public class ChocolateFactoryUpgradeWarningsConfig {
@Expose
@ConfigOption(name = "Upgrade Warning", desc = "Chat notification when you have a chocolate factory upgrade available to purchase.")
@ConfigEditorBoolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@ public String toString() {
@Expose
@ConfigLink(owner = MiningEventConfig.class, field = "enabled")
public Position position = new Position(200, 60, false, true);

@Expose
@ConfigOption(name = "Sharing Event Data", desc = "Sending Mining Event data to a server. This allows everyone to see more precise mining event timings. Thanks for your help!")
@ConfigEditorBoolean
public boolean allowDataSharing = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public HotspotRabbitStorage(@Nullable Integer year) {
public static class HitmanStatsStorage {
@Expose
@Nullable
public Integer availableEggs;
public Integer availableEggs = null;

@Expose
@Nullable
Expand All @@ -231,6 +231,10 @@ public static class HitmanStatsStorage {
@Expose
@Nullable
public SimpleTimeMark allSlotsCooldown = null;

@Expose
@Nullable
public Integer purchasedSlots = null;
}

@Expose
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/data/GuiEditManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ object GuiEditManager {
@JvmStatic
fun openGuiPositionEditor(hotkeyReminder: Boolean) {
SkyHanniMod.screenToOpen = GuiPositionEditor(
currentPositions.values().toList(),
currentPositions.values.toList(),
2,
Minecraft.getMinecraft().currentScreen as? GuiContainer,
)
Expand Down
37 changes: 21 additions & 16 deletions src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.inAnyIsland
import at.hannibal2.skyhanni.utils.RegexUtils.allMatches
import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RegexUtils.matches
Expand Down Expand Up @@ -89,11 +91,11 @@ object HypixelData {
)

/**
* REGEX-TEST: §r§b§lCoop §r§f(4)
* REGEX-TEST: §8[§r§a§r§8] §r§bBpoth §r§6§l℻
*/
private val playerAmountCoopPattern by patternGroup.pattern(
"playeramount.coop",
"^\\s*(?:§.)*Coop (?:§.)*\\((?<amount>\\d+)\\)\\s*$",
private val playerAmountOnIslandPattern by patternGroup.pattern(
"playeramount.onisland",
"^§.\\[[§\\w]{6,11}] §r.*",
)

/**
Expand All @@ -112,14 +114,6 @@ object HypixelData {
"^\\s*(?:§.)+Party (?:§.)+\\((?<amount>\\d+)\\)\\s*$",
)

/**
* REGEX-TEST: §r§b§lIsland
*/
private val soloProfileAmountPattern by patternGroup.pattern(
"solo.profile.amount",
"^\\s*(?:§.)*Island\\s*$",
)

/**
* REGEX-TEST: §a✌ §7(§a11§7/20)
*/
Expand Down Expand Up @@ -178,6 +172,8 @@ object HypixelData {
var skyBlockArea: String? = null
var skyBlockAreaWithSymbol: String? = null

var playerAmountOnIsland = 0

// Data from locraw
var locrawData: JsonObject? = null
private val locraw: MutableMap<String, String> = listOf(
Expand Down Expand Up @@ -263,7 +259,6 @@ object HypixelData {
var amount = 0
val playerPatternList = mutableListOf(
playerAmountPattern,
playerAmountCoopPattern,
playerAmountGuestingPattern,
)
if (DungeonAPI.inDungeon()) {
Expand All @@ -278,14 +273,17 @@ object HypixelData {
}
}
}
amount += TabListData.getTabList().count { soloProfileAmountPattern.matches(it) }

return amount
if (!inAnyIsland(IslandType.GARDEN, IslandType.GARDEN_GUEST, IslandType.PRIVATE_ISLAND, IslandType.PRIVATE_ISLAND_GUEST)) {
playerAmountOnIsland = 0
}

return amount + playerAmountOnIsland
}

fun getMaxPlayersForCurrentServer(): Int {
scoreboardVisitingAmountPattern.firstMatcher(ScoreboardData.sidebarLinesFormatted) {
return group("maxamount").toInt()
return group("maxamount").toInt() + playerAmountOnIsland
}

return when (skyBlockIsland) {
Expand Down Expand Up @@ -449,6 +447,8 @@ object HypixelData {
when (event.widget) {
TabWidget.AREA -> checkIsland(event)
TabWidget.PROFILE -> checkProfile()
TabWidget.COOP -> countPlayersOnIsland(event)
TabWidget.ISLAND -> countPlayersOnIsland(event)
else -> Unit
}
}
Expand Down Expand Up @@ -570,4 +570,9 @@ object HypixelData {
val scoreboardTitle = displayName.removeColor()
return scoreboardTitlePattern.matches(scoreboardTitle)
}

private fun countPlayersOnIsland(event: WidgetUpdateEvent) {
if (event.isClear()) return
playerAmountOnIsland = playerAmountOnIslandPattern.allMatches(event.lines).size
}
}
3 changes: 2 additions & 1 deletion src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.entity.EntityClickEvent
import at.hannibal2.skyhanni.events.minecraft.packet.PacketSentEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.compat.getUsedItem
import at.hannibal2.skyhanni.utils.toLorenzVec
import net.minecraft.client.Minecraft
import net.minecraft.network.play.client.C02PacketUseEntity
Expand All @@ -24,7 +25,7 @@ object ItemClickData {
packet is C08PacketPlayerBlockPlacement -> {
if (packet.placedBlockDirection != 255) {
val position = packet.position.toLorenzVec()
BlockClickEvent(ClickType.RIGHT_CLICK, position, packet.stack).post()
BlockClickEvent(ClickType.RIGHT_CLICK, position, packet.getUsedItem()).post()
} else {
ItemClickEvent(InventoryUtils.getItemInHand(), ClickType.RIGHT_CLICK).post()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ data class NeuReforgeJson(
val itemType: Pair<String, List<NEUInternalName>>
get() = if (this::itemTypeField.isInitialized) itemTypeField
else run {
val any = this.rawItemTypes
return when (any) {
return when (val any = this.rawItemTypes) {
is String -> {
any.replace("/", "_AND_").uppercase() to emptyList()
}
Expand All @@ -55,7 +54,7 @@ data class NeuReforgeJson(
val map = any as? Map<String, List<String>> ?: return type to emptyList()
val internalNames = map["internalName"]?.map { it.toInternalName() }.orEmpty()
val itemType = map["itemid"]?.map {
NEUItems.getInternalNamesForItemId(Item.getByNameOrId(it))
NEUItems.getInternalNamesForItemId(Item.getByNameOrId(it) ?: return@map emptyList())
}?.flatten().orEmpty()
type to (internalNames + itemType)
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/at/hannibal2/skyhanni/data/mob/Mob.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import at.hannibal2.skyhanni.utils.EntityUtils.cleanName
import at.hannibal2.skyhanni.utils.EntityUtils.isCorrupted
import at.hannibal2.skyhanni.utils.EntityUtils.isRunic
import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer
import at.hannibal2.skyhanni.utils.LocationUtils.getCenter
import at.hannibal2.skyhanni.utils.LocationUtils.getBoxCenter
import at.hannibal2.skyhanni.utils.LocationUtils.union
import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import at.hannibal2.skyhanni.utils.MobUtils
Expand Down Expand Up @@ -233,7 +233,7 @@ class Mob(
internalHighlight()
}

val centerCords get() = boundingBox.getCenter()
val centerCords get() = boundingBox.getBoxCenter()

override fun hashCode() = id.hashCode()

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ enum class TabWidget(
// language=RegExp
"(?:§.)*Coop (?:§.)*.*",
),
ISLAND(
// language=RegExp
"(?:§.)*Island",
),
MINION(
// language=RegExp
"(?:§.)*Minions: (?:§.)*(?<used>\\d+)(?:§.)*/(?:§.)*(?<max>\\d+)",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package at.hannibal2.skyhanni.events

import at.hannibal2.skyhanni.utils.GuiRenderUtils
import net.minecraft.client.Minecraft
import at.hannibal2.skyhanni.utils.InventoryUtils
import net.minecraft.client.gui.inventory.GuiContainer
import net.minecraft.inventory.Container
import net.minecraft.inventory.Slot
Expand Down Expand Up @@ -85,9 +85,7 @@ abstract class GuiContainerEvent(open val gui: GuiContainer, open val container:
fun makePickblock() {
if (this.clickedButton == 2 && this.clickTypeEnum == ClickType.MIDDLE) return
slot?.slotNumber?.let { slotNumber ->
Minecraft.getMinecraft().playerController.windowClick(
container.windowId, slotNumber, 2, 3, Minecraft.getMinecraft().thePlayer,
)
InventoryUtils.clickSlot(slotNumber, container.windowId, 2, 3)
isCanceled = true
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ abstract class LorenzEvent : Event() {
this::class.simpleName!!
}

@Deprecated("Use SkyHanniEvent instead", ReplaceWith(""))
@Deprecated("Use SkyHanniEvent instead")
fun postAndCatch() = postAndCatchAndBlock {}

companion object {
Expand All @@ -39,7 +39,7 @@ abstract class LorenzEvent : Event() {
val isInGuardedEventHandler get() = eventHandlerDepth > 0 || PlatformUtils.isDevEnvironment
}

@Deprecated("Use SkyHanniEvent instead", ReplaceWith(""))
@Deprecated("Use SkyHanniEvent instead")
fun postAndCatchAndBlock(
printError: Boolean = true,
stopOnFirstError: Boolean = false,
Expand Down Expand Up @@ -75,18 +75,17 @@ abstract class LorenzEvent : Event() {
),
)
}
return if (isCancelable) isCanceled else false
return isCancelable && isCanceled
}

private fun getListeners(): Array<out IEventListener> {
val accessorEventBus = MinecraftForge.EVENT_BUS as AccessorEventBus
return listenerList.getListeners(accessorEventBus.busId)
}

@Deprecated("Use SkyHanniEvent instead", ReplaceWith(""))
@Deprecated("Use SkyHanniEvent instead")
fun postWithoutCatch() = MinecraftForge.EVENT_BUS.post(this)

@Deprecated("Use SkyHanniEvent instead", ReplaceWith(""))
fun cancel() {
isCanceled = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package at.hannibal2.skyhanni.events

import at.hannibal2.skyhanni.api.event.CancellableSkyHanniEvent

object NEURenderEvent : CancellableSkyHanniEvent()
class NEURenderEvent : CancellableSkyHanniEvent()
Loading

0 comments on commit 9f804b0

Please sign in to comment.