From 79333d25c23a6599357e5997bf7569186cfc3d88 Mon Sep 17 00:00:00 2001 From: Deftu Date: Fri, 27 Dec 2024 16:55:42 +0200 Subject: [PATCH] Port a sizable chunk using new OneConfig events --- build.gradle.kts | 4 +- .../hytils/forge/HytilsMixinPlugin.java | 19 ++------ .../hytils/handlers/chat/ChatHandler.java | 3 +- .../blockers/BridgeOwnGoalDeathRemover.java | 2 +- .../modules/blockers/ConnectedMessage.java | 2 +- .../blockers/ConnectionStatusRemover.java | 2 +- .../modules/blockers/CurseOfSpamRemover.java | 2 +- .../blockers/DiscordSafetyWarningRemover.java | 2 +- .../modules/blockers/DuelsBlockTrail.java | 2 +- .../modules/blockers/DuelsNoStatsChange.java | 2 +- .../blockers/EarnedCoinsAndExpRemover.java | 2 +- .../blockers/GameAnnouncementsRemover.java | 2 +- .../modules/blockers/GameTipsRemover.java | 2 +- .../chat/modules/blockers/GiftBlocker.java | 2 +- .../chat/modules/blockers/GuildMOTD.java | 3 +- .../modules/blockers/HotPotatoRemover.java | 2 +- .../blockers/HypeLimitReminderRemover.java | 2 +- .../chat/modules/blockers/KarmaRemover.java | 2 +- .../LobbyFishingAnnouncementRemover.java | 2 +- .../modules/blockers/LobbyStatusRemover.java | 2 +- .../modules/blockers/MvpEmotesRemover.java | 8 ++-- .../modules/blockers/OnlineStatusRemover.java | 2 +- .../chat/modules/blockers/QuestBlocker.java | 2 +- .../blockers/ReplayRecordedRemover.java | 2 +- .../blockers/SeasonalCollectedRemover.java | 2 +- .../chat/modules/blockers/ShoutBlocker.java | 10 ++-- .../blockers/SkyblockWelcomeRemover.java | 2 +- .../blockers/SoulWellAnnouncerRemover.java | 2 +- .../modules/blockers/StatsMessageRemover.java | 2 +- .../blockers/TicketMachineRemover.java | 2 +- .../modules/blockers/TipMessageRemover.java | 2 +- .../modules/modifiers/GameStartCompactor.java | 7 +-- .../chat/modules/modifiers/WhiteChat.java | 5 +- .../modifiers/WhitePrivateMessages.java | 5 +- .../chat/modules/triggers/AutoAfkReply.java | 2 +- .../triggers/AutoChatReportConfirm.java | 2 +- .../chat/modules/triggers/AutoFriend.java | 2 +- .../chat/modules/triggers/AutoGG.java | 2 +- .../chat/modules/triggers/AutoGL.java | 2 +- .../triggers/AutoPartyWarpConfirm.java | 2 +- .../chat/modules/triggers/AutoWB.java | 9 ++-- .../chat/modules/triggers/AutoWarn.java | 2 +- .../chat/modules/triggers/GuildWelcomer.java | 2 +- .../chat/modules/triggers/SilentRemoval.java | 2 +- .../chat/modules/triggers/ThankWatchdog.java | 2 +- .../game/dropper/DropperHurtSound.java | 7 +-- .../game/duels/SumoRenderDistance.java | 3 +- .../handlers/game/housing/HousingMusic.java | 7 +-- .../game/miniwalls/MiddleBeaconMiniWalls.java | 5 +- .../handlers/game/pit/PitLagReducer.java | 15 ++++-- .../handlers/game/uhc/MiddleWaypointUHC.java | 5 +- .../hytils/handlers/general/SoundHandler.java | 2 +- .../lobby/armorstands/ArmorStandHider.java | 15 ++++-- .../handlers/lobby/limbo/LimboLimiter.java | 3 +- .../hytils/handlers/lobby/npc/NPCHandler.java | 13 ++++-- .../handlers/lobby/sound/SilentLobby.java | 43 ++++++++--------- .../handlers/render/ChestHighlighter.java | 46 +++++++++++++------ .../cosmetics/RenderEntityItemMixin.java | 2 +- .../mixin/overlay/VertexLighterFlatMixin.java | 2 + .../polyfrost/hytils/util/WaypointUtil.java | 9 ++-- 60 files changed, 188 insertions(+), 132 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 468a985..887358d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,7 +20,7 @@ preprocess { toolkitLoomHelper { // Adds OneConfig to our project - useOneConfig("1.1.0-alpha.34", "1.0.0-alpha.43", mcData, "commands", "config-impl", "events", "hud", "internal", "ui") + useOneConfig("1.1.0-alpha.34", "1.0.0-alpha.46", mcData, "commands", "config-impl", "events", "hud", "internal", "ui") useDevAuth() // Removes the server configs from IntelliJ IDEA, leaving only client runs. @@ -69,7 +69,7 @@ dependencies { // If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier. if (mcData.isLegacyForge) { - compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT") + compileOnly("org.polyfrost:polymixin:0.8.4+build.2") } else if (mcData.isFabric) { if (mcData.isLegacyFabric) { modImplementation("net.legacyfabric.legacy-fabric-api:legacy-fabric-api:${mcData.dependencies.legacyFabric.legacyFabricApiVersion}") diff --git a/src/main/java/org/polyfrost/hytils/forge/HytilsMixinPlugin.java b/src/main/java/org/polyfrost/hytils/forge/HytilsMixinPlugin.java index 7c1834d..2b665e1 100644 --- a/src/main/java/org/polyfrost/hytils/forge/HytilsMixinPlugin.java +++ b/src/main/java/org/polyfrost/hytils/forge/HytilsMixinPlugin.java @@ -20,12 +20,11 @@ //#if FORGE import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper; -import org.spongepowered.asm.lib.tree.*; -//#else -//$$ import org.objectweb.asm.tree.*; //#endif import org.objectweb.asm.Opcodes; +import org.objectweb.asm.tree.*; +import org.polyfrost.oneconfig.api.platform.v1.DeobfuscationRemapper; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinInfo; @@ -79,11 +78,7 @@ public List getMixins() { @Override public void preApply( String targetClassName, - //#if FORGE && MC <= 1.12.2 - org.spongepowered.asm.lib.tree.ClassNode targetClass, - //#else - //$$ org.objectweb.asm.tree.ClassNode targetClass, - //#endif + ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo ) { @@ -93,17 +88,13 @@ public void preApply( @Override public void postApply( String targetClassName, - //#if FORGE && MC <= 1.12.2 - org.spongepowered.asm.lib.tree.ClassNode targetClass, - //#else - //$$ org.objectweb.asm.tree.ClassNode targetClass, - //#endif + ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo ) { if (!hasAppliedModifyName && !hasAppliedRenderHeads && targetClass != null && Objects.equals(targetClassName, "net.minecraft.client.gui.GuiPlayerTabOverlay")) { for (MethodNode method : targetClass.methods) { - final String methodName = FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(targetClass.name, method.name, method.desc); + final String methodName = DeobfuscationRemapper.INSTANCE.mapMethodName(targetClass.name, method.name, method.desc); final ListIterator iterator = method.instructions.iterator(); switch (methodName) { case "renderPlayerlist": diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java b/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java index 563f164..566c794 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java @@ -31,6 +31,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.polyfrost.oneconfig.api.event.v1.events.ChatReceiveEvent; +import org.polyfrost.oneconfig.api.event.v1.events.WorldUnloadEvent; import org.polyfrost.oneconfig.api.event.v1.invoke.impl.Subscribe; import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; @@ -133,7 +134,7 @@ private void registerDualModule(T } @Subscribe - public void handleWorldLeave(WorldEvent.Unload e) { // TODO + public void handleWorldLeave(WorldUnloadEvent e) { for (ChatReceiveResetModule module : this.resetModules) { module.reset(); } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/BridgeOwnGoalDeathRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/BridgeOwnGoalDeathRemover.java index 1bccc9e..a634cbd 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/BridgeOwnGoalDeathRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/BridgeOwnGoalDeathRemover.java @@ -27,7 +27,7 @@ public class BridgeOwnGoalDeathRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (message.equals(getLanguage().chatCleanerBridgeOwnGoalDeath)) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/ConnectedMessage.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/ConnectedMessage.java index 4de2253..285f490 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/ConnectedMessage.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/ConnectedMessage.java @@ -27,7 +27,7 @@ public class ConnectedMessage implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (getLanguage().connectedServerConnectMessageRegex.matcher(message).matches()) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/ConnectionStatusRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/ConnectionStatusRemover.java index ebd6d3b..088cabd 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/ConnectionStatusRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/ConnectionStatusRemover.java @@ -27,7 +27,7 @@ public class ConnectionStatusRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (getLanguage().chatCleanerConnectionStatusRegex.matcher(message).matches()) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/CurseOfSpamRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/CurseOfSpamRemover.java index 205671f..a5603d4 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/CurseOfSpamRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/CurseOfSpamRemover.java @@ -27,7 +27,7 @@ public class CurseOfSpamRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (message.equals(getLanguage().chatCleanerCurseOfSpam)) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/DiscordSafetyWarningRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/DiscordSafetyWarningRemover.java index e11197f..1e0831c 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/DiscordSafetyWarningRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/DiscordSafetyWarningRemover.java @@ -27,7 +27,7 @@ public class DiscordSafetyWarningRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (message.equals(getLanguage().chatDiscordSafetyWarning)) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/DuelsBlockTrail.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/DuelsBlockTrail.java index dfc6683..4500c81 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/DuelsBlockTrail.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/DuelsBlockTrail.java @@ -27,7 +27,7 @@ public class DuelsBlockTrail implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (message.equals(getLanguage().chatCleanerDuelsBlockTrail)) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/DuelsNoStatsChange.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/DuelsNoStatsChange.java index e3c6d83..7aacd8b 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/DuelsNoStatsChange.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/DuelsNoStatsChange.java @@ -27,7 +27,7 @@ public class DuelsNoStatsChange implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (getLanguage().chatCleanerDuelsNoStatsChangeRegex.matcher(message).matches()) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/EarnedCoinsAndExpRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/EarnedCoinsAndExpRemover.java index a401e7e..95cede5 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/EarnedCoinsAndExpRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/EarnedCoinsAndExpRemover.java @@ -27,7 +27,7 @@ public class EarnedCoinsAndExpRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText().replace("\n", "")); // Support doubled coins (guild rewards) message + String message = event.getFullyUnformattedMessage().replace("\n", ""); // Support doubled coins (guild rewards) message if (getLanguage().chatCleanerEarnedCoinsAndExpRegex.matcher(message).matches()) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/GameAnnouncementsRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/GameAnnouncementsRemover.java index c10f38d..eacfd7b 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/GameAnnouncementsRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/GameAnnouncementsRemover.java @@ -27,7 +27,7 @@ public class GameAnnouncementsRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (getLanguage().chatCleanerGameAnnouncementRegex.matcher(message).matches()) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/GameTipsRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/GameTipsRemover.java index fc7db79..fd2885a 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/GameTipsRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/GameTipsRemover.java @@ -27,7 +27,7 @@ public class GameTipsRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (getLanguage().chatCleanerGameTipsRegex.matcher(message).matches()) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/GiftBlocker.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/GiftBlocker.java index f44dff9..c6d6d85 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/GiftBlocker.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/GiftBlocker.java @@ -27,7 +27,7 @@ public class GiftBlocker implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (getLanguage().chatGiftBlockerRegex.matcher(message).matches()) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/GuildMOTD.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/GuildMOTD.java index d88596e..981c0dd 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/GuildMOTD.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/GuildMOTD.java @@ -19,6 +19,7 @@ package org.polyfrost.hytils.handlers.chat.modules.blockers; import org.polyfrost.oneconfig.api.event.v1.EventManager; +import org.polyfrost.oneconfig.api.event.v1.events.ServerJoinEvent; import org.polyfrost.oneconfig.api.event.v1.invoke.impl.Subscribe; import org.polyfrost.oneconfig.utils.v1.Multithreading; import org.polyfrost.hytils.config.HytilsConfig; @@ -46,7 +47,7 @@ public GuildMOTD() { } @Subscribe - public void onConnectedToServer(FMLNetworkEvent.ClientConnectedToServerEvent event) { // TODO + public void onConnectedToServer(ServerJoinEvent event) { // Allow checking of MOTD immediately after joining Hypixel. canCheckMOTD = true; isMOTD = false; diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/HotPotatoRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/HotPotatoRemover.java index 42783df..80815d9 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/HotPotatoRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/HotPotatoRemover.java @@ -27,7 +27,7 @@ public class HotPotatoRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (getLanguage().chatCleanerHotPotatoRegex.matcher(message).matches()) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/HypeLimitReminderRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/HypeLimitReminderRemover.java index 56919f2..eedf33c 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/HypeLimitReminderRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/HypeLimitReminderRemover.java @@ -27,7 +27,7 @@ public class HypeLimitReminderRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (message.startsWith(getLanguage().chatCleanerHypeLimit)) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/KarmaRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/KarmaRemover.java index a39901b..33ac3c3 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/KarmaRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/KarmaRemover.java @@ -27,7 +27,7 @@ public class KarmaRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (getLanguage().chatCleanerKarmaMessagesRegex.matcher(message).matches()) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/LobbyFishingAnnouncementRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/LobbyFishingAnnouncementRemover.java index 26cf686..9a5b63e 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/LobbyFishingAnnouncementRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/LobbyFishingAnnouncementRemover.java @@ -27,7 +27,7 @@ public class LobbyFishingAnnouncementRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (getLanguage().chatCleanerLobbyFishingAnnouncementRegex.matcher(message).matches()) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/LobbyStatusRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/LobbyStatusRemover.java index d988482..f4c907b 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/LobbyStatusRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/LobbyStatusRemover.java @@ -27,7 +27,7 @@ public class LobbyStatusRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - final String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + final String message = event.getFullyUnformattedMessage(); if (message.contains(": ")) return; if (getLanguage().chatCleanerJoinRegex.matcher(message).find()) { event.cancelled = true; diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/MvpEmotesRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/MvpEmotesRemover.java index e3dc64e..afb015d 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/MvpEmotesRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/MvpEmotesRemover.java @@ -18,6 +18,7 @@ package org.polyfrost.hytils.handlers.chat.modules.blockers; +import net.minecraft.util.IChatComponent; import org.polyfrost.hytils.config.HytilsConfig; import org.polyfrost.hytils.handlers.chat.ChatReceiveModule; import org.polyfrost.hytils.handlers.language.LanguageData; @@ -31,11 +32,12 @@ public class MvpEmotesRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { final LanguageData language = getLanguage(); - Matcher matcher = language.chatCleanerMvpEmotesRegex.matcher(event.message.getFormattedText()); + Matcher matcher = language.chatCleanerMvpEmotesRegex.matcher(event.getFullyUnformattedMessage()); if (matcher.find(0)) { - event.message = new ChatComponentText(event.message.getFormattedText().replaceAll( + IChatComponent message = event.getMessage(); + event.setMessage(new ChatComponentText(message.getFormattedText().replaceAll( language.chatCleanerMvpEmotesRegex.pattern(), "") - ); + )); } } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/OnlineStatusRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/OnlineStatusRemover.java index 0cd6dd6..adcabb9 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/OnlineStatusRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/OnlineStatusRemover.java @@ -27,7 +27,7 @@ public class OnlineStatusRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (getLanguage().chatCleanerOnlineStatusRegex.matcher(message).matches()) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/QuestBlocker.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/QuestBlocker.java index f5bafed..b9ab0f3 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/QuestBlocker.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/QuestBlocker.java @@ -26,7 +26,7 @@ public class QuestBlocker implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull final ChatReceiveEvent event) { - final String message = event.message.getUnformattedText(); + final String message = event.getFullyUnformattedMessage(); if (message.startsWith("§aAutomatically activated:")) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/ReplayRecordedRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/ReplayRecordedRemover.java index 0228a5c..321c96b 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/ReplayRecordedRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/ReplayRecordedRemover.java @@ -27,7 +27,7 @@ public class ReplayRecordedRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (getLanguage().chatCleanerReplayRecordedRegex.matcher(message).matches()) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/SeasonalCollectedRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/SeasonalCollectedRemover.java index e5b01c1..c42129f 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/SeasonalCollectedRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/SeasonalCollectedRemover.java @@ -27,7 +27,7 @@ public class SeasonalCollectedRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (getLanguage().chatCleanerGrinchPresentsRegex.matcher(message).matches()) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/ShoutBlocker.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/ShoutBlocker.java index b6d3057..c01fe6b 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/ShoutBlocker.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/ShoutBlocker.java @@ -19,6 +19,7 @@ package org.polyfrost.hytils.handlers.chat.modules.blockers; import net.hypixel.data.type.GameType; +import net.minecraft.util.IChatComponent; import org.polyfrost.hytils.config.HytilsConfig; import org.polyfrost.hytils.handlers.chat.ChatReceiveModule; import org.polyfrost.hytils.handlers.chat.ChatSendModule; @@ -84,10 +85,11 @@ private long getCooldownLengthInSeconds() { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { HypixelUtils.Location location = HypixelUtils.getLocation(); - if (location.getGameType().orElse(null) == GameType.SKYWARS && event.message.getFormattedText().equals(getLanguage().cannotShoutBeforeSkywars) || // fun fact: there is no message when you shout after a skywars game - event.message.getFormattedText().equals(getLanguage().cannotShoutAfterGame) || - event.message.getFormattedText().equals(getLanguage().cannotShoutBeforeGame) || - event.message.getFormattedText().equals(getLanguage().noSpectatorCommands) + IChatComponent message = event.getMessage(); + if (location.getGameType().orElse(null) == GameType.SKYWARS && message.getFormattedText().equals(getLanguage().cannotShoutBeforeSkywars) || // fun fact: there is no message when you shout after a skywars game + message.getFormattedText().equals(getLanguage().cannotShoutAfterGame) || + message.getFormattedText().equals(getLanguage().cannotShoutBeforeGame) || + message.getFormattedText().equals(getLanguage().noSpectatorCommands) ) { shoutCooldown = 0L; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/SkyblockWelcomeRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/SkyblockWelcomeRemover.java index cf1ef8a..74c91ca 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/SkyblockWelcomeRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/SkyblockWelcomeRemover.java @@ -27,7 +27,7 @@ public class SkyblockWelcomeRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (message.equals(getLanguage().chatCleanerSkyblockWelcome)) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/SoulWellAnnouncerRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/SoulWellAnnouncerRemover.java index a040f49..8e3bb51 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/SoulWellAnnouncerRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/SoulWellAnnouncerRemover.java @@ -27,7 +27,7 @@ public class SoulWellAnnouncerRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (getLanguage().chatCleanerSoulWellFindRegex.matcher(message).matches()) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/StatsMessageRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/StatsMessageRemover.java index 918aa1b..70d5537 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/StatsMessageRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/StatsMessageRemover.java @@ -27,7 +27,7 @@ public class StatsMessageRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (getLanguage().chatCleanerStatsRegex.matcher(message).matches()) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/TicketMachineRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/TicketMachineRemover.java index e6f92cb..9b6c1b9 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/TicketMachineRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/TicketMachineRemover.java @@ -30,7 +30,7 @@ public class TicketMachineRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { HypixelUtils.Location location = HypixelUtils.getLocation(); - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (location.getGameType().orElse(null) == GameType.BEDWARS && !location.inGame() && getLanguage().chatCleanerTicketAnnouncerRegex.matcher(message).matches()) { event.cancelled = true; diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/TipMessageRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/TipMessageRemover.java index 1331e6a..606b141 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/TipMessageRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/TipMessageRemover.java @@ -27,7 +27,7 @@ public class TipMessageRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText().replace("\n", "")); + String message = event.getFullyUnformattedMessage().replace("\n", ""); if (getLanguage().chatCleanerTipRegex.matcher(message).matches()) { event.cancelled = true; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/modifiers/GameStartCompactor.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/modifiers/GameStartCompactor.java index 7468247..9da4630 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/modifiers/GameStartCompactor.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/modifiers/GameStartCompactor.java @@ -46,8 +46,9 @@ public int getPriority() { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - final Matcher gameStartMatcher = getLanguage().chatRestylerGameStartCounterStyleRegex.matcher(event.message.getUnformattedText()); - final Matcher chatRestylerMatcher = getLanguage().chatRestylerGameStartCounterOutputStyleRegex.matcher(event.message.getFormattedText()); + IChatComponent message = event.getMessage(); + final Matcher gameStartMatcher = getLanguage().chatRestylerGameStartCounterStyleRegex.matcher(event.getFullyUnformattedMessage()); + final Matcher chatRestylerMatcher = getLanguage().chatRestylerGameStartCounterOutputStyleRegex.matcher(message.getFormattedText()); if (gameStartMatcher.matches() || (HytilsConfig.gameStatusRestyle && chatRestylerMatcher.matches())) { if (lastMessage != null) { final GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI(); @@ -57,7 +58,7 @@ public void onMessageReceived(@NotNull ChatReceiveEvent event) { removeChatLines(accessor.getDrawnChatLines(), oldTimerLines); } - lastMessage = event.message.createCopy(); + lastMessage = message.createCopy(); } } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/modifiers/WhiteChat.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/modifiers/WhiteChat.java index f56f1a5..09214fe 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/modifiers/WhiteChat.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/modifiers/WhiteChat.java @@ -31,10 +31,11 @@ public class WhiteChat implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - final Matcher matcher = getLanguage().whiteChatNonMessageRegex.matcher(event.message.getFormattedText()); + IChatComponent message = event.getMessage(); + final Matcher matcher = getLanguage().whiteChatNonMessageRegex.matcher(message.getFormattedText()); if (matcher.find(0)) { boolean foundStart = false; - for (IChatComponent sibling : event.message.getSiblings()) { + for (IChatComponent sibling : message.getSiblings()) { if (sibling.getFormattedText().startsWith("§7: ")) foundStart = true; if (foundStart && sibling.getChatStyle().getColor() == EnumChatFormatting.GRAY) { sibling.getChatStyle().setColor(EnumChatFormatting.WHITE); diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/modifiers/WhitePrivateMessages.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/modifiers/WhitePrivateMessages.java index ce2213f..8f2dac8 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/modifiers/WhitePrivateMessages.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/modifiers/WhitePrivateMessages.java @@ -31,10 +31,11 @@ public class WhitePrivateMessages implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - final Matcher matcher = getLanguage().privateMessageWhiteChatRegex.matcher(event.message.getFormattedText()); + IChatComponent message = event.getMessage(); + final Matcher matcher = getLanguage().privateMessageWhiteChatRegex.matcher(message.getFormattedText()); if (matcher.find(0)) { boolean foundStart = false; - for (IChatComponent sibling : event.message.getSiblings()) { + for (IChatComponent sibling : message.getSiblings()) { if (sibling.getFormattedText().equals("§7: §r")) foundStart = true; if (foundStart && sibling.getChatStyle().getColor() == EnumChatFormatting.GRAY) { sibling.getChatStyle().setColor(EnumChatFormatting.WHITE); diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoAfkReply.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoAfkReply.java index 12ffabd..dde93e6 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoAfkReply.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoAfkReply.java @@ -32,7 +32,7 @@ public class AutoAfkReply implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { if (!"limbo".equals(HypixelUtils.getLocation().getServerName().orElse(null))) return; - String message = event.message.getUnformattedText(); + String message = event.getFullyUnformattedMessage(); Matcher matcher = getLanguage().autoAfkReplyPatternRegex.matcher(message); if (matcher.matches()) { UChat.say("/msg " + matcher.group(2) + " Hey " + matcher.group(2) + ", I am currently AFK!"); diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoChatReportConfirm.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoChatReportConfirm.java index c7d5152..d856a3f 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoChatReportConfirm.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoChatReportConfirm.java @@ -30,7 +30,7 @@ public class AutoChatReportConfirm implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - if (event.message.getUnformattedText().equals(getLanguage().autoChatReportConfirm)) { + if (event.getFullyUnformattedMessage().equals(getLanguage().autoChatReportConfirm)) { event.cancelled = true; Multithreading.schedule(() -> Minecraft.getMinecraft().thePlayer.sendChatMessage("/report confirm"), 1, TimeUnit.SECONDS); } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoFriend.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoFriend.java index cfba96d..65fab7c 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoFriend.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoFriend.java @@ -36,7 +36,7 @@ public class AutoFriend implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = event.message.getUnformattedText().replace("\n", ""); + String message = event.getFullyUnformattedMessage().replace("\n", ""); Matcher matcher = getLanguage().autoFriendPatternRegex.matcher(message); if (message.contains(": ")) return; if (matcher.find()) { diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGG.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGG.java index cd86b3a..8c4b9e6 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGG.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGG.java @@ -44,7 +44,7 @@ private static String getGGMessageTwo() { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + String message = event.getFullyUnformattedMessage(); if (!hasGameEnded(message)) return; Multithreading.schedule(() -> UChat.say("/ac " + getGGMessageOne()), (long) (HytilsConfig.autoGGFirstPhraseDelay * 1000), TimeUnit.MILLISECONDS); if (HytilsConfig.autoGGSecondMessage) diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGL.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGL.java index 6ebb669..1225ecf 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGL.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoGL.java @@ -34,7 +34,7 @@ private static String getGLMessage() { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()).trim(); + String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.getFullyUnformattedMessage()).trim(); if (message.contains(": ")) return; if (message.endsWith("The game starts in 5 seconds!")) { Minecraft.getMinecraft().thePlayer.sendChatMessage("/ac " + getGLMessage()); diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoPartyWarpConfirm.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoPartyWarpConfirm.java index d543f93..da4a5bc 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoPartyWarpConfirm.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoPartyWarpConfirm.java @@ -31,7 +31,7 @@ public class AutoPartyWarpConfirm implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - final String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); + final String message = event.getFullyUnformattedMessage(); if (message.equals(getLanguage().autoPartyWarpConfirm)) { event.cancelled = true; Multithreading.schedule(() -> Minecraft.getMinecraft().thePlayer.sendChatMessage("/p warp"), 1500, TimeUnit.MILLISECONDS); diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoWB.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoWB.java index 45e9d04..714343f 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoWB.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoWB.java @@ -18,6 +18,7 @@ package org.polyfrost.hytils.handlers.chat.modules.triggers; +import net.minecraft.util.IChatComponent; import org.polyfrost.oneconfig.utils.v1.Multithreading; import org.polyfrost.hytils.HytilsReborn; import org.polyfrost.hytils.config.HytilsConfig; @@ -35,7 +36,8 @@ public class AutoWB implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - String msg = event.message.getFormattedText().trim(); + IChatComponent message = event.getMessage(); + String msg = message.getFormattedText().trim(); Matcher matcher = HytilsReborn.INSTANCE.getLanguageHandler().getCurrent().chatRestylerStatusPatternRegex.matcher(msg); if (matcher.matches()) { final String chatType; @@ -61,7 +63,8 @@ public void onMessageReceived(@NotNull ChatReceiveEvent event) { } else { return; } - String message = HytilsConfig.autoWBMessage1.replace("%player%", name); + + String sentMessage = HytilsConfig.autoWBMessage1.replace("%player%", name); if (HytilsConfig.randomAutoWB) { try { Multithreading.schedule(() -> Minecraft.getMinecraft().thePlayer.sendChatMessage(chatType + getNextMessage(name)), HytilsConfig.autoWBCooldown, TimeUnit.SECONDS); @@ -69,7 +72,7 @@ public void onMessageReceived(@NotNull ChatReceiveEvent event) { e.printStackTrace(); } } else { - Multithreading.schedule(() -> Minecraft.getMinecraft().thePlayer.sendChatMessage(chatType + message), HytilsConfig.autoWBCooldown, TimeUnit.SECONDS); + Multithreading.schedule(() -> Minecraft.getMinecraft().thePlayer.sendChatMessage(chatType + sentMessage), HytilsConfig.autoWBCooldown, TimeUnit.SECONDS); } } } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoWarn.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoWarn.java index 8ade7ce..728be95 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoWarn.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoWarn.java @@ -28,7 +28,7 @@ public class AutoWarn implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - if (UTextComponent.Companion.stripFormatting(event.message.getUnformattedText()).startsWith("A kick")) { + if (UTextComponent.Companion.stripFormatting(event.getFullyUnformattedMessage()).startsWith("A kick")) { UChat.say(HytilsConfig.putInCaps ? "/pc ---------REQUEUE, I'VE BEEN KICKED!---------" : "/pc ---------I've been kicked, please requeue!---------"); } } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/GuildWelcomer.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/GuildWelcomer.java index 83c9c44..46db673 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/GuildWelcomer.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/GuildWelcomer.java @@ -29,7 +29,7 @@ public class GuildWelcomer implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - final String text = event.message.getUnformattedText(); + final String text = event.getFullyUnformattedMessage(); final Matcher matcher = getLanguage().guildPlayerJoinRegex.matcher(text); if (matcher.matches()) { Minecraft.getMinecraft().thePlayer.sendChatMessage("/gc Welcome to the guild " + matcher.group("player") + "!"); diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/SilentRemoval.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/SilentRemoval.java index 24c6767..872cdaa 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/SilentRemoval.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/SilentRemoval.java @@ -34,7 +34,7 @@ public class SilentRemoval implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - final Matcher matcher = getLanguage().silentRemovalLeaveMessageRegex.matcher(EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText())); + final Matcher matcher = getLanguage().silentRemovalLeaveMessageRegex.matcher(EnumChatFormatting.getTextWithoutFormattingCodes(event.getFullyUnformattedMessage())); if (matcher.matches()) { // not a friend anymore :( diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/ThankWatchdog.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/ThankWatchdog.java index 4a385a6..beebe86 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/ThankWatchdog.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/ThankWatchdog.java @@ -27,7 +27,7 @@ public class ThankWatchdog implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ChatReceiveEvent event) { - if (event.message.getUnformattedText().equals("[WATCHDOG ANNOUNCEMENT]") || event.message.getUnformattedText().startsWith("A player has been removed from your")) { + if (event.getFullyUnformattedMessage().equals("[WATCHDOG ANNOUNCEMENT]") || event.getFullyUnformattedMessage().startsWith("A player has been removed from your")) { Minecraft.getMinecraft().thePlayer.sendChatMessage("/achat Thanks Watchdog!"); } } diff --git a/src/main/java/org/polyfrost/hytils/handlers/game/dropper/DropperHurtSound.java b/src/main/java/org/polyfrost/hytils/handlers/game/dropper/DropperHurtSound.java index e9d4e6b..cc07325 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/game/dropper/DropperHurtSound.java +++ b/src/main/java/org/polyfrost/hytils/handlers/game/dropper/DropperHurtSound.java @@ -19,16 +19,17 @@ package org.polyfrost.hytils.handlers.game.dropper; import org.polyfrost.hytils.config.HytilsConfig; +import org.polyfrost.oneconfig.api.event.v1.events.SoundPlayedEvent; import org.polyfrost.oneconfig.api.event.v1.invoke.impl.Subscribe; import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; public class DropperHurtSound { @Subscribe - public void onSound(PlaySoundEvent event) { // TODO + public void onSound(SoundPlayedEvent event) { HypixelUtils.Location location = HypixelUtils.getLocation(); - if (HytilsConfig.muteDropperHurtSound && HypixelUtils.isHypixel() && "dropper".equalsIgnoreCase(location.getMode().orElse(null)) && event.name.equals("game.player.hurt")) { - event.result = null; + if (HytilsConfig.muteDropperHurtSound && HypixelUtils.isHypixel() && "dropper".equalsIgnoreCase(location.getMode().orElse(null)) && event.getName().equals("game.player.hurt")) { + event.setSound(null); } } } diff --git a/src/main/java/org/polyfrost/hytils/handlers/game/duels/SumoRenderDistance.java b/src/main/java/org/polyfrost/hytils/handlers/game/duels/SumoRenderDistance.java index a919c6b..88d90ea 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/game/duels/SumoRenderDistance.java +++ b/src/main/java/org/polyfrost/hytils/handlers/game/duels/SumoRenderDistance.java @@ -21,6 +21,7 @@ import org.polyfrost.hytils.config.HytilsConfig; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.GameSettings; +import org.polyfrost.oneconfig.api.event.v1.events.PostWorldRenderEvent; import org.polyfrost.oneconfig.api.event.v1.invoke.impl.Subscribe; import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; @@ -31,7 +32,7 @@ public class SumoRenderDistance { boolean isFirstRender = true; @Subscribe - public void onWorldLoad(RenderWorldLastEvent event) { // TODO + public void onWorldLoad(PostWorldRenderEvent event) { // TODO HypixelUtils.Location location = HypixelUtils.getLocation(); if (HytilsConfig.sumoRenderDistance && HypixelUtils.isHypixel() && location.getMode().orElse("null").contains("SUMO")) { if (isFirstRender) { diff --git a/src/main/java/org/polyfrost/hytils/handlers/game/housing/HousingMusic.java b/src/main/java/org/polyfrost/hytils/handlers/game/housing/HousingMusic.java index 5770ac7..c9d4456 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/game/housing/HousingMusic.java +++ b/src/main/java/org/polyfrost/hytils/handlers/game/housing/HousingMusic.java @@ -20,17 +20,18 @@ import net.hypixel.data.type.GameType; import org.polyfrost.hytils.config.HytilsConfig; +import org.polyfrost.oneconfig.api.event.v1.events.SoundPlayedEvent; import org.polyfrost.oneconfig.api.event.v1.invoke.impl.Subscribe; import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; public class HousingMusic { @Subscribe - public void onPlaySound(PlaySoundEvent event) { // TODO + public void onPlaySound(SoundPlayedEvent event) { if (HypixelUtils.isHypixel() && HytilsConfig.muteHousingMusic) { HypixelUtils.Location location = HypixelUtils.getLocation(); - if (location.getGameType().orElse(null) == GameType.HOUSING && event.name.startsWith("note.")) { - event.result = null; + if (location.getGameType().orElse(null) == GameType.HOUSING && event.getName().startsWith("note.")) { + event.setSound(null); } } } diff --git a/src/main/java/org/polyfrost/hytils/handlers/game/miniwalls/MiddleBeaconMiniWalls.java b/src/main/java/org/polyfrost/hytils/handlers/game/miniwalls/MiddleBeaconMiniWalls.java index e641085..45eac67 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/game/miniwalls/MiddleBeaconMiniWalls.java +++ b/src/main/java/org/polyfrost/hytils/handlers/game/miniwalls/MiddleBeaconMiniWalls.java @@ -23,6 +23,7 @@ import org.polyfrost.hytils.util.WaypointUtil; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumChatFormatting; +import org.polyfrost.oneconfig.api.event.v1.events.PostWorldRenderEvent; import org.polyfrost.oneconfig.api.event.v1.events.WorldLoadEvent; import org.polyfrost.oneconfig.api.event.v1.invoke.impl.Subscribe; import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; @@ -48,8 +49,8 @@ public boolean shouldMakeBeacon() { } @Subscribe - public void onRenderWorldLast(RenderWorldLastEvent event) { // TODO + public void onRenderWorldLast(PostWorldRenderEvent event) { // TODO if (!shouldMakeBeacon()) return; - WaypointUtil.renderBeaconBeam(block, HytilsConfig.miniWallsMiddleBeaconColor, event.partialTicks); + WaypointUtil.renderBeaconBeam(block, HytilsConfig.miniWallsMiddleBeaconColor, event.getPartialTicks()); } } diff --git a/src/main/java/org/polyfrost/hytils/handlers/game/pit/PitLagReducer.java b/src/main/java/org/polyfrost/hytils/handlers/game/pit/PitLagReducer.java index 4333e69..07cc524 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/game/pit/PitLagReducer.java +++ b/src/main/java/org/polyfrost/hytils/handlers/game/pit/PitLagReducer.java @@ -19,10 +19,12 @@ package org.polyfrost.hytils.handlers.game.pit; import net.hypixel.data.type.GameType; +import net.minecraft.entity.Entity; import org.polyfrost.hytils.config.HytilsConfig; import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.item.EntityArmorStand; +import org.polyfrost.oneconfig.api.event.v1.events.RenderLivingEntityEvent; import org.polyfrost.oneconfig.api.event.v1.events.WorldLoadEvent; import org.polyfrost.oneconfig.api.event.v1.invoke.impl.Subscribe; import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; @@ -39,7 +41,7 @@ public void onWorldLoad(WorldLoadEvent event) { } @Subscribe(priority = 5) - public void onRenderLiving(RenderLivingEvent.Pre event) { // TODO + public void onRenderLiving(RenderLivingEntityEvent.Pre event) { // TODO if (!HypixelUtils.isHypixel()) { return; } @@ -49,14 +51,19 @@ public void onRenderLiving(RenderLivingEvent.Pre event) { // TODO return; } + Entity entity = (Entity) event.getEntity(); + if (!(entity instanceof EntityLiving)) { + return; + } + if (pitSpawnPos == -1) { // Update the spawn position by finding an armor stand in spawn. - if (event.entity instanceof EntityArmorStand && event.entity.getName().equals("§a§lJUMP! §c§lFIGHT!")) { - pitSpawnPos = event.entity.posY - 5; + if (entity instanceof EntityArmorStand && entity.getName().equals("§a§lJUMP! §c§lFIGHT!")) { + pitSpawnPos = entity.posY - 5; } } else if (HytilsConfig.pitLagReducer) { // If the entity being rendered is at spawn, and you are below spawn, cancel the rendering. - if (event.entity.posY > pitSpawnPos && Minecraft.getMinecraft().thePlayer.posY < pitSpawnPos) { + if (entity.posY > pitSpawnPos && Minecraft.getMinecraft().thePlayer.posY < pitSpawnPos) { event.cancelled = true; } } diff --git a/src/main/java/org/polyfrost/hytils/handlers/game/uhc/MiddleWaypointUHC.java b/src/main/java/org/polyfrost/hytils/handlers/game/uhc/MiddleWaypointUHC.java index c975ae7..fa64989 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/game/uhc/MiddleWaypointUHC.java +++ b/src/main/java/org/polyfrost/hytils/handlers/game/uhc/MiddleWaypointUHC.java @@ -22,6 +22,7 @@ import org.polyfrost.hytils.config.HytilsConfig; import org.polyfrost.hytils.util.WaypointUtil; import net.minecraft.util.BlockPos; +import org.polyfrost.oneconfig.api.event.v1.events.PostWorldRenderEvent; import org.polyfrost.oneconfig.api.event.v1.invoke.impl.Subscribe; import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; @@ -30,10 +31,10 @@ public class MiddleWaypointUHC { private final BlockPos block = new BlockPos(0,70,0); @Subscribe - public void onRenderWorldLast(RenderWorldLastEvent event) { // TODO + public void onRenderWorldLast(PostWorldRenderEvent event) { // TODO HypixelUtils.Location location = HypixelUtils.getLocation(); if (HypixelUtils.isHypixel() && location.inGame() && HytilsConfig.uhcMiddleWaypoint && location.getGameType().isPresent() && (location.getGameType().get() == GameType.UHC || location.getGameType().get() == GameType.SPEED_UHC)) { - WaypointUtil.renderWayPoint(HytilsConfig.uhcMiddleWaypointText, block, event.partialTicks); + WaypointUtil.renderWayPoint(HytilsConfig.uhcMiddleWaypointText, block, event.getPartialTicks()); } } } diff --git a/src/main/java/org/polyfrost/hytils/handlers/general/SoundHandler.java b/src/main/java/org/polyfrost/hytils/handlers/general/SoundHandler.java index b91f7c6..326f5c9 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/general/SoundHandler.java +++ b/src/main/java/org/polyfrost/hytils/handlers/general/SoundHandler.java @@ -39,7 +39,7 @@ public void onTick(TickEvent.Start e) { case BUILD_BATTLE: case HOUSING: case SKYBLOCK: return; } - if (Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem() != null && Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getItem() instanceof ItemBlock && !(((ItemBlock) Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getItem()).block instanceof BlockTNT) && Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().stackSize <= HytilsConfig.blockNumber && Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().stackSize > 4) { + if (Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem() != null && Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getItem() instanceof ItemBlock && !(((ItemBlock) Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getItem()).getBlock() instanceof BlockTNT) && Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().stackSize <= HytilsConfig.blockNumber && Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().stackSize > 4) { ticks++; if (ticks == 0) { playSound(); diff --git a/src/main/java/org/polyfrost/hytils/handlers/lobby/armorstands/ArmorStandHider.java b/src/main/java/org/polyfrost/hytils/handlers/lobby/armorstands/ArmorStandHider.java index 725aa85..e451f15 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/lobby/armorstands/ArmorStandHider.java +++ b/src/main/java/org/polyfrost/hytils/handlers/lobby/armorstands/ArmorStandHider.java @@ -24,16 +24,24 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.util.EnumChatFormatting; +import org.polyfrost.oneconfig.api.event.v1.events.RenderLivingEntityEvent; import org.polyfrost.oneconfig.api.event.v1.invoke.impl.Subscribe; import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; public class ArmorStandHider { + @Subscribe - public void onEntityRenderer(RenderLivingEvent.Pre event) { // TODO + public void onEntityRenderer(RenderLivingEntityEvent.Pre event) { + Object entityRaw = event.getEntity(); + if (!(entityRaw instanceof EntityLivingBase)) { + return; + } + + EntityLivingBase entity = (EntityLivingBase) entityRaw; final HypixelUtils.Location location = HypixelUtils.getLocation(); if (HypixelUtils.isHypixel() && ((!location.inGame() && HytilsConfig.hideUselessArmorStands) || (HytilsConfig.hideUselessArmorStandsGame && location.inGame() && location.getGameType().isPresent() && (location.getGameType().get() == GameType.SKYBLOCK || location.getGameType().get() == GameType.BEDWARS || location.getGameType().get() == GameType.SKYWARS || location.getMode().orElse("").contains("BRIDGE"))))) { - if (event.entity instanceof EntityArmorStand) { - String unformattedArmorStandName = EnumChatFormatting.getTextWithoutFormattingCodes(event.entity.getCustomNameTag().toLowerCase()); + if (entity instanceof EntityArmorStand) { + String unformattedArmorStandName = EnumChatFormatting.getTextWithoutFormattingCodes(entity.getCustomNameTag().toLowerCase()); for (String armorStands : ArmorStandHandler.INSTANCE.armorStandNames) { if (unformattedArmorStandName.contains(armorStands)) { event.cancelled = true; @@ -43,4 +51,5 @@ public void onEntityRenderer(RenderLivingEvent.Pre event) { // } } } + } diff --git a/src/main/java/org/polyfrost/hytils/handlers/lobby/limbo/LimboLimiter.java b/src/main/java/org/polyfrost/hytils/handlers/lobby/limbo/LimboLimiter.java index c40525e..305194b 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/lobby/limbo/LimboLimiter.java +++ b/src/main/java/org/polyfrost/hytils/handlers/lobby/limbo/LimboLimiter.java @@ -23,6 +23,7 @@ import net.minecraft.client.Minecraft; import org.lwjgl.opengl.Display; import org.polyfrost.oneconfig.api.event.v1.events.TickEvent; +import org.polyfrost.oneconfig.api.event.v1.events.WorldUnloadEvent; import org.polyfrost.oneconfig.api.event.v1.invoke.impl.Subscribe; import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; @@ -41,7 +42,7 @@ public void onTick(TickEvent event) { } @Subscribe - public void onWorldChange(WorldEvent.Unload event) { // TODO + public void onWorldChange(WorldUnloadEvent event) { // TODO limboStatus = false; DefaultChatRestyler.reset(); // putting this here so we don't have to make a new event class just to do this } diff --git a/src/main/java/org/polyfrost/hytils/handlers/lobby/npc/NPCHandler.java b/src/main/java/org/polyfrost/hytils/handlers/lobby/npc/NPCHandler.java index cc185f1..1426e3e 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/lobby/npc/NPCHandler.java +++ b/src/main/java/org/polyfrost/hytils/handlers/lobby/npc/NPCHandler.java @@ -26,6 +26,7 @@ import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.client.entity.EntityOtherPlayerMP; +import org.polyfrost.oneconfig.api.event.v1.events.RenderLivingEntityEvent; import org.polyfrost.oneconfig.api.event.v1.invoke.impl.Subscribe; import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; @@ -34,18 +35,24 @@ public class NPCHandler { @Subscribe - public void onEntityRender(RenderLivingEvent.Pre event) { // TODO + public void onEntityRender(RenderLivingEntityEvent.Pre event) { + Object entityRaw = event.getEntity(); + if (!(entityRaw instanceof EntityLivingBase)) { + return; + } + + EntityLivingBase entity = (EntityLivingBase) entityRaw; if (!HypixelUtils.isHypixel()) { return; } final HypixelUtils.Location location = HypixelUtils.getLocation(); // hypixel marks npc uuids as version 2 - if (event.entity.getUniqueID().version() == 2 || (event.entity instanceof EntityVillager)) { + if (entity.getUniqueID().version() == 2 || (entity instanceof EntityVillager)) { if (HytilsConfig.npcHider && !location.inGame()) { event.cancelled = true; } - } else if (HytilsConfig.hideNonNPCs && location.getGameType().orElse(null) == GameType.SKYBLOCK && !(event.entity instanceof EntityArmorStand && !event.entity.getCustomNameTag().toLowerCase().trim().isEmpty()) && event.entity instanceof EntityOtherPlayerMP) { + } else if (HytilsConfig.hideNonNPCs && location.getGameType().orElse(null) == GameType.SKYBLOCK && !(entity instanceof EntityArmorStand && !entity.getCustomNameTag().toLowerCase().trim().isEmpty()) && entity instanceof EntityOtherPlayerMP) { event.cancelled = true; } } diff --git a/src/main/java/org/polyfrost/hytils/handlers/lobby/sound/SilentLobby.java b/src/main/java/org/polyfrost/hytils/handlers/lobby/sound/SilentLobby.java index 9474c97..c56d98b 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/lobby/sound/SilentLobby.java +++ b/src/main/java/org/polyfrost/hytils/handlers/lobby/sound/SilentLobby.java @@ -19,16 +19,17 @@ package org.polyfrost.hytils.handlers.lobby.sound; import org.polyfrost.hytils.config.HytilsConfig; +import org.polyfrost.oneconfig.api.event.v1.events.SoundPlayedEvent; import org.polyfrost.oneconfig.api.event.v1.invoke.impl.Subscribe; import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; public class SilentLobby { @Subscribe - public void onSoundPlay(PlaySoundEvent event) { // TODO + public void onSoundPlay(SoundPlayedEvent event) { // TODO if (HypixelUtils.isHypixel() && !HypixelUtils.getLocation().inGame()) { - String sound = event.name; + String sound = event.getName(); if (HytilsConfig.silentLobby && !sound.startsWith("gui.")) { - event.result = null; + event.setSound(null); } else { /* This code is taken from LobbySounds by Sk1er LLC under the GPL License: @@ -36,75 +37,75 @@ public void onSoundPlay(PlaySoundEvent event) { // TODO Only changes to adapt to this project have been made, as well as additions. */ if (sound.startsWith("step.") && HytilsConfig.lobbyDisableSteppingSounds) { - event.result = null; + event.setSound(null); } if (sound.startsWith("mob.slime") && HytilsConfig.lobbyDisableSlimeSounds) { - event.result = null; + event.setSound(null); } if (sound.startsWith("mob.enderdragon") && HytilsConfig.lobbyDisableDragonSounds) { - event.result = null; + event.setSound(null); } if ((sound.startsWith("mob.wither") || sound.startsWith("mob.skeleton")) && HytilsConfig.lobbyDisableWitherSounds) { - event.result = null; + event.setSound(null); } if (sound.equals("random.orb") && HytilsConfig.lobbyDisableExperienceOrbSounds) { - event.result = null; + event.setSound(null); } if (sound.equals("random.pop") && HytilsConfig.lobbyDisableItemPickupSounds) { - event.result = null; + event.setSound(null); } if (sound.equals("game.tnt.primed") && HytilsConfig.lobbyDisablePrimedTntSounds) { - event.result = null; + event.setSound(null); } if (sound.equals("random.explode") && HytilsConfig.lobbyDisableExplosionSounds) { - event.result = null; + event.setSound(null); } if (sound.equals("mob.chicken.plop") && HytilsConfig.lobbyDisableDeliveryManSounds) { - event.result = null; + event.setSound(null); } if ((sound.startsWith("note.") || sound.equals("random.click")) && HytilsConfig.lobbyDisableNoteBlockSounds) { - event.result = null; + event.setSound(null); } if (sound.startsWith("fireworks") && HytilsConfig.lobbyDisableFireworkSounds) { - event.result = null; + event.setSound(null); } if (sound.equals("random.levelup") && HytilsConfig.lobbyDisableLevelupSounds) { - event.result = null; + event.setSound(null); } if (sound.startsWith("mob.bat") && HytilsConfig.lobbyDisableBatSounds) { - event.result = null; + event.setSound(null); } if (sound.equals("fire.fire") && HytilsConfig.lobbyDisableFireSounds) { - event.result = null; + event.setSound(null); } if (sound.startsWith("mob.endermen") && HytilsConfig.lobbyDisableEndermanSounds) { - event.result = null; + event.setSound(null); } if (sound.startsWith("random.bow") && HytilsConfig.lobbyDisableArrowSounds) { - event.result = null; + event.setSound(null); } if (sound.startsWith("random.door") && HytilsConfig.lobbyDisableDoorSounds) { - event.result = null; + event.setSound(null); } if (sound.startsWith("portal.portal") && HytilsConfig.lobbyDisablePortalSounds) { - event.result = null; + event.setSound(null); } } } diff --git a/src/main/java/org/polyfrost/hytils/handlers/render/ChestHighlighter.java b/src/main/java/org/polyfrost/hytils/handlers/render/ChestHighlighter.java index 8ad7ea7..407ebf1 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/render/ChestHighlighter.java +++ b/src/main/java/org/polyfrost/hytils/handlers/render/ChestHighlighter.java @@ -19,6 +19,10 @@ package org.polyfrost.hytils.handlers.render; import net.hypixel.data.type.GameType; +import net.minecraft.world.World; +import org.polyfrost.oneconfig.api.event.v1.events.PlayerInteractEvent; +import org.polyfrost.oneconfig.api.event.v1.events.PostWorldRenderEvent; +import org.polyfrost.oneconfig.api.event.v1.events.WorldUnloadEvent; import org.polyfrost.oneconfig.api.event.v1.invoke.impl.Subscribe; import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; import org.polyfrost.hytils.config.HytilsConfig; @@ -29,6 +33,7 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumChatFormatting; import org.polyfrost.hytils.util.WaypointUtil; +import org.polyfrost.universal.UMinecraft; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -37,22 +42,37 @@ public class ChestHighlighter { private final List highlightedChestPositions = new CopyOnWriteArrayList<>(); @Subscribe - public void onInteract(PlayerInteractEvent event) { // TODO - if (!HytilsConfig.highlightChests) return; - if (isNotSupported()) return; - if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { - TileEntity tile = event.world.getTileEntity(event.pos); - if (tile instanceof TileEntityChest && !highlightedChestPositions.contains(event.pos)) - highlightedChestPositions.add(event.pos); - } else if (event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) { - TileEntity tile = event.world.getTileEntity(event.pos); - if (tile instanceof TileEntityChest) - highlightedChestPositions.remove(event.pos); + public void onInteract(PlayerInteractEvent event) { + if (!HytilsConfig.highlightChests || event.getType() != PlayerInteractEvent.Type.BLOCK || isNotSupported()) { + return; + } + + World world = UMinecraft.getWorld(); + if (world == null) { + return; // Should never happen + } + + BlockPos pos = UMinecraft.getMinecraft().objectMouseOver.getBlockPos(); + TileEntity tile = world.getTileEntity(pos); + if (!(tile instanceof TileEntityChest)) { + return; + } + + switch (event.getAction()) { + case RIGHT: + if (!highlightedChestPositions.contains(pos)) { + highlightedChestPositions.add(pos); + } + + break; + case LEFT: + highlightedChestPositions.remove(pos); + break; } } @Subscribe - public void onWorldChange(WorldEvent.Unload event) { // TODO + public void onWorldChange(WorldUnloadEvent event) { highlightedChestPositions.clear(); } @@ -64,7 +84,7 @@ public void onTitle(TitleEvent event) { } @Subscribe - public void onWorldRendered(RenderWorldLastEvent event) { // TODO + public void onWorldRendered(PostWorldRenderEvent event) { if (!HytilsConfig.highlightChests) return; if (isNotSupported()) return; if (highlightedChestPositions.isEmpty()) diff --git a/src/main/java/org/polyfrost/hytils/mixin/cosmetics/RenderEntityItemMixin.java b/src/main/java/org/polyfrost/hytils/mixin/cosmetics/RenderEntityItemMixin.java index eb55ab8..45a04f4 100644 --- a/src/main/java/org/polyfrost/hytils/mixin/cosmetics/RenderEntityItemMixin.java +++ b/src/main/java/org/polyfrost/hytils/mixin/cosmetics/RenderEntityItemMixin.java @@ -43,7 +43,7 @@ public class RenderEntityItemMixin { if ((HytilsConfig.hideDuelsCosmetics && HypixelUtils.getLocation().getGameType().orElse(null) == GameType.DUELS) || (HytilsConfig.hideArcadeCosmetics && HypixelUtils.getLocation().getGameType().orElse(null) == GameType.ARCADE) && HypixelUtils.getLocation().inGame() && - (stack.getItem() instanceof ItemDoublePlant || stack.getItem() instanceof ItemDye || stack.getItem() instanceof ItemRecord || hytils$shouldRemove(stack.getItem().getUnlocalizedName()) || (stack.getItem() instanceof ItemBlock && (hytils$shouldRemove(((ItemBlock) stack.getItem()).block.getUnlocalizedName()) || ((ItemBlock) stack.getItem()).block instanceof BlockPumpkin)))) ci.cancel(); + (stack.getItem() instanceof ItemDoublePlant || stack.getItem() instanceof ItemDye || stack.getItem() instanceof ItemRecord || hytils$shouldRemove(stack.getItem().getUnlocalizedName()) || (stack.getItem() instanceof ItemBlock && (hytils$shouldRemove(((ItemBlock) stack.getItem()).getBlock().getUnlocalizedName()) || ((ItemBlock) stack.getItem()).getBlock() instanceof BlockPumpkin)))) ci.cancel(); } @Unique diff --git a/src/main/java/org/polyfrost/hytils/mixin/overlay/VertexLighterFlatMixin.java b/src/main/java/org/polyfrost/hytils/mixin/overlay/VertexLighterFlatMixin.java index 4ece1c1..5ec31af 100644 --- a/src/main/java/org/polyfrost/hytils/mixin/overlay/VertexLighterFlatMixin.java +++ b/src/main/java/org/polyfrost/hytils/mixin/overlay/VertexLighterFlatMixin.java @@ -18,6 +18,7 @@ package org.polyfrost.hytils.mixin.overlay; +//#if FORGE import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; import org.polyfrost.hytils.config.HytilsConfig; import org.polyfrost.hytils.util.DarkColorUtils; @@ -72,3 +73,4 @@ public class VertexLighterFlatMixin { } } +//#endif diff --git a/src/main/java/org/polyfrost/hytils/util/WaypointUtil.java b/src/main/java/org/polyfrost/hytils/util/WaypointUtil.java index c155aef..0fa1e88 100644 --- a/src/main/java/org/polyfrost/hytils/util/WaypointUtil.java +++ b/src/main/java/org/polyfrost/hytils/util/WaypointUtil.java @@ -34,6 +34,7 @@ import net.minecraft.util.*; import org.lwjgl.opengl.GL11; import org.lwjgl.util.vector.Vector3f; +import org.polyfrost.oneconfig.api.event.v1.events.PostWorldRenderEvent; import org.polyfrost.polyui.color.PolyColor; /** @@ -213,11 +214,11 @@ public static void drawFilledBoundingBox(AxisAlignedBB boundingBox, PolyColor co tessellator.draw(); } - public static void drawBoundingBox(RenderWorldLastEvent event, BlockPos pos, PolyColor color) { // TODO + public static void drawBoundingBox(PostWorldRenderEvent event, BlockPos pos, PolyColor color) { Entity viewer = Minecraft.getMinecraft().getRenderViewEntity(); - double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks; - double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks; - double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks; + double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.getPartialTicks(); + double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.getPartialTicks(); + double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.getPartialTicks(); double x = pos.getX() - viewerX; double y = pos.getY() - viewerY;