From 42703f02c9736a1565a0aa00007b04db9bc0baa7 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Mon, 8 Jul 2024 22:33:56 -0400 Subject: Bing bong locraw gone! --- src/main/resources/assets/skyblocker/lang/en_us.json | 2 ++ src/main/resources/fabric.mod.json | 1 + 2 files changed, 3 insertions(+) (limited to 'src/main/resources') diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index bf154048..ce7b7d46 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -654,6 +654,8 @@ "skyblocker.config.uiAndVisuals.waypoints.waypointType.@Tooltip": "Waypoint: Displays a highlight and a beacon beam.\n\nOutlined Waypoint: Displays both a waypoint and an outline.\n\nHighlight: Only displays a highlight.\n\nOutlined Highlight: Displays both a highlight and an outline.\n\nOutline: Only displays an outline.", "skyblocker.config.uiAndVisuals.waypoints.waypointType.generalNote": "\n\n\nThis option does not apply to all waypoints. Some waypoints such as secret waypoints have their own waypoint type option.", + "skyblocker.utils.locationUpdateError": "Failed to update your location! Some features of the mod may not work properly :(", + "skyblocker.itemTooltip.noData": "\u00a7cNo Data", "skyblocker.itemTooltip.nullMessage": "\u00a7cItem price information on tooltip will renew in max 60 seconds. If not, check latest.log", diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index e46085de..93e2bd6a 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -36,6 +36,7 @@ "fabricloader": ">=0.15.11", "fabric-api": ">=0.100.1+1.21", "yet_another_config_lib_v3": ">=3.5.0+1.21", + "hm-api": ">=1.0.0-alpha.10+1.21", "minecraft": "~1.21", "java": ">=21" }, -- cgit From df20f2dd76d68a5490f800813e74b7977e59d01a Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Mon, 8 Jul 2024 22:59:51 -0400 Subject: Reimplement /reparty ontop of the Mod API --- .../hysky/skyblocker/skyblock/dungeon/Reparty.java | 172 ++++++++++++--------- src/main/java/de/hysky/skyblocker/utils/Utils.java | 2 +- .../resources/assets/skyblocker/lang/en_us.json | 3 + 3 files changed, 99 insertions(+), 78 deletions(-) (limited to 'src/main/resources') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/Reparty.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/Reparty.java index 6165ac6a..80753c1d 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/Reparty.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/Reparty.java @@ -1,94 +1,112 @@ package de.hysky.skyblocker.skyblock.dungeon; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.utils.Constants; import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.chat.ChatFilterResult; import de.hysky.skyblocker.utils.chat.ChatPatternListener; import de.hysky.skyblocker.utils.scheduler.MessageScheduler; import de.hysky.skyblocker.utils.scheduler.Scheduler; +import net.azureaaron.hmapi.data.party.PartyRole; +import net.azureaaron.hmapi.events.HypixelPacketEvents; +import net.azureaaron.hmapi.network.HypixelNetworking; +import net.azureaaron.hmapi.network.packet.s2c.ErrorS2CPacket; +import net.azureaaron.hmapi.network.packet.s2c.HypixelS2CPacket; +import net.azureaaron.hmapi.network.packet.v2.s2c.PartyInfoS2CPacket; import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.text.Text; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; import java.util.regex.Matcher; -import java.util.regex.Pattern; + +import org.slf4j.Logger; + +import com.mojang.brigadier.Command; +import com.mojang.logging.LogUtils; public class Reparty extends ChatPatternListener { - private static final MinecraftClient client = MinecraftClient.getInstance(); - public static final Pattern PLAYER = Pattern.compile(" ([a-zA-Z0-9_]{2,16}) ●"); - private static final int BASE_DELAY = 10; - - private String[] players; - private int playersSoFar; - private boolean repartying; - private String partyLeader; - - public Reparty() { - super("^(?:You are not currently in a party\\." + - "|Party (?:Membe|Moderato)rs(?: \\(([0-9]+)\\)|:( .*))" + - "|([\\[A-z+\\]]* )?(?.*) has disbanded .*" + - "|.*\n([\\[A-z+\\]]* )?(?.*) has invited you to join their party!" + - "\nYou have 60 seconds to accept. Click here to join!\n.*)$"); - - this.repartying = false; - ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(ClientCommandManager.literal("rp").executes(context -> { - if (!Utils.isOnSkyblock() || this.repartying || client.player == null) return 0; - this.repartying = true; - MessageScheduler.INSTANCE.sendMessageAfterCooldown("/p list"); - return 0; - }))); - } - - @Override - public ChatFilterResult state() { - return (SkyblockerConfigManager.get().general.acceptReparty || this.repartying) ? ChatFilterResult.FILTER : ChatFilterResult.PASS; - } - - @Override - public boolean onMatch(Text message, Matcher matcher) { - if (matcher.group(1) != null && repartying) { - this.playersSoFar = 0; - this.players = new String[Integer.parseInt(matcher.group(1)) - 1]; - } else if (matcher.group(2) != null && repartying) { - Matcher m = PLAYER.matcher(matcher.group(2)); - while (m.find()) { - this.players[playersSoFar++] = m.group(1); - } - } else if (matcher.group("disband") != null && !matcher.group("disband").equals(client.getSession().getUsername())) { - partyLeader = matcher.group("disband"); - Scheduler.INSTANCE.schedule(() -> partyLeader = null, 61); - return false; - } else if (matcher.group("invite") != null && matcher.group("invite").equals(partyLeader)) { - String command = "/party accept " + partyLeader; - sendCommand(command, 0); - return false; - } else { - this.repartying = false; - return false; - } - if (this.playersSoFar == this.players.length) { - reparty(); - } - return false; - } - - private void reparty() { - ClientPlayerEntity playerEntity = client.player; - if (playerEntity == null) { - this.repartying = false; - return; - } - sendCommand("/p disband", 1); - for (int i = 0; i < this.players.length; ++i) { - String command = "/p invite " + this.players[i]; - sendCommand(command, i + 2); - } - Scheduler.INSTANCE.schedule(() -> this.repartying = false, this.players.length + 2); - } - - private void sendCommand(String command, int delay) { - MessageScheduler.INSTANCE.queueMessage(command, delay * BASE_DELAY); - } + private static final Logger LOGGER = LogUtils.getLogger(); + private static final MinecraftClient CLIENT = MinecraftClient.getInstance(); + private static final int BASE_DELAY = 10; + + private boolean repartying; + private String partyLeader; + + public Reparty() { + super("^(?:([\\[A-z+\\]]* )?(?.*) has disbanded .*" + + "|.*\n([\\[A-z+\\]]* )?(?.*) has invited you to join their party!" + + "\nYou have 60 seconds to accept. Click here to join!\n.*)$"); + + this.repartying = false; + HypixelPacketEvents.PARTY_INFO.register(this::onPacket); + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(ClientCommandManager.literal("rp").executes(context -> { + if (!Utils.isOnSkyblock() || this.repartying || CLIENT.player == null) return 0; + + this.repartying = true; + HypixelNetworking.sendPartyInfoC2SPacket(2); + + return Command.SINGLE_SUCCESS; + }))); + } + + private void onPacket(HypixelS2CPacket packet) { + switch (packet) { + case PartyInfoS2CPacket(var inParty, var members) when this.repartying -> { + UUID ourUuid = Objects.requireNonNull(CLIENT.getSession().getUuidOrNull()); + + if (inParty && members.get(ourUuid) == PartyRole.LEADER) { + sendCommand("/p disband", 1); + int count = 0; + + for (Map.Entry entry : members.entrySet()) { + UUID uuid = entry.getKey(); + PartyRole role = entry.getValue(); + + //Don't invite ourself + if (role != PartyRole.LEADER) sendCommand("/p " + uuid.toString(), ++count + 2); + } + + Scheduler.INSTANCE.schedule(() -> this.repartying = false, count * BASE_DELAY); + } else { + CLIENT.player.sendMessage(Constants.PREFIX.get().append(Text.translatable("skyblocker.reparty.notInPartyOrNotLeader"))); + this.repartying = false; + } + } + + case ErrorS2CPacket(var id, var error) when id.equals(PartyInfoS2CPacket.ID) && this.repartying -> { + CLIENT.player.sendMessage(Constants.PREFIX.get().append(Text.translatable("skyblocker.reparty.error"))); + LOGGER.error("[Skyblocker Reparty] The party info packet returned an unexpected error! {}", error); + + this.repartying = false; + } + + default -> {} //Do nothing + } + } + + @Override + public ChatFilterResult state() { + return SkyblockerConfigManager.get().general.acceptReparty ? ChatFilterResult.FILTER : ChatFilterResult.PASS; + } + + @Override + public boolean onMatch(Text message, Matcher matcher) { + if (matcher.group("disband") != null && !matcher.group("disband").equals(CLIENT.getSession().getUsername())) { + partyLeader = matcher.group("disband"); + Scheduler.INSTANCE.schedule(() -> partyLeader = null, 61); + } else if (matcher.group("invite") != null && matcher.group("invite").equals(partyLeader)) { + String command = "/party accept " + partyLeader; + sendCommand(command, 0); + } + + return false; + } + + private void sendCommand(String command, int delay) { + MessageScheduler.INSTANCE.queueMessage(command, delay * BASE_DELAY); + } } \ No newline at end of file diff --git a/src/main/java/de/hysky/skyblocker/utils/Utils.java b/src/main/java/de/hysky/skyblocker/utils/Utils.java index d0508096..e976f145 100644 --- a/src/main/java/de/hysky/skyblocker/utils/Utils.java +++ b/src/main/java/de/hysky/skyblocker/utils/Utils.java @@ -427,7 +427,7 @@ public class Utils { SkyblockEvents.LOCATION_CHANGE.invoker().onSkyblockLocationChange(location); } - case ErrorS2CPacket(var id, var error) when id == LocationUpdateS2CPacket.ID -> { + case ErrorS2CPacket(var id, var error) when id.equals(LocationUpdateS2CPacket.ID) -> { ClientPlayerEntity player = MinecraftClient.getInstance().player; if (player != null) { diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index ce7b7d46..6ea6cd70 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -656,6 +656,9 @@ "skyblocker.utils.locationUpdateError": "Failed to update your location! Some features of the mod may not work properly :(", + "skyblocker.reparty.notInPartyOrNotLeader": "You must be in a party and be the leader of it in order to reparty!", + "skyblocker.reparty.error": "Failed to reparty, try again in a moment!", + "skyblocker.itemTooltip.noData": "\u00a7cNo Data", "skyblocker.itemTooltip.nullMessage": "\u00a7cItem price information on tooltip will renew in max 60 seconds. If not, check latest.log", -- cgit From f2f50f2a956cada6c619f8efd46fc0ed9a830a16 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Thu, 11 Jul 2024 15:46:20 -0400 Subject: HM API 1.0.0 Release I went back to the "traditional" repository declaration because Gradle apparently doesn't allow two repositories in the forRepository thing --- build.gradle | 14 +++----------- gradle.properties | 4 ++-- src/main/resources/fabric.mod.json | 2 +- 3 files changed, 6 insertions(+), 14 deletions(-) (limited to 'src/main/resources') diff --git a/build.gradle b/build.gradle index b3c46376..56f281fb 100644 --- a/build.gradle +++ b/build.gradle @@ -31,16 +31,8 @@ repositories { maven { url "https://repo.codemc.io/repository/maven-public/" } // For Occlusion Culling library maven { url "https://repo.nea.moe/releases" } // For neu repoparser - exclusiveContent { - forRepository { - maven { url "https://maven.azureaaron.net/releases" } - maven { url "https://maven.azureaaron.net/snapshots" } - } - - filter { - includeGroup "net.azureaaron" - } - } + maven { url "https://maven.azureaaron.net/releases" } + maven { url "https://maven.azureaaron.net/snapshots" } } dependencies { @@ -61,7 +53,7 @@ dependencies { // YACL include modImplementation("dev.isxander:yet-another-config-lib:${project.yacl_version}-fabric") - // HM API + // HM API (Hypixel Mod API Library) include modImplementation("net.azureaaron:hm-api:${project.hm_api_version}") // Mod Menu diff --git a/gradle.properties b/gradle.properties index 9ece889f..e97585c9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,8 +14,8 @@ fabric_api_version=0.100.1+1.21 # Minecraft Mods ## YACL (https://github.com/isXander/YetAnotherConfigLib) yacl_version=3.5.0+1.21 -## HM API -hm_api_version=1.0.0-alpha.11+1.21 +## HM API (https://github.com/AzureAaron/hm-api) +hm_api_version=1.0.0+1.21 ## Mod Menu (https://modrinth.com/mod/modmenu/versions) mod_menu_version = 11.0.0-beta.1 ## REI (https://modrinth.com/mod/rei/versions?l=fabric) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 93e2bd6a..1361c00a 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -36,7 +36,7 @@ "fabricloader": ">=0.15.11", "fabric-api": ">=0.100.1+1.21", "yet_another_config_lib_v3": ">=3.5.0+1.21", - "hm-api": ">=1.0.0-alpha.10+1.21", + "hm-api": ">=1.0.0+1.21", "minecraft": "~1.21", "java": ">=21" }, -- cgit