From 99773d6a593c444151503de315f127bea6f74d49 Mon Sep 17 00:00:00 2001 From: Lorenz Date: Thu, 7 Jul 2022 00:31:50 +0200 Subject: init lorenz mod --- src/main/java/at/lorenz/mod/GuiContainerHook.kt | 61 +++ .../java/at/lorenz/mod/HideNotClickableItems.kt | 444 +++++++++++++++ src/main/java/at/lorenz/mod/bazaar/BazaarApi.kt | 59 ++ src/main/java/at/lorenz/mod/bazaar/BazaarData.kt | 3 + .../java/at/lorenz/mod/bazaar/BazaarDataGrabber.kt | 116 ++++ .../java/at/lorenz/mod/bazaar/BazaarOrderHelper.kt | 87 +++ src/main/java/at/lorenz/mod/chat/ChatFilter.kt | 279 ++++++++++ src/main/java/at/lorenz/mod/chat/ChatManager.kt | 47 ++ .../java/at/lorenz/mod/chat/PlayerChatFilter.kt | 78 +++ .../at/lorenz/mod/chat/PlayerMessageChannel.kt | 10 + src/main/java/at/lorenz/mod/config/LorenzConfig.kt | 12 + .../at/lorenz/mod/dungeon/DungeonChatFilter.kt | 259 +++++++++ .../java/at/lorenz/mod/events/GuiContainerEvent.kt | 54 ++ .../java/at/lorenz/mod/events/LorenzChatEvent.kt | 5 + src/main/java/at/lorenz/mod/events/LorenzEvent.kt | 20 + .../at/lorenz/mod/events/PlayerSendChatEvent.kt | 11 + .../at/lorenz/mod/mixins/MixinGuiContainer.java | 50 ++ src/main/java/at/lorenz/mod/utils/APIUtil.kt | 116 ++++ src/main/java/at/lorenz/mod/utils/ItemUtil.kt | 211 ++++++++ src/main/java/at/lorenz/mod/utils/ItemUtils.kt | 39 ++ src/main/java/at/lorenz/mod/utils/LorenzColor.kt | 27 + src/main/java/at/lorenz/mod/utils/LorenzLogger.kt | 70 +++ src/main/java/at/lorenz/mod/utils/LorenzUtils.kt | 91 ++++ src/main/java/at/lorenz/mod/utils/RenderUtil.kt | 20 + .../skyblockhud/ComponentHandler.java | 123 +++++ .../skyblockhud/DevModeConstants.java | 6 + .../com/thatgravyboat/skyblockhud/GuiTextures.java | 33 ++ .../com/thatgravyboat/skyblockhud/SkyblockHud.java | 195 +++++++ .../skyblockhud/api/KillTracking.java | 61 +++ .../skyblockhud/api/LeaderboardGetter.java | 65 +++ .../api/events/LocationChangeEvent.java | 15 + .../skyblockhud/api/events/ProfileJoinedEvent.java | 12 + .../api/events/ProfileSwitchedEvent.java | 12 + .../api/events/SidebarLineUpdateEvent.java | 22 + .../skyblockhud/api/events/SidebarPostEvent.java | 21 + .../skyblockhud/api/events/SidebarPreGetEvent.java | 18 + .../api/events/SkyBlockEntityKilled.java | 18 + .../skyblockhud/api/item/IAbility.java | 7 + .../api/sbentities/EntityTypeHelper.java | 36 ++ .../api/sbentities/EntityTypeRegistry.java | 27 + .../skyblockhud/api/sbentities/SkyBlockEntity.java | 27 + .../skyblockhud/commands/Commands.java | 105 ++++ .../skyblockhud/commands/SimpleCommand.java | 60 ++ .../skyblockhud/commands/SimpleSubCommand.java | 61 +++ .../skyblockhud/config/KeyBindings.java | 8 + .../skyblockhud/config/SBHConfig.java | 436 +++++++++++++++ .../skyblockhud/config/SBHConfigEditor.java | 602 +++++++++++++++++++++ .../skyblockhud/core/BackgroundBlur.java | 249 +++++++++ .../skyblockhud/core/ChromaColour.java | 93 ++++ .../skyblockhud/core/GlScissorStack.java | 86 +++ .../thatgravyboat/skyblockhud/core/GuiElement.java | 12 + .../skyblockhud/core/GuiElementBoolean.java | 118 ++++ .../skyblockhud/core/GuiElementColour.java | 370 +++++++++++++ .../skyblockhud/core/GuiElementTextField.java | 549 +++++++++++++++++++ .../skyblockhud/core/GuiScreenElementWrapper.java | 34 ++ .../skyblockhud/core/config/Config.java | 6 + .../skyblockhud/core/config/KeybindHelper.java | 49 ++ .../skyblockhud/core/config/Position.java | 197 +++++++ .../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 + .../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 | 81 +++ .../config/gui/GuiOptionEditorDraggableList.java | 268 +++++++++ .../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 +++ .../core/config/gui/GuiPositionEditor.java | 171 ++++++ .../core/config/struct/ConfigProcessor.java | 166 ++++++ .../skyblockhud/core/util/GuiElementSlider.java | 120 ++++ .../skyblockhud/core/util/StringUtils.java | 8 + .../skyblockhud/core/util/lerp/LerpUtils.java | 25 + .../skyblockhud/core/util/lerp/LerpingFloat.java | 68 +++ .../skyblockhud/core/util/lerp/LerpingInteger.java | 76 +++ .../skyblockhud/core/util/render/RenderUtils.java | 155 ++++++ .../core/util/render/TextRenderUtils.java | 155 ++++++ .../skyblockhud/dungeons/Classes.java | 48 ++ .../skyblockhud/dungeons/DungeonHandler.java | 195 +++++++ .../skyblockhud/dungeons/DungeonPlayer.java | 32 ++ .../skyblockhud/handlers/BossbarHandler.java | 36 ++ .../skyblockhud/handlers/CooldownHandler.java | 121 +++++ .../skyblockhud/handlers/CrystalWaypoints.java | 196 +++++++ .../skyblockhud/handlers/CurrencyHandler.java | 86 +++ .../skyblockhud/handlers/HeldItemHandler.java | 31 ++ .../skyblockhud/handlers/MapHandler.java | 206 +++++++ .../skyblockhud/handlers/NpcDialogue.java | 131 +++++ .../skyblockhud/handlers/SlayerHandler.java | 130 +++++ .../skyblockhud/handlers/TimeHandler.java | 28 + .../skyblockhud/handlers/WarpHandler.java | 179 ++++++ .../handlers/mapicons/DwarvenIcons.java | 39 ++ .../skyblockhud/handlers/mapicons/HubIcons.java | 55 ++ .../skyblockhud/location/EndIslandHandler.java | 53 ++ .../skyblockhud/location/FarmHouseHandler.java | 41 ++ .../skyblockhud/location/FarmingIslandHandler.java | 28 + .../skyblockhud/location/IslandHandler.java | 67 +++ .../skyblockhud/location/LocationCategory.java | 54 ++ .../skyblockhud/location/LocationHandler.java | 44 ++ .../skyblockhud/location/Locations.java | 161 ++++++ .../skyblockhud/location/MinesHandler.java | 192 +++++++ .../skyblockhud/location/ParkIslandHandler.java | 29 + .../skyblockhud/mixins/GuiChestAccessor.java | 12 + .../skyblockhud/mixins/MixinEntityArrow.java | 26 + .../skyblockhud/mixins/MixinGuiIngameForge.java | 113 ++++ .../skyblockhud/mixins/MixinItemStack.java | 42 ++ .../mixins/MixinNetHandlerPlayClient.java | 67 +++ .../skyblockhud/mixins/MixinRenderItem.java | 63 +++ .../skyblockhud/overlay/DungeonOverlay.java | 149 +++++ .../skyblockhud/overlay/GenericOverlays.java | 42 ++ .../skyblockhud/overlay/MiningHud.java | 76 +++ .../skyblockhud/overlay/OverlayHud.java | 331 +++++++++++ .../thatgravyboat/skyblockhud/overlay/RPGHud.java | 112 ++++ .../skyblockhud/playerstats/ActionBarParsing.java | 152 ++++++ .../thatgravyboat/skyblockhud/seasons/Season.java | 53 ++ .../skyblockhud/seasons/SeasonDateHandler.java | 73 +++ .../skyblockhud/textures/TextureObject.java | 37 ++ .../skyblockhud/textures/Textures.java | 58 ++ .../skyblockhud/tracker/TrackerFileLoader.java | 136 +++++ .../skyblockhud/tracker/TrackerHandler.java | 111 ++++ .../skyblockhud/tracker/TrackerObject.java | 97 ++++ .../skyblockhud/utils/ComponentBuilder.java | 54 ++ .../skyblockhud/utils/SpecialColour.java | 93 ++++ .../com/thatgravyboat/skyblockhud/utils/Utils.java | 380 +++++++++++++ 137 files changed, 12548 insertions(+) create mode 100644 src/main/java/at/lorenz/mod/GuiContainerHook.kt create mode 100644 src/main/java/at/lorenz/mod/HideNotClickableItems.kt create mode 100644 src/main/java/at/lorenz/mod/bazaar/BazaarApi.kt create mode 100644 src/main/java/at/lorenz/mod/bazaar/BazaarData.kt create mode 100644 src/main/java/at/lorenz/mod/bazaar/BazaarDataGrabber.kt create mode 100644 src/main/java/at/lorenz/mod/bazaar/BazaarOrderHelper.kt create mode 100644 src/main/java/at/lorenz/mod/chat/ChatFilter.kt create mode 100644 src/main/java/at/lorenz/mod/chat/ChatManager.kt create mode 100644 src/main/java/at/lorenz/mod/chat/PlayerChatFilter.kt create mode 100644 src/main/java/at/lorenz/mod/chat/PlayerMessageChannel.kt create mode 100644 src/main/java/at/lorenz/mod/config/LorenzConfig.kt create mode 100644 src/main/java/at/lorenz/mod/dungeon/DungeonChatFilter.kt create mode 100644 src/main/java/at/lorenz/mod/events/GuiContainerEvent.kt create mode 100644 src/main/java/at/lorenz/mod/events/LorenzChatEvent.kt create mode 100644 src/main/java/at/lorenz/mod/events/LorenzEvent.kt create mode 100644 src/main/java/at/lorenz/mod/events/PlayerSendChatEvent.kt create mode 100644 src/main/java/at/lorenz/mod/mixins/MixinGuiContainer.java create mode 100644 src/main/java/at/lorenz/mod/utils/APIUtil.kt create mode 100644 src/main/java/at/lorenz/mod/utils/ItemUtil.kt create mode 100644 src/main/java/at/lorenz/mod/utils/ItemUtils.kt create mode 100644 src/main/java/at/lorenz/mod/utils/LorenzColor.kt create mode 100644 src/main/java/at/lorenz/mod/utils/LorenzLogger.kt create mode 100644 src/main/java/at/lorenz/mod/utils/LorenzUtils.kt create mode 100644 src/main/java/at/lorenz/mod/utils/RenderUtil.kt create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/ComponentHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/DevModeConstants.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/GuiTextures.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/api/KillTracking.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/api/LeaderboardGetter.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/api/events/LocationChangeEvent.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/api/events/ProfileJoinedEvent.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/api/events/ProfileSwitchedEvent.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarLineUpdateEvent.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarPostEvent.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/api/events/SidebarPreGetEvent.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/api/events/SkyBlockEntityKilled.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/api/item/IAbility.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeHelper.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/EntityTypeRegistry.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/api/sbentities/SkyBlockEntity.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/commands/Commands.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleCommand.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/commands/SimpleSubCommand.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/config/KeyBindings.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfig.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/config/SBHConfigEditor.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/GuiScreenElementWrapper.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/Config.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/KeybindHelper.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/Position.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/Category.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigAccordionId.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorAccordion.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorBoolean.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorButton.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorColour.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorDraggableList.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorDropdown.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorKeybind.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorSlider.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorStyle.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorText.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigOption.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorBoolean.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorKeybind.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorStyle.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpUtils.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingFloat.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingInteger.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/util/render/RenderUtils.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/dungeons/Classes.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/dungeons/DungeonPlayer.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/handlers/BossbarHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/handlers/CooldownHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/handlers/CrystalWaypoints.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/handlers/CurrencyHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/handlers/HeldItemHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/handlers/MapHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/handlers/NpcDialogue.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/handlers/SlayerHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/handlers/TimeHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/handlers/WarpHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/DwarvenIcons.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/handlers/mapicons/HubIcons.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/location/EndIslandHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/location/FarmHouseHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/location/FarmingIslandHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/location/IslandHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/location/LocationCategory.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/location/LocationHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/location/Locations.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/location/MinesHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/location/ParkIslandHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/mixins/GuiChestAccessor.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinEntityArrow.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinGuiIngameForge.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinItemStack.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinNetHandlerPlayClient.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/mixins/MixinRenderItem.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/overlay/DungeonOverlay.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/overlay/GenericOverlays.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/overlay/MiningHud.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/overlay/OverlayHud.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/overlay/RPGHud.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/playerstats/ActionBarParsing.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/seasons/Season.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/seasons/SeasonDateHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/textures/TextureObject.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/textures/Textures.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerFileLoader.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerHandler.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/tracker/TrackerObject.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/utils/ComponentBuilder.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/utils/SpecialColour.java create mode 100644 src/main/java/com/thatgravyboat/skyblockhud/utils/Utils.java (limited to 'src/main/java') diff --git a/src/main/java/at/lorenz/mod/GuiContainerHook.kt b/src/main/java/at/lorenz/mod/GuiContainerHook.kt new file mode 100644 index 000000000..55b30e964 --- /dev/null +++ b/src/main/java/at/lorenz/mod/GuiContainerHook.kt @@ -0,0 +1,61 @@ +package at.lorenz.mod + +import at.lorenz.mod.events.GuiContainerEvent +import at.lorenz.mod.events.GuiContainerEvent.CloseWindowEvent +import at.lorenz.mod.events.GuiContainerEvent.SlotClickEvent +import net.minecraft.client.gui.inventory.GuiContainer +import net.minecraft.inventory.Slot +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo + +class GuiContainerHook(guiAny: Any) { + + val gui: GuiContainer + + init { + gui = guiAny as GuiContainer + } + + fun closeWindowPressed(ci: CallbackInfo) { + if (CloseWindowEvent(gui, gui.inventorySlots).postAndCatch()) ci.cancel() + } + + fun backgroundDrawn(mouseX: Int, mouseY: Int, partialTicks: Float, ci: CallbackInfo) { + GuiContainerEvent.BackgroundDrawnEvent( + gui, + gui.inventorySlots, + mouseX, + mouseY, + partialTicks + ).postAndCatch() + } + + fun foregroundDrawn(mouseX: Int, mouseY: Int, partialTicks: Float, ci: CallbackInfo) { + GuiContainerEvent.ForegroundDrawnEvent(gui, gui.inventorySlots, mouseX, mouseY, partialTicks).postAndCatch() + } + + fun onDrawSlot(slot: Slot, ci: CallbackInfo) { + if (GuiContainerEvent.DrawSlotEvent.Pre( + gui, + gui.inventorySlots, + slot + ).postAndCatch() + ) ci.cancel() + } + + fun onDrawSlotPost(slot: Slot, ci: CallbackInfo) { + GuiContainerEvent.DrawSlotEvent.Post(gui, gui.inventorySlots, slot).postAndCatch() + } + + fun onMouseClick(slot: Slot?, slotId: Int, clickedButton: Int, clickType: Int, ci: CallbackInfo) { + if ( + SlotClickEvent( + gui, + gui.inventorySlots, + slot, + slotId, + clickedButton, + clickType + ).postAndCatch() + ) ci.cancel() + } +} \ No newline at end of file diff --git a/src/main/java/at/lorenz/mod/HideNotClickableItems.kt b/src/main/java/at/lorenz/mod/HideNotClickableItems.kt new file mode 100644 index 000000000..3f94a1479 --- /dev/null +++ b/src/main/java/at/lorenz/mod/HideNotClickableItems.kt @@ -0,0 +1,444 @@ +package at.lorenz.mod + +import at.lorenz.mod.bazaar.BazaarApi +import at.lorenz.mod.config.LorenzConfig +import at.lorenz.mod.utils.LorenzUtils.Companion.removeColorCodes +import at.lorenz.mod.events.GuiContainerEvent +import at.lorenz.mod.utils.ItemUtils +import at.lorenz.mod.utils.ItemUtils.Companion.cleanName +import at.lorenz.mod.utils.ItemUtils.Companion.getLore +import at.lorenz.mod.utils.LorenzColor +import at.lorenz.mod.utils.LorenzUtils +import at.lorenz.mod.utils.RenderUtil.Companion.highlight +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.inventory.GuiChest +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.inventory.ContainerChest +import net.minecraft.item.ItemStack +import net.minecraftforge.event.entity.player.ItemTooltipEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import org.lwjgl.opengl.GL11 + +class HideNotClickableItems { + + private var hideReason = "" + + private var lastClickTime = 0L + private var bypassUntil = 0L + + @SubscribeEvent + fun onBackgroundDrawn(event: GuiContainerEvent.BackgroundDrawnEvent) { + if (isDisabled()) return + if (event.gui !is GuiChest) return + val guiChest = event.gui + val chest = guiChest.inventorySlots as ContainerChest + val chestName = chest.lowerChestInventory.displayName.unformattedText.trim() + + val lightingState = GL11.glIsEnabled(GL11.GL_LIGHTING) + GlStateManager.disableLighting() + GlStateManager.color(1f, 1f, 1f, 1f) + + for (slot in chest.inventorySlots) { + if (slot == null) continue + + if (slot.slotNumber == slot.slotIndex) continue + if (slot.stack == null) continue + + if (hide(chestName, slot.stack)) { + slot highlight LorenzColor.GRAY + } + } + + if (lightingState) GlStateManager.enableLighting() + } + + @SubscribeEvent + fun onDrawSlot(event: GuiContainerEvent.DrawSlotEvent.Pre) { + if (isDisabled()) return + if (event.gui !is GuiChest) return + val guiChest = event.gui + val chest = guiChest.inventorySlots as ContainerChest + val chestName = chest.lowerChestInventory.displayName.unformattedText.trim() + + val slot = event.slot + if (slot.slotNumber == slot.slotIndex) return + if (slot.stack == null) return + + val stack = slot.stack + + if (hide(chestName, stack)) { + event.isCanceled = true + } + } + + @SubscribeEvent + fun onTooltip(event: ItemTooltipEvent) { + if (isDisabled()) return + if (event.toolTip == null) return + val guiChest = Minecraft.getMinecraft().currentScreen + if (guiChest !is GuiChest) return + val chest = guiChest.inventorySlots as ContainerChest + val chestName = chest.lowerChestInventory.displayName.unformattedText.trim() + + val stack = event.itemStack + if (ItemUtils.getItemsInOpenChest().contains(stack)) return + + if (hide(chestName, stack)) { + val first = event.toolTip[0] + event.toolTip.clear() + event.toolTip.add("§7" + first.removeColorCodes()) + event.toolTip.add("") + if (hideReason == "") { + event.toolTip.add("§4No hide reason!") + LorenzUtils.warning("Not hide reason for not clickable item!") + } else { + event.toolTip.add("§c$hideReason") + } + } + } + + @SubscribeEvent + fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { + if (isDisabled()) return + if (event.gui !is GuiChest) return + val guiChest = event.gui + val chest = guiChest.inventorySlots as ContainerChest + val chestName = chest.lowerChestInventory.displayName.unformattedText.trim() + + val slot = event.slot ?: return + + if (slot.slotNumber == slot.slotIndex) return + if (slot.stack == null) return + + val stack = slot.stack + + if (hide(chestName, stack)) { + event.isCanceled = true +// SoundQueue.addToQueue("note.bass", 0.5f, 1f) + + if (System.currentTimeMillis() > lastClickTime + 5_000) { + lastClickTime = System.currentTimeMillis() +// EssentialAPI.getNotifications() +// .push( +// "§cThis item cannot be moved!", +// "§eClick here §fto disable this feature for 10 seconds!\n" + +// "§fOr disable it forever: §6/st §f+ '§6Hide Not Clickable Items§f'.", +// 5f, +// action = { +// bypassUntil = System.currentTimeMillis() + 10_000 +// }) + } + return + } + } + + private fun isDisabled(): Boolean { + if (bypassUntil > System.currentTimeMillis()) return true + + return !LorenzConfig.hideNotClickableItems + } + + private fun hide(chestName: String, stack: ItemStack): Boolean { + hideReason = "" + return when { + hideNpcSell(chestName, stack) -> true + hideChestBackpack(chestName, stack) -> true + hideSalvage(chestName, stack) -> true + hideTrade(chestName, stack) -> true + hideBazaarOrAH(chestName, stack) -> true + hideAccessoryBag(chestName, stack) -> true + hideSackOfSacks(chestName, stack) -> true + hideFishingBag(chestName, stack) -> true + hidePotionBag(chestName, stack) -> true + + else -> false + } + } + + private fun hidePotionBag(chestName: String, stack: ItemStack): Boolean { + if (!chestName.startsWith("Potion Bag")) return false + + val name = stack.cleanName() + if (isSkyBlockMenuItem(name)) { + hideReason = "The SkyBlock Menu cannot be put into the potion bag!" + return true + } + + if (stack.cleanName().endsWith(" Potion")) return false + + hideReason = "This item is not a potion!" + return true + } + + private fun hideFishingBag(chestName: String, stack: ItemStack): Boolean { + if (!chestName.startsWith("Fishing Bag")) return false + + val name = stack.cleanName() + if (isSkyBlockMenuItem(name)) { + hideReason = "The SkyBlock Menu cannot be put into the fishing bag!" + return true + } + + if (stack.cleanName().endsWith(" Bait")) return false + + hideReason = "This item is not a fishing bait!" + return true + } + + private fun hideSackOfSacks(chestName: String, stack: ItemStack): Boolean { + if (!chestName.startsWith("Sack of Sacks")) return false + + val name = stack.cleanName() + if (ItemUtils.isSack(name)) return false + if (isSkyBlockMenuItem(name)) return false + + hideReason = "This item is not a sack!" + return true + } + + private fun hideAccessoryBag(chestName: String, stack: ItemStack): Boolean { + if (!chestName.startsWith("Accessory Bag")) return false + + if (stack.getLore().any { it.contains("ACCESSORY") }) return false + if (isSkyBlockMenuItem(stack.cleanName())) return false + + hideReason = "This item is not an accessory!" + return true + } + + private fun hideTrade(chestName: String, stack: ItemStack): Boolean { + if (!chestName.startsWith("You ")) return false + + if (ItemUtils.isCoOpSoulBound(stack)) { + hideReason = "Coop-Soulbound items cannot be traded!" + return true + } + + val name = stack.cleanName() + + if (ItemUtils.isSack(name)) { + hideReason = "Sacks cannot be traded!" + return true + } + + if (isSkyBlockMenuItem(name)) { + hideReason = "The SkyBlock Menu cannot be traded!" + return true + } + + val result = when { + name.contains("Personal Deletor") -> true + name.contains("Day Crystal") -> true + name.contains("Night Crystal") -> true + name.contains("Cat Talisman") -> true + name.contains("Lynx Talisman") -> true + name.contains("Cheetah Talisman") -> true + else -> false + } + + if (result) hideReason = "This item cannot be traded!" + return result + } + + private fun hideNpcSell(chestName: String, stack: ItemStack): Boolean { + if (chestName != "Trades" && chestName != "Ophelia") return false + + var name = stack.cleanName() + val size = stack.stackSize + val amountText = " x$size" + if (name.endsWith(amountText)) { + name = name.substring(0, name.length - amountText.length) + } + + if (isSkyBlockMenuItem(name)) { + hideReason = "The SkyBlock Menu cannot be sold at the NPC!" + return true + } + + if (!ItemUtils.isRecombobulated(stack)) { + when (name) { + "Health Potion VIII Splash Potion" -> return false + "Stone Button" -> return false + "Revive Stone" -> return false + "Premium Flesh" -> return false + "Defuse Kit" -> return false + "White Wool" -> return false + "Enchanted Wool" -> return false + "Training Weights" -> return false + "Journal Entry" -> return false + + "Fairy's Galoshes" -> return false + } + + if (name.startsWith("Music Disc")) return false + } + + hideReason = "This item should not be sold at the NPC!" + return true + } + + private fun hideChestBackpack(chestName: String, stack: ItemStack): Boolean { + if (!chestName.contains("Ender Chest") && !chestName.contains("Backpack")) return false + + val name = stack.cleanName() + + if (isSkyBlockMenuItem(name)) { + hideReason = "The SkyBlock Menu cannot be put into the storage!" + return true + } + if (ItemUtils.isSack(name)) { + hideReason = "Sacks cannot be put into the storage!" + return true + } + + val result = when { + name.endsWith(" New Year Cake Bag") -> true + name == "Nether Wart Pouch" -> true + name == "Basket of Seeds" -> true + name == "Builder's Wand" -> true + + else -> false + } + + if (result) hideReason = "Bags cannot be put into the storage!" + return result + } + + private fun hideSalvage(chestName: String, stack: ItemStack): Boolean { + if (chestName != "Salvage Item") return false + + val name = stack.cleanName() + + val armorSets = listOf( + "Zombie Knight", + "Heavy", + "Zombie Soldier", + "Skeleton Grunt", + "Skeleton Soldier", + "Zombie Commander", + "Skeleton Master", + "Sniper", + "Skeletor", + "Rotten", + ) + + val items = mutableListOf() + for (armor in armorSets) { + items.add("$armor Helmet") + items.add("$armor Chestplate") + items.add("$armor Leggings") + items.add("$armor Boots") + } + + items.add("Zombie Soldier Cutlass") + items.add("Silent Death") + items.add("Zombie Knight Sword") + items.add("Conjuring") + items.add("Dreadlord Sword") + items.add("Soulstealer Bow") + items.add("Machine Gun Bow") + items.add("Earth Shard") + items.add("Zombie Commander Whip") + + for (item in items) { + if (name.endsWith(" $item")) { + + if (ItemUtils.isRecombobulated(stack)) { + hideReason = "This item should not be salvaged! (Recombobulated)" + return true + } +// val rarity = stack.getSkyBlockRarity() +// if (rarity == ItemRarity.LEGENDARY || rarity == ItemRarity.MYTHIC) { +// hideReason = "This item should not be salvaged! (Rarity)" +// return true +// } + + return false + } + } + + if (isSkyBlockMenuItem(name)) { + hideReason = "The SkyBlock Menu cannot be salvaged!" + return true + } + + hideReason = "This item cannot be salvaged!" + return true + } + + private fun hideBazaarOrAH(chestName: String, stack: ItemStack): Boolean { + val bazaarInventory = BazaarApi.isBazaarInventory(chestName) + + val auctionHouseInventory = + chestName == "Co-op Auction House" || chestName == "Auction House" || chestName == "Create BIN Auction" || chestName == "Create Auction" + if (!bazaarInventory && !auctionHouseInventory) return false + + + val displayName = stack.displayName + + if (isSkyBlockMenuItem(displayName.removeColorCodes())) { + if (bazaarInventory) hideReason = "The SkyBlock Menu is not a Bazaar Product!" + if (auctionHouseInventory) hideReason = "The SkyBlock Menu cannot be auctioned!" + return true + } + + if (bazaarInventory != BazaarApi.isBazaarItem(displayName)) { + if (bazaarInventory) hideReason = "This item is not a Bazaar Product!" + if (auctionHouseInventory) hideReason = "Bazaar Products cannot be auctioned!" + + return true + } + + if (isNotAuctionable(stack)) return true + + return false + } + + private fun isNotAuctionable(stack: ItemStack): Boolean { + if (ItemUtils.isCoOpSoulBound(stack)) { + hideReason = "Coop-Soulbound items cannot be auctioned!" + return true + } + + val name = stack.cleanName() + + if (ItemUtils.isSack(name)) { + hideReason = "Sacks cannot be auctioned!" + return true + } + + val result = when { + name.contains("Personal Deletor") -> true + name.contains("Day Crystal") -> true + name.contains("Night Crystal") -> true + + name.contains("Cat Talisman") -> true + name.contains("Lynx Talisman") -> true + name.contains("Cheetah Talisman") -> true + + name.contains("Hoe of Great Tilling") -> true + name.contains("Hoe of Greater Tilling") -> true + name.contains("InfiniDirt") -> true + name.contains("Prismapump") -> true + name.contains("Mathematical Hoe Blueprint") -> true + name.contains("Basket of Seeds") -> true + name.contains("Nether Wart Pouch") -> true + + name.contains("Carrot Hoe") -> true + name.contains("Sugar Cane Hoe") -> true + name.contains("Nether Warts Hoe") -> true + name.contains("Potato Hoe") -> true + name.contains("Melon Dicer") -> true + name.contains("Pumpkin Dicer") -> true + name.contains("Coco Chopper") -> true + name.contains("Wheat Hoe") -> true + + else -> false + } + + if (result) hideReason = "This item cannot be auctioned!" + return result + } + + private fun isSkyBlockMenuItem(name: String): Boolean = name == "SkyBlock Menu (Right Click)" +} diff --git a/src/main/java/at/lorenz/mod/bazaar/BazaarApi.kt b/src/main/java/at/lorenz/mod/bazaar/BazaarApi.kt new file mode 100644 index 000000000..28ce228e2 --- /dev/null +++ b/src/main/java/at/lorenz/mod/bazaar/BazaarApi.kt @@ -0,0 +1,59 @@ +package at.lorenz.mod.bazaar + +import at.lorenz.mod.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/lorenz/mod/bazaar/BazaarData.kt b/src/main/java/at/lorenz/mod/bazaar/BazaarData.kt new file mode 100644 index 000000000..a9f75370c --- /dev/null +++ b/src/main/java/at/lorenz/mod/bazaar/BazaarData.kt @@ -0,0 +1,3 @@ +package at.lorenz.mod.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/lorenz/mod/bazaar/BazaarDataGrabber.kt b/src/main/java/at/lorenz/mod/bazaar/BazaarDataGrabber.kt new file mode 100644 index 000000000..78341e05c --- /dev/null +++ b/src/main/java/at/lorenz/mod/bazaar/BazaarDataGrabber.kt @@ -0,0 +1,116 @@ +package at.lorenz.mod.bazaar + +import at.lorenz.mod.utils.APIUtil +import at.lorenz.mod.utils.LorenzUtils +import at.lorenz.mod.utils.LorenzUtils.Companion.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 = "lorenz-bazaar-update", period = 1000L) { + //TODO add +// 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) { +// LorenzUtils.warning("Bazaar buy order for $itemName not found!") + 0.0 + } + val buyPrice: Double = try { + itemData["buy_summary"].asJsonArray[0].asJsonObject["pricePerUnit"].asDouble.round(1) + } catch (e: Exception) { +// LorenzUtils.warning("Bazaar sell offers for $itemName not found!") + 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/lorenz/mod/bazaar/BazaarOrderHelper.kt b/src/main/java/at/lorenz/mod/bazaar/BazaarOrderHelper.kt new file mode 100644 index 000000000..0daa12b7d --- /dev/null +++ b/src/main/java/at/lorenz/mod/bazaar/BazaarOrderHelper.kt @@ -0,0 +1,87 @@ +package at.lorenz.mod.bazaar + +import at.lorenz.mod.config.LorenzConfig +import at.lorenz.mod.events.GuiContainerEvent +import at.lorenz.mod.utils.ItemUtils.Companion.getLore +import at.lorenz.mod.utils.LorenzColor +import at.lorenz.mod.utils.RenderUtil.Companion.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 (!LorenzConfig.lorenzBazaarOrderHelper) 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/lorenz/mod/chat/ChatFilter.kt b/src/main/java/at/lorenz/mod/chat/ChatFilter.kt new file mode 100644 index 000000000..8e2160928 --- /dev/null +++ b/src/main/java/at/lorenz/mod/chat/ChatFilter.kt @@ -0,0 +1,279 @@ +package at.lorenz.mod.chat + +import at.lorenz.mod.config.LorenzConfig +import at.lorenz.mod.utils.LorenzUtils +import at.lorenz.mod.utils.LorenzUtils.Companion.matchRegex +import at.lorenz.mod.events.LorenzChatEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class ChatFilter { + + @SubscribeEvent + fun onChatMessage(event: LorenzChatEvent) { + if (!LorenzConfig.chatFilter) 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) -> "lobby" + empty(message) -> "empty" + warping(message) -> "warping" + welcome(message) -> "welcome" + guild(message) -> "guild" + PlayerChatFilter.shouldBlock(message) -> "player_chat" + killCombo(message) -> "kill_combo" + bazaarAndAHMiniMessages(message) -> "bz_ah_minis" + watchdogAnnouncement(message) -> "watchdog" + slayer(message) -> "slayer" + slayerDrop(message) -> "slayer_drop" + uselessDrop(message) -> "useless_drop" + uselessNotification(message) -> "useless_notification" + party(message) -> "party" + money(message) -> "money" + winterIsland(message) -> "winter_island" + uselessWarning(message) -> "useless_warning" + friendJoin(message) -> "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 + + 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/lorenz/mod/chat/ChatManager.kt b/src/main/java/at/lorenz/mod/chat/ChatManager.kt new file mode 100644 index 000000000..a85643e1b --- /dev/null +++ b/src/main/java/at/lorenz/mod/chat/ChatManager.kt @@ -0,0 +1,47 @@ +package at.lorenz.mod.chat + +import at.lorenz.mod.utils.LorenzLogger +import at.lorenz.mod.events.LorenzChatEvent +import at.lorenz.mod.utils.LorenzUtils +import net.minecraftforge.client.event.ClientChatReceivedEvent +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: ClientChatReceivedEvent) { + val messageComponent = event.message + + val message = LorenzUtils.stripVanillaMessage(messageComponent.formattedText) + if (event.type.toInt() == 2) { +// val actionBarEvent = LorenzActionBarEvent(message) +// actionBarEvent.postAndC