From a5c540d977a3510812cac7fac340fe17e7d10983 Mon Sep 17 00:00:00 2001 From: Lorenz Date: Thu, 14 Jul 2022 12:06:07 +0200 Subject: renamed mod to SkyHanni --- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 119 ++++ .../java/at/hannibal2/skyhanni/bazaar/BazaarApi.kt | 59 ++ .../at/hannibal2/skyhanni/bazaar/BazaarData.kt | 3 + .../hannibal2/skyhanni/bazaar/BazaarDataGrabber.kt | 113 ++++ .../hannibal2/skyhanni/bazaar/BazaarOrderHelper.kt | 87 +++ .../java/at/hannibal2/skyhanni/chat/ChatFilter.kt | 284 ++++++++++ .../java/at/hannibal2/skyhanni/chat/ChatManager.kt | 51 ++ .../at/hannibal2/skyhanni/chat/PlayerChatFilter.kt | 90 +++ .../skyhanni/chat/PlayerMessageChannel.kt | 10 + .../at/hannibal2/skyhanni/config/Features.java | 274 ++++++++++ .../at/hannibal2/skyhanni/config/GuiTextures.java | 32 ++ .../skyhanni/config/commands/Commands.java | 26 + .../skyhanni/config/commands/SimpleCommand.java | 60 ++ .../skyhanni/config/config/ConfigEditor.java | 602 +++++++++++++++++++++ .../skyhanni/config/core/BackgroundBlur.java | 249 +++++++++ .../skyhanni/config/core/ChromaColour.java | 93 ++++ .../skyhanni/config/core/GlScissorStack.java | 86 +++ .../hannibal2/skyhanni/config/core/GuiElement.java | 12 + .../skyhanni/config/core/GuiElementBoolean.java | 118 ++++ .../skyhanni/config/core/GuiElementColour.java | 370 +++++++++++++ .../skyhanni/config/core/GuiElementTextField.java | 549 +++++++++++++++++++ .../config/core/GuiScreenElementWrapper.java | 34 ++ .../skyhanni/config/core/config/Config.java | 5 + .../skyhanni/config/core/config/KeybindHelper.java | 49 ++ .../skyhanni/config/core/config/Position.java | 197 +++++++ .../config/core/config/annotations/Category.java | 14 + .../core/config/annotations/ConfigAccordionId.java | 12 + .../config/annotations/ConfigEditorAccordion.java | 12 + .../config/annotations/ConfigEditorBoolean.java | 11 + .../config/annotations/ConfigEditorButton.java | 14 + .../config/annotations/ConfigEditorColour.java | 11 + .../annotations/ConfigEditorDraggableList.java | 12 + .../config/annotations/ConfigEditorDropdown.java | 14 + .../config/annotations/ConfigEditorKeybind.java | 12 + .../config/annotations/ConfigEditorSlider.java | 16 + .../core/config/annotations/ConfigEditorStyle.java | 11 + .../core/config/annotations/ConfigEditorText.java | 11 + .../core/config/annotations/ConfigOption.java | 16 + .../config/core/config/gui/GuiOptionEditor.java | 62 +++ .../core/config/gui/GuiOptionEditorAccordion.java | 80 +++ .../core/config/gui/GuiOptionEditorBoolean.java | 37 ++ .../core/config/gui/GuiOptionEditorButton.java | 60 ++ .../core/config/gui/GuiOptionEditorColour.java | 74 +++ .../config/gui/GuiOptionEditorDraggableList.java | 269 +++++++++ .../core/config/gui/GuiOptionEditorDropdown.java | 145 +++++ .../core/config/gui/GuiOptionEditorKeybind.java | 88 +++ .../core/config/gui/GuiOptionEditorSlider.java | 136 +++++ .../core/config/gui/GuiOptionEditorStyle.java | 42 ++ .../core/config/gui/GuiOptionEditorText.java | 78 +++ .../config/core/config/gui/GuiPositionEditor.java | 172 ++++++ .../config/core/config/struct/ConfigProcessor.java | 167 ++++++ .../config/core/util/GuiElementSlider.java | 121 +++++ .../skyhanni/config/core/util/StringUtils.java | 8 + .../skyhanni/config/core/util/lerp/LerpUtils.java | 25 + .../config/core/util/lerp/LerpingFloat.java | 68 +++ .../config/core/util/lerp/LerpingInteger.java | 76 +++ .../config/core/util/render/RenderUtils.java | 155 ++++++ .../config/core/util/render/TextRenderUtils.java | 155 ++++++ .../skyhanni/config/textures/TextureObject.java | 37 ++ .../skyhanni/config/textures/Textures.java | 54 ++ .../at/hannibal2/skyhanni/config/utils/Utils.java | 367 +++++++++++++ .../skyhanni/dungeon/DungeonBossMessages.kt | 51 ++ .../skyhanni/dungeon/DungeonChatFilter.kt | 224 ++++++++ .../hannibal2/skyhanni/dungeon/DungeonCleanEnd.kt | 130 +++++ .../at/hannibal2/skyhanni/dungeon/DungeonData.kt | 46 ++ .../skyhanni/dungeon/DungeonDeathCounter.kt | 97 ++++ .../dungeon/DungeonHighlightClickedBlocks.kt | 99 ++++ .../skyhanni/dungeon/DungeonMilestoneDisplay.kt | 96 ++++ .../damageindicator/DungeonBossDamageIndicator.kt | 181 +++++++ .../dungeon/damageindicator/DungeonBossFinder.kt | 381 +++++++++++++ .../skyhanni/dungeon/damageindicator/EntityData.kt | 6 + .../dungeon/damageindicator/EntityResult.kt | 3 + .../skyhanni/events/CheckRenderEntityEvent.kt | 14 + .../events/DamageIndicatorFinalBossEvent.kt | 3 + .../hannibal2/skyhanni/events/DungeonEnterEvent.kt | 3 + .../hannibal2/skyhanni/events/GuiContainerEvent.kt | 54 ++ .../skyhanni/events/GuiRenderItemEvent.kt | 23 + .../skyhanni/events/LorenzActionBarEvent.kt | 3 + .../hannibal2/skyhanni/events/LorenzChatEvent.kt | 5 + .../at/hannibal2/skyhanni/events/LorenzEvent.kt | 20 + .../at/hannibal2/skyhanni/events/PacketEvent.kt | 25 + .../skyhanni/events/PlayerSendChatEvent.kt | 11 + .../skyhanni/items/HideNotClickableItems.kt | 440 +++++++++++++++ .../skyhanni/items/ItemDisplayOverlayFeatures.kt | 107 ++++ .../items/abilitycooldown/ItemAbilityCooldown.kt | 197 +++++++ .../items/abilitycooldown/WitherImpactDetection.kt | 65 +++ .../at/hannibal2/skyhanni/misc/ButtonOnPause.kt | 51 ++ .../hannibal2/skyhanni/misc/CurrentPetDisplay.kt | 53 ++ .../skyhanni/misc/ExpBottleOnGroundHider.kt | 19 + .../java/at/hannibal2/skyhanni/misc/HypixelData.kt | 63 +++ .../at/hannibal2/skyhanni/misc/ScoreboardData.kt | 45 ++ .../skyhanni/mixinhooks/GuiContainerHook.kt | 61 +++ .../mixinhooks/NetHandlerPlayClientHook.kt | 9 + .../skyhanni/mixinhooks/NetworkManagerHook.kt | 10 + .../skyhanni/mixinhooks/RenderItemHook.kt | 28 + .../skyhanni/mixinhooks/RenderManagerHook.kt | 25 + .../skyhanni/mixins/MixinGuiContainer.java | 48 ++ .../skyhanni/mixins/MixinNetHandlerPlayClient.java | 24 + .../skyhanni/mixins/MixinNetworkManager.java | 20 + .../hannibal2/skyhanni/mixins/MixinRenderItem.java | 41 ++ .../skyhanni/mixins/MixinRenderManager.java | 19 + .../java/at/hannibal2/skyhanni/test/LorenzTest.kt | 28 + .../java/at/hannibal2/skyhanni/utils/APIUtil.kt | 48 ++ .../java/at/hannibal2/skyhanni/utils/BlockUtils.kt | 23 + .../java/at/hannibal2/skyhanni/utils/GuiRender.kt | 32 ++ .../java/at/hannibal2/skyhanni/utils/ItemUtil.kt | 213 ++++++++ .../java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 72 +++ .../at/hannibal2/skyhanni/utils/LorenzColor.kt | 27 + .../at/hannibal2/skyhanni/utils/LorenzDebug.kt | 16 + .../at/hannibal2/skyhanni/utils/LorenzLogger.kt | 70 +++ .../at/hannibal2/skyhanni/utils/LorenzUtils.kt | 113 ++++ .../java/at/hannibal2/skyhanni/utils/LorenzVec.kt | 61 +++ .../java/at/hannibal2/skyhanni/utils/NumberUtil.kt | 152 ++++++ .../at/hannibal2/skyhanni/utils/RenderUtils.kt | 355 ++++++++++++ 114 files changed, 10224 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java create mode 100644 src/main/java/at/hannibal2/skyhanni/bazaar/BazaarApi.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/bazaar/BazaarData.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/bazaar/BazaarDataGrabber.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/bazaar/BazaarOrderHelper.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/chat/ChatFilter.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/chat/ChatManager.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/chat/PlayerChatFilter.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/chat/PlayerMessageChannel.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/config/Features.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/GuiTextures.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/commands/Commands.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/config/ConfigEditor.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/BackgroundBlur.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/ChromaColour.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/GlScissorStack.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/GuiElement.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/GuiElementBoolean.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/GuiElementColour.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/GuiElementTextField.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/GuiScreenElementWrapper.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/Config.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/KeybindHelper.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/annotations/Category.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/annotations/ConfigAccordionId.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/annotations/ConfigEditorAccordion.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/annotations/ConfigEditorBoolean.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/annotations/ConfigEditorButton.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/annotations/ConfigEditorColour.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/annotations/ConfigEditorDraggableList.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/annotations/ConfigEditorDropdown.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/annotations/ConfigEditorKeybind.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/annotations/ConfigEditorSlider.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/annotations/ConfigEditorStyle.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/annotations/ConfigEditorText.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/annotations/ConfigOption.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiOptionEditor.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiOptionEditorAccordion.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiOptionEditorBoolean.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiOptionEditorButton.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiOptionEditorColour.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiOptionEditorDraggableList.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiOptionEditorDropdown.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiOptionEditorKeybind.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiOptionEditorSlider.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiOptionEditorStyle.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiOptionEditorText.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/config/struct/ConfigProcessor.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/util/GuiElementSlider.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/util/StringUtils.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/util/lerp/LerpUtils.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/util/lerp/LerpingFloat.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/util/lerp/LerpingInteger.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/util/render/RenderUtils.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/core/util/render/TextRenderUtils.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/textures/TextureObject.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/textures/Textures.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/utils/Utils.java create mode 100644 src/main/java/at/hannibal2/skyhanni/dungeon/DungeonBossMessages.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/dungeon/DungeonChatFilter.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/dungeon/DungeonCleanEnd.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/dungeon/DungeonData.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/dungeon/DungeonDeathCounter.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/dungeon/DungeonHighlightClickedBlocks.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/dungeon/DungeonMilestoneDisplay.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/dungeon/damageindicator/DungeonBossDamageIndicator.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/dungeon/damageindicator/DungeonBossFinder.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/dungeon/damageindicator/EntityData.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/dungeon/damageindicator/EntityResult.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/events/CheckRenderEntityEvent.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/events/DamageIndicatorFinalBossEvent.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/events/DungeonEnterEvent.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/events/GuiRenderItemEvent.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/events/LorenzActionBarEvent.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/events/LorenzChatEvent.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/events/PacketEvent.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/events/PlayerSendChatEvent.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/items/ItemDisplayOverlayFeatures.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/items/abilitycooldown/ItemAbilityCooldown.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/items/abilitycooldown/WitherImpactDetection.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/misc/ButtonOnPause.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/misc/CurrentPetDisplay.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/misc/ExpBottleOnGroundHider.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/misc/HypixelData.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/misc/ScoreboardData.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/mixinhooks/GuiContainerHook.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/mixinhooks/NetHandlerPlayClientHook.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/mixinhooks/NetworkManagerHook.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/mixinhooks/RenderItemHook.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/mixinhooks/RenderManagerHook.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/mixins/MixinGuiContainer.java create mode 100644 src/main/java/at/hannibal2/skyhanni/mixins/MixinNetHandlerPlayClient.java create mode 100644 src/main/java/at/hannibal2/skyhanni/mixins/MixinNetworkManager.java create mode 100644 src/main/java/at/hannibal2/skyhanni/mixins/MixinRenderItem.java create mode 100644 src/main/java/at/hannibal2/skyhanni/mixins/MixinRenderManager.java create mode 100644 src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/BlockUtils.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/GuiRender.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/ItemUtil.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/LorenzDebug.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/LorenzLogger.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java new file mode 100644 index 000000000..09355383c --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -0,0 +1,119 @@ +package at.hannibal2.skyhanni; + +import at.hannibal2.skyhanni.bazaar.BazaarApi; +import at.hannibal2.skyhanni.bazaar.BazaarOrderHelper; +import at.hannibal2.skyhanni.chat.ChatFilter; +import at.hannibal2.skyhanni.chat.ChatManager; +import at.hannibal2.skyhanni.chat.PlayerChatFilter; +import at.hannibal2.skyhanni.config.Features; +import at.hannibal2.skyhanni.config.commands.Commands; +import at.hannibal2.skyhanni.dungeon.*; +import at.hannibal2.skyhanni.dungeon.damageindicator.DungeonBossDamageIndicator; +import at.hannibal2.skyhanni.items.HideNotClickableItems; +import at.hannibal2.skyhanni.items.ItemDisplayOverlayFeatures; +import at.hannibal2.skyhanni.items.abilitycooldown.ItemAbilityCooldown; +import at.hannibal2.skyhanni.misc.*; +import at.hannibal2.skyhanni.test.LorenzTest; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import java.io.*; +import java.nio.charset.StandardCharsets; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; + +@Mod(modid = SkyHanniMod.MODID, version = SkyHanniMod.VERSION) +public class SkyHanniMod { + + public static final String MODID = "skyhanni"; + public static final String VERSION = "0."; + + public static Features feature; + private File configFile; + + private final Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create(); + + public static File configDirectory; + + @EventHandler + public void preInit(FMLPreInitializationEvent event) { + new BazaarApi(); + MinecraftForge.EVENT_BUS.register(this); + MinecraftForge.EVENT_BUS.register(new ChatManager()); + MinecraftForge.EVENT_BUS.register(new HypixelData()); + MinecraftForge.EVENT_BUS.register(new DungeonData()); + MinecraftForge.EVENT_BUS.register(new ScoreboardData()); + + MinecraftForge.EVENT_BUS.register(new BazaarOrderHelper()); + MinecraftForge.EVENT_BUS.register(new ChatFilter()); + MinecraftForge.EVENT_BUS.register(new PlayerChatFilter()); + MinecraftForge.EVENT_BUS.register(new DungeonChatFilter()); + MinecraftForge.EVENT_BUS.register(new HideNotClickableItems()); + MinecraftForge.EVENT_BUS.register(new DungeonHighlightClickedBlocks()); + MinecraftForge.EVENT_BUS.register(new ItemDisplayOverlayFeatures()); + MinecraftForge.EVENT_BUS.register(new CurrentPetDisplay()); + MinecraftForge.EVENT_BUS.register(new ExpBottleOnGroundHider()); + MinecraftForge.EVENT_BUS.register(new DungeonBossDamageIndicator()); + MinecraftForge.EVENT_BUS.register(new ItemAbilityCooldown()); + MinecraftForge.EVENT_BUS.register(new DungeonMilestoneDisplay()); + MinecraftForge.EVENT_BUS.register(new DungeonDeathCounter()); + MinecraftForge.EVENT_BUS.register(new DungeonCleanEnd()); + MinecraftForge.EVENT_BUS.register(new DungeonBossMessages()); + + Commands.init(); + + MinecraftForge.EVENT_BUS.register(new LorenzTest()); + MinecraftForge.EVENT_BUS.register(new ButtonOnPause()); + + configDirectory = new File("mods/SkyHanni/config"); + try { + //noinspection ResultOfMethodCallIgnored + configDirectory.mkdir(); + } catch (Exception ignored) {} + + configFile = new File(configDirectory, "config.json"); + + if (configFile.exists()) { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) { + feature = gson.fromJson(reader, Features.class); + } catch (Exception ignored) {} + } + + if (feature == null) { + feature = new Features(); + saveConfig(); + } + Runtime.getRuntime().addShutdownHook(new Thread(this::saveConfig)); + } + + public void saveConfig() { + try { + //noinspection ResultOfMethodCallIgnored + configFile.createNewFile(); + + try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))) { + writer.write(gson.toJson(feature)); + } + } catch (IOException ignored) {} + } + + public static GuiScreen screenToOpen = null; + private static int screenTicks = 0; + + @SubscribeEvent + public void onClientTick(TickEvent.ClientTickEvent event) { + if (screenToOpen != null) { + screenTicks++; + if (screenTicks == 5) { + Minecraft.getMinecraft().displayGuiScreen(screenToOpen); + screenTicks = 0; + screenToOpen = null; + } + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/bazaar/BazaarApi.kt new file mode 100644 index 000000000..cbebe951c --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/bazaar/BazaarApi.kt @@ -0,0 +1,59 @@ +package at.hannibal2.skyhanni.bazaar + +import at.hannibal2.skyhanni.utils.LorenzUtils + +class BazaarApi { + + companion object { + private val bazaarMap = mutableMapOf() + + fun isBazaarInventory(inventoryName: String): Boolean { + if (inventoryName.contains(" ➜ ") && !inventoryName.contains("Museum")) return true + if (BazaarOrderHelper.isBazaarOrderInventory(inventoryName)) return true + + return when (inventoryName) { + "Your Bazaar Orders" -> true + "How many do you want?" -> true + "How much do you want to pay?" -> true + "Confirm Buy Order" -> true + "Confirm Instant Buy" -> true + "At what price are you selling?" -> true + "Confirm Sell Offer" -> true + "Order options" -> true + + else -> false + } + } + + fun getCleanBazaarName(name: String): String { + if (name.endsWith(" Gemstone")) { + return name.substring(6) + } + if (name.startsWith("§")) { + return name.substring(2) + } + + return name + } + + fun getBazaarDataForName(name: String): BazaarData { + if (bazaarMap.containsKey(name)) { + val bazaarData = bazaarMap[name] + if (bazaarData != null) { + return bazaarData + } + LorenzUtils.error("Bazaar data is null for item '$name'") + } + throw Error("no bz data found for name '$name'") + } + + fun isBazaarItem(name: String): Boolean { + val bazaarName = getCleanBazaarName(name) + return bazaarMap.containsKey(bazaarName) + } + } + + init { + BazaarDataGrabber(bazaarMap).start() + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/bazaar/BazaarData.kt b/src/main/java/at/hannibal2/skyhanni/bazaar/BazaarData.kt new file mode 100644 index 000000000..01300e67c --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/bazaar/BazaarData.kt @@ -0,0 +1,3 @@ +package at.hannibal2.skyhanni.bazaar + +data class BazaarData(val apiName: String, val itemName: String, val sellPrice: Double, val buyPrice: Double) \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/bazaar/BazaarDataGrabber.kt b/src/main/java/at/hannibal2/skyhanni/bazaar/BazaarDataGrabber.kt new file mode 100644 index 000000000..1f2f1171a --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/bazaar/BazaarDataGrabber.kt @@ -0,0 +1,113 @@ +package at.hannibal2.skyhanni.bazaar + +import at.hannibal2.skyhanni.utils.APIUtil +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.round +import kotlin.concurrent.fixedRateTimer + +internal class BazaarDataGrabber(private var bazaarMap: MutableMap) { + + companion object { + private val itemNames = mutableMapOf() + + private var lastData = "" + var lastTime = 0L + var blockNoChange = false + var currentlyUpdating = false + } + + private fun loadItemNames(): Boolean { + currentlyUpdating = true + try { + val itemsData = APIUtil.getJSONResponse("https://api.hypixel.net/resources/skyblock/items") + for (element in itemsData["items"].asJsonArray) { + val jsonObject = element.asJsonObject + val name = jsonObject["name"].asString + val id = jsonObject["id"].asString + itemNames[id] = name + } + currentlyUpdating = false + return true + } catch (e: Throwable) { + e.printStackTrace() + LorenzUtils.error("Error while trying to read bazaar item list from api: " + e.message) + currentlyUpdating = false + return false + } + } + + fun start() { + fixedRateTimer(name = "skyhanni-bazaar-update", period = 1000L) { + if (!LorenzUtils.inSkyblock) { + return@fixedRateTimer + } + + if (currentlyUpdating) { + LorenzUtils.error("Bazaar update took too long! Error?") + return@fixedRateTimer + } + + if (itemNames.isEmpty()) { + if (!loadItemNames()) { + return@fixedRateTimer + } + } + checkIfUpdateNeeded() + } + } + + private fun checkIfUpdateNeeded() { + if (lastData != "") { + if (System.currentTimeMillis() - lastTime > 9_000) { + blockNoChange = true + } else { + if (blockNoChange) { + return + } + } + } + + currentlyUpdating = true + updateBazaarData() + currentlyUpdating = false + } + + private fun updateBazaarData() { + val bazaarData = APIUtil.getJSONResponse("https://api.hypixel.net/skyblock/bazaar") + if (bazaarData.toString() != lastData) { + lastData = bazaarData.toString() + lastTime = System.currentTimeMillis() + } + + val products = bazaarData["products"].asJsonObject + + for (entry in products.entrySet()) { + val apiName = entry.key + + if (apiName == "ENCHANTED_CARROT_ON_A_STICK") continue + if (apiName == "BAZAAR_COOKIE") continue + + val itemData = entry.value.asJsonObject + + val itemName = itemNames.getOrDefault(apiName, null) + if (itemName == null) { + LorenzUtils.error("Bazaar item name is null for '$apiName'! Restart to fix this problem!") + continue + } + + val sellPrice: Double = try { + itemData["sell_summary"].asJsonArray[0].asJsonObject["pricePerUnit"].asDouble.round(1) + } catch (e: Exception) { + 0.0 + } + val buyPrice: Double = try { + itemData["buy_summary"].asJsonArray[0].asJsonObject["pricePerUnit"].asDouble.round(1) + } catch (e: Exception) { + 0.0 + } + + val data = BazaarData(apiName, itemName, sellPrice, buyPrice) + bazaarMap[itemName] = data + } + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/bazaar/BazaarOrderHelper.kt b/src/main/java/at/hannibal2/skyhanni/bazaar/BazaarOrderHelper.kt new file mode 100644 index 000000000..eec055253 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/bazaar/BazaarOrderHelper.kt @@ -0,0 +1,87 @@ +package at.hannibal2.skyhanni.bazaar + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.RenderUtils.highlight +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.inventory.ContainerChest +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import org.lwjgl.opengl.GL11 + +class BazaarOrderHelper { + + companion object { + fun isBazaarOrderInventory(inventoryName: String): Boolean = when (inventoryName) { + "Your Bazaar Orders" -> true + "Co-op Bazaar Orders" -> true + else -> false + } + } + + @SubscribeEvent + fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (!SkyHanniMod.feature.bazaar.orderHelper) return + if (event.gui !is GuiChest) return + val guiChest = event.gui + val chest = guiChest.inventorySlots as ContainerChest + val inventoryName = chest.lowerChestInventory.displayName.unformattedText.trim() + + if (!isBazaarOrderInventory(inventoryName)) return + val lightingState = GL11.glIsEnabled(GL11.GL_LIGHTING) + GlStateManager.disableLighting() + GlStateManager.color(1f, 1f, 1f, 1f) + + out@ for (slot in chest.inventorySlots) { + if (slot == null) continue + if (slot.slotNumber != slot.slotIndex) continue + if (slot.stack == null) continue + + val stack = slot.stack + val displayName = stack.displayName + val isSelling = displayName.startsWith("§6§lSELL§7: ") + val isBuying = displayName.startsWith("§a§lBUY§7: ") + if (!isSelling && !isBuying) continue + + val text = displayName.split("§7: ")[1] + val name = BazaarApi.getCleanBazaarName(text) + val data = BazaarApi.getBazaarDataForName(name) + val buyPrice = data.buyPrice + val sellPrice = data.sellPrice + + val itemLore = stack.getLore() + for (line in itemLore) { + if (line.startsWith("§7Filled:")) { + if (line.endsWith(" §a§l100%!")) { + slot highlight LorenzColor.GREEN + continue@out + } + } + } + for (line in itemLore) { + if (line.startsWith("§7Price per unit:")) { + var text = line.split(": §6")[1] + text = text.substring(0, text.length - 6) + text = text.replace(",", "") + val price = text.toDouble() + if (isSelling) { + if (buyPrice < price) { + slot highlight LorenzColor.GOLD + continue@out + } + } else { + if (sellPrice > price) { + slot highlight LorenzColor.GOLD + continue@out + } + } + + } + } + } + + if (lightingState) GlStateManager.enableLighting() + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/chat/ChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/chat/ChatFilter.kt new file mode 100644 index 000000000..fc245405c --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/chat/ChatFilter.kt @@ -0,0 +1,284 @@ +package at.hannibal2.skyhanni.chat + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class ChatFilter { + + @SubscribeEvent + fun onChatMessage(event: LorenzChatEvent) { + if (!LorenzUtils.isOnHypixel) return + + val blockReason = block(event.message) + if (blockReason != "") { + event.blockedReason = blockReason + } + } + + private fun block(message: String): String = when { + message.startsWith("§aYou are playing on profile: §e") -> "profile"//TODO move into own class + lobby(message) && SkyHanniMod.feature.chat.hypixelHub -> "lobby" + empty(message) && SkyHanniMod.feature.chat.empty -> "empty" + warping(message) && SkyHanniMod.feature.chat.warping -> "warping" + welcome(message) && SkyHanniMod.feature.chat.welcome -> "welcome" + guild(message) && SkyHanniMod.feature.chat.others -> "guild" + killCombo(message) && SkyHanniMod.feature.chat.others -> "kill_combo" + bazaarAndAHMiniMessages(message) && SkyHanniMod.feature.chat.others -> "bz_ah_minis" + watchdogAnnouncement(message) && SkyHanniMod.feature.chat.others -> "watchdog" + slayer(message) && SkyHanniMod.feature.chat.others -> "slayer" + slayerDrop(message) && SkyHanniMod.feature.chat.others -> "slayer_drop" + uselessDrop(message) && SkyHanniMod.feature.chat.others -> "useless_drop" + uselessNotification(message) && SkyHanniMod.feature.chat.others -> "useless_notification" + party(message) && SkyHanniMod.feature.chat.others -> "party" + money(message) && SkyHanniMod.feature.chat.others -> "money" + winterIsland(message) && SkyHanniMod.feature.chat.others -> "winter_island" + uselessWarning(message) && SkyHanniMod.feature.chat.others -> "useless_warning" + friendJoin(message) && SkyHanniMod.feature.chat.others -> "friend_join" + + + + + else -> "" + } + + private fun friendJoin(message: String): Boolean { + return when { + message.matchRegex("§aFriend > §r(.*) §r§e(joined|left).") -> { + true + } + else -> false + } + + } + + private fun uselessNotification(message: String): Boolean { + return when { + message == "§eYour previous §r§6Plasmaflux Power Orb §r§ewas removed!" -> true + + message == "§aYou used your §r§6Mining Speed Boost §r§aPickaxe Ability!" -> true + message == "§cYour Mining Speed Boost has expired!" -> true + message == "§a§r§6Mining Speed Boost §r§ais now available!" -> true + + else -> false + } + } + + private fun uselessWarning(message: String): Boolean = when { + message == "§cYou are sending commands too fast! Please slow down." -> true//TODO prevent in the future + message == "§cYou can't use this while in combat!" -> true + message == "§cYou can not modify your equipped armor set!" -> true + message == "§cPlease wait a few seconds between refreshing!" -> true + message == "§cThis item is not salvageable!" -> true//prevent in the future + message == "§cPlace a Dungeon weapon or armor piece above the anvil to salvage it!" -> true + message == "§cWhoa! Slow down there!" -> true + message == "§cWait a moment before confirming!" -> true + message == "§cYou need to be out of combat for 3 seconds before opening the SkyBlock Menu!" -> true//TODO prevent in the future + + else -> false + } + + private fun uselessDrop(message: String): Boolean { + when { + message.matchRegex("§6§lRARE DROP! §r§aEnchanted Ender Pearl (.*)") -> return true + + message.matchRegex("§6§lRARE DROP! §r§fCarrot (.*)") -> return true + message.matchRegex("§6§lRARE DROP! §r§fPotato (.*)") -> return true + + message.matchRegex("§6§lRARE DROP! §r§9Machine Gun Bow (.*)") -> return true + message.matchRegex("§6§lRARE DROP! §r§5Earth Shard (.*)") -> return true + message.matchRegex("§6§lRARE DROP! §r§5Zombie Lord Chestplate (.*)") -> return true + } + + return false + } + + private fun winterIsland(message: String): Boolean = when { + message.matchRegex(" §r§f☃ §r§7§r(.*) §r§7mounted a §r§fSnow Cannon§r§7!") -> true + + else -> false + } + + private fun money(message: String): Boolean { + if (isBazaar(message)) return true + if (isAuctionHouse(message)) return true + + return false + } + + private fun isAuctionHouse(message: String): Boolean { + if (message == "§b-----------------------------------------------------") return true + if (message == "§eVisit the Auction House to collect your item!") return true + + return false + } + + private fun isBazaar(message: String): Boolean { + if (message.matchRegex("§eBuy Order Setup! §r§a(.*)§r§7x (.*) §r§7for §r§6(.*) coins§r§7.")) return true + if (message.matchRegex("§eSell Offer Setup! §r§a(.*)§r§7x (.*) §r§7for §r§6(.*) coins§r§7.")) return true + if (message.matchRegex("§cCancelled! §r§7Refunded §r§6(.*) coins §r§7from cancelling buy order!")) return true + if (message.matchRegex("§cCancelled! §r§7Refunded §r§a(.*)§r§7x (.*) §r§7from cancelling sell offer!")) return true + + return false + } + + private fun party(message: String): Boolean { + if (message == "§9§m-----------------------------") return true + if (message == "§9§m-----------------------------------------------------") return true + + return false + } + + private fun slayerDrop(message: String): Boolean { + //Revenant + if (message.matchRegex("§b§lRARE DROP! §r§7\\(§r§f§r§9Revenant Viscera§r§7\\) (.*)")) return true + if (message.matchRegex("§b§lRARE DROP! §r§7\\(§r§f§r§7(.*)x §r§f§r§9Foul Flesh§r§7\\) (.*)")) return true + if (message.matchRegex("§b§lRARE DROP! §r§7\\(§r§f§r§9Foul Flesh§r§7\\) (.*)")) return true + if (message.matchRegex("§6§lRARE DROP! §r§5Golden Powder (.*)")) return true + if (message.matchRegex("§9§lVERY RARE DROP! §r§7\\(§r§f§r§2(.*) Pestilence Rune I§r§7\\) (.*)")) { + LorenzUtils.debug("check regex for this blocked message!") + return true + } + if (message.matchRegex("§5§lVERY RARE DROP! §r§7\\(§r§f§r§5Revenant Catalyst§r§7\\) (.*)")) return true + if (message.matchRegex("§5§lVERY RARE DROP! §r§7\\(§r§f§r§9Undead Catalyst§r§7\\) (.*)")) return true + + //Enderman + if (message.matchRegex("§b§lRARE DROP! §r§7\\(§r§f§r§7(.*)x §r§f§r§aTwilight Arrow Poison§r§7\\) (.*)")) return true + if (message.matchRegex("§9§lVERY RARE DROP! §r§7\\(§r§fMana Steal I§r§7\\) (.*)")) return true + if (message.matchRegex("§5§lVERY RARE DROP! §r§7\\(§r§f§r§5Sinful Dice§r§7\\) (.*)")) return true + if (message.matchRegex("§9§lVERY RARE DROP! §r§7\\(§r§f§r§9Null Atom§r§7\\) (.*)")) return true + if (message.matchRegex("§9§lVERY RARE DROP! §r§7\\(§r§f§r§5Transmission Tuner§r§7\\) (.*)")) return true + if (message.matchRegex("§9§lVERY RARE DROP! §r§7\\(§r§fMana Steal I§r§7\\) (.*)")) return true + if (message.matchRegex("§9§lVERY RARE DROP! §r§7\\(§r§f§r§5◆ Endersnake Rune I§r§7\\) (.*)")) return true + if (message.matchRegex("§d§lCRAZY RARE DROP! §r§7\\(§r§f§r§fPocket Espresso Machine§r§7\\) (.*)")) return true + if (message.matchRegex("§5§lVERY RARE DROP! §r§7\\(§r§f§r§5◆ End Rune I§r§7\\) (.*)")) return true + + return false + } + + private fun slayer(message: String): Boolean { + //start + if (message.matchRegex(" §r§5§lSLAYER QUEST STARTED!")) return true + if (message.matchRegex(" §5§l» §7Slay §c(.*) Combat XP §7worth of (.*)§7.")) return true + + //end + if (message.matchRegex(" §r§a§lSLAYER QUEST COMPLETE!")) return true + if (message == " §r§6§lNICE! SLAYER BOSS SLAIN!") return true + if (message.matchRegex(" §r§e(.*)Slayer LVL 9 §r§5- §r§a§lLVL MAXED OUT!")) return true + if (message.matchRegex(" §r§5§l» §r§7Talk to Maddox to claim your (.*) Slayer XP!")) return true + + + if (message == "§eYou received kill credit for assisting on a slayer miniboss!") return true + + if (message == "§e✆ Ring... ") return true + if (message == "§e✆ Ring... Ring... ") return true + if (message == "§e✆ Ring... Ring... Ring... ") return true + + return false + } + + private fun watchdogAnnouncement(message: String): Boolean = when { + message == "§4[WATCHDOG ANNOUNCEMENT]" -> true + message.matchRegex("§fWatchdog has banned §r§c§l(.*)§r§f players in the last 7 days.") -> true + message.matchRegex("§fStaff have banned an additional §r§c§l(.*)§r§f in the last 7 days.") -> true + message == "§cBlacklisted modifications are a bannable offense!" -> true + else -> false + } + + private fun bazaarAndAHMiniMessages(message: String): Boolean = when (message) { + "§7Putting item in escrow...", + "§7Putting goods in escrow...", + "§7Putting coins in escrow...", + + //Auction House + "§7Setting up the auction...", + "§7Processing purchase...", + "§7Claiming order...", + "§7Processing bid...", + "§7Claiming BIN auction...", + + //Bazaar + "§7Submitting sell offer...", + "§7Submitting buy order...", + "§7Executing instant sell...", + "§7Executing instant buy...", + + //Bank + "§8Depositing coins...", + "§8Withdrawing coins..." -> true + else -> false + } + + private fun killCombo(message: String): Boolean { + //§a§l+5 Kill Combo §r§8+§r§b3% §r§b? Magic Find + return when { + message.matchRegex("§.§l\\+(.*) Kill Combo §r§8\\+(.*)") -> true + message.matchRegex("§cYour Kill Combo has expired! You reached a (.*) Kill Combo!") -> true + else -> false + } + } + + private fun lobby(message: String): Boolean = when { + //player join + message.matchRegex("(.*) §6joined the lobby!") -> true + message.matchRegex(" §b>§c>§a>§r (.*) §6joined the lobby!§r §a<§c<§b<") -> true + + //mystery box + message.matchRegex("§b✦ §r(.*) §r§7found a §r§e(.*) §r§bMystery Box§r§7!") -> true + message.matchRegex("§b✦ §r(.*) §r§7found (a|an) §r(.*) §r§7in a §r§aMystery Box§r§7!") -> true + + //prototype + message.contains("§r§6§lWelcome to the Prototype Lobby§r") -> true + message == " §r§f§l➤ §r§6You have reached your Hype limit! Add Hype to Prototype Lobby minigames by right-clicking with the Hype Diamond!" -> true + + //hypixel tournament notifications + message.contains("§r§e§6§lHYPIXEL§e is hosting a §b§lBED WARS DOUBLES§e tournament!") -> true + message.contains("§r§e§6§lHYPIXEL BED WARS DOUBLES§e tournament is live!") -> true + + //other + message.contains("§aYou are still radiating with §bGenerosity§r§a!") -> true + else -> false + } + + private fun guild(message: String): Boolean = when { + message.matchRegex("§2Guild > (.*) §r§e(joined|left).") -> true + message.matchRegex("§aYou earned §r§2(.*) GEXP §r§afrom playing SkyBlock!") -> true + message.matchRegex("§aYou earned §r§2(.*) GEXP §r§a\\+ §r§e(.*) Event EXP §r§afrom playing SkyBlock!") -> true + message == "§b§m-----------------------------------------------------" -> true + else -> false + } + + private fun welcome(message: String): Boolean = message == "§eWelcome to §r§aHypixel SkyBlock§r§e!" + + private fun warping(message: String): Boolean = when { + message.matchRegex("§7Sending to server (.*)\\.\\.\\.") -> true + message.matchRegex("§7Request join for Hub (.*)\\.\\.\\.") -> true + message.matchRegex("§7Request join for Dungeon Hub #(.*)\\.\\.\\.") -> true + message == "§7Warping..." -> true + message == "§7Warping you to your SkyBlock island..." -> true + message == "§7Warping using transfer token..." -> true + + //visiting other players + message == "§7Finding player..." -> true + message == "§7Sending a visit request..." -> true + + //warp portals on public islands (canvas room - flower house, election room - community center, void sepulture - the end) + message.matchRegex("§dWarped to (.*)§r§d!") -> true + else -> false + } + + private fun empty(message: String): Boolean = when (message) { + "§8 §r§8 §r§1 §r§3 §r§3 §r§7 §r§8 ", + + "§f §r§f §r§1 §r§0 §r§2 §r§4§r§f §r§f §r§2 §r§0 §r§4 §r§8§r§0§r§1§r§0§r§1§r§2§r§f§r§f§r§0§r§1§r§3§r§4§r§f§r§f§r§0§r§1§r§5§r§f§r§f§r§0§r§1§r§6§r§f§r§f§r§0§r§1§r§8§r§9§r§a§r§b§r§f§r§f§r§0§r§1§r§7§r§f§r§f§r§3 §r§9 §r§2 §r§0 §r§0 §r§1§r§3 §r§9 §r§2 §r§0 §r§0 §r§2§r§3 §r§9 §r§2 §r§0 §r§0 §r§3§r§0§r§0§r§1§r§f§r§e§r§0§r§0§r§2§r§f§r§e§r§0§r§0§r§3§r§4§r§5§r§6§r§7§r§8§r§f§r§e§r§3 §r§6 §r§3 §r§6 §r§3 §r§6 §r§e§r§3 §r§6 §r§3 §r§6 §r§3 §r§6 §r§d", + + "§f §r§r§r§f §r§r§r§1 §r§r§r§0 §r§r§r§2 §r§r§r§f §r§r§r§f §r§r§r§2 §r§r§r§0 §r§r§r§4 §r§r§r§3 §r§r§r§9 §r§r§r§2 §r§r§r§0 §r§r§r§0 §r§r§r§3 §r§r§r§9 §r§r§r§2 §r§r§r§0 §r§r§r§0 §r§r§r§3 §r§r§r§9 §r§r§r§2 §r§r§r§0 §r§r§r§0 ", + + "", + "§f", + "§c" -> true + else -> false + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/chat/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/chat/ChatManager.kt new file mode 100644 index 000000000..c189caa3d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/chat/ChatManager.kt @@ -0,0 +1,51 @@ +package at.hannibal2.skyhanni.chat + +import at.hannibal2.skyhanni.events.LorenzActionBarEvent +import at.hannibal2.skyhanni.utils.LorenzLogger +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.network.play.server.S02PacketChat +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class ChatManager { + + private val loggerAll = LorenzLogger("chat/filter_all") + private val loggerFiltered = LorenzLogger("chat/filter_blocked") + private val loggerAllowed = LorenzLogger("chat/filter_allowed") + private val loggerFilteredTypes = mutableMapOf() + + @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) + fun onChatPacket(event: PacketEvent.ReceiveEvent) { + val packet = event.packet + if (packet !is S02PacketChat) return + val messageComponent = packet.chatComponent + + val message = LorenzUtils.stripVanillaMessage(messageComponent.formattedText) + if (packet.type.toInt() == 2) { + val actionBarEvent = LorenzActionBarEvent(message) + actionBarEvent.postAndCatch() + } else { + + val chatEvent = LorenzChatEvent(message, messageComponent) + chatEvent.postAndCatch() + + val blockReason = chatEvent.blockedReason.uppercase() + if (blockReason != "") { + event.isCanceled = true + loggerFiltered.log("[$blockReason] $message") + loggerAll.log("[$blockReason] $message") + loggerFilteredTypes.getOrPut(blockReason) { LorenzLogger("chat/filter_blocked/$blockReason") } + .log(message) + return + } + + if (!message.startsWith("§f{\"server\":\"")) { + loggerAllowed.log(message) + loggerAll.log("[allowed] $message") + } + + } + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/chat/PlayerChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/chat/PlayerChatFilter.kt new file mode 100644 index 000000000..0159d77ec --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/chat/PlayerChatFilter.kt @@ -0,0 +1,90 @@ +package at.hannibal2.skyhanni.chat + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.PlayerSendChatEvent +import at.hannibal2.skyhanni.utils.LorenzLogger +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.removeColorCodes +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class PlayerChatFilter { + + @SubscribeEvent + fun onChatMessage(event: LorenzChatEvent) { + if (!LorenzUtils.isOnHypixel) return + if (!SkyHanniMod.feature.chat.playerMessages) return + + if (shouldBlock(event.message)) { + event.blockedReason = "player_chat" + } + } + + val loggerPlayerChat = LorenzLogger("chat/player") + + fun shouldBlock(originalMessage: String): Boolean { + val split: List = if (originalMessage.contains("§7§r§7: ")) { + originalMessage.split("§7§r§7: ") + } else if (originalMessage.contains("§f: ")) { + originalMessage.split("§f: ") + } else { + return false + } + + var rawName = split[0] + val message = split[1] + + val channel: PlayerMessageChannel + if (rawName.startsWith("§9Party §8> ")) { + channel = PlayerMessageChannel.PARTY + rawName = rawName.substring(12) + } else if (rawName.startsWith("§2Guild > ")) { + channel = PlayerMessageChannel.GUILD + rawName = rawName.substring(10) + } else if (rawName.startsWith("§bCo-op > ")) { + channel = PlayerMessageChannel.COOP + rawName = rawName.substring(10) + } else { + channel = PlayerMessageChannel.ALL + } + + val nameSplit = rawName.split(" ") + val first = nameSplit[0] + + val last = nameSplit.last() + val name = if (last.endsWith("]")) { + nameSplit[nameSplit.size - 2] + } else { + last + } + + if (first != name) { + if (!first.contains("VIP") && !first.contains("MVP")) { + //TODO support yt + admin + return false + } + } + + send(channel, name.removeColorCodes(), message.removeColorCodes()) + return true + } + + private fun send(channel: PlayerMessageChannel, name: String, message: String) { + loggerPlayerChat.log("[$channel] $name: $message") + val event = PlayerSendChatEvent(channel, name, message) + event.postAndCatch() + + if (event.cancelledReason != "") { + loggerPlayerChat.log("cancelled: " + event.cancelledReason) + } else { + val finalMessage = event.message + if (finalMessage != message) { + loggerPlayerChat.log("message changed: $finalMessage") + } + + val prefix = channel.prefix + LorenzUtils.chat("$prefix §b$name §f$finalMessage") + } + } + +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/chat/PlayerMessageChannel.kt b/src/main/java/at/hannibal2/skyhanni/chat/PlayerMessageChannel.kt new file mode 100644 index 000000000..826b490de --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/chat/PlayerMessageChannel.kt @@ -0,0 +1,10 @@ +package at.hannibal2.skyhanni.chat + +enum class PlayerMessageChannel(val prefix: String) { + + ALL("§fA>"), + ALL_ADVERTISEMENT("§8A>"), + PARTY("§9P>"), + GUILD("§2G>"), + COOP("§bCC>"), +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java new file mode 100644 index 000000000..90027ce4e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -0,0 +1,274 @@ +package at.hannibal2.skyhanni.config; + +import at.hannibal2.skyhanni.config.core.GuiElement; +import at.hannibal2.skyhanni.config.core.GuiScreenElementWrapper; +import at.hannibal2.skyhanni.config.core.config.Position; +import at.hannibal2.skyhanni.config.core.config.annotations.*; +import at.hannibal2.skyhanni.config.core.config.gui.GuiPositionEditor; +import at.hannibal2.skyhanni.SkyHanniMod; +import at.hannibal2.skyhanni.config.config.ConfigEditor; +import com.google.gson.annotations.Expose; +import net.minecraft.client.Minecraft; + +public class Features { + + private void editOverlay(String activeConfig, int width, int height, Position position) { + Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(position, width, height, () -> {}, () -> {}, () -> SkyHanniMod.screenToOpen = new GuiScreenElementWrapper(new ConfigEditor(SkyHanniMod.feature, activeConfig)))); + } + + public void executeRunnable(String runnableId) { + String activeConfigCategory = null; + if (Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper) { + GuiScreenElementWrapper wrapper = (GuiScreenElementWrapper) Minecraft.getMinecraft().currentScreen; + GuiElement element = wrapper.element; + if (element instanceof ConfigEditor) { + activeConfigCategory = ((ConfigEditor) element).getSelectedCategoryName(); + } + } + + if (runnableId.equals("petDisplay")) { + editOverlay(activeConfigCategory, 200, 16, misc.petDisplayPos); + return; + } + + if (runnableId.equals("testPos")) { + editOverlay(activeConfigCategory, 200, 16, debug.testPos); + return; + } + + if (runnableId.equals("dungeonMilestoneDisplay")) { + editOverlay(activeConfigCategory, 200, 16, dungeon.milestoneDisplayPos); + return; + } + + if (runnableId.equals("dungeonDeathCounter")) { + editOverlay(activeConfigCategory, 200, 16, dungeon.deathCounterDisplay); + return; + } + } + + @Expose + @Category(name = "Chat", desc = "Chat related features.") + public Chat chat = new Chat(); + + @Expose + @Category(name = "Dungeon", desc = "Features that change the catacombs dungeon experience.") + public Dungeon dungeon = new Dungeon(); + + @Expose + @Category(name = "Items", desc = "Changing the behavior around items and the inventory.") + public Items items = new Items(); + + @Expose + @Category(name = "Bazaar", desc = "Bazaar settings.") + public Bazaar bazaar = new Bazaar(); + + @Expose + @Category(name = "Misc", desc = "Settings without a category.") + public Misc misc = new Misc(); + + @Expose + @Category(name = "Debug", desc = "Debug and test stuff.") + public Debug debug = new Debug(); + + public static class Chat { + + @Expose + @ConfigOption(name = "Chat Filter Types", desc = "") + @ConfigEditorAccordion(id = 1) + public boolean filterTypes = false; + + @Expose + @ConfigOption(name = "HyPixel Hub", desc = "Block messages outside SkyBlock in the HyPixel lobby: player joins, loot boxes, prototype lobby messages, radiating generosity and HyPixel tournaments.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 1) + public boolean hypixelHub = false; + + @Expose + @ConfigOption(name = "Empty", desc = "Hide all the empty messages from the chat.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 1) + public boolean empty = false; + + @Expose + @ConfigOption(name = "Warping", desc = "Block 'sending request to join ..' and 'warping ..' messages.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 1) + public boolean warping = false; + + @Expose + @ConfigOption(name = "Welcome", desc = "Hide the 'welcome to skyblock' message.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 1) + public boolean welcome = false; + + //TODO remove + @Expose + @ConfigOption(name = "Others", desc = "Hide other annoying messages.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 1) + public boolean others = false; + + @Expose + @ConfigOption(name = "Player Messages", desc = "Add a fancy new chat format for player messages.") + @ConfigEditorBoolean + public boolean playerMessages = false; + + @Expose + @ConfigOption(name = "Dungeon Filter", desc = "Hide annoying messages inside dungeon.") + @ConfigEditorBoolean + public boolean dungeonMessages = false; + + @Expose + @ConfigOption(name = "Dungeon Boss Messages", desc = "Hide messages from watcher and bosses inside dungeon.") + @ConfigEditorBoolean + public boolean dungeonBossMessages = false; + } + + public static class Dungeon { + + @Expose + @ConfigOption(name = "Clicked Blocks", desc = "Highlight the following blocks when clicked in dungeon: Lever, Chest, Wither Essence") + @ConfigEditorBoolean + public boolean highlightClickedBlocks = false; + + @Expose + @ConfigOption(name = "Boss Damage Indicator", desc = "Show the missing health of a boss in the dungeon and the cooldown time until the boss becomes attackable.") + @ConfigEditorBoolean + public boolean bossDamageIndicator = false; + + @Expose + @ConfigOption(name = "Milestone Display", desc = "Show the current milestone inside Dungeons.") + @ConfigEditorBoolean + public boolean showMilestoneDisplay = false; + + @Expose + @ConfigOption(name = "Milestone Display Position", desc = "") + @ConfigEditorButton(runnableId = "dungeonMilestoneDisplay", buttonText = "Edit") + public Position milestoneDisplayPos = new Position(10, 10, false, true); + + @Expose + @ConfigOption(name = "Death Counter", desc = "Display the total amount of deaths in the current dungeon.") + @ConfigEditorBoolean + public boolean deathCounter = false; + + @Expose + @ConfigOption(name = "Death Counter Position", desc = "") + @ConfigEditorButton(runnableId = "dungeonDeathCounter", buttonText = "Edit") + public Position deathCounterDisplay = new Position(10, 10, false, true); + + @Expose + @ConfigOption(name = "Clean End", desc = "Hide entities and particles after the boss in Floor 1 - 6 has died.") + @ConfigEditorBoolean + public boolean cleanEnd = false; + + @Expose + @ConfigOption(name = "Ignore Guardians", desc = "Ignore F3 and M3 guardians from the clean end feature when sneaking. Makes it easier to kill them after the boss died already. Thanks hypixel.") + @ConfigEditorBoolean + public boolean cleanEndF3IgnoreGuardians = false; + } + + public static class Items { + + @Expose + @ConfigOption(name = "Not Clickable Items", desc = "Hide items that are not clickable in " + "the current inventory: ah, bz, accessory bag, etc") + @ConfigEditorBoolean + public boolean hideNotClickableItems = false; + + @Expose + @ConfigOption(name = "Item number as stack size", desc = "") + @ConfigEditorAccordion(id = 2) + public boolean filterTypes = false; + + @Expose + @ConfigOption(name = "Master Star Number", desc = "Show the Tier of the Master Star.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean displayMasterStarNumber = false; + + @Expose + @ConfigOption(name = "Master Skull Number", desc = "Show the tier of the Master Skull accessory.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean displayMasterSkullNumber = false; + + @Expose + @ConfigOption(name = "Dungeon Head Floor", desc = "Show the correct floor for golden and diamond heads.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean displayDungeonHeadFloor = false; + + @Expose + @ConfigOption(name = "New Year Cake", desc = "Show the Number of the Year of New Year Cakes.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean displayNewYearCakeNumber = false; + + @Expose + @ConfigOption(name = "Pet Level", desc = "Show the level of the pet when not maxed.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean displayPetLevel = false; + + @Expose + @ConfigOption(name = "Sack Name", desc = "Show an abbreviation of the Sack name.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean displaySackName = false; + + @Expose + @ConfigOption(name = "Minion Tier", desc = "Show the Minion Tier over Items.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean displayMinionTier = false; + + @Expose + @ConfigOption(name = "Ability Cooldown", desc = "Show the cooldown of item abilities.") + @ConfigEditorBoolean + public boolean itemAbilityCooldown = false; + } + + public static class Bazaar { + + @Expose + @ConfigOption(name = "Order Helper", desc = "Show visual hints inside the Bazaar Manage Order view when items are ready to pickup or outbid.") + @ConfigEditorBoolean + public boolean orderHelper = false; + } + + public static class Misc { + + @Expose + @ConfigOption(name = "Pet Display", desc = "Show the currently active pet.") + @ConfigEditorBoolean + public boolean petDisplay = false; + + @Expose + @ConfigOption(name = "Pet Display Position", desc = "") + @ConfigEditorButton(runnableId = "petDisplay", buttonText = "Edit") + public Position petDisplayPos = new Position(10, 10, false, true); + + @Expose + @ConfigOption(name = "Exp Bottles", desc = "Hides all the experience bottles lying on the ground.") + @ConfigEditorBoolean + public boolean hideExpBottles = false; + + @Expose + @ConfigOption(name = "Config Button", desc = "Add a but