From 938f9f5cd7e8e9c156e64a797551583bbca8c88f Mon Sep 17 00:00:00 2001 From: ev chang Date: Sun, 30 Jun 2024 02:23:17 +0900 Subject: [PATCH] more porting (it builds now!) --- build.gradle.kts | 15 +- .../org/polyfrost/hytils/HytilsReborn.java | 12 +- .../hytils/command/HousingVisitCommand.java | 8 +- .../hytils/command/HytilsCommand.java | 7 +- .../command/IgnoreTemporaryCommand.java | 6 +- .../hytils/command/LimboCommand.java | 3 +- .../polyfrost/hytils/command/PlayCommand.java | 7 +- .../hytils/command/RequeueCommand.java | 63 +++-- .../hytils/command/SilentRemoveCommand.java | 13 +- .../hytils/command/SkyblockVisitCommand.java | 22 +- .../hytils/command/parser/GameNameParser.java | 6 +- .../hytils/config/BlockHighlightConfig.java | 233 +++++++++--------- .../polyfrost/hytils/config/HytilsConfig.java | 63 ++--- .../handlers/cache/ArmorStandHandler.java | 6 +- .../handlers/cache/BedLocationHandler.java | 22 +- .../handlers/cache/CosmeticsHandler.java | 6 +- .../hytils/handlers/cache/HeightHandler.java | 12 +- .../handlers/cache/LocrawGamesHandler.java | 2 +- .../hytils/handlers/cache/PatternHandler.java | 4 +- .../hytils/handlers/chat/ChatHandler.java | 5 +- .../chat/modules/blockers/AdBlocker.java | 4 +- .../chat/modules/blockers/AntiGL.java | 4 +- .../BedwarsAdvertisementsRemover.java | 6 +- .../chat/modules/blockers/ShoutBlocker.java | 6 +- .../blockers/TicketMachineRemover.java | 6 +- .../modules/triggers/AutoChatSwapper.java | 2 +- .../chat/modules/triggers/AutoQueue.java | 4 +- .../chat/modules/triggers/AutoVictory.java | 10 +- .../chat/modules/triggers/SilentRemoval.java | 2 +- .../game/dropper/DropperHurtSound.java | 6 +- .../game/duels/SumoRenderDistance.java | 6 +- .../handlers/game/housing/HousingMusic.java | 6 +- .../game/miniwalls/MiddleBeaconMiniWalls.java | 6 +- .../handlers/game/pit/PitLagReducer.java | 6 +- .../handlers/game/titles/CountdownTitles.java | 4 +- .../game/titles/GameEndingTitles.java | 4 +- .../game/titles/GameStartingTitles.java | 4 +- .../handlers/game/uhc/MiddleWaypointUHC.java | 6 +- .../hytils/handlers/general/SoundHandler.java | 8 +- .../handlers/language/LanguageHandler.java | 12 +- .../lobby/armorstands/ArmorStandHider.java | 6 +- .../handlers/lobby/limbo/LimboLimiter.java | 6 +- .../handlers/lobby/limbo/LimboPmDing.java | 6 +- .../hytils/handlers/lobby/npc/NPCHandler.java | 12 +- .../handlers/lobby/sound/SilentLobby.java | 4 +- .../hytils/handlers/lobby/tab/TabChanger.java | 23 +- .../handlers/render/ChestHighlighter.java | 4 +- .../hytils/hooks/BlockModelRendererHook.java | 5 +- .../mixin/BossStatusMixin_HideBossbar.java | 4 +- .../EntityLivingBaseMixin_MiningFatigue.java | 4 +- .../GuiIngameForgeMixin_HideActionbar.java | 4 +- .../mixin/GuiIngameForgeMixin_HideHotbar.java | 29 +-- .../mixin/GuiIngameForgeMixin_TitleEvent.java | 4 +- .../mixin/GuiNewChatMixin_LocrawHider.java | 4 +- .../LayerArmorBaseMixin_HideIngameArmour.java | 6 +- .../RenderEntityItemMixin_UHCOverlay.java | 6 +- .../cosmetics/RenderEntityItemMixin.java | 6 +- .../hytils/mixin/cosmetics/WorldMixin.java | 6 +- .../mixin/overlay/VertexLighterFlatMixin.java | 4 +- .../hytils/util/HypixelAPIUtils.java | 66 +++-- .../hytils/util/friends/FriendCache.java | 5 +- 61 files changed, 425 insertions(+), 416 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 76dfae8..86f7f2d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -93,18 +93,19 @@ sourceSets { // Adds the Polyfrost maven repository so that we can get the libraries necessary to develop the mod. repositories { - mavenLocal() + maven("https://repo.polyfrost.org/snapshots") maven("https://repo.polyfrost.org/releases") } // Configures the libraries/dependencies for your mod. dependencies { // Adds the OneConfig library, so we can develop with it. - compileOnly("org.polyfrost.oneconfig:config-impl:1.0.0-alpha7") - compileOnly("org.polyfrost.oneconfig:commands:1.0.0-alpha7") - compileOnly("org.polyfrost.oneconfig:events:1.0.0-alpha7") - compileOnly("org.polyfrost.oneconfig:ui:1.0.0-alpha7") - modCompileOnly("org.polyfrost.oneconfig:$platform:1.0.0-alpha7") + compileOnly("org.polyfrost.oneconfig:config-impl:1.0.0-alpha.14") + compileOnly("org.polyfrost.oneconfig:commands:1.0.0-alpha.14") + compileOnly("org.polyfrost.oneconfig:events:1.0.0-alpha.14") + compileOnly("org.polyfrost.oneconfig:ui:1.0.0-alpha.14") + modCompileOnly("org.polyfrost.oneconfig:$platform:1.0.0-alpha.14") + modRuntimeOnly("me.djtheredstoner:DevAuth-${if (platform.isFabric) "fabric" else if (platform.isLegacyForge) "forge-legacy" else "forge-latest"}:1.1.2") @@ -181,7 +182,7 @@ tasks { // Configures our shadow/shade configuration, so we can // include some dependencies within our mod jar file. named("shadowJar") { - archiveClassifier.set("dev") // TODO: machete gets confused by the `dev` prefix. + archiveClassifier.set("dev") configurations = listOf(shade) duplicatesStrategy = DuplicatesStrategy.EXCLUDE diff --git a/src/main/java/org/polyfrost/hytils/HytilsReborn.java b/src/main/java/org/polyfrost/hytils/HytilsReborn.java index 6043ac2..0c38262 100644 --- a/src/main/java/org/polyfrost/hytils/HytilsReborn.java +++ b/src/main/java/org/polyfrost/hytils/HytilsReborn.java @@ -18,8 +18,6 @@ package org.polyfrost.hytils; -import org.polyfrost.oneconfig.api.config.v1.ConfigManager; -import org.polyfrost.oneconfig.api.event.v1.EventManager; import org.polyfrost.oneconfig.api.ui.v1.notifications.Notifications; import org.polyfrost.universal.ChatColor; import org.polyfrost.universal.UChat; @@ -124,6 +122,7 @@ public void init(FMLInitializationEvent event) { BedLocationHandler.INSTANCE.initialize(); LocrawGamesHandler.INSTANCE.initialize(); HeightHandler.INSTANCE.initialize(); + new HypixelAPIUtils().initialize(); registerHandlers(); } @@ -142,13 +141,13 @@ public void postInit(FMLPostInitializationEvent event) { isChatting = false; if (HytilsConfig.chattingIntegration) { HytilsConfig.chattingIntegration = false; - ConfigManager.active().save(config.getTree()); + config.save(); Notifications.INSTANCE.send("Hytils Reborn", "Hytils Reborn has detected Chatting, but it is not the latest version. Please update Chatting to the latest version."); } } } - Multithreading.runAsync(() -> rank = HypixelAPIUtils.getRank(Minecraft.getMinecraft().getSession().getUsername())); + Multithreading.submit(() -> rank = HypixelAPIUtils.getRank(Minecraft.getMinecraft().getSession().getUsername())); } @Mod.EventHandler @@ -192,11 +191,6 @@ private void registerHandlers() { eventBus.register(new MiddleBeaconMiniWalls()); eventBus.register(new MiddleWaypointUHC()); eventBus.register(new DropperHurtSound()); - - // height overlay - EventManager.INSTANCE.register(HeightHandler.INSTANCE); - - eventBus.register(new HypixelAPIUtils()); } public void sendMessage(String message) { diff --git a/src/main/java/org/polyfrost/hytils/command/HousingVisitCommand.java b/src/main/java/org/polyfrost/hytils/command/HousingVisitCommand.java index 2a62fcc..3d7a208 100644 --- a/src/main/java/org/polyfrost/hytils/command/HousingVisitCommand.java +++ b/src/main/java/org/polyfrost/hytils/command/HousingVisitCommand.java @@ -20,7 +20,7 @@ import net.hypixel.data.type.GameType; import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Parameter; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.universal.ChatColor; import org.polyfrost.universal.UChat; import org.polyfrost.oneconfig.utils.v1.Multithreading; @@ -55,7 +55,7 @@ private void main() { @Command(description = "Visits a player's house in Housing.") private void main(@Parameter("Player Name") GameProfile player) { - if (!HypixelUtils.INSTANCE.isHypixel()) { + if (!HypixelUtils.isHypixel()) { UChat.chat(ChatColor.RED + "You must be on Hypixel to use this command!"); return; } @@ -63,9 +63,9 @@ private void main(@Parameter("Player Name") GameProfile player) { playerName = player.getName(); // if we are in the housing lobby, just immediately run the /visit command - HypixelAPI.Location location = HypixelAPI.getLocation(); + HypixelUtils.Location location = HypixelUtils.getLocation(); Optional gameType = location.getGameType(); - if (gameType.isPresent() && gameType.get() == GameType.HOUSING && !location.isGame()) { + if (gameType.isPresent() && gameType.get() == GameType.HOUSING && !location.inGame()) { visit(0); } else { HytilsReborn.INSTANCE.getCommandQueue().queue("/l housing"); diff --git a/src/main/java/org/polyfrost/hytils/command/HytilsCommand.java b/src/main/java/org/polyfrost/hytils/command/HytilsCommand.java index f6d7e0f..ad5b54f 100644 --- a/src/main/java/org/polyfrost/hytils/command/HytilsCommand.java +++ b/src/main/java/org/polyfrost/hytils/command/HytilsCommand.java @@ -43,13 +43,14 @@ public class HytilsCommand { @Command private void main() { - HytilsReborn.INSTANCE.getConfig().openGui(); + //TODO + //HytilsReborn.INSTANCE.getConfig().openGui(); } @Command(value = {"guildexp", "guildexperience"}, description = "Shows your guild experience") @SuppressWarnings("SameParameterValue") private void gexp(@Parameter("Username") @Nullable GameProfile player, @Parameter("GEXP Type") @Nullable GEXPType type) { - Multithreading.runAsync(() -> { + Multithreading.submit(() -> { if (player != null) { if (type == null) { if (HypixelAPIUtils.getGEXP(player.getName())) { @@ -102,7 +103,7 @@ private void gexp(@Parameter("Username") @Nullable GameProfile player, @Paramete @Command(value = {"winstreak", "ws"}, description = "Shows your winstreak") @SuppressWarnings("SameParameterValue") private void winstreak(@Parameter("Username") @Nullable GameProfile player, @Parameter("Winstreak Type") @Nullable WinstreakType gamemode) { - Multithreading.runAsync(() -> { + Multithreading.submit(() -> { if (player != null) { if (gamemode != null) { if (HypixelAPIUtils.getWinstreak(player.getName(), gamemode.name())) { diff --git a/src/main/java/org/polyfrost/hytils/command/IgnoreTemporaryCommand.java b/src/main/java/org/polyfrost/hytils/command/IgnoreTemporaryCommand.java index fabf1cb..be41954 100644 --- a/src/main/java/org/polyfrost/hytils/command/IgnoreTemporaryCommand.java +++ b/src/main/java/org/polyfrost/hytils/command/IgnoreTemporaryCommand.java @@ -51,7 +51,7 @@ public class IgnoreTemporaryCommand { static { initialize(); - Multithreading.runAsync(() -> { + Multithreading.submit(() -> { Timer timer = new Timer(1, ignored -> { if (Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer != null) { if (json != null) { @@ -80,7 +80,7 @@ public class IgnoreTemporaryCommand { @Command(greedy = true) private void main(@Parameter("Player Name") GameProfile playerName, @Parameter("Time") String time) { - Multithreading.runAsync(() -> { + Multithreading.submit(() -> { try { long millis = addMillis(time.replace(",", "").replace(" ", "")); json.addProperty(playerName.getName(), millis + new Date().getTime()); @@ -106,7 +106,7 @@ private void add(@Parameter("Player Name") GameProfile playerName, @Parameter("T @Command(description = "Removes a player from the ignore list.") private void remove(@Parameter("Player Name") GameProfile playerName) { json.remove(playerName.getName()); - Multithreading.runAsync(() -> { + Multithreading.submit(() -> { try { FileUtils.writeStringToFile(ignoreFile, json.toString(), StandardCharsets.UTF_8); } catch (IOException e) { diff --git a/src/main/java/org/polyfrost/hytils/command/LimboCommand.java b/src/main/java/org/polyfrost/hytils/command/LimboCommand.java index ad218c2..80362a9 100644 --- a/src/main/java/org/polyfrost/hytils/command/LimboCommand.java +++ b/src/main/java/org/polyfrost/hytils/command/LimboCommand.java @@ -18,6 +18,7 @@ package org.polyfrost.hytils.command; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.universal.ChatColor; import org.polyfrost.universal.UChat; import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command; @@ -27,7 +28,7 @@ public class LimboCommand { @Command(description = "Sends you to limbo.") private void main() { - if (HypixelUtils.INSTANCE.isHypixel()) { + if (HypixelUtils.isHypixel()) { Minecraft.getMinecraft().thePlayer.sendChatMessage("§"); } else { UChat.chat(ChatColor.RED + "You must be on Hypixel to use this command."); diff --git a/src/main/java/org/polyfrost/hytils/command/PlayCommand.java b/src/main/java/org/polyfrost/hytils/command/PlayCommand.java index 8874cfa..e2bbe2d 100644 --- a/src/main/java/org/polyfrost/hytils/command/PlayCommand.java +++ b/src/main/java/org/polyfrost/hytils/command/PlayCommand.java @@ -18,14 +18,13 @@ package org.polyfrost.hytils.command; - +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.universal.ChatColor; import org.polyfrost.universal.UChat; import org.polyfrost.oneconfig.utils.v1.Multithreading; import org.polyfrost.oneconfig.utils.v1.NetworkUtils; import org.polyfrost.oneconfig.api.commands.v1.CommandManager; import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command; -import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; import org.polyfrost.hytils.HytilsReborn; import org.polyfrost.hytils.command.parser.GameName; import org.polyfrost.hytils.command.parser.GameNameParser; @@ -46,7 +45,7 @@ public class PlayCommand { private static Map games = new HashMap<>(); public static void init() { - Multithreading.runAsync(() -> { + Multithreading.submit(() -> { try { String url = "https://data.woverflow.cc/games.json"; String content = NetworkUtils.getString(url); @@ -66,7 +65,7 @@ public static void init() { @Command private void main(GameName game) { boolean autocompletePlayCommands = HytilsConfig.autocompletePlayCommands; - if (!HypixelUtils.INSTANCE.isHypixel()) { + if (!HypixelUtils.isHypixel()) { HytilsReborn.INSTANCE.getCommandQueue().queue("/play " + game.name); return; } diff --git a/src/main/java/org/polyfrost/hytils/command/RequeueCommand.java b/src/main/java/org/polyfrost/hytils/command/RequeueCommand.java index d31496e..a87b6d4 100644 --- a/src/main/java/org/polyfrost/hytils/command/RequeueCommand.java +++ b/src/main/java/org/polyfrost/hytils/command/RequeueCommand.java @@ -18,6 +18,8 @@ package org.polyfrost.hytils.command; +import net.hypixel.data.type.GameType; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.universal.ChatColor; import org.polyfrost.universal.UChat; import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command; @@ -33,31 +35,42 @@ public class RequeueCommand { @Command(description = "Requeues you into the last game you played.") private void main() { - LocrawInfo locraw = LocrawUtil.INSTANCE.getLocrawInfo(); - LocrawInfo lastLocraw = LocrawUtil.INSTANCE.getLastLocrawInfo(); - if (!HypixelUtils.INSTANCE.isHypixel() || locraw == null || lastLocraw == null) { + HypixelUtils.Location location = HypixelUtils.getLocation(); + if (!HypixelUtils.isHypixel()) { return; } - if (LocrawUtil.INSTANCE.isInGame()) { - game = locraw.getGameMode(); - switch (locraw.getGameType()) { - case SKYBLOCK: - case HOUSING: - case REPLAY: - UChat.chat(ChatColor.RED + "You must be in a valid game to use this command."); - return; + if (location.inGame()) { + game = location.getMode().orElse(null); + if (game == null) { + UChat.chat(ChatColor.RED + "You must be in a valid game to use this command."); + return; } - } else if (!LocrawUtil.INSTANCE.isInGame() && !lastLocraw.getGameMode().equals("lobby")) { - game = lastLocraw.getGameMode(); - switch (lastLocraw.getGameType()) { - case SKYBLOCK: - game = lastLocraw.getRawGameType(); // requeues you back into SkyBlock when you are in the lobby. Useful when you get kicked for being AFK. - break; - case HOUSING: - case REPLAY: - UChat.chat(ChatColor.RED + "The last round has to be a valid game to use this command."); - return; + if (location.getGameType().isPresent()) { + switch (location.getGameType().get()) { + case SKYBLOCK: + case HOUSING: + case REPLAY: + UChat.chat(ChatColor.RED + "You must be in a valid game to use this command."); + return; + } + } + } else if (!location.inGame() && location.wasInGame()) { + game = location.getLastMode().orElse(null); + if (game == null) { + UChat.chat(ChatColor.RED + "You must be in a valid game to use this command."); + return; + } + if (location.getLastGameType().isPresent()) { + switch (location.getLastGameType().get()) { + case SKYBLOCK: + game = GameType.SKYBLOCK.getDatabaseName(); // requeues you back into SkyBlock when you are in the lobby. Useful when you get kicked for being AFK. + break; + case HOUSING: + case REPLAY: + UChat.chat(ChatColor.RED + "The last round has to be a valid game to use this command."); + return; + } } } else { UChat.chat(ChatColor.RED + "The last round has to be a game to use this command."); @@ -65,9 +78,11 @@ private void main() { } // tries to get the game name from the LocrawGamesHandler, if it doesn't exist, it will use the game name from the LocrawInfo. - String value = LocrawGamesHandler.locrawGames.get(locraw.getRawGameType().toLowerCase() + "_" + game.toLowerCase()); - if (value != null) { - game = value; + if (location.getGameType().isPresent()) { + String value = LocrawGamesHandler.locrawGames.get(location.getGameType().get().getDatabaseName().toLowerCase() + "_" + game.toLowerCase()); + if (value != null) { + game = value; + } } // if the limboPlayCommandHelper is enabled and the player is in limbo, it will queue the /lobby command before the /play command. diff --git a/src/main/java/org/polyfrost/hytils/command/SilentRemoveCommand.java b/src/main/java/org/polyfrost/hytils/command/SilentRemoveCommand.java index 8b99a3f..9e83db0 100644 --- a/src/main/java/org/polyfrost/hytils/command/SilentRemoveCommand.java +++ b/src/main/java/org/polyfrost/hytils/command/SilentRemoveCommand.java @@ -18,12 +18,10 @@ package org.polyfrost.hytils.command; +import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Parameter; import org.polyfrost.universal.ChatColor; import org.polyfrost.universal.UChat; import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command; -import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Description; -import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Main; -import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.SubCommand; import org.polyfrost.hytils.handlers.chat.modules.triggers.SilentRemoval; import com.mojang.authlib.GameProfile; @@ -35,13 +33,12 @@ public class SilentRemoveCommand { protected static final Pattern usernameRegex = Pattern.compile("\\w{1,16}"); - @Main - public void handle() { + public void main() { UChat.chat(ChatColor.RED + "Usage: /silentremove "); } - @Main(description = "Adds or removes a player from the silent list.") - private void main(@Description("Player Name") GameProfile player) { + @Command(description = "Adds or removes a player from the silent list.") + private void main(@Parameter("Player Name") GameProfile player) { String name = player.getName(); if (!usernameRegex.matcher(name).matches()) { UChat.chat(ChatColor.RED + "Invalid username."); @@ -58,7 +55,7 @@ private void main(@Description("Player Name") GameProfile player) { UChat.chat("&aAdded &e" + name + " &ato the removal queue."); } - @SubCommand(description = "Clears the silent removal queue.") + @Command(description = "Clears the silent removal queue.") private void clear() { final Set silentUsers = SilentRemoval.getSilentUsers(); if (silentUsers.isEmpty()) { diff --git a/src/main/java/org/polyfrost/hytils/command/SkyblockVisitCommand.java b/src/main/java/org/polyfrost/hytils/command/SkyblockVisitCommand.java index f4ac3fb..f5f0013 100644 --- a/src/main/java/org/polyfrost/hytils/command/SkyblockVisitCommand.java +++ b/src/main/java/org/polyfrost/hytils/command/SkyblockVisitCommand.java @@ -18,15 +18,13 @@ package org.polyfrost.hytils.command; +import net.hypixel.data.type.GameType; +import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Parameter; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.universal.ChatColor; import org.polyfrost.universal.UChat; import org.polyfrost.oneconfig.utils.v1.Multithreading; import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command; -import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Description; -import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Main; -import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; -import org.polyfrost.oneconfig.api.hypixel.v1.LocrawInfo; -import org.polyfrost.oneconfig.api.hypixel.v1.LocrawUtil; import org.polyfrost.hytils.HytilsReborn; import com.mojang.authlib.GameProfile; import net.minecraft.util.EnumChatFormatting; @@ -37,7 +35,7 @@ import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; -@Command(value = "skyblockvisit", aliases = "sbvisit") +@Command({"skyblockvisit", "sbvisit"}) public class SkyblockVisitCommand { /** @@ -47,20 +45,20 @@ public class SkyblockVisitCommand { protected static String playerName = ""; - @Main - private void handle() { + @Command + private void main() { UChat.chat(EnumChatFormatting.RED + "Usage: /skyblockvisit "); } - @Main(description = "Visit a player's SkyBlock island.") - private void main(@Description("Player Name") GameProfile player) { - if (!HypixelUtils.INSTANCE.isHypixel()) { + @Command(description = "Visit a player's SkyBlock island.") + private void main(@Parameter("Player Name") GameProfile player) { + if (!HypixelUtils.isHypixel()) { UChat.chat(ChatColor.RED + "You must be on Hypixel to use this command!"); return; } if (usernameRegex.matcher(player.getName()).matches()) { playerName = player.getName(); - if (LocrawUtil.INSTANCE.getLocrawInfo() != null && LocrawUtil.INSTANCE.getLocrawInfo().getGameType() == LocrawInfo.GameType.SKYBLOCK && LocrawUtil.INSTANCE.isInGame()) { + if (GameType.SKYBLOCK.equals(HypixelUtils.getLocation().getGameType().orElse(null)) && HypixelUtils.getLocation().inGame()) { visit(0); return; } diff --git a/src/main/java/org/polyfrost/hytils/command/parser/GameNameParser.java b/src/main/java/org/polyfrost/hytils/command/parser/GameNameParser.java index b58a0f5..41e2107 100644 --- a/src/main/java/org/polyfrost/hytils/command/parser/GameNameParser.java +++ b/src/main/java/org/polyfrost/hytils/command/parser/GameNameParser.java @@ -19,13 +19,11 @@ package org.polyfrost.hytils.command.parser; import org.polyfrost.oneconfig.api.commands.v1.arguments.ArgumentParser; -import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.hytils.config.HytilsConfig; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.lang.reflect.Parameter; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -51,7 +49,7 @@ public Class getType() { @Override public @Nullable List getAutoCompletions(String game) { - if (!HypixelUtils.INSTANCE.isHypixel() || !HytilsConfig.autocompletePlayCommands) { + if (!HypixelUtils.isHypixel() || !HytilsConfig.autocompletePlayCommands) { return null; } return Stream.of(getListOfGames()).filter(s -> s.startsWith(game)).collect(Collectors.toList()); diff --git a/src/main/java/org/polyfrost/hytils/config/BlockHighlightConfig.java b/src/main/java/org/polyfrost/hytils/config/BlockHighlightConfig.java index 3c3710a..faec90d 100644 --- a/src/main/java/org/polyfrost/hytils/config/BlockHighlightConfig.java +++ b/src/main/java/org/polyfrost/hytils/config/BlockHighlightConfig.java @@ -27,122 +27,123 @@ import java.util.Map; import java.util.function.Supplier; +//TODO public class BlockHighlightConfig { - @Color( - title = "White", - category = "Colors" - ) - public static PolyColor white = ColorUtils.rgba(MapColor.snowColor.getMapColor(2)); - - @Color( - title = "Orange", - category = "Colors" - ) - public static PolyColor orange = ColorUtils.rgba(MapColor.adobeColor.getMapColor(2)); - - @Color( - title = "Magenta", - category = "Colors" - ) - public static PolyColor magenta = ColorUtils.rgba(MapColor.magentaColor.getMapColor(2)); - - @Color( - title = "Light Blue", - category = "Colors" - ) - public static PolyColor lightBlue = ColorUtils.rgba(MapColor.lightBlueColor.getMapColor(2)); - - @Color( - title = "Yellow", - category = "Colors" - ) - public static PolyColor yellow = ColorUtils.rgba(MapColor.yellowColor.getMapColor(2)); - - @Color( - title = "Lime", - category = "Colors" - ) - public static PolyColor lime = ColorUtils.rgba(MapColor.limeColor.getMapColor(2)); - - @Color( - title = "Pink", - category = "Colors" - ) - public static PolyColor pink = ColorUtils.rgba(MapColor.pinkColor.getMapColor(2)); - - @Color( - title = "Gray", - category = "Colors" - ) - public static PolyColor gray = ColorUtils.rgba(MapColor.grayColor.getMapColor(2)); - - @Color( - title = "Silver", - category = "Colors" - ) - public static PolyColor silver = ColorUtils.rgba(MapColor.silverColor.getMapColor(2)); - - @Color( - title = "Cyan", - category = "Colors" - ) - public static PolyColor cyan = ColorUtils.rgba(MapColor.cyanColor.getMapColor(2)); - - @Color( - title = "Purple", - category = "Colors" - ) - public static PolyColor purple = ColorUtils.rgba(MapColor.purpleColor.getMapColor(2)); - - @Color( - title = "Blue", - category = "Colors" - ) - public static PolyColor blue = ColorUtils.rgba(MapColor.blueColor.getMapColor(2)); - - @Color( - title = "Brown", - category = "Colors" - ) - public static PolyColor brown = ColorUtils.rgba(MapColor.brownColor.getMapColor(2)); - - @Color( - title = "Green", - category = "Colors" - ) - public static PolyColor green = ColorUtils.rgba(MapColor.greenColor.getMapColor(2)); - - @Color( - title = "Red", - category = "Colors" - ) - public static PolyColor red = ColorUtils.rgba(MapColor.redColor.getMapColor(2)); - - @Color( - title = "Black", - category = "Colors" - ) - public static PolyColor black = ColorUtils.rgba(MapColor.blackColor.getMapColor(2)); - - public BlockHighlightConfig() { - colorMap.putIfAbsent(MapColor.snowColor, () -> white); - colorMap.putIfAbsent(MapColor.adobeColor, () -> orange); - colorMap.putIfAbsent(MapColor.magentaColor, () -> magenta); - colorMap.putIfAbsent(MapColor.lightBlueColor, () -> lightBlue); - colorMap.putIfAbsent(MapColor.yellowColor, () -> yellow); - colorMap.putIfAbsent(MapColor.limeColor, () -> lime); - colorMap.putIfAbsent(MapColor.pinkColor, () -> pink); - colorMap.putIfAbsent(MapColor.grayColor, () -> gray); - colorMap.putIfAbsent(MapColor.silverColor, () -> silver); - colorMap.putIfAbsent(MapColor.cyanColor, () -> cyan); - colorMap.putIfAbsent(MapColor.purpleColor, () -> purple); - colorMap.putIfAbsent(MapColor.blueColor, () -> blue); - colorMap.putIfAbsent(MapColor.brownColor, () -> brown); - colorMap.putIfAbsent(MapColor.greenColor, () -> green); - colorMap.putIfAbsent(MapColor.redColor, () -> red); - colorMap.putIfAbsent(MapColor.blackColor, () -> black); - } - - public static transient final Map> colorMap = new HashMap<>(); + //@Color( + // title = "White", + // category = "Colors" + //) + //public static PolyColor white = ColorUtils.rgba(MapColor.snowColor.getMapColor(2)); +// + //@Color( + // title = "Orange", + // category = "Colors" + //) + //public static PolyColor orange = ColorUtils.rgba(MapColor.adobeColor.getMapColor(2)); +// + //@Color( + // title = "Magenta", + // category = "Colors" + //) + //public static PolyColor magenta = ColorUtils.rgba(MapColor.magentaColor.getMapColor(2)); +// + //@Color( + // title = "Light Blue", + // category = "Colors" + //) + //public static PolyColor lightBlue = ColorUtils.rgba(MapColor.lightBlueColor.getMapColor(2)); +// + //@Color( + // title = "Yellow", + // category = "Colors" + //) + //public static PolyColor yellow = ColorUtils.rgba(MapColor.yellowColor.getMapColor(2)); +// + //@Color( + // title = "Lime", + // category = "Colors" + //) + //public static PolyColor lime = ColorUtils.rgba(MapColor.limeColor.getMapColor(2)); +// + //@Color( + // title = "Pink", + // category = "Colors" + //) + //public static PolyColor pink = ColorUtils.rgba(MapColor.pinkColor.getMapColor(2)); +// + //@Color( + // title = "Gray", + // category = "Colors" + //) + //public static PolyColor gray = ColorUtils.rgba(MapColor.grayColor.getMapColor(2)); +// + //@Color( + // title = "Silver", + // category = "Colors" + //) + //public static PolyColor silver = ColorUtils.rgba(MapColor.silverColor.getMapColor(2)); +// + //@Color( + // title = "Cyan", + // category = "Colors" + //) + //public static PolyColor cyan = ColorUtils.rgba(MapColor.cyanColor.getMapColor(2)); +// + //@Color( + // title = "Purple", + // category = "Colors" + //) + //public static PolyColor purple = ColorUtils.rgba(MapColor.purpleColor.getMapColor(2)); +// + //@Color( + // title = "Blue", + // category = "Colors" + //) + //public static PolyColor blue = ColorUtils.rgba(MapColor.blueColor.getMapColor(2)); +// + //@Color( + // title = "Brown", + // category = "Colors" + //) + //public static PolyColor brown = ColorUtils.rgba(MapColor.brownColor.getMapColor(2)); +// + //@Color( + // title = "Green", + // category = "Colors" + //) + //public static PolyColor green = ColorUtils.rgba(MapColor.greenColor.getMapColor(2)); +// + //@Color( + // title = "Red", + // category = "Colors" + //) + //public static PolyColor red = ColorUtils.rgba(MapColor.redColor.getMapColor(2)); +// + //@Color( + // title = "Black", + // category = "Colors" + //) + //public static PolyColor black = ColorUtils.rgba(MapColor.blackColor.getMapColor(2)); +// + //public BlockHighlightConfig() { + // colorMap.putIfAbsent(MapColor.snowColor, () -> white); + // colorMap.putIfAbsent(MapColor.adobeColor, () -> orange); + // colorMap.putIfAbsent(MapColor.magentaColor, () -> magenta); + // colorMap.putIfAbsent(MapColor.lightBlueColor, () -> lightBlue); + // colorMap.putIfAbsent(MapColor.yellowColor, () -> yellow); + // colorMap.putIfAbsent(MapColor.limeColor, () -> lime); + // colorMap.putIfAbsent(MapColor.pinkColor, () -> pink); + // colorMap.putIfAbsent(MapColor.grayColor, () -> gray); + // colorMap.putIfAbsent(MapColor.silverColor, () -> silver); + // colorMap.putIfAbsent(MapColor.cyanColor, () -> cyan); + // colorMap.putIfAbsent(MapColor.purpleColor, () -> purple); + // colorMap.putIfAbsent(MapColor.blueColor, () -> blue); + // colorMap.putIfAbsent(MapColor.brownColor, () -> brown); + // colorMap.putIfAbsent(MapColor.greenColor, () -> green); + // colorMap.putIfAbsent(MapColor.redColor, () -> red); + // colorMap.putIfAbsent(MapColor.blackColor, () -> black); + //} +// + public static final Map> colorMap = new HashMap<>(); } diff --git a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java index 2e89472..2a84eda 100644 --- a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java +++ b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java @@ -19,7 +19,6 @@ package org.polyfrost.hytils.config; import org.polyfrost.oneconfig.api.config.v1.Config; -import org.polyfrost.oneconfig.api.config.v1.ConfigManager; import org.polyfrost.oneconfig.api.config.v1.annotations.*; import org.polyfrost.polyui.color.PolyColor; import org.polyfrost.hytils.HytilsReborn; @@ -63,12 +62,13 @@ public class HytilsConfig extends Config { ) public static boolean limboPlayCommandHelper = true; - @Info( - text = "Auto Queue will require you to interact with the game in a way to prevent abuse.", - category = "General", subcategory = "Automatic", - type = InfoType.WARNING - ) - private static boolean autoQueueInfo; + //TODO + //@Info( + // text = "Auto Queue will require you to interact with the game in a way to prevent abuse.", + // category = "General", subcategory = "Automatic", + // type = InfoType.WARNING + //) + //private static boolean autoQueueInfo; @Switch( title = "Auto Queue", @@ -96,8 +96,7 @@ public class HytilsConfig extends Config { title = "GEXP Mode", category = "General", subcategory = "Automatic", description = "Choose which GEXP to get.", - left = "Daily", - right = "Weekly" + options = {"Daily", "Weekly"} ) public static boolean gexpMode = false; @@ -801,19 +800,20 @@ public class HytilsConfig extends Config { ) public static boolean coloredBeds = true; - @Info( - text = "Height Overlay requires Smooth Lightning to work.", - category = "Game", subcategory = "BedWars", - type = InfoType.ERROR - ) - private static boolean heightOverlayInfo; - - @Info( - text = "Height Overlay reloads chunks automatically when toggled.", - category = "Game", subcategory = "BedWars", - type = InfoType.WARNING - ) - private static boolean heightOverlayInfo2; + //TODO + //@Info( + // text = "Height Overlay requires Smooth Lightning to work.", + // category = "Game", subcategory = "BedWars", + // type = InfoType.ERROR + //) + //private static boolean heightOverlayInfo; +// + //@Info( + // text = "Height Overlay reloads chunks automatically when toggled.", + // category = "Game", subcategory = "BedWars", + // type = InfoType.WARNING + //) + //private static boolean heightOverlayInfo2; @Switch( title = "Height Overlay", @@ -837,12 +837,13 @@ public class HytilsConfig extends Config { ) public static boolean manuallyEditHeightOverlay; - @Page( - title = "Manual Height Overlay Editor", - location = PageLocation.BOTTOM, - category = "Game", subcategory = "BedWars" - ) - public static BlockHighlightConfig blockHighlightConfig = new BlockHighlightConfig(); + //TODO SHOULD I MOVE TO ACCORDION? + //@Page( + // title = "Manual Height Overlay Editor", + // location = PageLocation.BOTTOM, + // category = "Game", subcategory = "BedWars" + //) + //public static BlockHighlightConfig blockHighlightConfig = new BlockHighlightConfig(); @Switch( title = "Hide Actionbar in Dropper", @@ -1009,7 +1010,7 @@ public class HytilsConfig extends Config { ) public static boolean limboDing = true; - public static int configNumber = 0; + @Include public static int configNumber = 0; public static final ArrayList wbMessages = new ArrayList<>(); @@ -1035,7 +1036,7 @@ public HytilsConfig() { overlayAmount = 300; } configNumber = 2; // set this to the current config version - ConfigManager.active().save(this.tree); + save(); } addDependency("autoQueueDelay", "autoQueue"); @@ -1110,7 +1111,7 @@ public void hideTabulous() { hidePingInTab = false; cleanerSkyblockTabInfo = false; hideAdsInTab = false; - ConfigManager.active().save(this.tree); + save(); addDependency("hideNpcsInTab", "Tabulous", () -> false); addDependency("keepImportantNpcsInTab", "Tabulous", () -> false); addDependency("hideGuildTagsInTab", "Tabulous", () -> false); diff --git a/src/main/java/org/polyfrost/hytils/handlers/cache/ArmorStandHandler.java b/src/main/java/org/polyfrost/hytils/handlers/cache/ArmorStandHandler.java index 2eac05e..bc5cfd6 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/cache/ArmorStandHandler.java +++ b/src/main/java/org/polyfrost/hytils/handlers/cache/ArmorStandHandler.java @@ -18,8 +18,8 @@ package org.polyfrost.hytils.handlers.cache; +import org.polyfrost.oneconfig.utils.v1.JsonUtils; import org.polyfrost.oneconfig.utils.v1.Multithreading; -import org.polyfrost.oneconfig.utils.v1.NetworkUtils; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -31,8 +31,8 @@ public class ArmorStandHandler { public List armorStandNames = new ArrayList<>(); public void initialize() { - Multithreading.runAsync(() -> { - final JsonElement gotten = NetworkUtils.getJsonElement("https://data.woverflow.cc/armorstands.json"); + Multithreading.submit(() -> { + final JsonElement gotten = JsonUtils.parseFromUrl("https://data.woverflow.cc/armorstands.json"); if (gotten != null) { JsonObject jsonObject = gotten.getAsJsonObject(); for (JsonElement tag : jsonObject.getAsJsonArray("tags")) { diff --git a/src/main/java/org/polyfrost/hytils/handlers/cache/BedLocationHandler.java b/src/main/java/org/polyfrost/hytils/handlers/cache/BedLocationHandler.java index fb680c2..1748b31 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/cache/BedLocationHandler.java +++ b/src/main/java/org/polyfrost/hytils/handlers/cache/BedLocationHandler.java @@ -21,9 +21,9 @@ import net.hypixel.data.type.GameType; import org.polyfrost.oneconfig.api.event.v1.events.HypixelLocationEvent; import org.polyfrost.oneconfig.api.event.v1.invoke.EventHandler; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; +import org.polyfrost.oneconfig.utils.v1.JsonUtils; import org.polyfrost.oneconfig.utils.v1.Multithreading; -import org.polyfrost.oneconfig.utils.v1.NetworkUtils; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -63,14 +63,14 @@ public class BedLocationHandler { private BedLocationHandler() { EventHandler.of(HypixelLocationEvent.class, (event) -> { - HypixelAPI.Location location = event.getLocation(); - String serverId = location.getServerId(); + HypixelUtils.Location location = event.getLocation(); + String serverId = location.getServerName().orElse(null); if (Objects.equals(lastServer, serverId)) { return; } lastServer = serverId; - if (!location.isGame() || location.getGameType().orElse(null) != GameType.BEDWARS) { + if (!location.inGame() || location.getGameType().orElse(null) != GameType.BEDWARS) { return; } @@ -82,7 +82,13 @@ private BedLocationHandler() { } public void initialize() { - Multithreading.runAsync(() -> locations = NetworkUtils.getJsonElement("https://data.woverflow.cc/bed_locations.json").getAsJsonObject()); + Multithreading.submit(() -> { + JsonElement maybeBedLocations = JsonUtils.parseFromUrl("https://data.woverflow.cc/bed_locations.json"); + if (maybeBedLocations == null) { + return; + } + locations = maybeBedLocations.getAsJsonObject(); + }); } private int[] processColors(JsonArray array) { @@ -97,8 +103,8 @@ private int[] processColors(JsonArray array) { } public int[] getBedLocations() { - HypixelAPI.Location location = HypixelAPI.getLocation(); - if (locations == null || !location.isGame() || location.getGameType().orElse(null) != GameType.BEDWARS || "BEDWARS_PRACTICE".equals(location.getMode().orElse(null))) { + HypixelUtils.Location location = HypixelUtils.getLocation(); + if (locations == null || !location.inGame() || location.getGameType().orElse(null) != GameType.BEDWARS || "BEDWARS_PRACTICE".equals(location.getMode().orElse(null))) { return (this.bedLocations = null); } diff --git a/src/main/java/org/polyfrost/hytils/handlers/cache/CosmeticsHandler.java b/src/main/java/org/polyfrost/hytils/handlers/cache/CosmeticsHandler.java index b0611eb..d0c9a08 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/cache/CosmeticsHandler.java +++ b/src/main/java/org/polyfrost/hytils/handlers/cache/CosmeticsHandler.java @@ -18,8 +18,8 @@ package org.polyfrost.hytils.handlers.cache; +import org.polyfrost.oneconfig.utils.v1.JsonUtils; import org.polyfrost.oneconfig.utils.v1.Multithreading; -import org.polyfrost.oneconfig.utils.v1.NetworkUtils; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -32,8 +32,8 @@ public class CosmeticsHandler { public List itemCosmetics = new ArrayList<>(); public void initialize() { - Multithreading.runAsync(() -> { - final JsonElement gotten = NetworkUtils.getJsonElement("https://data.woverflow.cc/cosmetics.json"); + Multithreading.submit(() -> { + final JsonElement gotten = JsonUtils.parseFromUrl("https://data.woverflow.cc/cosmetics.json"); if (gotten != null) { JsonObject jsonObject = gotten.getAsJsonObject(); for (JsonElement cosmetic : jsonObject.getAsJsonArray("particles")) { diff --git a/src/main/java/org/polyfrost/hytils/handlers/cache/HeightHandler.java b/src/main/java/org/polyfrost/hytils/handlers/cache/HeightHandler.java index 8d9a4dc..db4e2a5 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/cache/HeightHandler.java +++ b/src/main/java/org/polyfrost/hytils/handlers/cache/HeightHandler.java @@ -24,9 +24,9 @@ import org.polyfrost.oneconfig.api.event.v1.events.HypixelLocationEvent; import org.polyfrost.oneconfig.api.event.v1.events.WorldLoadEvent; import org.polyfrost.oneconfig.api.event.v1.invoke.EventHandler; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; +import org.polyfrost.oneconfig.utils.v1.JsonUtils; import org.polyfrost.oneconfig.utils.v1.Multithreading; -import org.polyfrost.oneconfig.utils.v1.NetworkUtils; import org.polyfrost.hytils.HytilsReborn; import com.google.gson.JsonObject; @@ -58,8 +58,8 @@ public class HeightHandler { public int getHeight() { if (currentHeight != -2) return currentHeight; - HypixelAPI.Location location = HypixelAPI.getLocation(); - if (jsonObject == null || !location.isGame()) { + HypixelUtils.Location location = HypixelUtils.getLocation(); + if (jsonObject == null || !location.inGame()) { return -1; } try { @@ -95,9 +95,9 @@ public int getHeight() { public void initialize() { - Multithreading.runAsync(() -> { + Multithreading.submit(() -> { try { - jsonObject = NetworkUtils.getJsonElement("https://maps.pinkulu.com").getAsJsonObject(); + jsonObject = Objects.requireNonNull(JsonUtils.parseFromUrl("https://maps.pinkulu.com")).getAsJsonObject(); } catch (Exception ex) { ex.printStackTrace(); } diff --git a/src/main/java/org/polyfrost/hytils/handlers/cache/LocrawGamesHandler.java b/src/main/java/org/polyfrost/hytils/handlers/cache/LocrawGamesHandler.java index 90829aa..4629751 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/cache/LocrawGamesHandler.java +++ b/src/main/java/org/polyfrost/hytils/handlers/cache/LocrawGamesHandler.java @@ -34,7 +34,7 @@ public class LocrawGamesHandler { public static Map locrawGames = new HashMap<>(); public void initialize() { - Multithreading.runAsync(() -> { + Multithreading.submit(() -> { try { String url = "https://data.woverflow.cc/locraw_games.json"; String content = NetworkUtils.getString(url); diff --git a/src/main/java/org/polyfrost/hytils/handlers/cache/PatternHandler.java b/src/main/java/org/polyfrost/hytils/handlers/cache/PatternHandler.java index 1a54555..3bfa75c 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/cache/PatternHandler.java +++ b/src/main/java/org/polyfrost/hytils/handlers/cache/PatternHandler.java @@ -34,7 +34,7 @@ public class PatternHandler { public List gameEnd = new ArrayList<>(); // OKAY DEFTU public void initialize() { - Multithreading.runAsync(() -> { + Multithreading.submit(() -> { try { JsonObject cached = HytilsReborn.INSTANCE.getLanguageHandler().getRegexJson(); if (cached != null) { @@ -43,7 +43,7 @@ public void initialize() { } final String gotten = NetworkUtils.getString("https://data.woverflow.cc/regex.json"); if (gotten != null) { - processJson(JsonUtils.parseString(gotten).getAsJsonObject()); + processJson(JsonUtils.parse(gotten).getAsJsonObject()); } } catch (Exception e) { e.printStackTrace(); 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 adfcf7d..dc244a2 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/ChatHandler.java @@ -33,6 +33,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import java.util.ArrayList; import java.util.Comparator; @@ -137,7 +138,7 @@ public void handleWorldLeave(WorldEvent.Unload e) { @SubscribeEvent public void handleChat(ClientChatReceivedEvent event) { - if (!HypixelUtils.INSTANCE.isHypixel()) { + if (!HypixelUtils.isHypixel()) { return; } @@ -169,7 +170,7 @@ public void handleChat(ClientChatReceivedEvent event) { @SuppressWarnings({"unused", "RedundantSuppression"}) @Nullable public String handleSentMessage(@NotNull String message) { - if (!HypixelUtils.INSTANCE.isHypixel()) { + if (!HypixelUtils.isHypixel()) { return message; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AdBlocker.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AdBlocker.java index 4360404..32a841f 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AdBlocker.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AdBlocker.java @@ -24,7 +24,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.jetbrains.annotations.NotNull; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; public class AdBlocker implements ChatReceiveModule { @@ -53,7 +53,7 @@ public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { event.setCanceled(true); } - if (HypixelAPI.getLocation().isGame()) return; + if (HypixelUtils.getLocation().inGame()) return; if (getLanguage().chatRankBeggingRegex.matcher(message).find(0)) { event.setCanceled(true); } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AntiGL.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AntiGL.java index c5074a1..e37abe8 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AntiGL.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/AntiGL.java @@ -24,14 +24,14 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.jetbrains.annotations.NotNull; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; public class AntiGL implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText().toLowerCase()); if ((message.startsWith("-") && message.endsWith("-")) || (message.startsWith("▬") && message.endsWith("▬")) || (message.startsWith("≡") && message.endsWith("≡")) || (!message.contains(": ")) || - (message.contains(Minecraft.getMinecraft().getSession().getUsername().toLowerCase())) || !(HypixelAPI.getLocation().isGame())) return; + (message.contains(Minecraft.getMinecraft().getSession().getUsername().toLowerCase())) || !(HypixelUtils.getLocation().inGame())) return; if (getLanguage().cancelGlMessagesRegex.matcher(message).find(0)) { event.setCanceled(true); } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/BedwarsAdvertisementsRemover.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/BedwarsAdvertisementsRemover.java index 9c4c50e..89056ca 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/BedwarsAdvertisementsRemover.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/blockers/BedwarsAdvertisementsRemover.java @@ -25,15 +25,15 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.jetbrains.annotations.NotNull; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; public class BedwarsAdvertisementsRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText().toLowerCase()); if ((message.startsWith("-") && message.endsWith("-")) || (message.startsWith("▬") && message.endsWith("▬")) || (message.startsWith("≡") && message.endsWith("≡")) || (!message.contains(": ")) || (message.contains(Minecraft.getMinecraft().getSession().getUsername().toLowerCase()))) return; - HypixelAPI.Location location = HypixelAPI.getLocation(); - if (location.getGameType().orElse(null) == GameType.BEDWARS && !location.isGame() + HypixelUtils.Location location = HypixelUtils.getLocation(); + if (location.getGameType().orElse(null) == GameType.BEDWARS && !location.inGame() && getLanguage().chatCleanerBedwarsPartyAdvertisementRegex.matcher(message).find()) { event.setCanceled(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 3385c8f..86471c7 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 @@ -25,7 +25,7 @@ import net.minecraft.client.Minecraft; import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.jetbrains.annotations.NotNull; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import java.text.DecimalFormat; @@ -58,7 +58,7 @@ public String onMessageSend(@NotNull String message) { } private long getCooldownLengthInSeconds() { - HypixelAPI.Location location = HypixelAPI.getLocation(); + HypixelUtils.Location location = HypixelUtils.getLocation(); if (!"LOBBY".equals(location.getMode()) && location.getGameType().isPresent()) { switch (location.getGameType().get()) { case BEDWARS: { @@ -83,7 +83,7 @@ private long getCooldownLengthInSeconds() { @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { - HypixelAPI.Location location = HypixelAPI.getLocation(); + 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) || 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 2b7460c..8b0c05f 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 @@ -24,14 +24,14 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.jetbrains.annotations.NotNull; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; public class TicketMachineRemover implements ChatReceiveModule { @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { - HypixelAPI.Location location = HypixelAPI.getLocation(); + HypixelUtils.Location location = HypixelUtils.getLocation(); String message = EnumChatFormatting.getTextWithoutFormattingCodes(event.message.getUnformattedText()); - if (location.getGameType().orElse(null) == GameType.BEDWARS && !location.isGame() + if (location.getGameType().orElse(null) == GameType.BEDWARS && !location.inGame() && getLanguage().chatCleanerTicketAnnouncerRegex.matcher(message).matches()) { event.setCanceled(true); } diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoChatSwapper.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoChatSwapper.java index 42a9f20..064df5a 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoChatSwapper.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoChatSwapper.java @@ -50,7 +50,7 @@ public int getPriority() { @SuppressWarnings("all") @Override public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { - Multithreading.runAsync(() -> { + Multithreading.submit(() -> { final Matcher statusMatcherLeave = getLanguage().autoChatSwapperPartyStatusRegex.matcher(UTextComponent.Companion.stripFormatting(event.message.getUnformattedText())); // leaving party final Matcher statusMatcherJoin = getLanguage().autoChatSwapperPartyStatusRegex2.matcher(UTextComponent.Companion.stripFormatting(event.message.getUnformattedText())); // joining party if (statusMatcherLeave.matches()) { diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoQueue.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoQueue.java index 7706c3b..2aac70c 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoQueue.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoQueue.java @@ -18,7 +18,7 @@ package org.polyfrost.hytils.handlers.chat.modules.triggers; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.oneconfig.utils.v1.Multithreading; import org.polyfrost.hytils.HytilsReborn; import org.polyfrost.hytils.config.HytilsConfig; @@ -53,7 +53,7 @@ public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { final String message = getStrippedMessage(event.message); Matcher matcher = getLanguage().autoQueuePrefixGlobalRegex.matcher(message); - HypixelAPI.Location location = HypixelAPI.getLocation(); + HypixelUtils.Location location = HypixelUtils.getLocation(); if (matcher.matches()) { if (location.getMode().isPresent() && location.getGameType().isPresent()) { String game = location.getMode().get(); diff --git a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoVictory.java b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoVictory.java index fe7360b..5b0a068 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoVictory.java +++ b/src/main/java/org/polyfrost/hytils/handlers/chat/modules/triggers/AutoVictory.java @@ -18,7 +18,7 @@ package org.polyfrost.hytils.handlers.chat.modules.triggers; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.oneconfig.api.ui.v1.notifications.Notifications; import org.polyfrost.universal.wrappers.message.UTextComponent; import org.polyfrost.oneconfig.utils.v1.Multithreading; @@ -61,7 +61,7 @@ public void onMessageReceived(@NotNull ClientChatReceivedEvent event) { String unformattedText = UTextComponent.Companion.stripFormatting(event.message.getUnformattedText()); if (PatternHandler.INSTANCE.gameEnd.size() != 0) { if (!victoryDetected) { // prevent victories being detected twice - Multithreading.runAsync(() -> { //run this async as getting from the API normally would freeze minecraft + Multithreading.submit(() -> { //run this async as getting from the API normally would freeze minecraft for (Pattern triggers : PatternHandler.INSTANCE.gameEnd) { if (triggers.matcher(unformattedText).matches()) { doNotification(); @@ -78,7 +78,7 @@ public void onTitle(TitleEvent event) { if (!victoryDetected) { final String title = EnumChatFormatting.getTextWithoutFormattingCodes(event.getTitle().toLowerCase(Locale.ENGLISH)); if (title.equals("victory!") || title.equals("game over") || title.equals("game over!") || title.endsWith(" wins!")) { - Multithreading.runAsync(this::doNotification); + Multithreading.submit(this::doNotification); } } } @@ -118,7 +118,7 @@ private void doNotification() { .send(HytilsReborn.MOD_NAME, "There was a problem trying to get your GEXP."); } } - if (isSupportedMode(HypixelAPI.getLocation()) && HytilsConfig.autoGetWinstreak) { + if (isSupportedMode(HypixelUtils.getLocation()) && HytilsConfig.autoGetWinstreak) { try { if (HypixelAPIUtils.getWinstreak()) { Notifications.INSTANCE.send( @@ -142,7 +142,7 @@ public void reset() { ((GuiIngameAccessor) Minecraft.getMinecraft().ingameGUI).setDisplayedSubTitle(""); } - private boolean isSupportedMode(HypixelAPI.Location location) { + private boolean isSupportedMode(HypixelUtils.Location location) { if (location.getGameType().isPresent()) { switch (location.getGameType().get()) { case BEDWARS: 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 38d71f3..002efbf 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 @@ -18,12 +18,12 @@ package org.polyfrost.hytils.handlers.chat.modules.triggers; -import org.polyfrost.oneconfig.utils.v1.Notifications; import org.polyfrost.hytils.HytilsReborn; import org.polyfrost.hytils.handlers.chat.ChatReceiveModule; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; import org.jetbrains.annotations.NotNull; +import org.polyfrost.oneconfig.api.ui.v1.notifications.Notifications; import java.util.HashSet; import java.util.Set; 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 d00546a..4148761 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 @@ -21,14 +21,14 @@ import org.polyfrost.hytils.config.HytilsConfig; import net.minecraftforge.client.event.sound.PlaySoundEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; public class DropperHurtSound { @SubscribeEvent public void onSound(PlaySoundEvent event) { - HypixelAPI.Location location = HypixelAPI.getLocation(); - if (HytilsConfig.muteDropperHurtSound && HypixelUtils.INSTANCE.isHypixel() && "dropper".equalsIgnoreCase(location.getMode().orElse(null)) && event.name.equals("game.player.hurt")) { + 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; } } 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 584f5da..0fea374 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 @@ -23,7 +23,7 @@ import net.minecraft.client.settings.GameSettings; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; public class SumoRenderDistance { final GameSettings gs = Minecraft.getMinecraft().gameSettings; @@ -33,8 +33,8 @@ public class SumoRenderDistance { @SubscribeEvent public void onWorldLoad(RenderWorldLastEvent event) { - HypixelAPI.Location location = HypixelAPI.getLocation(); - if (HytilsConfig.sumoRenderDistance && HypixelUtils.INSTANCE.isHypixel() && location.getMode().orElse("null").contains("SUMO")) { + HypixelUtils.Location location = HypixelUtils.getLocation(); + if (HytilsConfig.sumoRenderDistance && HypixelUtils.isHypixel() && location.getMode().orElse("null").contains("SUMO")) { if (isFirstRender) { final int oldRd = gs.renderDistanceChunks; wasSumo = true; 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 da2d5f6..8f58474 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 @@ -22,14 +22,14 @@ import org.polyfrost.hytils.config.HytilsConfig; import net.minecraftforge.client.event.sound.PlaySoundEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; public class HousingMusic { @SubscribeEvent public void onPlaySound(PlaySoundEvent event) { - if (HypixelUtils.INSTANCE.isHypixel() && HytilsConfig.muteHousingMusic) { - HypixelAPI.Location location = HypixelAPI.getLocation(); + if (HypixelUtils.isHypixel() && HytilsConfig.muteHousingMusic) { + HypixelUtils.Location location = HypixelUtils.getLocation(); if (location.getGameType().orElse(null) == GameType.HOUSING && event.name.startsWith("note.")) { event.result = 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 d65e803..91fb85a 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 @@ -26,7 +26,7 @@ import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; public class MiddleBeaconMiniWalls { private boolean miniWitherDead; @@ -44,8 +44,8 @@ public void onTitle(TitleEvent event) { } public boolean shouldMakeBeacon() { - HypixelAPI.Location location = HypixelAPI.getLocation(); - return HypixelUtils.INSTANCE.isHypixel() && "mini_walls".equalsIgnoreCase(location.getMode().orElse(null)) && HytilsConfig.miniWallsMiddleBeacon && this.miniWitherDead; + HypixelUtils.Location location = HypixelUtils.getLocation(); + return HypixelUtils.isHypixel() && "mini_walls".equalsIgnoreCase(location.getMode().orElse(null)) && HytilsConfig.miniWallsMiddleBeacon && this.miniWitherDead; } @SubscribeEvent 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 f9062f0..900e479 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 @@ -27,7 +27,7 @@ import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; public class PitLagReducer { @@ -42,11 +42,11 @@ public void onWorldLoad(WorldEvent.Load event) { @SubscribeEvent(priority = EventPriority.HIGHEST) public void onRenderLiving(RenderLivingEvent.Pre event) { - if (!HypixelUtils.INSTANCE.isHypixel()) { + if (!HypixelUtils.isHypixel()) { return; } - HypixelAPI.Location location = HypixelAPI.getLocation(); + HypixelUtils.Location location = HypixelUtils.getLocation(); if (location.getGameType().orElse(null) != GameType.PIT) { return; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/game/titles/CountdownTitles.java b/src/main/java/org/polyfrost/hytils/handlers/game/titles/CountdownTitles.java index 715107f..fa0d070 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/game/titles/CountdownTitles.java +++ b/src/main/java/org/polyfrost/hytils/handlers/game/titles/CountdownTitles.java @@ -18,7 +18,7 @@ package org.polyfrost.hytils.handlers.game.titles; -import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.hytils.config.HytilsConfig; import org.polyfrost.hytils.events.TitleEvent; import net.minecraft.util.EnumChatFormatting; @@ -28,7 +28,7 @@ public class CountdownTitles { @SubscribeEvent(priority = EventPriority.LOWEST) public void onTitle(TitleEvent event) { - if (!HypixelUtils.INSTANCE.isHypixel() || !HytilsConfig.hideCountdownTitles) { + if (!HypixelUtils.isHypixel() || !HytilsConfig.hideCountdownTitles) { return; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/game/titles/GameEndingTitles.java b/src/main/java/org/polyfrost/hytils/handlers/game/titles/GameEndingTitles.java index 6a459b1..139115b 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/game/titles/GameEndingTitles.java +++ b/src/main/java/org/polyfrost/hytils/handlers/game/titles/GameEndingTitles.java @@ -18,7 +18,7 @@ package org.polyfrost.hytils.handlers.game.titles; -import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.hytils.config.HytilsConfig; import org.polyfrost.hytils.events.TitleEvent; import net.minecraft.util.EnumChatFormatting; @@ -28,7 +28,7 @@ public class GameEndingTitles { @SubscribeEvent(priority = EventPriority.LOWEST) public void onTitle(TitleEvent event) { - if (!HypixelUtils.INSTANCE.isHypixel() || !HytilsConfig.hideGameEndingTitles) { + if (!HypixelUtils.isHypixel() || !HytilsConfig.hideGameEndingTitles) { return; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/game/titles/GameStartingTitles.java b/src/main/java/org/polyfrost/hytils/handlers/game/titles/GameStartingTitles.java index 0fa27ac..635521f 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/game/titles/GameStartingTitles.java +++ b/src/main/java/org/polyfrost/hytils/handlers/game/titles/GameStartingTitles.java @@ -18,7 +18,7 @@ package org.polyfrost.hytils.handlers.game.titles; -import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.hytils.config.HytilsConfig; import org.polyfrost.hytils.events.TitleEvent; import net.minecraft.util.EnumChatFormatting; @@ -29,7 +29,7 @@ public class GameStartingTitles { // Hides the countdown timer title text that is displayed before a game is about to start and other titles @SubscribeEvent(priority = EventPriority.LOWEST) public void onTitle(TitleEvent event) { - if (!HypixelUtils.INSTANCE.isHypixel() || !HytilsConfig.hideGameStartingTitles) { + if (!HypixelUtils.isHypixel() || !HytilsConfig.hideGameStartingTitles) { return; } 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 53bd1e5..1eeebd7 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 @@ -24,7 +24,7 @@ import net.minecraft.util.BlockPos; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; public class MiddleWaypointUHC { // y 70 is a completely arbitrary height, being slightly above sea level. feel free to change as one may see fit @@ -32,8 +32,8 @@ public class MiddleWaypointUHC { @SubscribeEvent public void onRenderWorldLast(RenderWorldLastEvent event) { - HypixelAPI.Location location = HypixelAPI.getLocation(); - if (HypixelUtils.INSTANCE.isHypixel() && location.isGame() && HytilsConfig.uhcMiddleWaypoint && location.getGameType().isPresent() && (location.getGameType().get() == GameType.UHC || location.getGameType().get() == GameType.SPEED_UHC)) { + 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); } } 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 706004b..e8f5acf 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/general/SoundHandler.java +++ b/src/main/java/org/polyfrost/hytils/handlers/general/SoundHandler.java @@ -24,7 +24,7 @@ import net.minecraft.item.ItemBlock; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; public class SoundHandler { @@ -33,9 +33,9 @@ public class SoundHandler { @SubscribeEvent public void onTick(TickEvent.ClientTickEvent e) { if (e.phase == TickEvent.Phase.START) { - if (HypixelUtils.INSTANCE.isHypixel() && Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem() != null) { - HypixelAPI.Location location = HypixelAPI.getLocation(); - if (HytilsConfig.blockNotify && location.isGame() && location.getGameType().isPresent()) { + if (HypixelUtils.isHypixel() && Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem() != null) { + HypixelUtils.Location location = HypixelUtils.getLocation(); + if (HytilsConfig.blockNotify && location.inGame() && location.getGameType().isPresent()) { switch (location.getGameType().get()) { case BUILD_BATTLE: case HOUSING: diff --git a/src/main/java/org/polyfrost/hytils/handlers/language/LanguageHandler.java b/src/main/java/org/polyfrost/hytils/handlers/language/LanguageHandler.java index 5854ead..46ee4cf 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/language/LanguageHandler.java +++ b/src/main/java/org/polyfrost/hytils/handlers/language/LanguageHandler.java @@ -18,8 +18,9 @@ package org.polyfrost.hytils.handlers.language; +import com.google.gson.JsonElement; +import org.polyfrost.oneconfig.utils.v1.JsonUtils; import org.polyfrost.oneconfig.utils.v1.Multithreading; -import org.polyfrost.oneconfig.utils.v1.NetworkUtils; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; @@ -42,13 +43,16 @@ public class LanguageHandler { private LanguageData current = fallback; public LanguageHandler() { - Multithreading.runAsync(this::initialize); + Multithreading.submit(this::initialize); } private void initialize() { fallback.initialize(); - regex = NetworkUtils.getJsonElement("https://data.woverflow.cc/regex.json").getAsJsonObject(); - if (!regex.entrySet().isEmpty()) { + JsonElement maybeRegex = JsonUtils.parseFromUrl("https://data.woverflow.cc/regex.json"); + if (maybeRegex != null) { + regex = maybeRegex.getAsJsonObject(); + } + if (regex != null && !regex.entrySet().isEmpty()) { current = gson.fromJson(regex.getAsJsonObject("en").toString(), LanguageData.class); } current.initialize(); 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 c20b12e..2d6ff2d 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 @@ -27,13 +27,13 @@ import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; public class ArmorStandHider { @SubscribeEvent(priority = EventPriority.HIGHEST) public void onEntityRenderer(RenderLivingEvent.Pre event) { - final HypixelAPI.Location location = HypixelAPI.getLocation(); - if (HypixelUtils.INSTANCE.isHypixel() && ((!location.isGame() && HytilsConfig.hideUselessArmorStands) || (HytilsConfig.hideUselessArmorStandsGame && location.isGame() && location.getGameType().isPresent() && (location.getGameType().get() == GameType.SKYBLOCK || location.getGameType().get() == GameType.BEDWARS || location.getGameType().get() == GameType.SKYWARS || location.getMode().orElse("").contains("BRIDGE"))))) { + 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()); for (String armorStands : ArmorStandHandler.INSTANCE.armorStandNames) { 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 039c4d3..3addafe 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 @@ -25,7 +25,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import org.lwjgl.opengl.Display; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; public class LimboLimiter { @@ -48,8 +48,8 @@ public void onWorldChange(WorldEvent.Unload event) { } public static boolean shouldLimitFramerate() { - HypixelAPI.Location location = HypixelAPI.getLocation(); - if (HypixelUtils.INSTANCE.isHypixel() && location.getServerId().equals("limbo")) limboStatus = true; + HypixelUtils.Location location = HypixelUtils.getLocation(); + if (HypixelUtils.isHypixel() && "limbo".equals(location.getServerName().orElse(null))) limboStatus = true; return (!Display.isActive() || limboStatus) && HytilsConfig.limboLimiter && time * 20 >= 5 && Minecraft.getMinecraft().gameSettings.limitFramerate > 15; // if the FPS limit is > 15, don't activate, as you would be increasing the fps limit diff --git a/src/main/java/org/polyfrost/hytils/handlers/lobby/limbo/LimboPmDing.java b/src/main/java/org/polyfrost/hytils/handlers/lobby/limbo/LimboPmDing.java index 4cb07dc..3b28a59 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/lobby/limbo/LimboPmDing.java +++ b/src/main/java/org/polyfrost/hytils/handlers/lobby/limbo/LimboPmDing.java @@ -22,13 +22,13 @@ import net.minecraft.client.Minecraft; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; public class LimboPmDing { @SubscribeEvent public void onChat(ClientChatReceivedEvent event) { - HypixelAPI.Location location = HypixelAPI.getLocation(); - if (HypixelUtils.INSTANCE.isHypixel() && location.getServerId().equals("limbo") && event.message.getFormattedText().startsWith("§dFrom §r") && HytilsConfig.limboDing) { + HypixelUtils.Location location = HypixelUtils.getLocation(); + if (HypixelUtils.isHypixel() && "limbo".equals(location.getServerName().orElse(null)) && event.message.getFormattedText().startsWith("§dFrom §r") && HytilsConfig.limboDing) { Minecraft.getMinecraft().thePlayer.playSound("random.orb", 1f, 1f); } } 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 4d58b7e..329d76b 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 @@ -28,7 +28,7 @@ import net.minecraft.client.entity.EntityOtherPlayerMP; import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import java.util.Collection; @@ -36,14 +36,14 @@ public class NPCHandler { @SubscribeEvent public void onEntityRender(RenderLivingEvent.Pre event) { - if (!HypixelUtils.INSTANCE.isHypixel()) { + if (!HypixelUtils.isHypixel()) { return; } - final HypixelAPI.Location location = HypixelAPI.getLocation(); + final HypixelUtils.Location location = HypixelUtils.getLocation(); // hypixel marks npc uuids as version 2 if (event.entity.getUniqueID().version() == 2 || (event.entity instanceof EntityVillager)) { - if (HytilsConfig.npcHider && !location.isGame()) { + if (HytilsConfig.npcHider && !location.inGame()) { event.setCanceled(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) { @@ -53,8 +53,8 @@ public void onEntityRender(RenderLivingEvent.Pre event) { public static Collection hideTabNpcs(Collection playerInfoCollection) { if (playerInfoCollection == null) return null; - HypixelAPI.Location location = HypixelAPI.getLocation(); - if (!HypixelUtils.INSTANCE.isHypixel() || !HytilsConfig.hideNpcsInTab) { + HypixelUtils.Location location = HypixelUtils.getLocation(); + if (!HypixelUtils.isHypixel() || !HytilsConfig.hideNpcsInTab) { return playerInfoCollection; } else { if (HytilsConfig.keepImportantNpcsInTab && location.getGameType().isPresent() && (location.getGameType().get() == GameType.SKYBLOCK || location.getGameType().get() == GameType.REPLAY)) { 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 55c4648..3fd0cfb 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 @@ -21,13 +21,13 @@ import org.polyfrost.hytils.config.HytilsConfig; import net.minecraftforge.client.event.sound.PlaySoundEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; public class SilentLobby { @SubscribeEvent public void onSoundPlay(PlaySoundEvent event) { - if (HypixelUtils.INSTANCE.isHypixel() && !HypixelAPI.getLocation().isGame() && HytilsConfig.silentLobby) { + if (HypixelUtils.isHypixel() && !HypixelUtils.getLocation().inGame() && HytilsConfig.silentLobby) { if (!event.name.startsWith("gui.")) { event.result = null; } diff --git a/src/main/java/org/polyfrost/hytils/handlers/lobby/tab/TabChanger.java b/src/main/java/org/polyfrost/hytils/handlers/lobby/tab/TabChanger.java index 365ca19..023f9c8 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/lobby/tab/TabChanger.java +++ b/src/main/java/org/polyfrost/hytils/handlers/lobby/tab/TabChanger.java @@ -26,13 +26,13 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.network.NetworkPlayerInfo; import org.polyfrost.hytils.forge.HytilsMixinPlugin; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import java.util.*; import java.util.regex.Pattern; /** - * Used in {@link HytilsMixinPlugin + * Used in {@link HytilsMixinPlugin} */ @SuppressWarnings("unused") public class TabChanger { @@ -86,10 +86,10 @@ private static String addStarToNameSelf(String displayName) { } public static String modifyName(String name, NetworkPlayerInfo networkPlayerInfo) { - if (HypixelUtils.INSTANCE.isHypixel()) { + if (HypixelUtils.isHypixel()) { final UUID uuid = networkPlayerInfo.getGameProfile().getId(); - if (HytilsConfig.hidePlayerRanksInTab && name.startsWith("[", 2) && !HypixelAPI.getLocation().isGame()) { + if (HytilsConfig.hidePlayerRanksInTab && name.startsWith("[", 2) && !HypixelUtils.getLocation().inGame()) { // keep the name color if player rank is removed // §b[MVP§c+§b] Steve final String color = "\u00a7" + name.charAt(1); @@ -98,8 +98,8 @@ public static String modifyName(String name, NetworkPlayerInfo networkPlayerInfo name = color + name.substring(name.indexOf("]") + 2); } - HypixelAPI.Location location = HypixelAPI.getLocation(); - if (HytilsConfig.hideGuildTagsInTab && name.endsWith("]") && (location.getGameType().orElse(null) != GameType.HOUSING || !location.isGame())) { + HypixelUtils.Location location = HypixelUtils.getLocation(); + if (HytilsConfig.hideGuildTagsInTab && name.endsWith("]") && (location.getGameType().orElse(null) != GameType.HOUSING || !location.inGame())) { // trim off the guild tag // e.g. Steve §6[GUILD] name = name.substring(0, name.lastIndexOf("[") - 3); @@ -124,7 +124,7 @@ public static String modifyName(String name, NetworkPlayerInfo networkPlayerInfo } public static List modifyFooter(FontRenderer instance, String formattedFooter, int wrapWidth) { - if (HytilsConfig.hideAdsInTab && HypixelUtils.INSTANCE.isHypixel() && formattedFooter.contains(language.tabFooterAdvertisement)) { + if (HytilsConfig.hideAdsInTab && HypixelUtils.isHypixel() && formattedFooter.contains(language.tabFooterAdvertisement)) { String trimmedFooter = formattedFooter.replaceAll((trimChatComponentTextRegex.pattern()), ""); if (trimmedFooter.matches(language.tabFooterAdvertisement)) { return new ArrayList<>(); @@ -140,7 +140,7 @@ public static List modifyFooter(FontRenderer instance, String formattedF } public static List modifyHeader(FontRenderer instance, String formattedHeader, int wrapWidth) { - if (HytilsConfig.hideAdsInTab && HypixelUtils.INSTANCE.isHypixel() && formattedHeader.contains(language.tabHeaderAdvertisement)) { + if (HytilsConfig.hideAdsInTab && HypixelUtils.isHypixel() && formattedHeader.contains(language.tabHeaderAdvertisement)) { String trimmedHeader = formattedHeader.replaceAll((trimChatComponentTextRegex.pattern()), ""); if (trimmedHeader.matches(language.tabHeaderAdvertisement)) { return new ArrayList<>(); @@ -156,17 +156,18 @@ public static List modifyHeader(FontRenderer instance, String formattedH } public static boolean shouldRenderPlayerHead(NetworkPlayerInfo networkPlayerInfo) { - return !HypixelUtils.INSTANCE.isHypixel() || !isSkyblockTabInformationEntry(networkPlayerInfo); + return !HypixelUtils.isHypixel() || !isSkyblockTabInformationEntry(networkPlayerInfo); } public static boolean hidePing(NetworkPlayerInfo networkPlayerInfo) { - return HypixelUtils.INSTANCE.isHypixel() && ((HytilsConfig.hidePingInTab && HypixelAPI.getLocation().isGame()) || isSkyblockTabInformationEntry(networkPlayerInfo)); + + return HypixelUtils.isHypixel() && ((HytilsConfig.hidePingInTab && HypixelUtils.getLocation().inGame()) || isSkyblockTabInformationEntry(networkPlayerInfo)); } private static boolean isSkyblockTabInformationEntry(NetworkPlayerInfo networkPlayerInfo) { if (!HytilsConfig.cleanerSkyblockTabInfo) return false; return - HypixelAPI.getLocation().getGameType().orElse(null) == GameType.SKYBLOCK && + HypixelUtils.getLocation().getGameType().orElse(null) == GameType.SKYBLOCK && skyblockTabInformationEntryGameProfileNameRegex.matcher(networkPlayerInfo.getGameProfile().getName()).matches() && !validMinecraftUsername.matcher(networkPlayerInfo.getDisplayName().getUnformattedText()).matches(); } 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 e1ccff0..93b35a3 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/render/ChestHighlighter.java +++ b/src/main/java/org/polyfrost/hytils/handlers/render/ChestHighlighter.java @@ -19,7 +19,7 @@ package org.polyfrost.hytils.handlers.render; import net.hypixel.data.type.GameType; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.polyui.color.PolyColor; import org.polyfrost.hytils.config.HytilsConfig; import org.polyfrost.hytils.events.TitleEvent; @@ -170,6 +170,6 @@ private void drawFilledBoundingBox(AxisAlignedBB aabb, PolyColor c) { } private boolean isNotSupported() { - return !HypixelAPI.getLocation().getGameType().isPresent() || (HypixelAPI.getLocation().getGameType().get() != GameType.SKYWARS && HypixelAPI.getLocation().getGameType().get() != GameType.SURVIVAL_GAMES && (HypixelAPI.getLocation().getGameType().get() != GameType.DUELS || !HypixelAPI.getLocation().getMode().orElse("").contains("_SW_"))); + return !HypixelUtils.getLocation().getGameType().isPresent() || (HypixelUtils.getLocation().getGameType().get() != GameType.SKYWARS && HypixelUtils.getLocation().getGameType().get() != GameType.SURVIVAL_GAMES && (HypixelUtils.getLocation().getGameType().get() != GameType.DUELS || !HypixelUtils.getLocation().getMode().orElse("").contains("_SW_"))); } } diff --git a/src/main/java/org/polyfrost/hytils/hooks/BlockModelRendererHook.java b/src/main/java/org/polyfrost/hytils/hooks/BlockModelRendererHook.java index 22a8bba..df4cf30 100644 --- a/src/main/java/org/polyfrost/hytils/hooks/BlockModelRendererHook.java +++ b/src/main/java/org/polyfrost/hytils/hooks/BlockModelRendererHook.java @@ -27,20 +27,21 @@ import org.polyfrost.hytils.config.BlockHighlightConfig; import org.polyfrost.hytils.config.HytilsConfig; import org.polyfrost.hytils.handlers.cache.HeightHandler; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.polyui.utils.ColorUtils; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; public class BlockModelRendererHook { public static void handleHeightOverlay(Args args, IBlockState stateIn, BlockPos blockPosIn) { - if (HypixelUtils.INSTANCE.isHypixel() && HytilsConfig.heightOverlay && stateIn.getBlock() instanceof BlockColored) { + if (HypixelUtils.isHypixel() && HytilsConfig.heightOverlay && stateIn.getBlock() instanceof BlockColored) { int height = HeightHandler.INSTANCE.getHeight(); if (height == -1) { return; } MapColor mapColor = stateIn.getBlock().getMapColor(stateIn); if (blockPosIn.getY() == (height - 1) && mapColor != null && (!(stateIn.getBlock().getMaterial() == Material.rock) || check(mapColor.colorIndex))) { - int color = HytilsConfig.manuallyEditHeightOverlay ? BlockHighlightConfig.colorMap.get(mapColor).get().getRGB() : DarkColorUtils.getCachedDarkColor(mapColor.colorValue); + int color = HytilsConfig.manuallyEditHeightOverlay ? BlockHighlightConfig.colorMap.get(mapColor).get().getArgb() : DarkColorUtils.getCachedDarkColor(mapColor.colorValue); args.set(0, (float) ColorUtils.getRed(color) / 255); args.set(1, (float) ColorUtils.getGreen(color) / 255); args.set(2, (float) ColorUtils.getBlue(color) / 255); diff --git a/src/main/java/org/polyfrost/hytils/mixin/BossStatusMixin_HideBossbar.java b/src/main/java/org/polyfrost/hytils/mixin/BossStatusMixin_HideBossbar.java index b27f279..b316a19 100644 --- a/src/main/java/org/polyfrost/hytils/mixin/BossStatusMixin_HideBossbar.java +++ b/src/main/java/org/polyfrost/hytils/mixin/BossStatusMixin_HideBossbar.java @@ -18,11 +18,11 @@ package org.polyfrost.hytils.mixin; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; import org.polyfrost.hytils.HytilsReborn; import org.polyfrost.hytils.config.HytilsConfig; import net.minecraft.entity.boss.BossStatus; import net.minecraft.entity.boss.IBossDisplayData; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -34,7 +34,7 @@ public abstract class BossStatusMixin_HideBossbar { @Inject(method = "setBossStatus", at = @At("HEAD"), cancellable = true) private static void cancelBossStatus(IBossDisplayData displayData, boolean hasColorModifierIn, CallbackInfo ci) { if (displayData == null) return; - if (HytilsConfig.lobbyBossbar && !HypixelAPI.getLocation().isGame() || HytilsConfig.gameAdBossbar && displayData.getDisplayName().getFormattedText().matches(HytilsReborn.INSTANCE.getLanguageHandler().getCurrent().gameBossbarAdvertisementRegex.pattern())) + if (HytilsConfig.lobbyBossbar && !HypixelUtils.getLocation().inGame() || HytilsConfig.gameAdBossbar && displayData.getDisplayName().getFormattedText().matches(HytilsReborn.INSTANCE.getLanguageHandler().getCurrent().gameBossbarAdvertisementRegex.pattern())) ci.cancel(); } } diff --git a/src/main/java/org/polyfrost/hytils/mixin/EntityLivingBaseMixin_MiningFatigue.java b/src/main/java/org/polyfrost/hytils/mixin/EntityLivingBaseMixin_MiningFatigue.java index d913d0d..8789f93 100644 --- a/src/main/java/org/polyfrost/hytils/mixin/EntityLivingBaseMixin_MiningFatigue.java +++ b/src/main/java/org/polyfrost/hytils/mixin/EntityLivingBaseMixin_MiningFatigue.java @@ -24,7 +24,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.oneconfig.api.ui.v1.notifications.Notifications; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -38,7 +38,7 @@ public class EntityLivingBaseMixin_MiningFatigue { @Inject(method = "addPotionEffect", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityLivingBase;onNewPotionEffect(Lnet/minecraft/potion/PotionEffect;)V")) private void onPotionEffect(PotionEffect potioneffectIn, CallbackInfo ci) { - if (HytilsConfig.notifyMiningFatigue && potioneffectIn.getPotionID() == Potion.digSlowdown.getId() && ($this instanceof EntityPlayerSP) && (!HytilsConfig.disableNotifyMiningFatigueSkyblock || !(HypixelAPI.getLocation().getGameType().orElse(null) == GameType.SKYBLOCK))) { + if (HytilsConfig.notifyMiningFatigue && potioneffectIn.getPotionID() == Potion.digSlowdown.getId() && ($this instanceof EntityPlayerSP) && (!HytilsConfig.disableNotifyMiningFatigueSkyblock || !(HypixelUtils.getLocation().getGameType().orElse(null) == GameType.SKYBLOCK))) { Notifications.INSTANCE.send("Hytils Reborn", "You have mining fatigue!"); } } diff --git a/src/main/java/org/polyfrost/hytils/mixin/GuiIngameForgeMixin_HideActionbar.java b/src/main/java/org/polyfrost/hytils/mixin/GuiIngameForgeMixin_HideActionbar.java index 593483d..5b719f0 100644 --- a/src/main/java/org/polyfrost/hytils/mixin/GuiIngameForgeMixin_HideActionbar.java +++ b/src/main/java/org/polyfrost/hytils/mixin/GuiIngameForgeMixin_HideActionbar.java @@ -21,7 +21,7 @@ import net.hypixel.data.type.GameType; import org.polyfrost.hytils.config.HytilsConfig; import net.minecraftforge.client.GuiIngameForge; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -31,7 +31,7 @@ public class GuiIngameForgeMixin_HideActionbar { @Inject(method = "renderRecordOverlay", at = @At("HEAD"), cancellable = true) private void cancelActionBar(int width, int height, float partialTicks, CallbackInfo ci) { - if (HypixelUtils.INSTANCE.isHypixel() && ((HytilsConfig.hideHousingActionBar && HypixelAPI.getLocation().getGameType().orElse(null) == GameType.HOUSING) || (HytilsConfig.hideDropperActionBar && "DROPPER".equals(HypixelAPI.getLocation().getMode().orElse(null))))) + if (HypixelUtils.isHypixel() && ((HytilsConfig.hideHousingActionBar && HypixelUtils.getLocation().getGameType().orElse(null) == GameType.HOUSING) || (HytilsConfig.hideDropperActionBar && "DROPPER".equals(HypixelUtils.getLocation().getMode().orElse(null))))) ci.cancel(); } } diff --git a/src/main/java/org/polyfrost/hytils/mixin/GuiIngameForgeMixin_HideHotbar.java b/src/main/java/org/polyfrost/hytils/mixin/GuiIngameForgeMixin_HideHotbar.java index 44aec05..a35b911 100644 --- a/src/main/java/org/polyfrost/hytils/mixin/GuiIngameForgeMixin_HideHotbar.java +++ b/src/main/java/org/polyfrost/hytils/mixin/GuiIngameForgeMixin_HideHotbar.java @@ -19,10 +19,10 @@ package org.polyfrost.hytils.mixin; import net.hypixel.data.type.GameType; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; import org.polyfrost.hytils.config.HytilsConfig; import net.minecraft.client.Minecraft; import net.minecraftforge.client.GuiIngameForge; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -32,9 +32,9 @@ public class GuiIngameForgeMixin_HideHotbar { @Inject(method = "renderHealth", at = @At("HEAD"), cancellable = true) public void cancelHealthbar(int width, int height, CallbackInfo ci) { - HypixelAPI.Location location = HypixelAPI.getLocation(); - if (HytilsConfig.hideHudElements && HypixelUtils.INSTANCE.isHypixel()) { - if (!location.isGame() || !location.getGameType().isPresent()) { + HypixelUtils.Location location = HypixelUtils.getLocation(); + if (HytilsConfig.hideHudElements && HypixelUtils.isHypixel()) { + if (!location.inGame() || !location.getGameType().isPresent() || "limbo".equals(location.getServerName().orElse(null))) { // rudimentary check if player has engaged in pvp or something if (Minecraft.getMinecraft().thePlayer.getHealth() < 20) return; ci.cancel(); @@ -49,7 +49,6 @@ public void cancelHealthbar(int width, int height, CallbackInfo ci) { case HOUSING: case MURDER_MYSTERY: case BUILD_BATTLE: - case LIMBO: // TODO have to test how to find limbo case QUAKECRAFT: case REPLAY: // rudimentary check if player has engaged in pvp or something @@ -79,9 +78,9 @@ public void cancelHealthbar(int width, int height, CallbackInfo ci) { @Inject(method = "renderFood", at = @At("HEAD"), cancellable = true) public void cancelFood(int width, int height, CallbackInfo ci) { - HypixelAPI.Location location = HypixelAPI.getLocation(); - if (HytilsConfig.hideHudElements && HypixelUtils.INSTANCE.isHypixel()) { - if (!location.isGame() || !location.getGameType().isPresent()) { + HypixelUtils.Location location = HypixelUtils.getLocation(); + if (HytilsConfig.hideHudElements && HypixelUtils.isHypixel()) { + if (!location.inGame() || !location.getGameType().isPresent() || "limbo".equals(location.getServerName().orElse(null))) { ci.cancel(); return; } @@ -96,7 +95,6 @@ public void cancelFood(int width, int height, CallbackInfo ci) { case BEDWARS: case MURDER_MYSTERY: case HOUSING: - case LIMBO: case PAINTBALL: case PIT: case DUELS: @@ -133,9 +131,9 @@ public void cancelFood(int width, int height, CallbackInfo ci) { @Inject(method = "renderArmor", at = @At("HEAD"), cancellable = true) public void cancelArmor(int width, int height, CallbackInfo ci) { - HypixelAPI.Location location = HypixelAPI.getLocation(); - if (HytilsConfig.hideHudElements && HypixelUtils.INSTANCE.isHypixel()) { - if (!location.isGame() || !location.getGameType().isPresent()) { + HypixelUtils.Location location = HypixelUtils.getLocation(); + if (HytilsConfig.hideHudElements && HypixelUtils.isHypixel()) { + if (!location.inGame() || !location.getGameType().isPresent() || "limbo".equals(location.getServerName().orElse(null))) { ci.cancel(); return; } @@ -150,7 +148,6 @@ public void cancelArmor(int width, int height, CallbackInfo ci) { case REPLAY: case MURDER_MYSTERY: case BUILD_BATTLE: - case LIMBO: case QUAKECRAFT: case TNTGAMES: case SKYBLOCK: @@ -170,9 +167,9 @@ public void cancelArmor(int width, int height, CallbackInfo ci) { @Inject(method = "renderAir", at = @At("HEAD"), cancellable = true) public void cancelAir(int width, int height, CallbackInfo ci) { - HypixelAPI.Location location = HypixelAPI.getLocation(); - if (HytilsConfig.hideHudElements && HypixelUtils.INSTANCE.isHypixel()) { - if (!location.isGame() || !location.getGameType().isPresent()) { + HypixelUtils.Location location = HypixelUtils.getLocation(); + if (HytilsConfig.hideHudElements && HypixelUtils.isHypixel()) { + if (!location.inGame() || !location.getGameType().isPresent()) { ci.cancel(); return; } diff --git a/src/main/java/org/polyfrost/hytils/mixin/GuiIngameForgeMixin_TitleEvent.java b/src/main/java/org/polyfrost/hytils/mixin/GuiIngameForgeMixin_TitleEvent.java index d78f82f..afc0ecf 100644 --- a/src/main/java/org/polyfrost/hytils/mixin/GuiIngameForgeMixin_TitleEvent.java +++ b/src/main/java/org/polyfrost/hytils/mixin/GuiIngameForgeMixin_TitleEvent.java @@ -18,7 +18,7 @@ package org.polyfrost.hytils.mixin; -import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.hytils.HytilsReborn; import org.polyfrost.hytils.events.TitleEvent; import net.minecraft.client.Minecraft; @@ -45,7 +45,7 @@ private boolean isHardcore(WorldInfo instance) { @Inject(method = "renderTitle", at = @At("HEAD"), cancellable = true) private void postTitleEvent(int l, int age, float opacity, CallbackInfo ci) { - if (HypixelUtils.INSTANCE.isHypixel()) { + if (HypixelUtils.isHypixel()) { TitleEvent event = new TitleEvent(displayedTitle, displayedSubTitle); MinecraftForge.EVENT_BUS.post(event); diff --git a/src/main/java/org/polyfrost/hytils/mixin/GuiNewChatMixin_LocrawHider.java b/src/main/java/org/polyfrost/hytils/mixin/GuiNewChatMixin_LocrawHider.java index d074399..eadc66d 100644 --- a/src/main/java/org/polyfrost/hytils/mixin/GuiNewChatMixin_LocrawHider.java +++ b/src/main/java/org/polyfrost/hytils/mixin/GuiNewChatMixin_LocrawHider.java @@ -18,7 +18,7 @@ package org.polyfrost.hytils.mixin; -import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.hytils.HytilsReborn; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ChatLine; @@ -56,7 +56,7 @@ private void handleSetChatLine(IChatComponent chatComponent, int chatLineId, int } private void handleHytilsMessage(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci) { - if (HytilsConfig.hideLocraw && HypixelUtils.INSTANCE.isHypixel() && chatComponent.getUnformattedTextForChat().startsWith("{") && chatComponent.getUnformattedTextForChat().endsWith("}")) { + if (HytilsConfig.hideLocraw && HypixelUtils.isHypixel() && chatComponent.getUnformattedTextForChat().startsWith("{") && chatComponent.getUnformattedTextForChat().endsWith("}")) { percentComplete = 1.0F; if (chatLineId != 0) { deleteChatLine(chatLineId); diff --git a/src/main/java/org/polyfrost/hytils/mixin/LayerArmorBaseMixin_HideIngameArmour.java b/src/main/java/org/polyfrost/hytils/mixin/LayerArmorBaseMixin_HideIngameArmour.java index 3db403e..032b761 100644 --- a/src/main/java/org/polyfrost/hytils/mixin/LayerArmorBaseMixin_HideIngameArmour.java +++ b/src/main/java/org/polyfrost/hytils/mixin/LayerArmorBaseMixin_HideIngameArmour.java @@ -25,7 +25,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -45,8 +45,8 @@ private void cancelArmor(EntityLivingBase entitylivingbaseIn, float p_177182_2_, } private static boolean shouldCancel(ItemStack itemStack) { - if (!HytilsConfig.hideArmor || itemStack == null || !HypixelUtils.INSTANCE.isHypixel()) return false; - final HypixelAPI.Location location = HypixelAPI.getLocation(); + if (!HytilsConfig.hideArmor || itemStack == null || !HypixelUtils.isHypixel()) return false; + final HypixelUtils.Location location = HypixelUtils.getLocation(); final Item item = itemStack.getItem(); if (location.getGameType().isPresent() && location.getMode().isPresent()) { if (item instanceof ItemArmor && ((ItemArmor) item).getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER) { diff --git a/src/main/java/org/polyfrost/hytils/mixin/RenderEntityItemMixin_UHCOverlay.java b/src/main/java/org/polyfrost/hytils/mixin/RenderEntityItemMixin_UHCOverlay.java index 09ff67c..b3ed413 100644 --- a/src/main/java/org/polyfrost/hytils/mixin/RenderEntityItemMixin_UHCOverlay.java +++ b/src/main/java/org/polyfrost/hytils/mixin/RenderEntityItemMixin_UHCOverlay.java @@ -19,13 +19,13 @@ package org.polyfrost.hytils.mixin; import net.hypixel.data.type.GameType; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; import org.polyfrost.hytils.config.HytilsConfig; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderEntityItem; import net.minecraft.client.resources.model.IBakedModel; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.Item; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -36,8 +36,8 @@ public class RenderEntityItemMixin_UHCOverlay { @Inject(method = "func_177077_a(Lnet/minecraft/entity/item/EntityItem;DDDFLnet/minecraft/client/resources/model/IBakedModel;)I", at = @At(("TAIL"))) public void scaleSpecialItems(EntityItem entity, double f4, double f5, double flag, float i, IBakedModel f, CallbackInfoReturnable cir) { Item item = entity.getEntityItem().getItem(); - GameType gameType = HypixelAPI.getLocation().getGameType().orElse(null); - if (HypixelUtils.INSTANCE.isHypixel() && (gameType == GameType.UHC || gameType == GameType.SPEED_UHC) && HytilsConfig.uhcOverlay) { + GameType gameType = HypixelUtils.getLocation().getGameType().orElse(null); + if (HypixelUtils.isHypixel() && (gameType == GameType.UHC || gameType == GameType.SPEED_UHC) && HytilsConfig.uhcOverlay) { if (item.getRegistryName().equals("minecraft:apple") || item.getRegistryName().equals("minecraft:golden_apple") || item.getRegistryName().equals("minecraft:skull") || item.getRegistryName().equals("minecraft:gold_ingot") || item.getRegistryName().equals("minecraft:gold_nugget")) { GlStateManager.scale(HytilsConfig.uhcOverlayMultiplier, HytilsConfig.uhcOverlayMultiplier, HytilsConfig.uhcOverlayMultiplier); } 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 0df3e09..6da5334 100644 --- a/src/main/java/org/polyfrost/hytils/mixin/cosmetics/RenderEntityItemMixin.java +++ b/src/main/java/org/polyfrost/hytils/mixin/cosmetics/RenderEntityItemMixin.java @@ -25,7 +25,7 @@ import net.minecraft.client.renderer.entity.RenderEntityItem; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.*; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -39,8 +39,8 @@ public class RenderEntityItemMixin { private void removeItemCosmetics(EntityItem entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) { ItemStack stack = entity.getEntityItem(); if (stack == null) return; - if ((HytilsConfig.hideDuelsCosmetics && HypixelAPI.getLocation().getGameType().orElse(null) == GameType.DUELS) || (HytilsConfig.hideArcadeCosmetics && - HypixelAPI.getLocation().getGameType().orElse(null) == GameType.ARCADE) && HypixelAPI.getLocation().isGame() && + 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 || shouldRemove(stack.getItem().getUnlocalizedName()) || (stack.getItem() instanceof ItemBlock && (shouldRemove(((ItemBlock) stack.getItem()).block.getUnlocalizedName()) || ((ItemBlock) stack.getItem()).block instanceof BlockPumpkin)))) ci.cancel(); } diff --git a/src/main/java/org/polyfrost/hytils/mixin/cosmetics/WorldMixin.java b/src/main/java/org/polyfrost/hytils/mixin/cosmetics/WorldMixin.java index dc13f9d..d62a1cb 100644 --- a/src/main/java/org/polyfrost/hytils/mixin/cosmetics/WorldMixin.java +++ b/src/main/java/org/polyfrost/hytils/mixin/cosmetics/WorldMixin.java @@ -23,7 +23,7 @@ import org.polyfrost.hytils.handlers.cache.CosmeticsHandler; import net.minecraft.util.EnumParticleTypes; import net.minecraft.world.World; -import org.polyfrost.oneconfig.api.hypixel.v0.HypixelAPI; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -34,8 +34,8 @@ public class WorldMixin { @Inject(method = "spawnParticle(IZDDDDDD[I)V", at = @At("HEAD"), cancellable = true) private void removeParticles(int particleID, boolean p_175720_2_, double xCood, double yCoord, double zCoord, double xOffset, double yOffset, double zOffset, int[] p_175720_15_, CallbackInfo ci) { - if ((HytilsConfig.hideDuelsCosmetics && HypixelAPI.getLocation().getGameType().orElse(null) == GameType.DUELS) || - (HytilsConfig.hideArcadeCosmetics && HypixelAPI.getLocation().getGameType().orElse(null) == GameType.ARCADE) && HypixelAPI.getLocation().isGame()) { + if ((HytilsConfig.hideDuelsCosmetics && HypixelUtils.getLocation().getGameType().orElse(null) == GameType.DUELS) || + (HytilsConfig.hideArcadeCosmetics && HypixelUtils.getLocation().getGameType().orElse(null) == GameType.ARCADE) && HypixelUtils.getLocation().inGame()) { String particleName = EnumParticleTypes.getParticleFromId(particleID).getParticleName(); CosmeticsHandler.INSTANCE.particleCosmetics.forEach((particle) -> { if (particleName.equalsIgnoreCase(particle)) { 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 2713f4f..3166527 100644 --- a/src/main/java/org/polyfrost/hytils/mixin/overlay/VertexLighterFlatMixin.java +++ b/src/main/java/org/polyfrost/hytils/mixin/overlay/VertexLighterFlatMixin.java @@ -18,7 +18,7 @@ package org.polyfrost.hytils.mixin.overlay; -import org.polyfrost.oneconfig.api.hypixel.v1.HypixelUtils; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.hytils.config.HytilsConfig; import org.polyfrost.hytils.util.DarkColorUtils; import net.minecraft.block.BlockColored; @@ -43,7 +43,7 @@ public class VertexLighterFlatMixin { @ModifyArgs(method = "processQuad", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/client/model/pipeline/VertexLighterFlat;updateColor([F[FFFFFI)V")) private void modifyArgs(Args args) { - if (HypixelUtils.INSTANCE.isHypixel() && HytilsConfig.heightOverlay && blockInfo.getBlock() instanceof BlockColored) { + if (HypixelUtils.isHypixel() && HytilsConfig.heightOverlay && blockInfo.getBlock() instanceof BlockColored) { int height = HeightHandler.INSTANCE.getHeight(); if (height == -1) return; if (blockInfo.getBlockPos().getY() != (height - 1)) return; diff --git a/src/main/java/org/polyfrost/hytils/util/HypixelAPIUtils.java b/src/main/java/org/polyfrost/hytils/util/HypixelAPIUtils.java index d293895..62e5dea 100644 --- a/src/main/java/org/polyfrost/hytils/util/HypixelAPIUtils.java +++ b/src/main/java/org/polyfrost/hytils/util/HypixelAPIUtils.java @@ -18,13 +18,10 @@ package org.polyfrost.hytils.util; -import org.polyfrost.oneconfig.api.event.v1.events.event.LocrawEvent; -import org.polyfrost.oneconfig.api.event.v1.events.event.Stage; -import org.polyfrost.oneconfig.api.event.v1.events.event.TickEvent; -import org.polyfrost.oneconfig.libs.eventbus.Subscribe; +import org.polyfrost.oneconfig.api.event.v1.events.TickEvent; +import org.polyfrost.oneconfig.api.event.v1.invoke.EventHandler; +import org.polyfrost.oneconfig.api.hypixel.v0.HypixelUtils; import org.polyfrost.oneconfig.utils.v1.JsonUtils; -import org.polyfrost.oneconfig.utils.v1.NetworkUtils; -import org.polyfrost.oneconfig.api.hypixel.v1.LocrawInfo; import org.polyfrost.hytils.HytilsReborn; import org.polyfrost.hytils.handlers.cache.HeightHandler; import org.polyfrost.hytils.util.ranks.RankType; @@ -52,7 +49,6 @@ public class HypixelAPIUtils { private static final String[] rankValues = {"rank", "monthlyPackageRank", "newPackageRank", "packageRank"}; public static String gexp; public static String winstreak; - public static LocrawInfo locraw; @Nullable private static String token; @Nullable @@ -63,6 +59,18 @@ public class HypixelAPIUtils { private static String serverId; private int ticks = 0; + public void initialize() { + EventHandler.of(TickEvent.Start.class, () -> { + if (ticks % 20 == 0) { + if (Minecraft.getMinecraft().thePlayer != null) { + HeightHandler.INSTANCE.getHeight(); + } + ticks = 0; + } + ticks++; + }).register(); + } + private static String getCurrentESTTime() { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("EST")); @@ -88,7 +96,7 @@ private static JsonObject getJsonObjectAuth(String url) { HttpURLConnection connection = setupConnection(url); if (connection == null) return null; try (InputStreamReader input = new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)) { - JsonElement element = JsonUtils.parseString(IOUtils.toString(input)); + JsonElement element = JsonUtils.parse(IOUtils.toString(input)); if (username != null && serverId != null) { token = connection.getHeaderField("x-ursa-token"); expiry = calculateExpiry(connection.getHeaderField("x-ursa-expires")); @@ -261,8 +269,8 @@ public static boolean getWinstreak() { return false; } JsonObject playerStats = jsonObject.getAsJsonObject("player").getAsJsonObject("stats"); - if (locraw != null) { - switch (locraw.getGameType()) { + if (HypixelUtils.getLocation().getGameType().isPresent()) { + switch (HypixelUtils.getLocation().getGameType().get()) { case BEDWARS: try { winstreak = Integer.toString(playerStats.getAsJsonObject("Bedwars").get("winstreak").getAsInt()); @@ -305,8 +313,8 @@ public static boolean getWinstreak(String username) { return false; } JsonObject playerStats = jsonObject.getAsJsonObject("player").getAsJsonObject("stats"); - if (locraw != null) { - switch (locraw.getGameType()) { + if (HypixelUtils.getLocation().getGameType().isPresent()) { + switch (HypixelUtils.getLocation().getGameType().get()) { case BEDWARS: try { winstreak = Integer.toString(playerStats.getAsJsonObject("Bedwars").get("winstreak").getAsInt()); @@ -414,34 +422,18 @@ public static RankType getRank(String username) { */ public static String getUUID(String username) { try { - JsonObject uuidResponse = NetworkUtils.getJsonElement("https://api.mojang.com/users/profiles/minecraft/" + username).getAsJsonObject(); - if (uuidResponse.has("error")) { - HytilsReborn.INSTANCE.sendMessage(EnumChatFormatting.RED + "Failed with error: " + uuidResponse.get("reason").getAsString()); - return null; + JsonElement maybeUuidResponse = JsonUtils.parseFromUrl("https://api.mojang.com/users/profiles/minecraft/" + username); + if (maybeUuidResponse != null) { + JsonObject uuidResponse = maybeUuidResponse.getAsJsonObject(); + if (uuidResponse.has("error")) { + HytilsReborn.INSTANCE.sendMessage(EnumChatFormatting.RED + "Failed with error: " + uuidResponse.get("reason").getAsString()); + return null; + } + return uuidResponse.get("id").getAsString(); } - return uuidResponse.get("id").getAsString(); } catch (Exception e) { HytilsReborn.INSTANCE.sendMessage(EnumChatFormatting.RED + "Failed to fetch " + username + "'s data. Please make sure this user exists."); - return null; } - } - - @Subscribe - public void onTick(TickEvent event) { - if (event.stage == Stage.START) { - if (ticks % 20 == 0) { - if (Minecraft.getMinecraft().thePlayer != null) { - HeightHandler.INSTANCE.getHeight(); - } - ticks = 0; - } - - ticks++; - } - } - - @Subscribe - private void onLocraw(LocrawEvent event) { - locraw = event.info; + return null; } } diff --git a/src/main/java/org/polyfrost/hytils/util/friends/FriendCache.java b/src/main/java/org/polyfrost/hytils/util/friends/FriendCache.java index c565cc9..4bed1bb 100644 --- a/src/main/java/org/polyfrost/hytils/util/friends/FriendCache.java +++ b/src/main/java/org/polyfrost/hytils/util/friends/FriendCache.java @@ -18,6 +18,7 @@ package org.polyfrost.hytils.util.friends; +import org.polyfrost.oneconfig.utils.v1.JsonUtils; import org.polyfrost.oneconfig.utils.v1.Multithreading; import org.polyfrost.oneconfig.utils.v1.NetworkUtils; import org.polyfrost.hytils.HytilsReborn; @@ -58,7 +59,7 @@ private Set downloadFriendDataFromApi() { try { // Convert output format into a list of names // TODO: Error handling if JSON data is in bad format - JsonObject json = NetworkUtils.getJsonElement(url, "OneConfig/1.0.0", 15000, false).getAsJsonObject(); + JsonObject json = JsonUtils.parse(NetworkUtils.getString(url, "OneConfig/1.0.0", 15000, false)).getAsJsonObject(); Set friends = new HashSet<>(); // Note that the keys are the UUIDs for (Map.Entry key : json.entrySet()) { @@ -98,7 +99,7 @@ public Set getFriendUUIDs() { return friends; } else if (!currentlyDownloadingFriendData && !hasRequestFailed) { // Start thread to download friend data - Multithreading.runAsync(() -> { + Multithreading.submit(() -> { currentlyDownloadingFriendData = true; Set result = downloadFriendDataFromApi(); if (result != null) {