From c8ca60a8264a5d3bafcc4fef23250aa18aa609f6 Mon Sep 17 00:00:00 2001 From: Constructor Date: Fri, 25 Feb 2022 01:48:30 +0100 Subject: [PATCH] Remove submodules (#238) * Removed submodules - No one used the libs anyways - Was making things unnecessary complicated * Remove weird import artifact * Still waiting for GitHub to allow delete caches. * Remove sourceSets * Not yet working * Cleanup error handling --- .github/workflows/nightly_build.yml | 14 +- build.gradle | 7 - setupWorkspace.sh | 31 +-- src/main/cape-api | 1 - src/main/command | 1 - src/main/commons | 1 - src/main/event | 1 - .../client/capeapi/AbstractUUIDManager.kt | 161 ++++++++++++ .../com/lambda/client/capeapi/DataClasses.kt | 73 ++++++ .../com/lambda/client/capeapi/UUIDUtils.kt | 26 ++ .../client/command/AbstractCommandManager.kt | 111 +++++++++ .../kotlin/com/lambda/client/command/Args.kt | 10 +- .../lambda/client/command/ClientCommand.kt | 10 +- .../com/lambda/client/command/Command.kt | 75 ++++++ .../lambda/client/command/CommandBuilder.kt | 234 ++++++++++++++++++ .../lambda/client/command/CommandManager.kt | 14 +- .../lambda/client/command/args/AbstractArg.kt | 64 +++++ .../client/command/args/ArgIdentifier.kt | 9 + .../com/lambda/client/command/args/Args.kt | 186 ++++++++++++++ .../client/command/args/AutoComplete.kt | 26 ++ .../lambda/client/command/args/FinalArg.kt | 93 +++++++ .../client/command/commands/ConfigCommand.kt | 2 +- .../client/command/commands/CreditsCommand.kt | 2 +- .../command/commands/EntityStatsCommand.kt | 2 +- .../client/command/commands/NBTCommand.kt | 2 +- .../command/commands/SignBookCommand.kt | 2 +- .../client/command/execute/ExecuteEvent.kt | 40 +++ .../client/command/execute/ExecuteOption.kt | 34 +++ .../client/command/execute/IExecuteEvent.kt | 32 +++ .../client/command/utils/BlockTypeAlias.kt | 24 ++ .../lambda/client/command/utils/Exceptions.kt | 20 ++ .../lambda/client/command/utils/Invokable.kt | 17 ++ .../client/commons/collections/AliasSet.kt | 28 +++ .../commons/collections/CloseableList.kt | 53 ++++ .../client/commons/collections/NameableSet.kt | 56 +++++ .../lambda/client/commons/extension/Any.kt | 7 + .../client/commons/extension/Collection.kt | 33 +++ .../lambda/client/commons/extension/Enum.kt | 10 + .../lambda/client/commons/extension/Map.kt | 25 ++ .../lambda/client/commons/extension/Math.kt | 23 ++ .../lambda/client/commons/extension/String.kt | 26 ++ .../lambda/client/commons/interfaces/Alias.kt | 5 + .../client/commons/interfaces/DisplayEnum.kt | 5 + .../client/commons/interfaces/Nameable.kt | 5 + .../lambda/client/commons/utils/ClassUtils.kt | 28 +++ .../client/commons/utils/ConnectionUtils.kt | 33 +++ .../lambda/client/commons/utils/MathUtils.kt | 61 +++++ .../client/commons/utils/StringUtils.kt | 12 + .../client/commons/utils/SystemUtils.kt | 25 ++ .../com/lambda/client/event/ClientEvents.kt | 4 +- .../com/lambda/client/event/LambdaEventBus.kt | 6 +- .../com/lambda/client/event/LambdaEvents.kt | 4 +- .../lambda/client/event/ListenerManager.kt | 63 +++++ .../event/eventbus/AbstractAsyncEventBus.kt | 25 ++ .../client/event/eventbus/AbstractEventBus.kt | 28 +++ .../client/event/eventbus/EventBusImpl.kt | 35 +++ .../client/event/eventbus/IAsyncEventBus.kt | 19 ++ .../lambda/client/event/eventbus/IEventBus.kt | 39 +++ .../client/event/eventbus/IMultiEventBus.kt | 16 ++ .../events/OnUpdateWalkingPlayerEvent.kt | 2 +- .../client/event/listener/AbstractListener.kt | 35 +++ .../lambda/client/event/listener/IListener.kt | 35 +++ .../client/event/listener/ListenerImpl.kt | 80 ++++++ .../com/lambda/client/gui/GuiManager.kt | 6 +- .../client/gui/clickgui/LambdaClickGui.kt | 2 +- .../client/gui/hudgui/AbstractHudElement.kt | 6 +- .../client/gui/hudgui/AbstractLabelHud.kt | 2 +- .../lambda/client/gui/hudgui/LambdaHudGui.kt | 2 +- .../gui/hudgui/elements/client/ModuleList.kt | 4 +- .../gui/hudgui/elements/combat/Armor.kt | 2 +- .../hudgui/elements/combat/CrystalDamage.kt | 2 +- .../client/gui/hudgui/elements/misc/CPS.kt | 2 +- .../gui/hudgui/elements/misc/Queue2B2T.kt | 2 +- .../gui/hudgui/elements/player/Durability.kt | 2 +- .../gui/hudgui/elements/player/PlayerSpeed.kt | 4 +- .../gui/hudgui/elements/player/Rotation.kt | 2 +- .../gui/hudgui/elements/player/TimerSpeed.kt | 2 +- .../gui/hudgui/elements/world/ChunkSize.kt | 2 +- .../gui/hudgui/elements/world/TextRadar.kt | 2 +- .../gui/hudgui/elements/world/WorldTime.kt | 2 +- .../com/lambda/client/gui/mc/LambdaGuiChat.kt | 6 +- .../com/lambda/client/gui/rgui/Component.kt | 2 +- .../client/gui/rgui/InteractiveComponent.kt | 2 +- .../lambda/client/gui/rgui/WindowComponent.kt | 2 +- .../client/gui/rgui/component/EnumSlider.kt | 2 +- .../gui/rgui/component/SettingSlider.kt | 2 +- .../client/gui/rgui/windows/BasicWindow.kt | 2 +- .../client/gui/rgui/windows/CleanWindow.kt | 2 +- .../client/gui/rgui/windows/ListWindow.kt | 6 +- .../client/gui/rgui/windows/SettingWindow.kt | 2 +- .../lambda/client/manager/ManagerLoader.kt | 4 +- .../client/manager/managers/FriendManager.kt | 4 +- .../client/manager/managers/HotbarManager.kt | 10 +- .../client/manager/managers/MacroManager.kt | 2 +- .../client/manager/managers/MessageManager.kt | 2 +- .../manager/managers/NotificationManager.kt | 23 ++ .../managers/PlayerInventoryManager.kt | 2 +- .../manager/managers/PlayerPacketManager.kt | 2 +- .../client/manager/managers/TimerManager.kt | 4 +- .../client/manager/managers/UUIDManager.kt | 6 +- .../lambda/client/module/AbstractModule.kt | 4 +- .../com/lambda/client/module/Category.kt | 2 +- .../com/lambda/client/module/ModuleManager.kt | 6 +- .../client/module/modules/chat/AntiSpam.kt | 2 +- .../client/module/modules/chat/AutoTPA.kt | 2 +- .../client/module/modules/chat/ChatFilter.kt | 2 +- .../module/modules/chat/ChatTimestamp.kt | 2 +- .../client/module/modules/chat/FancyChat.kt | 2 +- .../module/modules/chat/FriendHighlight.kt | 2 +- .../client/module/modules/chat/LambdaMoji.kt | 2 +- .../module/modules/chat/LoginMessage.kt | 2 +- .../client/module/modules/chat/Spammer.kt | 2 +- .../client/module/modules/client/Baritone.kt | 2 +- .../client/module/modules/client/Capes.kt | 10 +- .../client/module/modules/client/ClickGUI.kt | 2 +- .../module/modules/client/CommandConfig.kt | 2 +- .../module/modules/client/Configurations.kt | 4 +- .../client/module/modules/client/HudEditor.kt | 2 +- .../client/module/modules/combat/AutoEZ.kt | 4 +- .../client/module/modules/combat/AutoLog.kt | 2 +- .../client/module/modules/combat/AutoMend.kt | 4 +- .../module/modules/combat/AutoOffhand.kt | 2 +- .../client/module/modules/combat/AutoTrap.kt | 2 +- .../module/modules/combat/CombatSetting.kt | 4 +- .../client/module/modules/combat/Criticals.kt | 4 +- .../module/modules/combat/CrystalAura.kt | 6 +- .../module/modules/combat/CrystalBasePlace.kt | 2 +- .../module/modules/combat/CrystalESP.kt | 4 +- .../client/module/modules/combat/HoleSnap.kt | 6 +- .../client/module/modules/combat/KillAura.kt | 2 +- .../module/modules/combat/TotemPopCounter.kt | 4 +- .../client/module/modules/misc/AntiAFK.kt | 2 +- .../module/modules/misc/AutoObsidian.kt | 4 +- .../module/modules/misc/AutoReconnect.kt | 2 +- .../client/module/modules/misc/AutoTunnel.kt | 2 +- .../client/module/modules/misc/DiscordRPC.kt | 4 +- .../client/module/modules/misc/FakePlayer.kt | 2 +- .../module/modules/misc/LogoutLogger.kt | 2 +- .../client/module/modules/misc/NoSoundLag.kt | 2 +- .../client/module/modules/misc/NoteBot.kt | 2 +- .../client/module/modules/misc/PingSpoof.kt | 2 +- .../client/module/modules/misc/StashLogger.kt | 2 +- .../module/modules/misc/TeleportLogger.kt | 2 +- .../module/modules/movement/AutoWalk.kt | 6 +- .../module/modules/movement/ElytraFlight.kt | 2 +- .../client/module/modules/movement/Flight.kt | 2 +- .../client/module/modules/movement/Jesus.kt | 4 +- .../client/module/modules/movement/Step.kt | 2 +- .../client/module/modules/player/AutoEat.kt | 2 +- .../client/module/modules/player/Blink.kt | 2 +- .../client/module/modules/player/FastUse.kt | 2 +- .../client/module/modules/player/Freecam.kt | 8 +- .../module/modules/player/InventoryManager.kt | 2 +- .../module/modules/player/LagNotifier.kt | 4 +- .../client/module/modules/player/NoSwing.kt | 2 +- .../module/modules/player/PacketCancel.kt | 2 +- .../module/modules/player/PacketLimiter.kt | 2 +- .../module/modules/player/PacketLogger.kt | 4 +- .../module/modules/player/PortalGodMode.kt | 2 +- .../client/module/modules/player/Scaffold.kt | 2 +- .../client/module/modules/player/Timer.kt | 2 +- .../client/module/modules/player/XCarry.kt | 2 +- .../client/module/modules/render/BossStack.kt | 2 +- .../module/modules/render/Breadcrumbs.kt | 2 +- .../module/modules/render/BreakingESP.kt | 2 +- .../module/modules/render/ContainerPreview.kt | 2 +- .../client/module/modules/render/ESP.kt | 2 +- .../client/module/modules/render/EyeFinder.kt | 2 +- .../module/modules/render/HungerOverlay.kt | 2 +- .../client/module/modules/render/MobOwner.kt | 2 +- .../client/module/modules/render/Nametags.kt | 8 +- .../client/module/modules/render/NewChunks.kt | 2 +- .../client/module/modules/render/NoRender.kt | 2 +- .../module/modules/render/StorageESP.kt | 2 +- .../client/module/modules/render/Tracers.kt | 4 +- .../module/modules/render/WaypointRender.kt | 2 +- .../com/lambda/client/plugin/PluginError.kt | 81 +++--- .../com/lambda/client/plugin/PluginInfo.kt | 2 +- .../com/lambda/client/plugin/PluginLoader.kt | 4 +- .../com/lambda/client/plugin/PluginManager.kt | 23 +- .../lambda/client/plugin/api/IPluginClass.kt | 2 +- .../com/lambda/client/plugin/api/Plugin.kt | 6 +- .../lambda/client/setting/ConfigManager.kt | 2 +- .../client/setting/GenericConfigClass.kt | 2 +- .../lambda/client/setting/configs/IConfig.kt | 2 +- .../client/setting/configs/NameableConfig.kt | 2 +- .../client/setting/groups/SettingGroup.kt | 2 +- .../setting/settings/AbstractSetting.kt | 2 +- .../settings/impl/primitive/EnumSetting.kt | 2 +- .../com/lambda/client/util/EntityUtils.kt | 4 +- .../com/lambda/client/util/TpsCalculator.kt | 2 +- .../kotlin/com/lambda/client/util/WebUtils.kt | 2 +- .../lambda/client/util/color/ColorGradient.kt | 2 +- .../lambda/client/util/combat/CombatUtils.kt | 2 +- .../client/util/graphics/AnimationUtils.kt | 2 +- .../client/util/graphics/RenderUtils2D.kt | 2 +- .../client/util/graphics/ShaderHelper.kt | 2 +- .../client/util/graphics/font/Alignment.kt | 2 +- .../client/util/graphics/font/FontGlyphs.kt | 2 +- .../com/lambda/client/util/math/Direction.kt | 2 +- .../lambda/client/util/math/RotationUtils.kt | 2 +- .../com/lambda/client/util/math/Vec2d.kt | 2 +- .../com/lambda/client/util/math/Vec2f.kt | 2 +- .../lambda/client/util/math/VectorUtils.kt | 6 +- .../client/util/threads/MainThreadExecutor.kt | 2 +- .../client/util/threads/ThreadSafety.kt | 8 +- 206 files changed, 2351 insertions(+), 327 deletions(-) delete mode 160000 src/main/cape-api delete mode 160000 src/main/command delete mode 160000 src/main/commons delete mode 160000 src/main/event create mode 100644 src/main/kotlin/com/lambda/client/capeapi/AbstractUUIDManager.kt create mode 100644 src/main/kotlin/com/lambda/client/capeapi/DataClasses.kt create mode 100644 src/main/kotlin/com/lambda/client/capeapi/UUIDUtils.kt create mode 100644 src/main/kotlin/com/lambda/client/command/AbstractCommandManager.kt create mode 100644 src/main/kotlin/com/lambda/client/command/Command.kt create mode 100644 src/main/kotlin/com/lambda/client/command/CommandBuilder.kt create mode 100644 src/main/kotlin/com/lambda/client/command/args/AbstractArg.kt create mode 100644 src/main/kotlin/com/lambda/client/command/args/ArgIdentifier.kt create mode 100644 src/main/kotlin/com/lambda/client/command/args/Args.kt create mode 100644 src/main/kotlin/com/lambda/client/command/args/AutoComplete.kt create mode 100644 src/main/kotlin/com/lambda/client/command/args/FinalArg.kt create mode 100644 src/main/kotlin/com/lambda/client/command/execute/ExecuteEvent.kt create mode 100644 src/main/kotlin/com/lambda/client/command/execute/ExecuteOption.kt create mode 100644 src/main/kotlin/com/lambda/client/command/execute/IExecuteEvent.kt create mode 100644 src/main/kotlin/com/lambda/client/command/utils/BlockTypeAlias.kt create mode 100644 src/main/kotlin/com/lambda/client/command/utils/Exceptions.kt create mode 100644 src/main/kotlin/com/lambda/client/command/utils/Invokable.kt create mode 100644 src/main/kotlin/com/lambda/client/commons/collections/AliasSet.kt create mode 100644 src/main/kotlin/com/lambda/client/commons/collections/CloseableList.kt create mode 100644 src/main/kotlin/com/lambda/client/commons/collections/NameableSet.kt create mode 100644 src/main/kotlin/com/lambda/client/commons/extension/Any.kt create mode 100644 src/main/kotlin/com/lambda/client/commons/extension/Collection.kt create mode 100644 src/main/kotlin/com/lambda/client/commons/extension/Enum.kt create mode 100644 src/main/kotlin/com/lambda/client/commons/extension/Map.kt create mode 100644 src/main/kotlin/com/lambda/client/commons/extension/Math.kt create mode 100644 src/main/kotlin/com/lambda/client/commons/extension/String.kt create mode 100644 src/main/kotlin/com/lambda/client/commons/interfaces/Alias.kt create mode 100644 src/main/kotlin/com/lambda/client/commons/interfaces/DisplayEnum.kt create mode 100644 src/main/kotlin/com/lambda/client/commons/interfaces/Nameable.kt create mode 100644 src/main/kotlin/com/lambda/client/commons/utils/ClassUtils.kt create mode 100644 src/main/kotlin/com/lambda/client/commons/utils/ConnectionUtils.kt create mode 100644 src/main/kotlin/com/lambda/client/commons/utils/MathUtils.kt create mode 100644 src/main/kotlin/com/lambda/client/commons/utils/StringUtils.kt create mode 100644 src/main/kotlin/com/lambda/client/commons/utils/SystemUtils.kt create mode 100644 src/main/kotlin/com/lambda/client/event/ListenerManager.kt create mode 100644 src/main/kotlin/com/lambda/client/event/eventbus/AbstractAsyncEventBus.kt create mode 100644 src/main/kotlin/com/lambda/client/event/eventbus/AbstractEventBus.kt create mode 100644 src/main/kotlin/com/lambda/client/event/eventbus/EventBusImpl.kt create mode 100644 src/main/kotlin/com/lambda/client/event/eventbus/IAsyncEventBus.kt create mode 100644 src/main/kotlin/com/lambda/client/event/eventbus/IEventBus.kt create mode 100644 src/main/kotlin/com/lambda/client/event/eventbus/IMultiEventBus.kt create mode 100644 src/main/kotlin/com/lambda/client/event/listener/AbstractListener.kt create mode 100644 src/main/kotlin/com/lambda/client/event/listener/IListener.kt create mode 100644 src/main/kotlin/com/lambda/client/event/listener/ListenerImpl.kt create mode 100644 src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt diff --git a/.github/workflows/nightly_build.yml b/.github/workflows/nightly_build.yml index f51b6b0de..93f0b45fe 100644 --- a/.github/workflows/nightly_build.yml +++ b/.github/workflows/nightly_build.yml @@ -17,29 +17,29 @@ jobs: - name: Check out repository uses: actions/checkout@v2 - - name: Check out submodules - uses: snickerbockers/submodules-init@v4 - - name: Set up JDK uses: actions/setup-java@v1 with: java-version: 1.8 + - name: Fix wrapper permissions + run: chmod +x ./gradlew + - name: Gradle cache uses: actions/cache@v2 with: path: | ~/.gradle/caches ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/*.gradle*') }} + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} restore-keys: | - ${{ runner.os }}-gradle-${{ secrets.CACHE_VERSION }}- + ${{ runner.os }}-gradle- - name: Prepare workspace run: ./gradlew --no-daemon classes - - name : Build forge mod - run : ./gradlew --build-cache build + - name: Build forge mod + run: ./gradlew --build-cache build - name: Rename built forge mod run: mv build/libs/lambda-*.jar lambda-${{ github.run_number }}.jar diff --git a/build.gradle b/build.gradle index 5f30efae5..341cfa0a3 100644 --- a/build.gradle +++ b/build.gradle @@ -22,13 +22,6 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.jetbrains.dokka' apply plugin: 'org.spongepowered.mixin' -sourceSets.main.java { - srcDirs += 'src/main/cape-api' - srcDirs += 'src/main/command' - srcDirs += 'src/main/commons' - srcDirs += 'src/main/event' -} - compileJava { sourceCompatibility = targetCompatibility = '1.8' options.encoding = 'UTF-8' diff --git a/setupWorkspace.sh b/setupWorkspace.sh index 819532cf7..74e4296e0 100755 --- a/setupWorkspace.sh +++ b/setupWorkspace.sh @@ -9,44 +9,15 @@ # To allow use from outside the lambda directory cd "$(dirname "$0")" || exit -echo "[$(date +"%H:%M:%S")] Checking if git is installed..." -if [ -z "$(which git)" ]; then - echo "[$(date +"%H:%M:%S")] ERROR: Git is not installed, please make sure you install the CLI version of git, not some desktop wrapper for it" >&2 - exit 1 -fi -echo "[$(date +"%H:%M:%S")] Git is installed!" - -# - -echo "[$(date +"%H:%M:%S")] Checking for .git dir..." -if [ ! -d ".git" ]; then - echo "[$(date +"%H:%M:%S")] ERROR: Could not detect git repository, exiting" >&2 - exit 1 -fi -echo "[$(date +"%H:%M:%S")] Found git repository!" - -# - -echo "[$(date +"%H:%M:%S")] Downloading git submodules..." -git submodule update --init --recursive || { - echo "[$(date +"%H:%M:%S")] ERROR: Failed to init git submodules" - exit 1 -} -echo "[$(date +"%H:%M:%S")] Downloaded git submodules!" - -# - echo "[$(date +"%H:%M:%S")] Running gradlew classes without daemon..." ./gradlew --no-daemon classes || { echo "[$(date +"%H:%M:%S")] ERROR: Running gradlew build failed! Run './gradlew --no-daemon classes' manually" exit 1 } -# - cat logo_ascii.txt 2>/dev/null echo "==========================================================================" echo "" -echo "[$(date +"%H:%M:%S")] Build succeeded! All checks passed, you can build normally now!" +echo "[$(date +"%H:%M:%S")] Build succeeded! All checks passed, you can build normally now! Welcome to Lambda." echo "" echo "==========================================================================" diff --git a/src/main/cape-api b/src/main/cape-api deleted file mode 160000 index e36138233..000000000 --- a/src/main/cape-api +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e361382331beb5356ccf4d65cb070dc4b2fac150 diff --git a/src/main/command b/src/main/command deleted file mode 160000 index ab82bfc21..000000000 --- a/src/main/command +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ab82bfc2199871d6aacd7a5053403498f4ab6f6d diff --git a/src/main/commons b/src/main/commons deleted file mode 160000 index 6240ffbd9..000000000 --- a/src/main/commons +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6240ffbd944463c7e7836e8248b8cc942d6e4d04 diff --git a/src/main/event b/src/main/event deleted file mode 160000 index b6576a1d1..000000000 --- a/src/main/event +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b6576a1d1d4ad196900f0dfd9f3cb0104bc1f459 diff --git a/src/main/kotlin/com/lambda/client/capeapi/AbstractUUIDManager.kt b/src/main/kotlin/com/lambda/client/capeapi/AbstractUUIDManager.kt new file mode 100644 index 000000000..3e36624fa --- /dev/null +++ b/src/main/kotlin/com/lambda/client/capeapi/AbstractUUIDManager.kt @@ -0,0 +1,161 @@ +package com.lambda.client.capeapi + +import com.google.gson.GsonBuilder +import com.google.gson.JsonParser +import com.google.gson.reflect.TypeToken +import com.lambda.client.commons.extension.synchronized +import com.lambda.client.commons.utils.ConnectionUtils +import org.apache.logging.log4j.Logger +import java.io.File +import java.io.FileWriter +import java.util.* + +abstract class AbstractUUIDManager( + filePath: String, + private val logger: Logger, + private val maxCacheSize: Int = 500 +) { + + private val file = File(filePath) + + @Suppress("DEPRECATION") + private val parser = JsonParser() + private val gson = GsonBuilder().setPrettyPrinting().create() + private val type = TypeToken.getArray(PlayerProfile::class.java).type + + private val nameProfileMap = LinkedHashMap().synchronized() + private val uuidNameMap = LinkedHashMap().synchronized() + + fun getByString(stringIn: String?) = stringIn?.let { string -> + UUIDUtils.fixUUID(string)?.let { getByUUID(it) } ?: getByName(string) + } + + fun getByUUID(uuid: UUID?) = uuid?.let { + uuidNameMap.getOrPut(uuid) { + getOrRequest(uuid.toString())?.also { profile -> + // If UUID already present in nameUuidMap but not in uuidNameMap (user changed name) + nameProfileMap[profile.name]?.let { uuidNameMap.remove(it.uuid) } + nameProfileMap[profile.name] = profile + } ?: return null + }.also { + trimMaps() + } + } + + fun getByName(name: String?) = name?.let { + nameProfileMap.getOrPut(name.lowercase()) { + getOrRequest(name)?.also { profile -> + // If UUID already present in uuidNameMap but not in nameUuidMap (user changed name) + uuidNameMap[profile.uuid]?.let { nameProfileMap.remove(it.name) } + uuidNameMap[profile.uuid] = profile + } ?: return null + }.also { + trimMaps() + } + } + + private fun trimMaps() { + while (nameProfileMap.size > maxCacheSize) { + nameProfileMap.remove(nameProfileMap.keys.first())?.also { + uuidNameMap.remove(it.uuid) + } + } + } + + /** + * Overwrites this if you want to get UUID from other source + * eg. online player in game client + */ + protected open fun getOrRequest(nameOrUUID: String): PlayerProfile? { + return requestProfile(nameOrUUID) + } + + private fun requestProfile(nameOrUUID: String): PlayerProfile? { + val isUUID = UUIDUtils.isUUID(nameOrUUID) + val response = if (isUUID) requestProfileFromUUID(nameOrUUID) else requestProfileFromName(nameOrUUID) + + return if (response.isNullOrBlank()) { + logger.error("Response is null or blank, internet might be down") + null + } else { + try { + @Suppress("DEPRECATION") val jsonElement = parser.parse(response) + if (isUUID) { + val name = jsonElement.asJsonArray.last().asJsonObject["name"].asString + PlayerProfile(UUID.fromString(nameOrUUID), name) + } else { + val id = jsonElement.asJsonObject["id"].asString + val name = jsonElement.asJsonObject["name"].asString + PlayerProfile(UUIDUtils.fixUUID(id)!!, name) // let it throw a NPE if failed to parse the string to UUID + } + } catch (e: Exception) { + logger.error("Failed parsing profile", e) + null + } + } + } + + private fun requestProfileFromUUID(uuid: String): String? { + return request("https://api.mojang.com/user/profiles/${UUIDUtils.removeDashes(uuid)}/names") + } + + private fun requestProfileFromName(name: String): String? { + return request("https://api.mojang.com/users/profiles/minecraft/$name") + } + + private fun request(url: String): String? { + return ConnectionUtils.requestRawJsonFrom(url) { + logger.error("Failed requesting from Mojang API", it) + } + } + + fun load(): Boolean { + fixEmptyJson(file) + return try { + val cacheList = file.bufferedReader().use { + gson.fromJson>(it, type) + } + uuidNameMap.clear() + nameProfileMap.clear() + uuidNameMap.putAll(cacheList.associateBy { it.uuid }) + nameProfileMap.putAll(cacheList.associateBy { it.name.lowercase() }) + logger.info("UUID cache loaded") + true + } catch (e: Exception) { + logger.warn("Failed loading UUID cache", e) + false + } + } + + fun save(): Boolean { + return try { + val cacheList = uuidNameMap.values.sortedBy { it.name } + file.bufferedWriter().use { + gson.toJson(cacheList, it) + } + logger.info("UUID cache saved") + true + } catch (e: Exception) { + logger.warn("Failed saving UUID cache", e) + false + } + } + + private fun fixEmptyJson(file: File) { + if (!file.exists()) file.createNewFile() + var notEmpty = false + file.forEachLine { notEmpty = notEmpty || it.trim().isNotBlank() || it == "[]" || it == "{}" } + + if (!notEmpty) { + val fileWriter = FileWriter(file) + try { + fileWriter.write("[]") + } catch (e: Exception) { + logger.error("Failed to fix empty json", e) + } finally { + fileWriter.close() + } + } + } + +} diff --git a/src/main/kotlin/com/lambda/client/capeapi/DataClasses.kt b/src/main/kotlin/com/lambda/client/capeapi/DataClasses.kt new file mode 100644 index 000000000..5d2fd6b57 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/capeapi/DataClasses.kt @@ -0,0 +1,73 @@ +package com.lambda.client.capeapi + +import com.google.gson.annotations.SerializedName +import java.util.* + +data class CapeUser( + val id: Long, + val capes: ArrayList, + @SerializedName("is_premium") + var isPremium: Boolean = false +) { + override fun equals(other: Any?): Boolean { + return this === other + || other is CapeUser + && other.id == this.id + && other.capes == capes + } + + override fun hashCode(): Int { + return 31 * id.hashCode() + capes.hashCode() + } +} + +data class Cape( + @SerializedName("cape_uuid") + val capeUUID: String = UUID.randomUUID().toString().substring(0, 5), + @SerializedName("player_uuid") + var playerUUID: UUID? = null, + val type: CapeType, + var color: CapeColor = type.color +) { + override fun equals(other: Any?): Boolean { + return this === other + || other is Cape + && other.capeUUID == capeUUID + && other.type == other.type + } + + override fun hashCode(): Int { + return 31 * capeUUID.hashCode() + type.hashCode() + } +} + +data class CapeColor( + val primary: String, + val border: String +) { + override fun toString(): String { + return "#$primary, #$border" + } +} + +data class PlayerProfile( + @SerializedName("uuid", alternate = ["UUID"]) + val uuid: UUID, + @SerializedName("name", alternate = ["Name"]) + val name: String +) { + override fun equals(other: Any?): Boolean { + return this === other + || other is PlayerProfile + && other.uuid == uuid + } + + override fun hashCode(): Int { + return uuid.hashCode() + } +} + +enum class CapeType(val realName: String, val imageKey: String, val color: CapeColor) { + CONTRIBUTOR("Contributor", "github", CapeColor("272727", "363636")) +} + diff --git a/src/main/kotlin/com/lambda/client/capeapi/UUIDUtils.kt b/src/main/kotlin/com/lambda/client/capeapi/UUIDUtils.kt new file mode 100644 index 000000000..4fad14468 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/capeapi/UUIDUtils.kt @@ -0,0 +1,26 @@ +package com.lambda.client.capeapi + +import java.util.* + +object UUIDUtils { + private val uuidRegex = "[a-z0-9].{7}-[a-z0-9].{3}-[a-z0-9].{3}-[a-z0-9].{3}-[a-z0-9].{11}".toRegex() + + fun fixUUID(string: String): UUID? { + if (isUUID(string)) return UUID.fromString(string) + if (string.length < 32) return null + val fixed = insertDashes(string) + return if (isUUID(fixed)) UUID.fromString(fixed) + else null + } + + fun isUUID(string: String) = uuidRegex.matches(string) + + fun removeDashes(string: String) = string.replace("-", "") + + private fun insertDashes(string: String) = StringBuilder(string) + .insert(8, '-') + .insert(13, '-') + .insert(18, '-') + .insert(23, '-') + .toString() +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/command/AbstractCommandManager.kt b/src/main/kotlin/com/lambda/client/command/AbstractCommandManager.kt new file mode 100644 index 000000000..8e7e0c8da --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/AbstractCommandManager.kt @@ -0,0 +1,111 @@ +package com.lambda.client.command + +import com.lambda.client.command.execute.IExecuteEvent +import com.lambda.client.command.utils.CommandNotFoundException +import com.lambda.client.commons.collections.AliasSet + +/** + * Manager for [Command] registration and execution + * + * @param E Type of [IExecuteEvent], can be itself or its subtype + */ +abstract class AbstractCommandManager { + + /** + * Registered [Command] for this [AbstractCommandManager] + */ + private val commands = AliasSet>() + + /** + * Registered [CommandBuilder] to their built [Command] + */ + private val builderCommandMap = HashMap, Command>() + + protected val lockObject = Any() + + /** + * Build [builder] and register it to this [AbstractCommandManager] + * + * @return The built [Command] + */ + open fun register(builder: CommandBuilder): Command { + return synchronized(lockObject) { + builder.buildCommand().also { + commands.add(it) + builderCommandMap[builder] = it + } + } + } + + /** + * Unregister the [Command] built from this [CommandBuilder] + * + * @return The unregistered [Command] + */ + open fun unregister(builder: CommandBuilder): Command? { + return synchronized(lockObject) { + builderCommandMap.remove(builder)?.also { + commands.remove(it) + } + } + } + + + /** + * Get all commands + */ + fun getCommands() = commands.toSet() + + /** + * Get command for [name] + * + * @throws CommandNotFoundException + */ + fun getCommand(name: String) = commands[name] ?: throw CommandNotFoundException(name) + + /** + * Get command for [name], or null if [name] is invalid + */ + fun getCommandOrNull(name: String) = commands[name] + + + /** + * Invoke a command for [event] + * + * @throws IllegalArgumentException If [event]'s argument is empty + * @throws CommandNotFoundException If no command found + */ + open suspend fun invoke(event: E) { + val name = event.args.getOrNull(0) ?: throw IllegalArgumentException("Arguments can not be empty!") + getCommand(name).invoke(event) + } + + /** + * Parse [string] in to arguments ([Array] of [String]) + * + * @throws IllegalArgumentException If [string] is blank or empty + */ + fun parseArguments(string: String): Array { + if (string.isBlank()) { + throw if (string.isEmpty()) IllegalArgumentException("Input can not be empty!") + else IllegalArgumentException("Input can not be blank!") + } + + return string + .trim() + .split(splitRegex) + .map { + it.removeSurrounding("\"") + .replace("''", "\"") + } + .toTypedArray() + } + + private companion object { + /** + * Used by [parseArguments] to split the [String] into array of argument [String] + */ + val splitRegex = " (?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)".toRegex() + } + +} diff --git a/src/main/kotlin/com/lambda/client/command/Args.kt b/src/main/kotlin/com/lambda/client/command/Args.kt index 46cf58500..941991dd6 100644 --- a/src/main/kotlin/com/lambda/client/command/Args.kt +++ b/src/main/kotlin/com/lambda/client/command/Args.kt @@ -1,6 +1,6 @@ package com.lambda.client.command -import com.lambda.capeapi.PlayerProfile +import com.lambda.client.capeapi.PlayerProfile import com.lambda.client.gui.GuiManager import com.lambda.client.gui.hudgui.AbstractHudElement import com.lambda.client.manager.managers.UUIDManager @@ -8,10 +8,10 @@ import com.lambda.client.module.AbstractModule import com.lambda.client.module.ModuleManager import com.lambda.client.util.* import com.lambda.client.util.threads.runSafeR -import com.lambda.command.args.AbstractArg -import com.lambda.command.args.AutoComplete -import com.lambda.command.args.DynamicPrefixMatch -import com.lambda.command.args.StaticPrefixMatch +import com.lambda.client.command.args.AbstractArg +import com.lambda.client.command.args.AutoComplete +import com.lambda.client.command.args.DynamicPrefixMatch +import com.lambda.client.command.args.StaticPrefixMatch import kotlinx.coroutines.Dispatchers import net.minecraft.block.Block import net.minecraft.item.Item diff --git a/src/main/kotlin/com/lambda/client/command/ClientCommand.kt b/src/main/kotlin/com/lambda/client/command/ClientCommand.kt index 32739eb09..8a835b12f 100644 --- a/src/main/kotlin/com/lambda/client/command/ClientCommand.kt +++ b/src/main/kotlin/com/lambda/client/command/ClientCommand.kt @@ -1,6 +1,6 @@ package com.lambda.client.command -import com.lambda.capeapi.PlayerProfile +import com.lambda.client.capeapi.PlayerProfile import com.lambda.client.event.ClientExecuteEvent import com.lambda.client.event.SafeExecuteEvent import com.lambda.client.gui.hudgui.AbstractHudElement @@ -9,10 +9,10 @@ import com.lambda.client.module.modules.client.CommandConfig import com.lambda.client.util.Wrapper import com.lambda.client.util.threads.defaultScope import com.lambda.client.util.threads.toSafe -import com.lambda.command.CommandBuilder -import com.lambda.command.args.AbstractArg -import com.lambda.command.utils.BuilderBlock -import com.lambda.command.utils.ExecuteBlock +import com.lambda.client.command.CommandBuilder +import com.lambda.client.command.args.AbstractArg +import com.lambda.client.command.utils.BuilderBlock +import com.lambda.client.command.utils.ExecuteBlock import kotlinx.coroutines.launch import net.minecraft.block.Block import net.minecraft.item.Item diff --git a/src/main/kotlin/com/lambda/client/command/Command.kt b/src/main/kotlin/com/lambda/client/command/Command.kt new file mode 100644 index 000000000..0ed6123a1 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/Command.kt @@ -0,0 +1,75 @@ +package com.lambda.client.command + +import com.lambda.client.command.args.FinalArg +import com.lambda.client.command.execute.IExecuteEvent +import com.lambda.client.command.utils.Invokable +import com.lambda.client.command.utils.SubCommandNotFoundException +import com.lambda.client.commons.interfaces.Alias +import com.lambda.client.commons.interfaces.Nameable + +/** + * Command built from [CommandBuilder], this shouldn't be used + * directly for instance creation in implementation. + * + * @param E Type of [IExecuteEvent], can be itself or its subtype + * @param name Name of this [Command], used to call the [Command] or identifying + * @param alias Alias of [Command], functions the same as [name] + * @param description Description of this [Command] + * @param finalArgs Possible argument combinations of this [Command] + */ +class Command internal constructor( + override val name: String, + override val alias: Array, + val description: String, + val finalArgs: Array>, + val builder: CommandBuilder +) : Nameable, Alias, Invokable { + + /** + * [name] + [alias] + */ + val allNames = arrayOf(name, *alias) + + /** + * Invoke this [Command] with [event]. + * + * @param event Event being used for invoking, must match the type [E] + * + * @throws SubCommandNotFoundException if no sub command is found + */ + override suspend fun invoke(event: E) { + finalArgs.firstOrNull { it.checkArgs(event.args) }?.invoke(event) + ?: throw SubCommandNotFoundException(event.args, this) + } + + /** + * Returns argument help for this [Command]. + */ + fun printArgHelp(): String { + return finalArgs.joinToString("\n\n") { + var argHelp = it.printArgHelp() + val description = it.toString() + + if (argHelp.isBlank()) argHelp = "" + if (description.isNotBlank()) argHelp += "\n$it" + argHelp + } + } + + override fun equals(other: Any?) = this === other + || (other is Command<*> + && name == other.name + && alias.contentEquals(other.alias) + && description == other.description + && finalArgs.contentEquals(other.finalArgs) + && builder == other.builder) + + override fun hashCode(): Int { + var result = name.hashCode() + result = 31 * result + alias.contentHashCode() + result = 31 * result + description.hashCode() + result = 31 * result + finalArgs.contentHashCode() + return 31 * result + builder.hashCode() + } + +} diff --git a/src/main/kotlin/com/lambda/client/command/CommandBuilder.kt b/src/main/kotlin/com/lambda/client/command/CommandBuilder.kt new file mode 100644 index 000000000..cff917d7f --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/CommandBuilder.kt @@ -0,0 +1,234 @@ +package com.lambda.client.command + +import com.lambda.client.command.args.* +import com.lambda.client.command.execute.ExecuteOption +import com.lambda.client.command.execute.IExecuteEvent +import com.lambda.client.command.utils.BuilderBlock +import com.lambda.client.command.utils.ExecuteBlock + +/** + * Builder for [Command], extend this or subtype of this + * to build a command. Or extend this to add more arg types. + * + * @param E Type of [IExecuteEvent], can be itself or its subtype + * @param name (Optional) Name for the [Command] + * @param description (Optional) Description for the [Command] + */ +open class CommandBuilder( + name: String, + alias: Array = emptyArray(), + private val description: String = "No description", +) : LiteralArg(name, alias) { + + /** + * Final arguments to be used for building the command + */ + private val finalArgs = ArrayList>() + + /** + * Appends a [FinalArg], adds it to [finalArgs] + * + * @param options (Optional) [ExecuteOption] used to check before invoking [block] + * @param block [ExecuteBlock] to run on invoking + */ + @CommandBuilder + protected fun AbstractArg<*>.execute( + vararg options: ExecuteOption, + block: ExecuteBlock + ) { + execute("No description", *options, block = block) + } + + /** + * Appends a [FinalArg], adds it to [finalArgs] + * + * @param description (Optional) Description for this argument combination + * @param options (Optional) [ExecuteOption] used to check before invoking [block] + * @param block [ExecuteBlock] to run on invoking + */ + @CommandBuilder + protected fun AbstractArg<*>.execute( + description: String = "No description", + vararg options: ExecuteOption, + block: ExecuteBlock + ) { + val arg = FinalArg(description, options, block) + this.append(arg) + finalArgs.add(arg) + } + + /** + * Appends a [BooleanArg] + * + * @param name Name of this argument + * @param block [BuilderBlock] to appends more arguments + */ + @CommandBuilder + protected inline fun AbstractArg<*>.boolean( + name: String, + block: BuilderBlock + ) { + arg(BooleanArg(name), block) + } + + /** + * Appends a [EnumArg] + * + * @param E Type of Enum + * @param name Name of this argument + * @param block [BuilderBlock] to appends more arguments + */ + @CommandBuilder + protected inline fun > AbstractArg<*>.enum( + name: String, + block: BuilderBlock + ) { + arg(EnumArg(name, E::class.java), block) + } + + /** + * Appends a [LongArg] + * + * @param name Name of this argument + * @param block [BuilderBlock] to appends more arguments + */ + @CommandBuilder + protected inline fun AbstractArg<*>.long( + name: String, + block: BuilderBlock + ) { + arg(LongArg(name), block) + } + + /** + * Appends a [IntArg] + * + * @param name Name of this argument + * @param block [BuilderBlock] to appends more arguments + */ + @CommandBuilder + protected inline fun AbstractArg<*>.int( + name: String, + block: BuilderBlock + ) { + arg(IntArg(name), block) + } + + /** + * Appends a [ShortArg] + * + * @param name Name of this argument + * @param block [BuilderBlock] to appends more arguments + */ + @CommandBuilder + protected inline fun AbstractArg<*>.short( + name: String, + block: BuilderBlock + ) { + arg(ShortArg(name), block) + } + + /** + * Appends a [FloatArg] + * + * @param name Name of this argument + * @param block [BuilderBlock] to appends more arguments + */ + @CommandBuilder + protected inline fun AbstractArg<*>.float( + name: String, + block: BuilderBlock + ) { + arg(FloatArg(name), block) + } + + /** + * Appends a [DoubleArg] + * + * @param name Name of this argument + * @param block [BuilderBlock] to appends more arguments + */ + @CommandBuilder + protected inline fun AbstractArg<*>.double( + name: String, + block: BuilderBlock + ) { + arg(DoubleArg(name), block) + } + + /** + * Appends a [LiteralArg] + * + * @param name Name of this argument + * @param alias Alias of this literal argument + * @param block [BuilderBlock] to appends more arguments + */ + @CommandBuilder + protected inline fun AbstractArg<*>.literal( + name: String, + vararg alias: String, + block: LiteralArg.() -> Unit + ) { + val arg = LiteralArg(name, alias) + this.append(arg) + arg.block() + } + + /** + * Appends a [StringArg] + * + * @param name Name of this argument + * @param block [BuilderBlock] to appends more arguments + */ + @CommandBuilder + protected inline fun AbstractArg<*>.string( + name: String, + block: BuilderBlock + ) { + arg(StringArg(name), block) + } + + /** + * Appends a [GreedyStringArg] + * + * @param name Name of this argument + * @param block [BuilderBlock] to appends more arguments + */ + @CommandBuilder + protected inline fun AbstractArg<*>.greedy( + name: String, + block: BuilderBlock + ) { + arg(GreedyStringArg(name), block) + } + + /** + * Appends a [AbstractArg] with type of [T] + * + * @param T The type of [arg] + * @param arg Argument to append + * @param block [BuilderBlock] to appends more arguments + */ + @CommandBuilder + protected inline fun AbstractArg<*>.arg( + arg: AbstractArg, + block: BuilderBlock + ) { + this.append(arg) + arg.block(arg.identifier) + } + + /** + * Annotation to mark the builder methods + */ + @DslMarker + protected annotation class CommandBuilder + + /** + * Built this into a [Command] + */ + internal fun buildCommand(): Command { + return Command(name, alias, description, finalArgs.toTypedArray(), this) + } + +} diff --git a/src/main/kotlin/com/lambda/client/command/CommandManager.kt b/src/main/kotlin/com/lambda/client/command/CommandManager.kt index 809bc869d..f08a52e0c 100644 --- a/src/main/kotlin/com/lambda/client/command/CommandManager.kt +++ b/src/main/kotlin/com/lambda/client/command/CommandManager.kt @@ -9,13 +9,13 @@ import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.formatValue import com.lambda.client.util.threads.defaultScope import com.lambda.client.util.threads.onMainThread -import com.lambda.command.AbstractCommandManager -import com.lambda.command.Command -import com.lambda.command.CommandBuilder -import com.lambda.command.utils.CommandNotFoundException -import com.lambda.command.utils.SubCommandNotFoundException -import com.lambda.commons.utils.ClassUtils -import com.lambda.commons.utils.ClassUtils.instance +import com.lambda.client.command.AbstractCommandManager +import com.lambda.client.command.Command +import com.lambda.client.command.CommandBuilder +import com.lambda.client.command.utils.CommandNotFoundException +import com.lambda.client.command.utils.SubCommandNotFoundException +import com.lambda.client.commons.utils.ClassUtils +import com.lambda.client.commons.utils.ClassUtils.instance import kotlinx.coroutines.Deferred import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking diff --git a/src/main/kotlin/com/lambda/client/command/args/AbstractArg.kt b/src/main/kotlin/com/lambda/client/command/args/AbstractArg.kt new file mode 100644 index 000000000..6aa3aa211 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/args/AbstractArg.kt @@ -0,0 +1,64 @@ +package com.lambda.client.command.args + +import com.lambda.client.commons.interfaces.Nameable + +/** + * Base of an Argument type, extends this to make new argument type + * + * @param T type of this argument + */ +abstract class AbstractArg : Nameable { + + /** + * Type name of this argument type, used by [toString] + */ + protected open val typeName = javaClass.simpleName.removeSuffix("Arg") + + /** + * Argument tree for building up the arguments + */ + protected val argTree = ArrayList>() + + /** + * ID of this argument + */ + val identifier by lazy { ArgIdentifier(name) } + + /** + * Get a immutable copy of [argTree] + */ + fun getArgTree() = argTree.toList() + + /** + * Check if [string] matches with this argument + */ + internal open suspend fun checkType(string: String?) = convertToType(string) != null + + /** + * Convert [string] to the the argument type [T] + */ + internal abstract suspend fun convertToType(string: String?): T? + + /** + * Appends a new [AbstractArg], copy the [argTree] + * + * @param arg [AbstractArg] to append + */ + fun append(arg: AbstractArg): AbstractArg { + if (this is FinalArg<*>) { + throw IllegalArgumentException("${this.javaClass.simpleName} can't be appended") + } + + arg.argTree.addAll(this.argTree) + arg.argTree.add(this) + return arg + } + + /** + * Used for printing argument help + */ + override fun toString(): String { + return "<$name:${typeName}>" + } + +} diff --git a/src/main/kotlin/com/lambda/client/command/args/ArgIdentifier.kt b/src/main/kotlin/com/lambda/client/command/args/ArgIdentifier.kt new file mode 100644 index 000000000..d0bce3a66 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/args/ArgIdentifier.kt @@ -0,0 +1,9 @@ +package com.lambda.client.command.args + +import com.lambda.client.commons.interfaces.Nameable + +/** + * The ID for an argument + */ +@Suppress("UNUSED") +data class ArgIdentifier(override val name: String) : Nameable diff --git a/src/main/kotlin/com/lambda/client/command/args/Args.kt b/src/main/kotlin/com/lambda/client/command/args/Args.kt new file mode 100644 index 000000000..e7d5a148f --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/args/Args.kt @@ -0,0 +1,186 @@ +package com.lambda.client.command.args + +import com.lambda.client.commons.interfaces.Alias +import com.lambda.client.commons.interfaces.DisplayEnum + +/** + * Argument that takes a [Boolean] as input + * + * @param name Name of this argument + */ +class BooleanArg( + override val name: String +) : AbstractArg() { + + override suspend fun convertToType(string: String?): Boolean? { + return string.toTrueOrNull() ?: string.toFalseOrNull() + } + + private fun String?.toTrueOrNull() = + if (this != null && (this.equals("true", true) || this.equals("on", true))) true + else null + + private fun String?.toFalseOrNull() = + if (this != null && (this.equals("false", true) || this.equals("off", true))) false + else null + +} + +/** + * Argument that takes a [Enum] as input + * + * @param E Type of input [Enum] + * @param name Name of this argument + * @param enumClass Class of [E] + */ +class EnumArg>( + override val name: String, + enumClass: Class +) : AbstractArg(), AutoComplete by StaticPrefixMatch(getAllNames(enumClass)) { + + private val enumValues = enumClass.enumConstants + + override suspend fun convertToType(string: String?): E? { + return enumValues.find { it.name.equals(string, true) } + } + + private companion object { + private fun > getAllNames(clazz: Class) = ArrayList().apply { + for (enum in clazz.enumConstants) { + if (enum is DisplayEnum) add(enum.displayName) + add(enum.name) + } + } + } +} + +/** + * Argument that takes a [Int] as input + * + * @param name Name of this argument + */ +class IntArg( + override val name: String +) : AbstractArg() { + + override suspend fun convertToType(string: String?): Int? { + return string?.toIntOrNull() + } + +} + +/** + * Argument that takes a [Short] as input + * + * @param name Name of this argument + */ +class ShortArg( + override val name: String +) : AbstractArg() { + + override suspend fun convertToType(string: String?): Short? { + return string?.toShortOrNull() + } + +} + +/** + * Argument that takes a [Long] as input + * + * @param name Name of this argument + */ +class LongArg( + override val name: String +) : AbstractArg() { + + override suspend fun convertToType(string: String?): Long? { + return string?.toLongOrNull() + } + +} + +/** + * Argument that takes a [Float] as input + * + * @param name Name of this argument + */ +class FloatArg( + override val name: String +) : AbstractArg() { + + override suspend fun convertToType(string: String?): Float? { + return string?.toFloatOrNull() + } + +} + +/** + * Argument that takes a [Double] as input + * + * @param name Name of this argument + */ +class DoubleArg( + override val name: String +) : AbstractArg() { + + override suspend fun convertToType(string: String?): Double? { + return string?.toDoubleOrNull() + } + +} + +/** + * Argument that takes a [String] as input, and must be + * matched with [name] or one of the [alias] + * + * @param name Name of this argument + * @param alias Alias of this literal argument + */ +open class LiteralArg( + override val name: String, + override val alias: Array, +) : AbstractArg(), Alias, AutoComplete by StaticPrefixMatch(listOf(name, *alias)) { + + override suspend fun convertToType(string: String?): String? { + return if (string.equals(name, true) || alias.any { string.equals(it, false) }) { + string + } else { + null + } + } + + override fun toString(): String { + return "[$name]" + } + +} + +/** + * Argument that takes a [String] as input + * + * @param name Name of this argument + */ +class StringArg( + override val name: String +) : AbstractArg() { + + override suspend fun convertToType(string: String?): String? { + return string + } + +} + +/** + * Argument that takes all [String] after as input + * + * @param name Name of this argument + */ +class GreedyStringArg( + override val name: String +) : AbstractArg() { + + override suspend fun convertToType(string: String?): String? { + return string + } + +} diff --git a/src/main/kotlin/com/lambda/client/command/args/AutoComplete.kt b/src/main/kotlin/com/lambda/client/command/args/AutoComplete.kt new file mode 100644 index 000000000..734d0e112 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/args/AutoComplete.kt @@ -0,0 +1,26 @@ +package com.lambda.client.command.args + +interface AutoComplete { + fun completeForInput(string: String): String? +} + +class DynamicPrefixMatch( + private val matchList: () -> Collection? +) : AutoComplete { + override fun completeForInput(string: String): String? { + if (string.isBlank()) return null + val list = matchList() ?: return null + + return list.find { it.startsWith(string, true) } + } +} + +class StaticPrefixMatch( + private val matchList: Collection +) : AutoComplete { + override fun completeForInput(string: String): String? { + if (string.isBlank()) return null + + return matchList.find { it.startsWith(string, true) } + } +} diff --git a/src/main/kotlin/com/lambda/client/command/args/FinalArg.kt b/src/main/kotlin/com/lambda/client/command/args/FinalArg.kt new file mode 100644 index 000000000..cdf009f67 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/args/FinalArg.kt @@ -0,0 +1,93 @@ +package com.lambda.client.command.args + +import com.lambda.client.command.execute.ExecuteOption +import com.lambda.client.command.execute.IExecuteEvent +import com.lambda.client.command.utils.ExecuteBlock +import com.lambda.client.command.utils.Invokable + +/** + * An argument that take no input and has a [ExecuteBlock] + * + * @param description (Optional) Description for this argument combination + * @param options (Optional) [ExecuteOption] used to check before invoking [block] + * @param block [ExecuteBlock] to run on invoking + */ +class FinalArg( + private val description: String, + private val options: Array>, + private val block: ExecuteBlock +) : AbstractArg(), Invokable { + + override val name: String + get() = argTree.joinToString(".") + + override suspend fun convertToType(string: String?): Unit? { + return if (string == null) Unit + else null + } + + /** + * Check if [argsIn] matches with all arguments in [argTree] + * + * @return True if all matched + */ + suspend fun checkArgs(argsIn: Array): Boolean { + val lastArgType = argTree.last() + + if (argsIn.size != argTree.size + && !(argsIn.size - 1 == argTree.size && argsIn.last().isBlank()) + && !(argsIn.size > argTree.size && lastArgType is GreedyStringArg) + ) return false + + return countArgs(argsIn) == argTree.size + } + + /** + * Count matched arguments in [argsIn] + * + * @return Number of matched arguments + */ + suspend fun countArgs(argsIn: Array): Int { + var matched = 0 + + for ((index, argType) in argTree.withIndex()) { + val success = if (argType is GreedyStringArg) { + matched++ + break + } else { + argType.checkType(argsIn.getOrNull(index)) + } + + if (success) matched++ + else break + } + + return matched + } + + /** + * Maps arguments in the [event] and invoke the [block] if passed all the [options] + */ + override suspend fun invoke(event: E) { + event.mapArgs(argTree) + + for (option in options) { + if (!option.canExecute(event)) { + option.onFailed(event) + return + } + } + + block.invoke(event) + } + + override fun toString(): String { + return if (description.isNotBlank()) "- $description" else "" + } + + fun printArgHelp(): String { + return (argTree.first().name + + argTree.subList(1, argTree.size).joinToString(" ", " ")).trimEnd() + } + +} diff --git a/src/main/kotlin/com/lambda/client/command/commands/ConfigCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/ConfigCommand.kt index e992662c3..c1d129c66 100644 --- a/src/main/kotlin/com/lambda/client/command/commands/ConfigCommand.kt +++ b/src/main/kotlin/com/lambda/client/command/commands/ConfigCommand.kt @@ -9,7 +9,7 @@ import com.lambda.client.util.TimeUnit import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.formatValue import com.lambda.client.util.threads.defaultScope -import com.lambda.command.execute.IExecuteEvent +import com.lambda.client.command.execute.IExecuteEvent import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/src/main/kotlin/com/lambda/client/command/commands/CreditsCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/CreditsCommand.kt index 7d84c5661..3d3565ca7 100644 --- a/src/main/kotlin/com/lambda/client/command/commands/CreditsCommand.kt +++ b/src/main/kotlin/com/lambda/client/command/commands/CreditsCommand.kt @@ -6,7 +6,7 @@ import com.lambda.client.LambdaMod import com.lambda.client.command.ClientCommand import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.formatValue -import com.lambda.commons.utils.ConnectionUtils +import com.lambda.client.commons.utils.ConnectionUtils object CreditsCommand : ClientCommand( name = "credits", diff --git a/src/main/kotlin/com/lambda/client/command/commands/EntityStatsCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/EntityStatsCommand.kt index c4a0893a4..515547553 100644 --- a/src/main/kotlin/com/lambda/client/command/commands/EntityStatsCommand.kt +++ b/src/main/kotlin/com/lambda/client/command/commands/EntityStatsCommand.kt @@ -3,7 +3,7 @@ package com.lambda.client.command.commands import com.lambda.client.command.ClientCommand import com.lambda.client.manager.managers.UUIDManager import com.lambda.client.util.text.MessageSendHelper -import com.lambda.commons.utils.MathUtils +import com.lambda.client.commons.utils.MathUtils import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.passive.AbstractHorse import kotlin.math.pow diff --git a/src/main/kotlin/com/lambda/client/command/commands/NBTCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/NBTCommand.kt index 760fea599..79755d07b 100644 --- a/src/main/kotlin/com/lambda/client/command/commands/NBTCommand.kt +++ b/src/main/kotlin/com/lambda/client/command/commands/NBTCommand.kt @@ -4,7 +4,7 @@ import com.lambda.client.command.ClientCommand import com.lambda.client.event.SafeExecuteEvent import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.formatValue -import com.lambda.commons.utils.SystemUtils +import com.lambda.client.commons.utils.SystemUtils import net.minecraft.item.ItemStack import net.minecraft.nbt.JsonToNBT import net.minecraft.nbt.NBTTagCompound diff --git a/src/main/kotlin/com/lambda/client/command/commands/SignBookCommand.kt b/src/main/kotlin/com/lambda/client/command/commands/SignBookCommand.kt index 298d7d9cb..e24bfbffd 100644 --- a/src/main/kotlin/com/lambda/client/command/commands/SignBookCommand.kt +++ b/src/main/kotlin/com/lambda/client/command/commands/SignBookCommand.kt @@ -5,7 +5,7 @@ import com.lambda.client.util.items.itemPayload import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.MessageSendHelper.sendChatMessage import com.lambda.client.util.text.formatValue -import com.lambda.commons.extension.max +import com.lambda.client.commons.extension.max import net.minecraft.item.ItemWritableBook import net.minecraft.nbt.NBTTagList import net.minecraft.nbt.NBTTagString diff --git a/src/main/kotlin/com/lambda/client/command/execute/ExecuteEvent.kt b/src/main/kotlin/com/lambda/client/command/execute/ExecuteEvent.kt new file mode 100644 index 000000000..5e9f96478 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/execute/ExecuteEvent.kt @@ -0,0 +1,40 @@ +package com.lambda.client.command.execute + +import com.lambda.client.command.AbstractCommandManager +import com.lambda.client.command.args.AbstractArg +import com.lambda.client.command.args.ArgIdentifier +import com.lambda.client.command.args.GreedyStringArg + +/** + * Default implementation of [IExecuteEvent] + */ +open class ExecuteEvent( + override val commandManager: AbstractCommandManager<*>, + override val args: Array +) : IExecuteEvent { + + /** + * Mapping [ArgIdentifier] to their converted arguments + */ + private val mappedArgs = HashMap, Any>() + + override suspend fun mapArgs(argTree: List>) { + for ((index, arg) in argTree.withIndex()) { + if (arg is GreedyStringArg) { + arg.convertToType(args.slice(index until args.size).joinToString(" "))?.let { + mappedArgs[arg.identifier] = it + } + break + } else { + arg.convertToType(args.getOrNull(index))?.let { + mappedArgs[arg.identifier] = it + } + } + } + } + + @Suppress("UNCHECKED_CAST") + override val ArgIdentifier.value: T + get() = mappedArgs[this] as T + +} diff --git a/src/main/kotlin/com/lambda/client/command/execute/ExecuteOption.kt b/src/main/kotlin/com/lambda/client/command/execute/ExecuteOption.kt new file mode 100644 index 000000000..841b837f6 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/execute/ExecuteOption.kt @@ -0,0 +1,34 @@ +package com.lambda.client.command.execute + +import com.lambda.client.command.args.FinalArg + +/** + * Used to check if a [FinalArg] can be invoke with an [IExecuteEvent]. + * The default behavior is all [ExecuteOption]'s [canExecute] must returns true. + * + * @param E Type of [IExecuteEvent] + */ +interface ExecuteOption { + /** + * A predicate to check if the [event] can be used to invoke a [FinalArg] + */ + suspend fun canExecute(event: E): Boolean + + /** + * Action to perform if [canExecute] returns false + */ + suspend fun onFailed(event: E) +} + +/** + * A wrapper for allowing `or` operation check on multiple [ExecuteOption] + */ +class AnyOption(private vararg val options: ExecuteOption) : ExecuteOption { + override suspend fun canExecute(event: E): Boolean { + return options.any { it.canExecute(event) } + } + + override suspend fun onFailed(event: E) { + options.last().onFailed(event) + } +} diff --git a/src/main/kotlin/com/lambda/client/command/execute/IExecuteEvent.kt b/src/main/kotlin/com/lambda/client/command/execute/IExecuteEvent.kt new file mode 100644 index 000000000..5fab6d5ff --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/execute/IExecuteEvent.kt @@ -0,0 +1,32 @@ +package com.lambda.client.command.execute + +import com.lambda.client.command.AbstractCommandManager +import com.lambda.client.command.Command +import com.lambda.client.command.args.AbstractArg +import com.lambda.client.command.args.ArgIdentifier + +/** + * Event being used for executing the [Command] + */ +interface IExecuteEvent { + + val commandManager: AbstractCommandManager<*> + + /** + * Parsed arguments + */ + val args: Array + + /** + * Maps argument for the [argTree] + */ + suspend fun mapArgs(argTree: List>) + + /** + * Gets mapped value for an [ArgIdentifier] + * + * @throws NullPointerException If this [ArgIdentifier] isn't mapped + */ + val ArgIdentifier.value: T + +} diff --git a/src/main/kotlin/com/lambda/client/command/utils/BlockTypeAlias.kt b/src/main/kotlin/com/lambda/client/command/utils/BlockTypeAlias.kt new file mode 100644 index 000000000..652c3aa24 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/utils/BlockTypeAlias.kt @@ -0,0 +1,24 @@ +package com.lambda.client.command.utils + +import com.lambda.client.command.CommandBuilder +import com.lambda.client.command.args.AbstractArg +import com.lambda.client.command.args.ArgIdentifier +import com.lambda.client.command.execute.IExecuteEvent + +/** + * Type alias for a block used for execution of a argument combination + * + * @param E Type of [IExecuteEvent], can be itself or its subtype + * + * @see CommandBuilder.execute + */ +typealias ExecuteBlock = suspend E.() -> Unit + +/** + * Type alias for a block used for Argument building + * + * @param T Type of argument + * + * @see CommandBuilder + */ +typealias BuilderBlock = AbstractArg.(ArgIdentifier) -> Unit diff --git a/src/main/kotlin/com/lambda/client/command/utils/Exceptions.kt b/src/main/kotlin/com/lambda/client/command/utils/Exceptions.kt new file mode 100644 index 000000000..f11f17446 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/utils/Exceptions.kt @@ -0,0 +1,20 @@ +package com.lambda.client.command.utils + +import com.lambda.client.command.AbstractCommandManager +import com.lambda.client.command.Command + +/** + * Exception throws when no command is found in a [AbstractCommandManager] + * + * @see AbstractCommandManager.getCommand + */ +class CommandNotFoundException(val command: String?) : + Exception("Command not found: '$command'.") + +/** + * Exception throws when no subcommand is found for a [Command] + * + * @see Command.invoke + */ +class SubCommandNotFoundException(args: Array, val command: Command<*>) : + Exception("No matching sub command found for args: \"${args.sliceArray(1 until args.size).joinToString(" ")}\".") diff --git a/src/main/kotlin/com/lambda/client/command/utils/Invokable.kt b/src/main/kotlin/com/lambda/client/command/utils/Invokable.kt new file mode 100644 index 000000000..a63b5a3cb --- /dev/null +++ b/src/main/kotlin/com/lambda/client/command/utils/Invokable.kt @@ -0,0 +1,17 @@ +package com.lambda.client.command.utils + +import com.lambda.client.command.execute.IExecuteEvent + +/** + * Interface for class that can be invoked with an [IExecuteEvent] + * + * @param E Type of [IExecuteEvent], can be itself or its subtype + */ +interface Invokable { + + /** + * Invoke this with [event] + */ + suspend fun invoke(event: E) + +} diff --git a/src/main/kotlin/com/lambda/client/commons/collections/AliasSet.kt b/src/main/kotlin/com/lambda/client/commons/collections/AliasSet.kt new file mode 100644 index 000000000..1178a2914 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/commons/collections/AliasSet.kt @@ -0,0 +1,28 @@ +package com.lambda.client.commons.collections + +import com.lambda.client.commons.interfaces.Alias +import java.util.concurrent.ConcurrentHashMap + +class AliasSet( + map: MutableMap = ConcurrentHashMap() +) : NameableSet(map) { + + override fun add(element: T): Boolean { + var modified = super.add(element) + element.alias.forEach { alias -> + val prevValue = map.put(alias.lowercase(), element) + prevValue?.let { remove(it) } + modified = prevValue == null || modified + } + return modified + } + + override fun remove(element: T): Boolean { + var modified = super.remove(element) + element.alias.forEach { + modified = map.remove(it.lowercase()) != null || modified + } + return modified + } + +} diff --git a/src/main/kotlin/com/lambda/client/commons/collections/CloseableList.kt b/src/main/kotlin/com/lambda/client/commons/collections/CloseableList.kt new file mode 100644 index 000000000..0e6cea8ea --- /dev/null +++ b/src/main/kotlin/com/lambda/client/commons/collections/CloseableList.kt @@ -0,0 +1,53 @@ +package com.lambda.client.commons.collections + +class CloseableList( + val list: MutableList = ArrayList() +) : MutableList by list { + + private var closed = false + + fun close() { + closed = true + } + + override fun add(element: E) = + if (closed) throw IllegalAccessException("This list is immutable!") + else list.add(element) + + override fun add(index: Int, element: E) = + if (closed) throw IllegalAccessException("This list is immutable!") + else list.add(index, element) + + override fun addAll(index: Int, elements: Collection) = + if (closed) throw IllegalAccessException("This list is immutable!") + else list.addAll(index, elements) + + override fun addAll(elements: Collection) = + if (closed) throw IllegalAccessException("This list is immutable!") + else list.addAll(elements) + + override fun clear() = + if (closed) throw IllegalAccessException("This list is immutable!") + else list.clear() + + override fun remove(element: E) = + if (closed) throw IllegalAccessException("This list is immutable!") + else list.remove(element) + + override fun removeAll(elements: Collection) = + if (closed) throw IllegalAccessException("This list is immutable!") + else list.removeAll(elements) + + override fun removeAt(index: Int): E = + if (closed) throw IllegalAccessException("This list is immutable!") + else list.removeAt(index) + + override fun retainAll(elements: Collection) = + if (closed) throw IllegalAccessException("This list is immutable!") + else list.retainAll(elements) + + override fun set(index: Int, element: E): E = + if (closed) throw IllegalAccessException("This list is immutable!") + else list.set(index, element) + +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/commons/collections/NameableSet.kt b/src/main/kotlin/com/lambda/client/commons/collections/NameableSet.kt new file mode 100644 index 000000000..a58678830 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/commons/collections/NameableSet.kt @@ -0,0 +1,56 @@ +package com.lambda.client.commons.collections + +import com.lambda.client.commons.interfaces.Nameable +import java.util.concurrent.ConcurrentHashMap + +open class NameableSet( + protected val map: MutableMap = ConcurrentHashMap() +) : AbstractMutableSet() { + + override val size get() = map.size + + fun containsName(name: String): Boolean = map.containsKey(name.lowercase()) + + fun containsNames(names: Iterable): Boolean = names.all { containsName(it) } + + fun containsNames(names: Array): Boolean = names.all { containsName(it) } + + override fun contains(element: T): Boolean { + return map.containsKey(element.name.lowercase()) + } + + override fun containsAll(elements: Collection): Boolean { + return elements.all { contains(it) } + } + + override fun iterator() = map.values.iterator() + + operator fun get(name: String) = map[name.lowercase()] + + fun getOrPut(name: String, value: () -> T) = get(name) ?: value().also { add(it) } + + override fun add(element: T) = map.put(element.name.lowercase(), element) == null + + override fun addAll(elements: Collection): Boolean { + var modified = false + elements.forEach { + modified = add(it) || modified + } + return modified + } + + override fun remove(element: T) = map.remove(element.name.lowercase()) != null + + override fun removeAll(elements: Collection): Boolean { + var modified = false + elements.forEach { + modified = remove(it) || modified + } + return modified + } + + override fun clear() { + map.clear() + } + +} diff --git a/src/main/kotlin/com/lambda/client/commons/extension/Any.kt b/src/main/kotlin/com/lambda/client/commons/extension/Any.kt new file mode 100644 index 000000000..e6c8e8df2 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/commons/extension/Any.kt @@ -0,0 +1,7 @@ +package com.lambda.client.commons.extension + +inline fun Any?.ifType(block: (T) -> Unit) { + if (this is T) block(this) +} + + diff --git a/src/main/kotlin/com/lambda/client/commons/extension/Collection.kt b/src/main/kotlin/com/lambda/client/commons/extension/Collection.kt new file mode 100644 index 000000000..da8dbdb6b --- /dev/null +++ b/src/main/kotlin/com/lambda/client/commons/extension/Collection.kt @@ -0,0 +1,33 @@ +package com.lambda.client.commons.extension + +import java.util.* + +fun MutableCollection.add(e: E?) { + if (e != null) this.add(e) +} + +/** + * Returns the sum of all values produced by [selector] function applied to each element in the collection. + */ +inline fun Iterable.sumByFloat(selector: (T) -> Float): Float { + var sum = 0.0f + for (element in this) { + sum += selector(element) + } + return sum +} + +fun MutableCollection.synchronized(): MutableCollection = + Collections.synchronizedCollection(this) + +fun MutableList.synchronized(): MutableList = + Collections.synchronizedList(this) + +fun MutableSet.synchronized(): MutableSet = + Collections.synchronizedSet(this) + +fun SortedSet.synchronized(): SortedSet = + Collections.synchronizedSortedSet(this) + +fun NavigableSet.synchronized(): NavigableSet = + Collections.synchronizedNavigableSet(this) \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/commons/extension/Enum.kt b/src/main/kotlin/com/lambda/client/commons/extension/Enum.kt new file mode 100644 index 000000000..31f9811da --- /dev/null +++ b/src/main/kotlin/com/lambda/client/commons/extension/Enum.kt @@ -0,0 +1,10 @@ +package com.lambda.client.commons.extension + +import com.lambda.client.commons.interfaces.DisplayEnum + +fun > E.next(): E = declaringClass.enumConstants.run { + get((ordinal + 1) % size) +} + +fun Enum<*>.readableName() = (this as? DisplayEnum)?.displayName + ?: name.mapEach('_') { low -> low.lowercase().replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() } }.joinToString(" ") \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/commons/extension/Map.kt b/src/main/kotlin/com/lambda/client/commons/extension/Map.kt new file mode 100644 index 000000000..d9e8148a1 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/commons/extension/Map.kt @@ -0,0 +1,25 @@ +package com.lambda.client.commons.extension + +import java.util.* + + +fun SortedMap.firstKeyOrNull(): K? = + if (this.isNotEmpty()) firstKey() else null + +fun NavigableMap.firstValueOrNull(): V? = + this.firstEntryOrNull()?.value + +fun NavigableMap.firstValue(): V = + this.firstEntry().value + +fun NavigableMap.firstEntryOrNull(): MutableMap.MutableEntry? = + if (this.isNotEmpty()) firstEntry() else null + +fun MutableMap.synchronized(): MutableMap = + Collections.synchronizedMap(this) + +fun SortedMap.synchronized(): SortedMap = + Collections.synchronizedSortedMap(this) + +fun NavigableMap.synchronized(): NavigableMap = + Collections.synchronizedNavigableMap(this) \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/commons/extension/Math.kt b/src/main/kotlin/com/lambda/client/commons/extension/Math.kt new file mode 100644 index 000000000..c72aa51ef --- /dev/null +++ b/src/main/kotlin/com/lambda/client/commons/extension/Math.kt @@ -0,0 +1,23 @@ +package com.lambda.client.commons.extension + +import kotlin.math.PI +import kotlin.math.ceil +import kotlin.math.floor + +const val PI_FLOAT = 3.14159265358979323846f + +fun Double.floorToInt() = floor(this).toInt() + +fun Float.floorToInt() = floor(this).toInt() + +fun Double.ceilToInt() = ceil(this).toInt() + +fun Float.ceilToInt() = ceil(this).toInt() + +fun Float.toRadian() = this / 180.0f * PI_FLOAT + +fun Double.toRadian() = this / 180.0 * PI + +fun Float.toDegree() = this * 180.0f / PI_FLOAT + +fun Double.toDegree() = this * 180.0 / PI \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/commons/extension/String.kt b/src/main/kotlin/com/lambda/client/commons/extension/String.kt new file mode 100644 index 000000000..ecbcde67d --- /dev/null +++ b/src/main/kotlin/com/lambda/client/commons/extension/String.kt @@ -0,0 +1,26 @@ +package com.lambda.client.commons.extension + +/** + * Limit the length of this string to [max] + */ +fun String.max(max: Int) = this.substring(0, this.length.coerceAtMost(max)) + +/** + * Limit the length to this string [max] with [suffix] appended + */ +fun String.max(max: Int, suffix: String): String { + return if (this.length > max) { + this.max(max - suffix.length) + suffix + } else { + this.max(max) + } +} + +fun String.surroundedBy(prefix: CharSequence, suffix: CharSequence, ignoreCase: Boolean = false) = + this.startsWith(prefix, ignoreCase) && this.endsWith(suffix, ignoreCase) + +fun String.surroundedBy(prefix: Char, suffix: Char, ignoreCase: Boolean = false) = + this.startsWith(prefix, ignoreCase) && this.endsWith(suffix, ignoreCase) + +fun String.mapEach(vararg delimiters: Char, transformer: (String) -> String) = + split(*delimiters).map(transformer) \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/commons/interfaces/Alias.kt b/src/main/kotlin/com/lambda/client/commons/interfaces/Alias.kt new file mode 100644 index 000000000..7bfe967e2 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/commons/interfaces/Alias.kt @@ -0,0 +1,5 @@ +package com.lambda.client.commons.interfaces + +interface Alias : Nameable { + val alias: Array +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/commons/interfaces/DisplayEnum.kt b/src/main/kotlin/com/lambda/client/commons/interfaces/DisplayEnum.kt new file mode 100644 index 000000000..8769032ac --- /dev/null +++ b/src/main/kotlin/com/lambda/client/commons/interfaces/DisplayEnum.kt @@ -0,0 +1,5 @@ +package com.lambda.client.commons.interfaces + +interface DisplayEnum { + val displayName: String +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/commons/interfaces/Nameable.kt b/src/main/kotlin/com/lambda/client/commons/interfaces/Nameable.kt new file mode 100644 index 000000000..8724487de --- /dev/null +++ b/src/main/kotlin/com/lambda/client/commons/interfaces/Nameable.kt @@ -0,0 +1,5 @@ +package com.lambda.client.commons.interfaces + +interface Nameable { + val name: String +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/commons/utils/ClassUtils.kt b/src/main/kotlin/com/lambda/client/commons/utils/ClassUtils.kt new file mode 100644 index 000000000..60b6b5aa1 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/commons/utils/ClassUtils.kt @@ -0,0 +1,28 @@ +package com.lambda.client.commons.utils + +import org.reflections.Reflections + +object ClassUtils { + + inline fun findClasses( + pack: String, + noinline block: Sequence>.() -> Sequence> = { this } + ): List> { + return findClasses(pack, T::class.java, block) + } + + fun findClasses( + pack: String, + subType: Class, + block: Sequence>.() -> Sequence> = { this } + ): List> { + return Reflections(pack).getSubTypesOf(subType).asSequence() + .run(block) + .sortedBy { it.simpleName } + .toList() + } + + @Suppress("UNCHECKED_CAST") + val Class.instance + get() = this.getDeclaredField("INSTANCE")[null] as T +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/commons/utils/ConnectionUtils.kt b/src/main/kotlin/com/lambda/client/commons/utils/ConnectionUtils.kt new file mode 100644 index 000000000..b72478aa8 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/commons/utils/ConnectionUtils.kt @@ -0,0 +1,33 @@ +package com.lambda.client.commons.utils + +import com.lambda.client.module.modules.client.Plugins +import java.net.URL +import javax.net.ssl.HttpsURLConnection + +object ConnectionUtils { + + fun requestRawJsonFrom(url: String, catch: (Exception) -> Unit = { it.printStackTrace() }): String? { + return runConnection(url, { connection -> + connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8") + if (Plugins.token.isNotBlank()) connection.setRequestProperty("Authorization", "token ${Plugins.token}") + connection.requestMethod = "GET" + connection.inputStream.readBytes().toString(Charsets.UTF_8) + }, catch) + } + + fun runConnection(url: String, block: (HttpsURLConnection) -> T?, catch: (Exception) -> Unit = { it.printStackTrace() }): T? { + (URL(url).openConnection() as HttpsURLConnection).run { + return try { + doOutput = true + doInput = true + block(this) + } catch (e: Exception) { + catch(e) + null + } finally { + disconnect() + } + } + } + +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/commons/utils/MathUtils.kt b/src/main/kotlin/com/lambda/client/commons/utils/MathUtils.kt new file mode 100644 index 000000000..b5826d5f5 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/commons/utils/MathUtils.kt @@ -0,0 +1,61 @@ +package com.lambda.client.commons.utils + +import kotlin.math.max +import kotlin.math.min +import kotlin.math.pow +import kotlin.math.round + +object MathUtils { + + fun ceilToPOT(valueIn: Int): Int { + // Magical bit shifting + var i = valueIn + i-- + i = i or (i shr 1) + i = i or (i shr 2) + i = i or (i shr 4) + i = i or (i shr 8) + i = i or (i shr 16) + i++ + return i + } + + fun round(value: Float, places: Int): Double { + val scale = 10.0.pow(places.toDouble()) + return round(value * scale) / scale + } + + fun round(value: Double, places: Int): Double { + val scale = 10.0.pow(places.toDouble()) + return round(value * scale) / scale + } + + fun decimalPlaces(value: Double) = value.toString().split('.').getOrElse(1) { "0" }.length + + fun decimalPlaces(value: Float) = value.toString().split('.').getOrElse(1) { "0" }.length + + fun isNumberEven(i: Int): Boolean { + return i and 1 == 0 + } + + fun reverseNumber(num: Int, min: Int, max: Int): Int { + return max + min - num + } + + fun convertRange(valueIn: Int, minIn: Int, maxIn: Int, minOut: Int, maxOut: Int): Int { + return convertRange(valueIn.toDouble(), minIn.toDouble(), maxIn.toDouble(), minOut.toDouble(), maxOut.toDouble()).toInt() + } + + fun convertRange(valueIn: Float, minIn: Float, maxIn: Float, minOut: Float, maxOut: Float): Float { + return convertRange(valueIn.toDouble(), minIn.toDouble(), maxIn.toDouble(), minOut.toDouble(), maxOut.toDouble()).toFloat() + } + + fun convertRange(valueIn: Double, minIn: Double, maxIn: Double, minOut: Double, maxOut: Double): Double { + val rangeIn = maxIn - minIn + val rangeOut = maxOut - minOut + val convertedIn = (valueIn - minIn) * (rangeOut / rangeIn) + minOut + val actualMin = min(minOut, maxOut) + val actualMax = max(minOut, maxOut) + return min(max(convertedIn, actualMin), actualMax) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/commons/utils/StringUtils.kt b/src/main/kotlin/com/lambda/client/commons/utils/StringUtils.kt new file mode 100644 index 000000000..f39d6e114 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/commons/utils/StringUtils.kt @@ -0,0 +1,12 @@ +package com.lambda.client.commons.utils + +inline fun buildString(block: StringBuilder.() -> Unit) = + StringBuilder().apply(block).toString() + +fun grammar(amount: Int, singular: String, plural: String): String { + return if (amount == 1) { + "$amount $singular" + } else { + "$amount $plural" + } +} diff --git a/src/main/kotlin/com/lambda/client/commons/utils/SystemUtils.kt b/src/main/kotlin/com/lambda/client/commons/utils/SystemUtils.kt new file mode 100644 index 000000000..af77af79a --- /dev/null +++ b/src/main/kotlin/com/lambda/client/commons/utils/SystemUtils.kt @@ -0,0 +1,25 @@ +package com.lambda.client.commons.utils + +import java.awt.Toolkit +import java.awt.datatransfer.Clipboard +import java.awt.datatransfer.DataFlavor +import java.awt.datatransfer.StringSelection + +object SystemUtils { + + fun setClipboard(text: String) { + val selection = StringSelection(text) + val clipboard: Clipboard = Toolkit.getDefaultToolkit().systemClipboard + clipboard.setContents(selection, null) + } + + fun getClipboard(): String? { + val clipboard: Clipboard = Toolkit.getDefaultToolkit().systemClipboard + return try { + clipboard.getData(DataFlavor.stringFlavor)?.toString() + } catch (e: Exception) { + null + } + } + +} diff --git a/src/main/kotlin/com/lambda/client/event/ClientEvents.kt b/src/main/kotlin/com/lambda/client/event/ClientEvents.kt index 0501e8899..6ce72ed54 100644 --- a/src/main/kotlin/com/lambda/client/event/ClientEvents.kt +++ b/src/main/kotlin/com/lambda/client/event/ClientEvents.kt @@ -2,8 +2,8 @@ package com.lambda.client.event import com.lambda.client.command.CommandManager import com.lambda.client.util.Wrapper -import com.lambda.command.execute.ExecuteEvent -import com.lambda.command.execute.IExecuteEvent +import com.lambda.client.command.execute.ExecuteEvent +import com.lambda.client.command.execute.IExecuteEvent import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.client.multiplayer.PlayerControllerMP import net.minecraft.client.multiplayer.WorldClient diff --git a/src/main/kotlin/com/lambda/client/event/LambdaEventBus.kt b/src/main/kotlin/com/lambda/client/event/LambdaEventBus.kt index 0f807d1fc..14c8285f6 100644 --- a/src/main/kotlin/com/lambda/client/event/LambdaEventBus.kt +++ b/src/main/kotlin/com/lambda/client/event/LambdaEventBus.kt @@ -1,9 +1,9 @@ package com.lambda.client.event import com.lambda.client.util.Wrapper -import com.lambda.event.eventbus.AbstractAsyncEventBus -import com.lambda.event.listener.AsyncListener -import com.lambda.event.listener.Listener +import com.lambda.client.event.eventbus.AbstractAsyncEventBus +import com.lambda.client.event.listener.AsyncListener +import com.lambda.client.event.listener.Listener import io.netty.util.internal.ConcurrentSet import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/src/main/kotlin/com/lambda/client/event/LambdaEvents.kt b/src/main/kotlin/com/lambda/client/event/LambdaEvents.kt index 500b8656a..c9bea9e67 100644 --- a/src/main/kotlin/com/lambda/client/event/LambdaEvents.kt +++ b/src/main/kotlin/com/lambda/client/event/LambdaEvents.kt @@ -1,7 +1,7 @@ package com.lambda.client.event -import com.lambda.commons.interfaces.DisplayEnum -import com.lambda.event.eventbus.IEventBus +import com.lambda.client.commons.interfaces.DisplayEnum +import com.lambda.client.event.eventbus.IEventBus interface Event diff --git a/src/main/kotlin/com/lambda/client/event/ListenerManager.kt b/src/main/kotlin/com/lambda/client/event/ListenerManager.kt new file mode 100644 index 000000000..4ef7a8ba4 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/event/ListenerManager.kt @@ -0,0 +1,63 @@ +package com.lambda.client.event + +import com.lambda.client.event.listener.AsyncListener +import com.lambda.client.event.listener.Listener +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.CopyOnWriteArrayList + +/** + * Used for storing the map of objects and their listeners + */ +object ListenerManager { + + private val listenerMap = ConcurrentHashMap>>() + + private val asyncListenerMap = ConcurrentHashMap>>() + + /** + * Register the [listener] to the [ListenerManager] + * + * @param obj object of the [listener] belongs to + * @param listener listener to register + */ + fun register(obj: Any, listener: Listener<*>) { + listenerMap.getOrPut(obj, ::CopyOnWriteArrayList).add(listener) + } + + /** + * Register the [asyncListener] to the [ListenerManager] + * + * @param obj object of the [asyncListener] belongs to + * @param asyncListener async listener to register + */ + fun register(obj: Any, asyncListener: AsyncListener<*>) { + asyncListenerMap.getOrPut(obj, ::CopyOnWriteArrayList).add(asyncListener) + } + + /** + * Unregister all listeners of this object, this can not be undone + */ + fun unregister(obj: Any) { + listenerMap.remove(obj) + asyncListenerMap.remove(obj) + } + + /** + * Get all registered listeners of this [obj] + * + * @param obj object to get listeners + * + * @return registered listeners of [obj] + */ + fun getListeners(obj: Any): List>? = listenerMap[obj] + + /** + * Get all registered async listeners of this [obj] + * + * @param obj object to get async listeners + * + * @return registered async listeners of [obj] + */ + fun getAsyncListeners(obj: Any): List>? = asyncListenerMap[obj] + +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/event/eventbus/AbstractAsyncEventBus.kt b/src/main/kotlin/com/lambda/client/event/eventbus/AbstractAsyncEventBus.kt new file mode 100644 index 000000000..358950f68 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/event/eventbus/AbstractAsyncEventBus.kt @@ -0,0 +1,25 @@ +package com.lambda.client.event.eventbus + +import com.lambda.client.event.ListenerManager + +/** + * [IAsyncEventBus] with some basic implementation + * Must be used with Kotlinx Coroutine and overridden [post] method + */ +abstract class AbstractAsyncEventBus : AbstractEventBus(), IAsyncEventBus { + override fun subscribe(objs: Any) { + super.subscribe(objs) + + ListenerManager.getAsyncListeners(objs)?.forEach { + subscribedListenersAsync.getOrPut(it.eventClass, ::newSetAsync).add(it) + } + } + + override fun unsubscribe(objs: Any) { + super.unsubscribe(objs) + + ListenerManager.getAsyncListeners(objs)?.forEach { + subscribedListenersAsync[it.eventClass]?.remove(it) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/event/eventbus/AbstractEventBus.kt b/src/main/kotlin/com/lambda/client/event/eventbus/AbstractEventBus.kt new file mode 100644 index 000000000..3f0b1c1dc --- /dev/null +++ b/src/main/kotlin/com/lambda/client/event/eventbus/AbstractEventBus.kt @@ -0,0 +1,28 @@ +package com.lambda.client.event.eventbus + +import com.lambda.client.event.ListenerManager +import com.lambda.client.event.listener.Listener + +/** + * [IEventBus] with some basic implementation + */ +abstract class AbstractEventBus : IEventBus { + override fun subscribe(objs: Any) { + ListenerManager.getListeners(objs)?.forEach { + subscribedListeners.getOrPut(it.eventClass, ::newSet).add(it) + } + } + + override fun unsubscribe(objs: Any) { + ListenerManager.getListeners(objs)?.forEach { + subscribedListeners[it.eventClass]?.remove(it) + } + } + + override fun post(event: Any) { + subscribedListeners[event.javaClass]?.let { + @Suppress("UNCHECKED_CAST") // IDE meme + for (listener in it) (listener as Listener).function.invoke(event) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/event/eventbus/EventBusImpl.kt b/src/main/kotlin/com/lambda/client/event/eventbus/EventBusImpl.kt new file mode 100644 index 000000000..f5357a565 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/event/eventbus/EventBusImpl.kt @@ -0,0 +1,35 @@ +package com.lambda.client.event.eventbus + +import com.lambda.client.event.listener.Listener +import java.util.* +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.ConcurrentSkipListSet + +/** + * A concurrent implementation of [AbstractEventBus] + */ +open class ConcurrentEventBus : AbstractEventBus() { + final override val subscribedListeners = ConcurrentHashMap, MutableSet>>() + + override fun newSet() = ConcurrentSkipListSet>(Comparator.reverseOrder()) +} + +/** + * A concurrent implementation of [AbstractEventBus] and [IMultiEventBus] + */ +open class MultiEventBus : ConcurrentEventBus(), IMultiEventBus { + private val subscribedEventBus = Collections.newSetFromMap(ConcurrentHashMap()) + + final override fun subscribe(eventBus: IEventBus) { + subscribedEventBus.add(eventBus) + } + + final override fun unsubscribe(eventBus: IEventBus) { + subscribedEventBus.remove(eventBus) + } + + final override fun post(event: Any) { + super.post(event) + for (eventBus in subscribedEventBus) eventBus.post(event) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/event/eventbus/IAsyncEventBus.kt b/src/main/kotlin/com/lambda/client/event/eventbus/IAsyncEventBus.kt new file mode 100644 index 000000000..23eeeb050 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/event/eventbus/IAsyncEventBus.kt @@ -0,0 +1,19 @@ +package com.lambda.client.event.eventbus + +import com.lambda.client.event.listener.AsyncListener + +interface IAsyncEventBus : IEventBus { + + /** + * A map for events and their subscribed listeners + * + * > + */ + val subscribedListenersAsync: MutableMap, MutableSet>> + + /** + * Called when putting a new set to the map + */ + fun newSetAsync(): MutableSet> + +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/event/eventbus/IEventBus.kt b/src/main/kotlin/com/lambda/client/event/eventbus/IEventBus.kt new file mode 100644 index 000000000..5c697a901 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/event/eventbus/IEventBus.kt @@ -0,0 +1,39 @@ +package com.lambda.client.event.eventbus + +import com.lambda.client.event.listener.Listener + +/** + * The basic Interface for an event bus + */ +interface IEventBus { + /** + * A map for events and their subscribed listeners + * + * > + */ + val subscribedListeners: MutableMap, MutableSet>> + + /** + * Subscribe an [objs]'s listeners to this event bus + */ + fun subscribe(objs: Any) + + + /** + * unsubscribes an [objs]'s listeners from this event bus + */ + fun unsubscribe(objs: Any) + + + /** + * Posts an event to this event bus, and calls + * All the listeners of this event + */ + fun post(event: Any) + + + /** + * Called when putting a new set to the map + */ + fun newSet(): MutableSet> +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/event/eventbus/IMultiEventBus.kt b/src/main/kotlin/com/lambda/client/event/eventbus/IMultiEventBus.kt new file mode 100644 index 000000000..2aa5c619a --- /dev/null +++ b/src/main/kotlin/com/lambda/client/event/eventbus/IMultiEventBus.kt @@ -0,0 +1,16 @@ +package com.lambda.client.event.eventbus + +/** + * Event bus that allow subscribing another [IEventBus] to it + */ +interface IMultiEventBus : IEventBus { + /** + * Subscribe an [eventBus] to this event bus + */ + fun subscribe(eventBus: IEventBus) + + /** + * unsubscribes an [eventBus] from this event bus + */ + fun unsubscribe(eventBus: IEventBus) +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt b/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt index 623b2efe3..90f95afb2 100644 --- a/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt +++ b/src/main/kotlin/com/lambda/client/event/events/OnUpdateWalkingPlayerEvent.kt @@ -6,7 +6,7 @@ import com.lambda.client.event.IMultiPhase import com.lambda.client.event.Phase import com.lambda.client.manager.managers.PlayerPacketManager import com.lambda.client.util.math.Vec2f -import com.lambda.commons.extension.next +import com.lambda.client.commons.extension.next import net.minecraft.util.math.Vec3d class OnUpdateWalkingPlayerEvent private constructor( diff --git a/src/main/kotlin/com/lambda/client/event/listener/AbstractListener.kt b/src/main/kotlin/com/lambda/client/event/listener/AbstractListener.kt new file mode 100644 index 000000000..3e7f73c72 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/event/listener/AbstractListener.kt @@ -0,0 +1,35 @@ +package com.lambda.client.event.listener + +import com.lambda.client.commons.interfaces.Nameable +import java.lang.ref.WeakReference +import java.util.concurrent.atomic.AtomicInteger +import kotlin.reflect.KProperty + +abstract class AbstractListener(owner: Any) : IListener { + final override val id: Int = listenerId.getAndIncrement() + final override val owner: Any? by WeakReference(owner) + final override val ownerName: String = if (owner is Nameable) owner.name else owner.javaClass.simpleName + + operator fun WeakReference.getValue(thisRef: Any?, property: KProperty<*>) = get() + + override fun compareTo(other: IListener<*, *>): Int { + val result = priority.compareTo(other.priority) + return if (result != 0) result + else id.compareTo(other.id) // :monkey: code for getting around TreeSet duplicated check + } + + override fun equals(other: Any?): Boolean { + return this === other + || (other is IListener<*, *> + && other.eventClass == this.eventClass + && other.id == this.id) + } + + override fun hashCode(): Int { + return 31 * eventClass.hashCode() + id.hashCode() + } + + companion object { + private val listenerId = AtomicInteger(Int.MIN_VALUE) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/event/listener/IListener.kt b/src/main/kotlin/com/lambda/client/event/listener/IListener.kt new file mode 100644 index 000000000..20552cdef --- /dev/null +++ b/src/main/kotlin/com/lambda/client/event/listener/IListener.kt @@ -0,0 +1,35 @@ +package com.lambda.client.event.listener + +interface IListener : Comparable> { + + /** + * Object of this listener belongs to + */ + val owner: Any? + + /** + * Name of the [owner] + */ + val ownerName: String + + /** + * Class of the target event + */ + val eventClass: Class + + /** + * Priority of this listener when calling by event bus + */ + val priority: Int + + /** + * Action to perform when this listener gets called by event bus + */ + val function: F + + /** + * An unique id for a listener + */ + val id: Int + +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/event/listener/ListenerImpl.kt b/src/main/kotlin/com/lambda/client/event/listener/ListenerImpl.kt new file mode 100644 index 000000000..e0aede6da --- /dev/null +++ b/src/main/kotlin/com/lambda/client/event/listener/ListenerImpl.kt @@ -0,0 +1,80 @@ +package com.lambda.client.event.listener + +import com.lambda.client.event.ListenerManager +import com.lambda.client.event.eventbus.IAsyncEventBus + + +/** + * Default priority for listeners + */ +const val DEFAULT_PRIORITY = 0 + +/** + * Create and register a new async listener for this object + * Must be used with Kotlinx Coroutine and a implementation of [IAsyncEventBus] + * + * @param T type of the target event + * @param function action to perform when this listener gets called by event bus + */ +inline fun Any.asyncListener(noinline function: suspend (T) -> Unit) { + this.asyncListener(T::class.java, function) +} + +/** + * Create and register a new async listener for this object + * Must be used with Kotlinx Coroutine and a implementation of [IAsyncEventBus] + * + * @param T type of the target event + * @param clazz class of the target event + * @param function action to perform when this listener gets called by event bus + */ +fun Any.asyncListener(clazz: Class, function: suspend (T) -> Unit) { + ListenerManager.register(this, AsyncListener(this, clazz, function)) +} + +/** + * Create and register a new listener for this object + * + * @param T type of the target event + * @param priority priority of this listener when calling by event bus + * @param function action to perform when this listener gets called by event bus + */ +inline fun Any.listener(priority: Int = DEFAULT_PRIORITY, noinline function: (T) -> Unit) { + this.listener(priority, T::class.java, function) +} + +/** + * Create and register a new listener for this object + * + * @param T type of the target event + * @param clazz class of the target event + * @param priority priority of this listener when calling by event bus + * @param function action to perform when this listener gets called by event bus + */ +fun Any.listener(priority: Int = DEFAULT_PRIORITY, clazz: Class, function: (T) -> Unit) { + ListenerManager.register(this, Listener(this, clazz, priority, function)) +} + +/** + * Implementation of [AbstractListener] with suspend block + * Must be used with Kotlinx Coroutine and a implementation of [IAsyncEventBus] + */ +class AsyncListener( + owner: Any, + override val eventClass: Class, + override val function: suspend (T) -> Unit +) : AbstractListener Unit>(owner) { + override val priority: Int = DEFAULT_PRIORITY +} + +/** + * Basic implementation of [AbstractListener] + */ +class Listener( + owner: Any, + override val eventClass: Class, + override val priority: Int, + override val function: (T) -> Unit +) : AbstractListener Unit>(owner) + + diff --git a/src/main/kotlin/com/lambda/client/gui/GuiManager.kt b/src/main/kotlin/com/lambda/client/gui/GuiManager.kt index fa5bd0085..ba93ba108 100644 --- a/src/main/kotlin/com/lambda/client/gui/GuiManager.kt +++ b/src/main/kotlin/com/lambda/client/gui/GuiManager.kt @@ -8,9 +8,9 @@ import com.lambda.client.gui.hudgui.LambdaHudGui import com.lambda.client.util.AsyncCachedValue import com.lambda.client.util.StopTimer import com.lambda.client.util.TimeUnit -import com.lambda.commons.collections.AliasSet -import com.lambda.commons.utils.ClassUtils -import com.lambda.commons.utils.ClassUtils.instance +import com.lambda.client.commons.collections.AliasSet +import com.lambda.client.commons.utils.ClassUtils +import com.lambda.client.commons.utils.ClassUtils.instance import kotlinx.coroutines.Deferred import java.lang.reflect.Modifier diff --git a/src/main/kotlin/com/lambda/client/gui/clickgui/LambdaClickGui.kt b/src/main/kotlin/com/lambda/client/gui/clickgui/LambdaClickGui.kt index 89b576ffb..75760026a 100644 --- a/src/main/kotlin/com/lambda/client/gui/clickgui/LambdaClickGui.kt +++ b/src/main/kotlin/com/lambda/client/gui/clickgui/LambdaClickGui.kt @@ -16,7 +16,7 @@ import com.lambda.client.util.FolderUtils import com.lambda.client.util.math.Vec2f import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.defaultScope -import com.lambda.commons.utils.ConnectionUtils +import com.lambda.client.commons.utils.ConnectionUtils import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import net.minecraft.util.text.TextFormatting diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt index c4f848fea..849adb72a 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractHudElement.kt @@ -15,9 +15,9 @@ import com.lambda.client.util.math.Vec2d import com.lambda.client.util.math.Vec2f import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener -import com.lambda.commons.interfaces.Alias -import com.lambda.commons.interfaces.DisplayEnum -import com.lambda.commons.interfaces.Nameable +import com.lambda.client.commons.interfaces.Alias +import com.lambda.client.commons.interfaces.DisplayEnum +import com.lambda.client.commons.interfaces.Nameable import net.minecraftforge.fml.common.gameevent.TickEvent import org.lwjgl.opengl.GL11.glScalef diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt index 637636e3d..5df88a0b6 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/AbstractLabelHud.kt @@ -6,7 +6,7 @@ import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.graphics.font.TextComponent import com.lambda.client.util.math.Vec2d import com.lambda.client.util.threads.safeAsyncListener -import com.lambda.commons.interfaces.Nameable +import com.lambda.client.commons.interfaces.Nameable import net.minecraftforge.fml.common.gameevent.TickEvent abstract class AbstractLabelHud( diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/LambdaHudGui.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/LambdaHudGui.kt index 2fb7be5ec..79d9fe279 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/LambdaHudGui.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/LambdaHudGui.kt @@ -13,7 +13,7 @@ import com.lambda.client.module.modules.client.HudEditor import com.lambda.client.util.graphics.GlStateUtils import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.math.Vec2f -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraftforge.fml.common.gameevent.InputEvent import org.lwjgl.input.Keyboard import org.lwjgl.opengl.GL11.* diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/ModuleList.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/ModuleList.kt index c7857c4e4..daa261e88 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/ModuleList.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/client/ModuleList.kt @@ -15,8 +15,8 @@ import com.lambda.client.util.graphics.font.HAlign import com.lambda.client.util.graphics.font.TextComponent import com.lambda.client.util.graphics.font.VAlign import com.lambda.client.util.threads.safeAsyncListener -import com.lambda.commons.extension.sumByFloat -import com.lambda.commons.interfaces.DisplayEnum +import com.lambda.client.commons.extension.sumByFloat +import com.lambda.client.commons.interfaces.DisplayEnum import net.minecraft.client.renderer.GlStateManager import net.minecraftforge.fml.common.gameevent.TickEvent import java.awt.Color diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/combat/Armor.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/combat/Armor.kt index b0a46e28b..2d328ef36 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/combat/Armor.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/combat/Armor.kt @@ -13,7 +13,7 @@ import com.lambda.client.util.items.countItem import com.lambda.client.util.math.Vec2d import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeAsyncListener -import com.lambda.commons.utils.MathUtils +import com.lambda.client.commons.utils.MathUtils import net.minecraft.client.renderer.GlStateManager import net.minecraft.init.Items import net.minecraft.item.ItemStack diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/combat/CrystalDamage.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/combat/CrystalDamage.kt index ca07b21e0..ef53d76be 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/combat/CrystalDamage.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/combat/CrystalDamage.kt @@ -5,7 +5,7 @@ import com.lambda.client.gui.hudgui.LabelHud import com.lambda.client.manager.managers.CombatManager import com.lambda.client.util.Quad import com.lambda.client.util.combat.CrystalUtils.canPlaceCollide -import com.lambda.commons.utils.MathUtils +import com.lambda.client.commons.utils.MathUtils import kotlin.math.max internal object CrystalDamage : LabelHud( diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/CPS.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/CPS.kt index 33978289d..6fa6c4e35 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/CPS.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/CPS.kt @@ -5,7 +5,7 @@ import com.lambda.client.event.events.RunGameLoopEvent import com.lambda.client.gui.hudgui.LabelHud import com.lambda.client.util.TickTimer import com.lambda.client.util.graphics.AnimationUtils -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraftforge.fml.common.gameevent.InputEvent import org.lwjgl.input.Mouse diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Queue2B2T.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Queue2B2T.kt index 7e13e2604..6ba1dbdcc 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Queue2B2T.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/misc/Queue2B2T.kt @@ -11,7 +11,7 @@ import com.lambda.client.util.TimeUnit import com.lambda.client.util.WebUtils import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.defaultScope -import com.lambda.commons.utils.grammar +import com.lambda.client.commons.utils.grammar import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Durability.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Durability.kt index dec48f80f..8da8b95bd 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Durability.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Durability.kt @@ -2,7 +2,7 @@ package com.lambda.client.gui.hudgui.elements.player import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud -import com.lambda.commons.utils.MathUtils +import com.lambda.client.commons.utils.MathUtils import net.minecraft.util.EnumHand internal object Durability : LabelHud( diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/PlayerSpeed.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/PlayerSpeed.kt index 2460a141b..5e57f9dcb 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/PlayerSpeed.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/PlayerSpeed.kt @@ -3,8 +3,8 @@ package com.lambda.client.gui.hudgui.elements.player import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud import com.lambda.client.util.InfoCalculator.speed -import com.lambda.commons.interfaces.DisplayEnum -import com.lambda.commons.utils.MathUtils +import com.lambda.client.commons.interfaces.DisplayEnum +import com.lambda.client.commons.utils.MathUtils import java.util.* internal object PlayerSpeed : LabelHud( diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Rotation.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Rotation.kt index 9ac97d140..7ce662755 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Rotation.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/Rotation.kt @@ -3,7 +3,7 @@ package com.lambda.client.gui.hudgui.elements.player import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud import com.lambda.client.util.math.RotationUtils -import com.lambda.commons.utils.MathUtils +import com.lambda.client.commons.utils.MathUtils internal object Rotation : LabelHud( name = "Rotation", diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/TimerSpeed.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/TimerSpeed.kt index 1df319d1a..e0dd5687b 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/TimerSpeed.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/TimerSpeed.kt @@ -3,7 +3,7 @@ package com.lambda.client.gui.hudgui.elements.player import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud import com.lambda.client.manager.managers.TimerManager -import com.lambda.commons.utils.MathUtils +import com.lambda.client.commons.utils.MathUtils internal object TimerSpeed : LabelHud( name = "TimerSpeed", diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/ChunkSize.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/ChunkSize.kt index 97e081fe1..263c44f11 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/ChunkSize.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/ChunkSize.kt @@ -3,7 +3,7 @@ package com.lambda.client.gui.hudgui.elements.world import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud import com.lambda.client.mixin.extension.writeChunkToNBT -import com.lambda.commons.utils.MathUtils.round +import com.lambda.client.commons.utils.MathUtils.round import net.minecraft.nbt.CompressedStreamTools import net.minecraft.nbt.NBTTagCompound import net.minecraft.util.datafix.DataFixer diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/TextRadar.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/TextRadar.kt index d5f05ba6a..2f0602568 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/TextRadar.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/TextRadar.kt @@ -8,7 +8,7 @@ import com.lambda.client.util.color.ColorGradient import com.lambda.client.util.color.ColorHolder import com.lambda.client.util.color.DyeColors import com.lambda.client.util.threads.runSafeR -import com.lambda.commons.utils.MathUtils +import com.lambda.client.commons.utils.MathUtils import net.minecraft.entity.player.EntityPlayer import net.minecraft.init.MobEffects diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/WorldTime.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/WorldTime.kt index e20dfdaec..67ada6de6 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/WorldTime.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/world/WorldTime.kt @@ -2,7 +2,7 @@ package com.lambda.client.gui.hudgui.elements.world import com.lambda.client.event.SafeClientEvent import com.lambda.client.gui.hudgui.LabelHud -import com.lambda.commons.interfaces.DisplayEnum +import com.lambda.client.commons.interfaces.DisplayEnum import org.apache.commons.lang3.time.DurationFormatUtils internal object WorldTime : LabelHud( diff --git a/src/main/kotlin/com/lambda/client/gui/mc/LambdaGuiChat.kt b/src/main/kotlin/com/lambda/client/gui/mc/LambdaGuiChat.kt index dc33dae22..0dd4c11b3 100644 --- a/src/main/kotlin/com/lambda/client/gui/mc/LambdaGuiChat.kt +++ b/src/main/kotlin/com/lambda/client/gui/mc/LambdaGuiChat.kt @@ -9,9 +9,9 @@ import com.lambda.client.util.graphics.RenderUtils2D import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.math.Vec2d import com.lambda.client.util.threads.defaultScope -import com.lambda.command.args.AbstractArg -import com.lambda.command.args.AutoComplete -import com.lambda.command.args.GreedyStringArg +import com.lambda.client.command.args.AbstractArg +import com.lambda.client.command.args.AutoComplete +import com.lambda.client.command.args.GreedyStringArg import kotlinx.coroutines.launch import net.minecraft.client.gui.GuiChat import org.lwjgl.input.Keyboard diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/Component.kt b/src/main/kotlin/com/lambda/client/gui/rgui/Component.kt index b396ffb63..56ffee9bf 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/Component.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/Component.kt @@ -10,7 +10,7 @@ import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.graphics.font.HAlign import com.lambda.client.util.graphics.font.VAlign import com.lambda.client.util.math.Vec2f -import com.lambda.commons.interfaces.Nameable +import com.lambda.client.commons.interfaces.Nameable import kotlin.math.max open class Component( diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/InteractiveComponent.kt b/src/main/kotlin/com/lambda/client/gui/rgui/InteractiveComponent.kt index 8da67d8d6..44f86dca6 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/InteractiveComponent.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/InteractiveComponent.kt @@ -3,7 +3,7 @@ package com.lambda.client.gui.rgui import com.lambda.client.setting.GuiConfig import com.lambda.client.setting.configs.AbstractConfig import com.lambda.client.util.math.Vec2f -import com.lambda.commons.interfaces.Nameable +import com.lambda.client.commons.interfaces.Nameable open class InteractiveComponent( name: String, diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/WindowComponent.kt b/src/main/kotlin/com/lambda/client/gui/rgui/WindowComponent.kt index 76b772f08..c67c325fc 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/WindowComponent.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/WindowComponent.kt @@ -6,7 +6,7 @@ import com.lambda.client.util.graphics.AnimationUtils import com.lambda.client.util.graphics.font.HAlign import com.lambda.client.util.graphics.font.VAlign import com.lambda.client.util.math.Vec2f -import com.lambda.commons.interfaces.Nameable +import com.lambda.client.commons.interfaces.Nameable import kotlin.math.max import kotlin.math.min diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/component/EnumSlider.kt b/src/main/kotlin/com/lambda/client/gui/rgui/component/EnumSlider.kt index 56b0ecff6..7b0dd58da 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/component/EnumSlider.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/component/EnumSlider.kt @@ -7,7 +7,7 @@ import com.lambda.client.setting.settings.impl.primitive.EnumSetting import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.Vec2f -import com.lambda.commons.extension.readableName +import com.lambda.client.commons.extension.readableName import kotlin.math.floor class EnumSlider(val setting: EnumSetting<*>) : Slider(setting.name, 0.0, setting.description, setting.visibility) { diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/component/SettingSlider.kt b/src/main/kotlin/com/lambda/client/gui/rgui/component/SettingSlider.kt index 961d5dea9..732cbf2fc 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/component/SettingSlider.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/component/SettingSlider.kt @@ -9,7 +9,7 @@ import com.lambda.client.setting.settings.impl.number.NumberSetting import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.Vec2f -import com.lambda.commons.utils.MathUtils +import com.lambda.client.commons.utils.MathUtils import org.lwjgl.input.Keyboard import kotlin.math.abs import kotlin.math.floor diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/windows/BasicWindow.kt b/src/main/kotlin/com/lambda/client/gui/rgui/windows/BasicWindow.kt index 4571f6134..05ee76463 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/windows/BasicWindow.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/windows/BasicWindow.kt @@ -8,7 +8,7 @@ import com.lambda.client.util.graphics.RenderUtils2D import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.math.Vec2d import com.lambda.client.util.math.Vec2f -import com.lambda.commons.interfaces.Nameable +import com.lambda.client.commons.interfaces.Nameable /** * Window with rectangle rendering diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/windows/CleanWindow.kt b/src/main/kotlin/com/lambda/client/gui/rgui/windows/CleanWindow.kt index 3955451e7..019185c6a 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/windows/CleanWindow.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/windows/CleanWindow.kt @@ -3,7 +3,7 @@ package com.lambda.client.gui.rgui.windows import com.lambda.client.gui.rgui.WindowComponent import com.lambda.client.setting.GuiConfig import com.lambda.client.setting.configs.AbstractConfig -import com.lambda.commons.interfaces.Nameable +import com.lambda.client.commons.interfaces.Nameable /** * Window with no rendering diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt b/src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt index 8368f7e40..41c210976 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt @@ -8,9 +8,9 @@ import com.lambda.client.util.TickTimer import com.lambda.client.util.graphics.GlStateUtils import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.math.Vec2f -import com.lambda.commons.extension.ceilToInt -import com.lambda.commons.extension.floorToInt -import com.lambda.commons.extension.sumByFloat +import com.lambda.client.commons.extension.ceilToInt +import com.lambda.client.commons.extension.floorToInt +import com.lambda.client.commons.extension.sumByFloat import kotlinx.coroutines.runBlocking import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock diff --git a/src/main/kotlin/com/lambda/client/gui/rgui/windows/SettingWindow.kt b/src/main/kotlin/com/lambda/client/gui/rgui/windows/SettingWindow.kt index c79f61311..6191c03b5 100644 --- a/src/main/kotlin/com/lambda/client/gui/rgui/windows/SettingWindow.kt +++ b/src/main/kotlin/com/lambda/client/gui/rgui/windows/SettingWindow.kt @@ -11,7 +11,7 @@ import com.lambda.client.setting.settings.impl.primitive.EnumSetting import com.lambda.client.setting.settings.impl.primitive.StringSetting import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.Vec2f -import com.lambda.commons.extension.sumByFloat +import com.lambda.client.commons.extension.sumByFloat import org.lwjgl.input.Keyboard abstract class SettingWindow( diff --git a/src/main/kotlin/com/lambda/client/manager/ManagerLoader.kt b/src/main/kotlin/com/lambda/client/manager/ManagerLoader.kt index e5590a5af..f2455fd08 100644 --- a/src/main/kotlin/com/lambda/client/manager/ManagerLoader.kt +++ b/src/main/kotlin/com/lambda/client/manager/ManagerLoader.kt @@ -3,8 +3,8 @@ package com.lambda.client.manager import com.lambda.client.LambdaMod import com.lambda.client.event.LambdaEventBus import com.lambda.client.util.StopTimer -import com.lambda.commons.utils.ClassUtils -import com.lambda.commons.utils.ClassUtils.instance +import com.lambda.client.commons.utils.ClassUtils +import com.lambda.client.commons.utils.ClassUtils.instance import kotlinx.coroutines.Deferred internal object ManagerLoader : com.lambda.client.AsyncLoader>> { diff --git a/src/main/kotlin/com/lambda/client/manager/managers/FriendManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/FriendManager.kt index 326f51e5e..c8b3628e7 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/FriendManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/FriendManager.kt @@ -3,11 +3,11 @@ package com.lambda.client.manager.managers import com.google.gson.GsonBuilder import com.google.gson.annotations.SerializedName import com.google.gson.reflect.TypeToken -import com.lambda.capeapi.PlayerProfile +import com.lambda.client.capeapi.PlayerProfile import com.lambda.client.LambdaMod import com.lambda.client.manager.Manager import com.lambda.client.util.ConfigUtils -import com.lambda.commons.extension.synchronized +import com.lambda.client.commons.extension.synchronized import java.io.File import java.io.FileReader import java.io.FileWriter diff --git a/src/main/kotlin/com/lambda/client/manager/managers/HotbarManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/HotbarManager.kt index 41a4dc548..9d63d26e4 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/HotbarManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/HotbarManager.kt @@ -8,11 +8,11 @@ import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeoutFlag import com.lambda.client.util.items.HotbarSlot import com.lambda.client.util.threads.runSafe -import com.lambda.commons.extension.firstEntryOrNull -import com.lambda.commons.extension.firstKeyOrNull -import com.lambda.commons.extension.firstValue -import com.lambda.commons.extension.synchronized -import com.lambda.event.listener.listener +import com.lambda.client.commons.extension.firstEntryOrNull +import com.lambda.client.commons.extension.firstKeyOrNull +import com.lambda.client.commons.extension.firstValue +import com.lambda.client.commons.extension.synchronized +import com.lambda.client.event.listener.listener import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.item.ItemStack import net.minecraft.network.play.client.CPacketHeldItemChange diff --git a/src/main/kotlin/com/lambda/client/manager/managers/MacroManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/MacroManager.kt index ea6dab076..bc24966c9 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/MacroManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/MacroManager.kt @@ -7,7 +7,7 @@ import com.lambda.client.command.CommandManager import com.lambda.client.manager.Manager import com.lambda.client.util.ConfigUtils import com.lambda.client.util.text.MessageSendHelper -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraftforge.fml.common.gameevent.InputEvent import org.lwjgl.input.Keyboard import java.io.File diff --git a/src/main/kotlin/com/lambda/client/manager/managers/MessageManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/MessageManager.kt index 99e62d382..5f94abe1c 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/MessageManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/MessageManager.kt @@ -8,7 +8,7 @@ import com.lambda.client.module.modules.client.ChatSetting import com.lambda.client.util.TaskState import com.lambda.client.util.TickTimer import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.network.play.client.CPacketChatMessage import net.minecraftforge.fml.common.gameevent.TickEvent import java.util.* diff --git a/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt new file mode 100644 index 000000000..027acfcf3 --- /dev/null +++ b/src/main/kotlin/com/lambda/client/manager/managers/NotificationManager.kt @@ -0,0 +1,23 @@ +package com.lambda.client.manager.managers + +import com.lambda.client.manager.Manager +import com.lambda.client.util.text.MessageSendHelper +import com.lambda.client.util.threads.safeListener +import net.minecraftforge.fml.common.gameevent.TickEvent +import java.util.* + +object NotificationManager : Manager { + private val pendingNotifications: Queue = LinkedList() + + init { + safeListener { + while (pendingNotifications.isNotEmpty()) { + MessageSendHelper.sendErrorMessage(pendingNotifications.poll()) + } + } + } + + fun registerNotification(message: String) { + pendingNotifications.add(message) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/manager/managers/PlayerInventoryManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/PlayerInventoryManager.kt index 02186b56e..53b9e56ee 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/PlayerInventoryManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/PlayerInventoryManager.kt @@ -11,7 +11,7 @@ import com.lambda.client.util.TpsCalculator import com.lambda.client.util.items.clickSlot import com.lambda.client.util.items.removeHoldingItem import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.inventory.ClickType import java.util.* diff --git a/src/main/kotlin/com/lambda/client/manager/managers/PlayerPacketManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/PlayerPacketManager.kt index 5d288217c..2bad800b8 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/PlayerPacketManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/PlayerPacketManager.kt @@ -10,7 +10,7 @@ import com.lambda.client.module.AbstractModule import com.lambda.client.util.Wrapper import com.lambda.client.util.math.Vec2f import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.network.play.client.CPacketPlayer import net.minecraft.util.math.Vec3d import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt index 133b48c39..804e3f035 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt @@ -7,8 +7,8 @@ import com.lambda.client.mixin.extension.timer import com.lambda.client.module.AbstractModule import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit -import com.lambda.commons.extension.synchronized -import com.lambda.event.listener.listener +import com.lambda.client.commons.extension.synchronized +import com.lambda.client.event.listener.listener import java.util.* object TimerManager : Manager { diff --git a/src/main/kotlin/com/lambda/client/manager/managers/UUIDManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/UUIDManager.kt index 998cc03a6..09b1423de 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/UUIDManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/UUIDManager.kt @@ -1,8 +1,8 @@ package com.lambda.client.manager.managers -import com.lambda.capeapi.AbstractUUIDManager -import com.lambda.capeapi.PlayerProfile -import com.lambda.capeapi.UUIDUtils +import com.lambda.client.capeapi.AbstractUUIDManager +import com.lambda.client.capeapi.PlayerProfile +import com.lambda.client.capeapi.UUIDUtils import com.lambda.client.LambdaMod import com.lambda.client.manager.Manager import com.lambda.client.util.Wrapper diff --git a/src/main/kotlin/com/lambda/client/module/AbstractModule.kt b/src/main/kotlin/com/lambda/client/module/AbstractModule.kt index 193d8bcba..fab8bf006 100644 --- a/src/main/kotlin/com/lambda/client/module/AbstractModule.kt +++ b/src/main/kotlin/com/lambda/client/module/AbstractModule.kt @@ -12,8 +12,8 @@ import com.lambda.client.setting.settings.impl.other.BindSetting import com.lambda.client.setting.settings.impl.primitive.BooleanSetting import com.lambda.client.util.Bind import com.lambda.client.util.text.MessageSendHelper -import com.lambda.commons.interfaces.Alias -import com.lambda.commons.interfaces.Nameable +import com.lambda.client.commons.interfaces.Alias +import com.lambda.client.commons.interfaces.Nameable import net.minecraft.client.Minecraft @Suppress("UNCHECKED_CAST") diff --git a/src/main/kotlin/com/lambda/client/module/Category.kt b/src/main/kotlin/com/lambda/client/module/Category.kt index eb782f088..7af29f1f4 100644 --- a/src/main/kotlin/com/lambda/client/module/Category.kt +++ b/src/main/kotlin/com/lambda/client/module/Category.kt @@ -1,6 +1,6 @@ package com.lambda.client.module -import com.lambda.commons.interfaces.DisplayEnum +import com.lambda.client.commons.interfaces.DisplayEnum enum class Category(override val displayName: String) : DisplayEnum { CHAT("Chat"), diff --git a/src/main/kotlin/com/lambda/client/module/ModuleManager.kt b/src/main/kotlin/com/lambda/client/module/ModuleManager.kt index f00775848..c39b51064 100644 --- a/src/main/kotlin/com/lambda/client/module/ModuleManager.kt +++ b/src/main/kotlin/com/lambda/client/module/ModuleManager.kt @@ -6,9 +6,9 @@ import com.lambda.client.event.LambdaEventBus import com.lambda.client.util.AsyncCachedValue import com.lambda.client.util.StopTimer import com.lambda.client.util.TimeUnit -import com.lambda.commons.collections.AliasSet -import com.lambda.commons.utils.ClassUtils -import com.lambda.commons.utils.ClassUtils.instance +import com.lambda.client.commons.collections.AliasSet +import com.lambda.client.commons.utils.ClassUtils +import com.lambda.client.commons.utils.ClassUtils.instance import kotlinx.coroutines.Deferred import org.lwjgl.input.Keyboard import java.lang.reflect.Modifier diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/AntiSpam.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/AntiSpam.kt index ebde06e6b..ef2c4dfba 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/AntiSpam.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/AntiSpam.kt @@ -6,7 +6,7 @@ import com.lambda.client.module.Module import com.lambda.client.util.text.MessageDetection import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.SpamFilters -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.util.text.TextComponentString import net.minecraftforge.client.event.ClientChatReceivedEvent import java.util.concurrent.ConcurrentHashMap diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/AutoTPA.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/AutoTPA.kt index 676a2bf28..0fbabdb3b 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/AutoTPA.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/AutoTPA.kt @@ -6,7 +6,7 @@ import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.text.MessageDetection import com.lambda.client.util.text.MessageSendHelper.sendServerMessage -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.network.play.server.SPacketChat object AutoTPA : Module( diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/ChatFilter.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/ChatFilter.kt index bf77208b5..660a2998c 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/ChatFilter.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/ChatFilter.kt @@ -6,7 +6,7 @@ import com.lambda.client.module.Module import com.lambda.client.util.text.MessageDetection import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.formatValue -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraftforge.client.event.ClientChatReceivedEvent import java.io.File import java.io.FileNotFoundException diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/ChatTimestamp.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/ChatTimestamp.kt index c6141ab04..9d943cb18 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/ChatTimestamp.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/ChatTimestamp.kt @@ -6,7 +6,7 @@ import com.lambda.client.util.TimeUtils import com.lambda.client.util.color.EnumTextColor import com.lambda.client.util.text.format import com.lambda.client.util.threads.safeListener -import com.lambda.commons.interfaces.DisplayEnum +import com.lambda.client.commons.interfaces.DisplayEnum import net.minecraft.util.text.TextComponentString import net.minecraftforge.client.event.ClientChatReceivedEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/FancyChat.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/FancyChat.kt index d05e70ce2..7a933c66b 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/FancyChat.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/FancyChat.kt @@ -4,7 +4,7 @@ import com.lambda.client.manager.managers.MessageManager.newMessageModifier import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.text.MessageDetection -import com.lambda.commons.utils.MathUtils +import com.lambda.client.commons.utils.MathUtils import kotlin.math.min object FancyChat : Module( diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/FriendHighlight.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/FriendHighlight.kt index e5c1b5c3f..338a12940 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/FriendHighlight.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/FriendHighlight.kt @@ -5,7 +5,7 @@ import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.color.EnumTextColor import com.lambda.client.util.text.MessageSendHelper -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.client.audio.PositionedSoundRecord import net.minecraft.init.SoundEvents import net.minecraft.util.text.TextComponentString diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/LambdaMoji.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/LambdaMoji.kt index 439c2de4f..535ae906a 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/LambdaMoji.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/LambdaMoji.kt @@ -5,7 +5,7 @@ import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.graphics.GlStateUtils import com.lambda.client.util.graphics.texture.MipmapTexture -import com.lambda.commons.extension.ceilToInt +import com.lambda.client.commons.extension.ceilToInt import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.vertex.DefaultVertexFormats diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/LoginMessage.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/LoginMessage.kt index cf14810c0..cbd36143d 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/LoginMessage.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/LoginMessage.kt @@ -10,7 +10,7 @@ import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.MessageSendHelper.sendServerMessage import com.lambda.client.util.threads.defaultScope import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/chat/Spammer.kt b/src/main/kotlin/com/lambda/client/module/modules/chat/Spammer.kt index 8dd120c5a..e3c07b3e4 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/chat/Spammer.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/chat/Spammer.kt @@ -10,7 +10,7 @@ import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.MessageSendHelper.sendServerMessage import com.lambda.client.util.threads.defaultScope import com.lambda.client.util.threads.safeListener -import com.lambda.commons.extension.synchronized +import com.lambda.client.commons.extension.synchronized import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Baritone.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Baritone.kt index 5f5b3668d..decdad95a 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Baritone.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Baritone.kt @@ -9,7 +9,7 @@ import com.lambda.client.util.color.ColorHolder import com.lambda.client.util.graphics.RenderUtils2D import com.lambda.client.util.math.Vec2d import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.util.math.BlockPos object Baritone : Module( diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Capes.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Capes.kt index e6b105433..088988061 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Capes.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Capes.kt @@ -2,9 +2,9 @@ package com.lambda.client.module.modules.client import com.google.gson.Gson import com.google.gson.reflect.TypeToken -import com.lambda.capeapi.Cape -import com.lambda.capeapi.CapeType -import com.lambda.capeapi.CapeUser +import com.lambda.client.capeapi.Cape +import com.lambda.client.capeapi.CapeType +import com.lambda.client.capeapi.CapeUser import com.lambda.client.LambdaMod import com.lambda.client.gui.clickgui.LambdaClickGui import com.lambda.client.module.Category @@ -16,8 +16,8 @@ import com.lambda.client.util.color.ColorHolder import com.lambda.client.util.color.DyeColors import com.lambda.client.util.threads.BackgroundScope import com.lambda.client.util.threads.defaultScope -import com.lambda.commons.extension.synchronized -import com.lambda.commons.utils.ConnectionUtils +import com.lambda.client.commons.extension.synchronized +import com.lambda.client.commons.utils.ConnectionUtils import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/ClickGUI.kt b/src/main/kotlin/com/lambda/client/module/modules/client/ClickGUI.kt index 5b8e72507..1babe0444 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/ClickGUI.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/ClickGUI.kt @@ -6,7 +6,7 @@ import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.StopTimer import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraftforge.fml.common.gameevent.TickEvent import org.lwjgl.input.Keyboard import kotlin.math.round diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/CommandConfig.kt b/src/main/kotlin/com/lambda/client/module/modules/client/CommandConfig.kt index fb634267f..76c6e111b 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/CommandConfig.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/CommandConfig.kt @@ -7,7 +7,7 @@ import com.lambda.client.module.Module import com.lambda.client.util.TickTimer import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.format -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.util.text.TextFormatting import net.minecraftforge.fml.common.gameevent.TickEvent import org.lwjgl.opengl.Display diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/Configurations.kt b/src/main/kotlin/com/lambda/client/module/modules/client/Configurations.kt index a6570b6a4..8c0e6a0e9 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/Configurations.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/Configurations.kt @@ -20,8 +20,8 @@ import com.lambda.client.util.text.formatValue import com.lambda.client.util.threads.BackgroundScope import com.lambda.client.util.threads.defaultScope import com.lambda.client.util.threads.safeListener -import com.lambda.commons.interfaces.DisplayEnum -import com.lambda.event.listener.listener +import com.lambda.client.commons.interfaces.DisplayEnum +import com.lambda.client.event.listener.listener import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/client/HudEditor.kt b/src/main/kotlin/com/lambda/client/module/modules/client/HudEditor.kt index 5895f6b0d..45daa799d 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/client/HudEditor.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/client/HudEditor.kt @@ -4,7 +4,7 @@ import com.lambda.client.event.events.ShutdownEvent import com.lambda.client.gui.hudgui.LambdaHudGui import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener object HudEditor : Module( name = "HudEditor", diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoEZ.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoEZ.kt index 5add12ebe..0095fde13 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoEZ.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoEZ.kt @@ -10,8 +10,8 @@ import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.MessageSendHelper.sendServerMessage import com.lambda.client.util.text.formatValue import com.lambda.client.util.threads.safeListener -import com.lambda.commons.extension.synchronized -import com.lambda.event.listener.listener +import com.lambda.client.commons.extension.synchronized +import com.lambda.client.event.listener.listener import net.minecraft.entity.player.EntityPlayer import net.minecraftforge.client.event.ClientChatReceivedEvent import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoLog.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoLog.kt index 8493d50e5..a023a902d 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoLog.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoLog.kt @@ -12,7 +12,7 @@ import com.lambda.client.util.combat.CombatUtils.scaledHealth import com.lambda.client.util.items.allSlots import com.lambda.client.util.items.countItem import com.lambda.client.util.threads.safeListener -import com.lambda.commons.utils.MathUtils +import com.lambda.client.commons.utils.MathUtils import net.minecraft.client.audio.PositionedSoundRecord import net.minecraft.client.gui.GuiMainMenu import net.minecraft.client.gui.GuiMultiplayer diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoMend.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoMend.kt index 4768387d9..0c7b5dea9 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoMend.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoMend.kt @@ -15,8 +15,8 @@ import com.lambda.client.util.items.swapToSlot import com.lambda.client.util.math.Vec2f import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener -import com.lambda.commons.utils.MathUtils.reverseNumber -import com.lambda.event.listener.listener +import com.lambda.client.commons.utils.MathUtils.reverseNumber +import com.lambda.client.event.listener.listener import net.minecraft.enchantment.EnchantmentHelper import net.minecraft.entity.player.EntityPlayer import net.minecraft.init.Enchantments diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt index 4a66dff4c..3f316febf 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoOffhand.kt @@ -14,7 +14,7 @@ import com.lambda.client.util.combat.CombatUtils.scaledHealth import com.lambda.client.util.items.* import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener -import com.lambda.commons.extension.next +import com.lambda.client.commons.extension.next import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.entity.item.EntityEnderCrystal import net.minecraft.entity.monster.EntityMob diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoTrap.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoTrap.kt index 54b265c49..f79a72bab 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/AutoTrap.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/AutoTrap.kt @@ -20,7 +20,7 @@ import com.lambda.client.util.threads.isActiveOrFalse import com.lambda.client.util.threads.safeListener import com.lambda.client.util.world.buildStructure import com.lambda.client.util.world.isPlaceable -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import kotlinx.coroutines.Job import kotlinx.coroutines.launch import net.minecraft.init.Blocks diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/CombatSetting.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/CombatSetting.kt index 76d5102f7..82eecc9c0 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/CombatSetting.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/CombatSetting.kt @@ -26,8 +26,8 @@ import com.lambda.client.util.threads.defaultScope import com.lambda.client.util.threads.isActiveOrFalse import com.lambda.client.util.threads.runSafeR import com.lambda.client.util.threads.safeListener -import com.lambda.commons.extension.ceilToInt -import com.lambda.event.listener.listener +import com.lambda.client.commons.extension.ceilToInt +import com.lambda.client.event.listener.listener import kotlinx.coroutines.Job import kotlinx.coroutines.launch import net.minecraft.entity.Entity diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/Criticals.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/Criticals.kt index de7f43bf5..86c958d38 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/Criticals.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/Criticals.kt @@ -8,8 +8,8 @@ import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.EntityUtils.isInOrAboveLiquid import com.lambda.client.util.threads.safeListener -import com.lambda.commons.interfaces.DisplayEnum -import com.lambda.event.listener.listener +import com.lambda.client.commons.interfaces.DisplayEnum +import com.lambda.client.event.listener.listener import net.minecraft.entity.Entity import net.minecraft.entity.EntityLivingBase import net.minecraft.init.MobEffects diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalAura.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalAura.kt index 3ca8e0d6d..9605cebf1 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalAura.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalAura.kt @@ -37,9 +37,9 @@ import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.runSafeR import com.lambda.client.util.threads.safeListener import com.lambda.client.util.world.getClosestVisibleSide -import com.lambda.commons.extension.synchronized -import com.lambda.commons.interfaces.DisplayEnum -import com.lambda.event.listener.listener +import com.lambda.client.commons.extension.synchronized +import com.lambda.client.commons.interfaces.DisplayEnum +import com.lambda.client.event.listener.listener import it.unimi.dsi.fastutil.ints.Int2LongMaps import it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap import net.minecraft.client.entity.EntityPlayerSP diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalBasePlace.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalBasePlace.kt index 4fa1bbed9..450b3f1da 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalBasePlace.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalBasePlace.kt @@ -25,7 +25,7 @@ import com.lambda.client.util.world.PlaceInfo import com.lambda.client.util.world.getNeighbour import com.lambda.client.util.world.hasNeighbour import com.lambda.client.util.world.isPlaceable -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.entity.EntityLivingBase import net.minecraft.init.Blocks import net.minecraft.item.ItemStack diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalESP.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalESP.kt index e0b0eb0e5..0812ddc15 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalESP.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/CrystalESP.kt @@ -19,8 +19,8 @@ import com.lambda.client.util.graphics.ProjectionUtils import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.VectorUtils.toVec3dCenter import com.lambda.client.util.threads.safeListener -import com.lambda.commons.utils.MathUtils -import com.lambda.event.listener.listener +import com.lambda.client.commons.utils.MathUtils +import com.lambda.client.event.listener.listener import net.minecraft.init.Items import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock import net.minecraft.util.EnumHand diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/HoleSnap.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/HoleSnap.kt index 34abadf5e..bf75fb13d 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/HoleSnap.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/HoleSnap.kt @@ -21,9 +21,9 @@ import com.lambda.client.util.math.VectorUtils.distanceTo import com.lambda.client.util.math.VectorUtils.toVec3d import com.lambda.client.util.threads.safeAsyncListener import com.lambda.client.util.threads.safeListener -import com.lambda.commons.extension.ceilToInt -import com.lambda.commons.extension.toRadian -import com.lambda.event.listener.listener +import com.lambda.client.commons.extension.ceilToInt +import com.lambda.client.commons.extension.toRadian +import com.lambda.client.event.listener.listener import net.minecraft.network.play.server.SPacketPlayerPosLook import net.minecraft.util.MovementInputFromOptions import net.minecraft.util.math.BlockPos diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/KillAura.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/KillAura.kt index deb611fcb..2b700e5ce 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/KillAura.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/KillAura.kt @@ -16,7 +16,7 @@ import com.lambda.client.util.items.isWeapon import com.lambda.client.util.math.RotationUtils.faceEntityClosest import com.lambda.client.util.math.RotationUtils.getRotationToEntityClosest import com.lambda.client.util.threads.safeListener -import com.lambda.commons.interfaces.DisplayEnum +import com.lambda.client.commons.interfaces.DisplayEnum import net.minecraft.entity.Entity import net.minecraft.entity.projectile.EntityLargeFireball import net.minecraft.util.EnumHand diff --git a/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt b/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt index 75e84b434..1d9a3c585 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/combat/TotemPopCounter.kt @@ -11,8 +11,8 @@ import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.text.MessageSendHelper.sendServerMessage import com.lambda.client.util.text.format import com.lambda.client.util.threads.safeListener -import com.lambda.commons.extension.synchronized -import com.lambda.event.listener.listener +import com.lambda.client.commons.extension.synchronized +import com.lambda.client.event.listener.listener import net.minecraft.entity.player.EntityPlayer import net.minecraft.network.play.server.SPacketEntityStatus import net.minecraft.util.text.TextFormatting diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/AntiAFK.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/AntiAFK.kt index 0d83e97d5..590b9c3d8 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/AntiAFK.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/AntiAFK.kt @@ -14,7 +14,7 @@ import com.lambda.client.util.TimeUnit import com.lambda.client.util.text.MessageDetection import com.lambda.client.util.text.MessageSendHelper.sendServerMessage import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.network.play.server.SPacketChat import net.minecraft.util.EnumHand import net.minecraft.util.math.BlockPos diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/AutoObsidian.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/AutoObsidian.kt index 5d0578635..1168b5231 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/AutoObsidian.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/AutoObsidian.kt @@ -27,8 +27,8 @@ import com.lambda.client.util.threads.onMainThread import com.lambda.client.util.threads.onMainThreadSafe import com.lambda.client.util.threads.safeListener import com.lambda.client.util.world.* -import com.lambda.commons.interfaces.DisplayEnum -import com.lambda.event.listener.listener +import com.lambda.client.commons.interfaces.DisplayEnum +import com.lambda.client.event.listener.listener import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/AutoReconnect.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/AutoReconnect.kt index 4cc8f7304..bd454b826 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/AutoReconnect.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/AutoReconnect.kt @@ -7,7 +7,7 @@ import com.lambda.client.mixin.extension.reason import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.StopTimer -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.client.gui.GuiDisconnected import net.minecraft.client.multiplayer.GuiConnecting import net.minecraft.client.multiplayer.ServerData diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/AutoTunnel.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/AutoTunnel.kt index 4562d261b..44826f5a4 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/AutoTunnel.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/AutoTunnel.kt @@ -9,7 +9,7 @@ import com.lambda.client.util.BaritoneUtils import com.lambda.client.util.math.RotationUtils import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.util.EnumFacing import net.minecraftforge.fml.common.gameevent.TickEvent import kotlin.math.round diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/DiscordRPC.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/DiscordRPC.kt index 5a35d3bb9..1683f0aff 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/DiscordRPC.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/DiscordRPC.kt @@ -4,7 +4,7 @@ import com.jagrosh.discordipc.IPCClient import com.jagrosh.discordipc.entities.RichPresence import com.jagrosh.discordipc.entities.pipe.PipeStatus import com.jagrosh.discordipc.exceptions.NoDiscordClientException -import com.lambda.capeapi.CapeType +import com.lambda.client.capeapi.CapeType import com.lambda.client.LambdaMod import com.lambda.client.module.Category import com.lambda.client.module.Module @@ -20,7 +20,7 @@ import com.lambda.client.util.threads.BackgroundJob import com.lambda.client.util.threads.BackgroundScope import com.lambda.client.util.threads.runSafeR import com.lambda.client.util.threads.safeListener -import com.lambda.commons.utils.MathUtils +import com.lambda.client.commons.utils.MathUtils import net.minecraft.client.Minecraft import net.minecraftforge.fml.common.gameevent.TickEvent import java.time.OffsetDateTime diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/FakePlayer.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/FakePlayer.kt index 114bd2a40..b98111178 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/FakePlayer.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/FakePlayer.kt @@ -11,7 +11,7 @@ import com.lambda.client.util.text.formatValue import com.lambda.client.util.threads.onMainThread import com.lambda.client.util.threads.onMainThreadSafe import com.lambda.client.util.threads.runSafeR -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import com.mojang.authlib.GameProfile import kotlinx.coroutines.runBlocking import net.minecraft.client.entity.EntityOtherPlayerMP diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/LogoutLogger.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/LogoutLogger.kt index d64f48d9c..7f33be3e3 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/LogoutLogger.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/LogoutLogger.kt @@ -12,7 +12,7 @@ import com.lambda.client.util.math.CoordinateConverter.asString import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.onMainThread import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.asyncListener +import com.lambda.client.event.listener.asyncListener import com.mojang.authlib.GameProfile import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.util.math.BlockPos diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/NoSoundLag.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/NoSoundLag.kt index 6b9404e7b..e3ff5c0b6 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/NoSoundLag.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/NoSoundLag.kt @@ -3,7 +3,7 @@ package com.lambda.client.module.modules.misc import com.lambda.client.event.events.PacketEvent import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.init.SoundEvents import net.minecraft.network.play.server.SPacketSoundEffect import net.minecraft.util.SoundCategory diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/NoteBot.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/NoteBot.kt index 1e68c176d..83e3ae3b9 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/NoteBot.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/NoteBot.kt @@ -14,7 +14,7 @@ import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.runSafeR import com.lambda.client.util.threads.safeListener import com.lambda.client.util.world.getMiningSide -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import net.minecraft.init.Blocks diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/PingSpoof.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/PingSpoof.kt index f1ae787cd..44d964199 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/PingSpoof.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/PingSpoof.kt @@ -5,7 +5,7 @@ import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.threads.defaultScope import com.lambda.client.util.threads.onMainThreadSafe -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import kotlinx.coroutines.delay import kotlinx.coroutines.launch import net.minecraft.network.play.client.CPacketKeepAlive diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/StashLogger.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/StashLogger.kt index 74425fa34..a0cf4ad7f 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/StashLogger.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/StashLogger.kt @@ -12,7 +12,7 @@ import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.defaultScope import com.lambda.client.util.threads.onMainThread import com.lambda.client.util.threads.safeListener -import com.lambda.commons.extension.synchronized +import com.lambda.client.commons.extension.synchronized import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch import net.minecraft.client.audio.PositionedSoundRecord diff --git a/src/main/kotlin/com/lambda/client/module/modules/misc/TeleportLogger.kt b/src/main/kotlin/com/lambda/client/module/modules/misc/TeleportLogger.kt index 99678fa5d..98aa7052f 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/misc/TeleportLogger.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/misc/TeleportLogger.kt @@ -6,7 +6,7 @@ import com.lambda.client.module.Module import com.lambda.client.util.EntityUtils.isFakeOrSelf import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener -import com.lambda.commons.utils.MathUtils +import com.lambda.client.commons.utils.MathUtils import net.minecraft.util.math.BlockPos import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/AutoWalk.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/AutoWalk.kt index ec9a8cdb1..9051e5607 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/AutoWalk.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/AutoWalk.kt @@ -14,9 +14,9 @@ import com.lambda.client.util.math.Direction import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener -import com.lambda.commons.extension.floorToInt -import com.lambda.commons.interfaces.DisplayEnum -import com.lambda.event.listener.listener +import com.lambda.client.commons.extension.floorToInt +import com.lambda.client.commons.interfaces.DisplayEnum +import com.lambda.client.event.listener.listener import net.minecraft.util.MovementInputFromOptions import net.minecraftforge.client.event.InputUpdateEvent import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt index 20e9f456b..9706180a6 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/ElytraFlight.kt @@ -18,7 +18,7 @@ import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener import com.lambda.client.util.world.getGroundPos import com.lambda.client.util.world.isLiquidBelow -import com.lambda.commons.extension.toRadian +import com.lambda.client.commons.extension.toRadian import net.minecraft.client.audio.PositionedSoundRecord import net.minecraft.init.Items import net.minecraft.init.SoundEvents diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Flight.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Flight.kt index b06a58b36..50b3cdc87 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Flight.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Flight.kt @@ -11,7 +11,7 @@ import com.lambda.client.util.MovementUtils import com.lambda.client.util.MovementUtils.calcMoveYaw import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.network.play.client.CPacketPlayer import net.minecraft.network.play.server.SPacketCloseWindow import kotlin.math.cos diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt index 1052a6890..03ac35c01 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Jesus.kt @@ -9,8 +9,8 @@ import com.lambda.client.module.Module import com.lambda.client.util.BaritoneUtils import com.lambda.client.util.EntityUtils import com.lambda.client.util.threads.safeListener -import com.lambda.commons.extension.ceilToInt -import com.lambda.commons.extension.floorToInt +import com.lambda.client.commons.extension.ceilToInt +import com.lambda.client.commons.extension.floorToInt import net.minecraft.block.Block import net.minecraft.block.BlockLiquid import net.minecraft.entity.Entity diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt index b90c65720..ccca34a34 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt @@ -13,7 +13,7 @@ import com.lambda.client.util.EntityUtils.isInOrAboveLiquid import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.network.play.client.CPacketPlayer import net.minecraftforge.fml.common.gameevent.InputEvent import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/AutoEat.kt b/src/main/kotlin/com/lambda/client/module/modules/player/AutoEat.kt index 2e95aa527..daa9fbcdd 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/AutoEat.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/AutoEat.kt @@ -9,7 +9,7 @@ import com.lambda.client.util.combat.CombatUtils.scaledHealth import com.lambda.client.util.items.* import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener -import com.lambda.commons.extension.next +import com.lambda.client.commons.extension.next import net.minecraft.init.Items import net.minecraft.init.MobEffects import net.minecraft.inventory.Slot diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Blink.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Blink.kt index 2a2990e00..dea7b8737 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Blink.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Blink.kt @@ -10,7 +10,7 @@ import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.network.play.client.CPacketPlayer import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/FastUse.kt b/src/main/kotlin/com/lambda/client/module/modules/player/FastUse.kt index 166dd5826..dd2ef92c9 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/FastUse.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/FastUse.kt @@ -5,7 +5,7 @@ import com.lambda.client.mixin.extension.rightClickDelayTimer import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.init.Items import net.minecraft.item.* import net.minecraft.network.play.client.CPacketPlayerDigging diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Freecam.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Freecam.kt index 816b22a85..6aede2466 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Freecam.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Freecam.kt @@ -18,10 +18,10 @@ import com.lambda.client.util.math.RotationUtils.getRotationTo import com.lambda.client.util.threads.onMainThreadSafe import com.lambda.client.util.threads.runSafeR import com.lambda.client.util.threads.safeListener -import com.lambda.commons.extension.floorToInt -import com.lambda.commons.extension.toRadian -import com.lambda.commons.interfaces.DisplayEnum -import com.lambda.event.listener.listener +import com.lambda.client.commons.extension.floorToInt +import com.lambda.client.commons.extension.toRadian +import com.lambda.client.commons.interfaces.DisplayEnum +import com.lambda.client.event.listener.listener import kotlinx.coroutines.runBlocking import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.client.entity.EntityPlayerSP diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/InventoryManager.kt b/src/main/kotlin/com/lambda/client/module/modules/player/InventoryManager.kt index 564bb0736..8eb2c432d 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/InventoryManager.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/InventoryManager.kt @@ -12,7 +12,7 @@ import com.lambda.client.util.TickTimer import com.lambda.client.util.TimeUnit import com.lambda.client.util.items.* import com.lambda.client.util.threads.safeListener -import com.lambda.commons.extension.ceilToInt +import com.lambda.client.commons.extension.ceilToInt import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.inventory.Slot import net.minecraft.item.ItemStack diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/LagNotifier.kt b/src/main/kotlin/com/lambda/client/module/modules/player/LagNotifier.kt index ab08bd1f6..96d2cd3f4 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/LagNotifier.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/LagNotifier.kt @@ -14,8 +14,8 @@ import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.Vec2f import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.safeListener -import com.lambda.commons.utils.MathUtils -import com.lambda.event.listener.listener +import com.lambda.client.commons.utils.MathUtils +import com.lambda.client.event.listener.listener import net.minecraft.client.gui.ScaledResolution import net.minecraft.network.play.server.SPacketPlayerPosLook import net.minecraft.util.math.Vec3d diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/NoSwing.kt b/src/main/kotlin/com/lambda/client/module/modules/player/NoSwing.kt index d118b42d2..8d2a1f2e9 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/NoSwing.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/NoSwing.kt @@ -4,7 +4,7 @@ import com.lambda.client.event.events.PacketEvent import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.network.play.client.CPacketAnimation import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/PacketCancel.kt b/src/main/kotlin/com/lambda/client/module/modules/player/PacketCancel.kt index 614481766..7dcaa791d 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/PacketCancel.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/PacketCancel.kt @@ -3,7 +3,7 @@ package com.lambda.client.module.modules.player import com.lambda.client.event.events.PacketEvent import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.network.login.client.CPacketEncryptionResponse import net.minecraft.network.login.client.CPacketLoginStart import net.minecraft.network.login.server.SPacketEnableCompression diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/PacketLimiter.kt b/src/main/kotlin/com/lambda/client/module/modules/player/PacketLimiter.kt index 1014420f9..fdcecdb56 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/PacketLimiter.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/PacketLimiter.kt @@ -6,7 +6,7 @@ import com.lambda.client.manager.managers.TimerManager.modifyTimer import com.lambda.client.manager.managers.TimerManager.resetTimer import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.network.play.client.CPacketPlayer import net.minecraftforge.fml.common.gameevent.TickEvent import kotlin.math.min diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt b/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt index ff4e58052..c3208e7a5 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/PacketLogger.kt @@ -13,8 +13,8 @@ import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.defaultScope import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener -import com.lambda.commons.interfaces.DisplayEnum -import com.lambda.event.listener.listener +import com.lambda.client.commons.interfaces.DisplayEnum +import com.lambda.client.event.listener.listener import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import net.minecraft.network.Packet diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/PortalGodMode.kt b/src/main/kotlin/com/lambda/client/module/modules/player/PortalGodMode.kt index b41506642..ed537e114 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/PortalGodMode.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/PortalGodMode.kt @@ -4,7 +4,7 @@ import com.lambda.client.event.events.PacketEvent import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.threads.runSafe -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.network.play.client.CPacketConfirmTeleport object PortalGodMode : Module( diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index d0c4d02ea..cb09471a9 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -26,7 +26,7 @@ import com.lambda.client.util.threads.safeListener import com.lambda.client.util.world.PlaceInfo import com.lambda.client.util.world.getNeighbour import com.lambda.client.util.world.placeBlock -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.item.ItemBlock import net.minecraft.network.play.client.CPacketEntityAction import net.minecraft.network.play.server.SPacketPlayerPosLook diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt index 72241d753..e00a7484b 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Timer.kt @@ -4,7 +4,7 @@ import com.lambda.client.manager.managers.TimerManager.modifyTimer import com.lambda.client.manager.managers.TimerManager.resetTimer import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraftforge.fml.common.gameevent.TickEvent object Timer : Module( diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/XCarry.kt b/src/main/kotlin/com/lambda/client/module/modules/player/XCarry.kt index d8db4bf4c..3bfb4bda8 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/XCarry.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/XCarry.kt @@ -4,7 +4,7 @@ import com.lambda.client.event.events.PacketEvent import com.lambda.client.mixin.extension.windowID import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.network.play.client.CPacketCloseWindow object XCarry : Module( diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/BossStack.kt b/src/main/kotlin/com/lambda/client/module/modules/render/BossStack.kt index 08556b65e..634e89206 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/BossStack.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/BossStack.kt @@ -6,7 +6,7 @@ import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.TickTimer import com.lambda.client.util.graphics.GlStateUtils -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.client.gui.BossInfoClient import net.minecraft.client.gui.ScaledResolution import net.minecraft.client.renderer.GlStateManager diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/Breadcrumbs.kt b/src/main/kotlin/com/lambda/client/module/modules/render/Breadcrumbs.kt index feda425b0..3d4f2ff50 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/Breadcrumbs.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/Breadcrumbs.kt @@ -11,7 +11,7 @@ import com.lambda.client.util.graphics.LambdaTessellator import com.lambda.client.util.math.VectorUtils.distanceTo import com.lambda.client.util.text.MessageSendHelper.sendChatMessage import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.client.renderer.GlStateManager import net.minecraft.util.math.Vec3d import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/BreakingESP.kt b/src/main/kotlin/com/lambda/client/module/modules/render/BreakingESP.kt index fac5ea607..55e8ed609 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/BreakingESP.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/BreakingESP.kt @@ -11,7 +11,7 @@ import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.math.VectorUtils.distanceTo import com.lambda.client.util.text.MessageSendHelper.sendChatMessage import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.client.audio.PositionedSoundRecord import net.minecraft.client.gui.ScaledResolution import net.minecraft.init.Blocks diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/ContainerPreview.kt b/src/main/kotlin/com/lambda/client/module/modules/render/ContainerPreview.kt index bbad17e9e..d15d12514 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/ContainerPreview.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/ContainerPreview.kt @@ -9,7 +9,7 @@ import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.graphics.font.FontRenderAdapter import com.lambda.client.util.items.block import com.lambda.client.util.math.Vec2d -import com.lambda.commons.extension.ceilToInt +import com.lambda.client.commons.extension.ceilToInt import net.minecraft.client.renderer.GlStateManager import net.minecraft.init.Blocks import net.minecraft.inventory.IInventory diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/ESP.kt b/src/main/kotlin/com/lambda/client/module/modules/render/ESP.kt index 5e63a55a8..650814c4e 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/ESP.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/ESP.kt @@ -16,7 +16,7 @@ import com.lambda.client.util.graphics.LambdaTessellator import com.lambda.client.util.graphics.ShaderHelper import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.shader.Shader import net.minecraft.entity.Entity diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/EyeFinder.kt b/src/main/kotlin/com/lambda/client/module/modules/render/EyeFinder.kt index e3add0fa0..d9516e474 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/EyeFinder.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/EyeFinder.kt @@ -9,7 +9,7 @@ import com.lambda.client.util.color.ColorHolder import com.lambda.client.util.graphics.ESPRenderer import com.lambda.client.util.graphics.LambdaTessellator import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.client.Minecraft import net.minecraft.client.renderer.GlStateManager import net.minecraft.entity.Entity diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/HungerOverlay.kt b/src/main/kotlin/com/lambda/client/module/modules/render/HungerOverlay.kt index f3e77e1df..8bf8616fa 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/HungerOverlay.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/HungerOverlay.kt @@ -6,7 +6,7 @@ import com.lambda.client.util.graphics.GlStateUtils import com.lambda.client.util.items.foodValue import com.lambda.client.util.items.saturation import com.lambda.client.util.threads.safeListener -import com.lambda.commons.extension.ceilToInt +import com.lambda.client.commons.extension.ceilToInt import net.minecraft.client.gui.Gui import net.minecraft.client.gui.ScaledResolution import net.minecraft.init.MobEffects diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/MobOwner.kt b/src/main/kotlin/com/lambda/client/module/modules/render/MobOwner.kt index b006602b8..bd3d508f5 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/MobOwner.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/MobOwner.kt @@ -5,7 +5,7 @@ import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener -import com.lambda.commons.utils.MathUtils.round +import com.lambda.client.commons.utils.MathUtils.round import net.minecraft.entity.passive.AbstractHorse import net.minecraft.entity.passive.EntityTameable import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/Nametags.kt b/src/main/kotlin/com/lambda/client/module/modules/render/Nametags.kt index bfd7b5b15..4eabb7ce2 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/Nametags.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/Nametags.kt @@ -16,10 +16,10 @@ import com.lambda.client.util.graphics.font.* import com.lambda.client.util.items.originalName import com.lambda.client.util.math.Vec2d import com.lambda.client.util.threads.safeListener -import com.lambda.commons.extension.ceilToInt -import com.lambda.commons.extension.floorToInt -import com.lambda.commons.utils.MathUtils -import com.lambda.event.listener.listener +import com.lambda.client.commons.extension.ceilToInt +import com.lambda.client.commons.extension.floorToInt +import com.lambda.client.commons.utils.MathUtils +import com.lambda.client.event.listener.listener import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.client.renderer.RenderHelper import net.minecraft.entity.Entity diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt index 77c479def..a8641d4a2 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/NewChunks.kt @@ -19,7 +19,7 @@ import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.onMainThread import com.lambda.client.util.threads.safeAsyncListener import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.asyncListener +import com.lambda.client.event.listener.asyncListener import kotlinx.coroutines.runBlocking import net.minecraft.client.renderer.vertex.DefaultVertexFormats import net.minecraft.network.play.server.SPacketChunkData diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/NoRender.kt b/src/main/kotlin/com/lambda/client/module/modules/render/NoRender.kt index ded45c118..ab34d7d53 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/NoRender.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/NoRender.kt @@ -7,7 +7,7 @@ import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.block.BlockSnow import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.client.particle.Particle diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/StorageESP.kt b/src/main/kotlin/com/lambda/client/module/modules/render/StorageESP.kt index 966c5f0e3..64aa28bb0 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/StorageESP.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/StorageESP.kt @@ -10,7 +10,7 @@ import com.lambda.client.util.color.HueCycler import com.lambda.client.util.graphics.ESPRenderer import com.lambda.client.util.graphics.GeometryMasks import com.lambda.client.util.threads.safeAsyncListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/Tracers.kt b/src/main/kotlin/com/lambda/client/module/modules/render/Tracers.kt index ecdbd5ee1..8b637575c 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/Tracers.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/Tracers.kt @@ -11,8 +11,8 @@ import com.lambda.client.util.color.ColorHolder import com.lambda.client.util.color.HueCycler import com.lambda.client.util.graphics.ESPRenderer import com.lambda.client.util.threads.safeListener -import com.lambda.commons.utils.MathUtils.convertRange -import com.lambda.event.listener.listener +import com.lambda.client.commons.utils.MathUtils.convertRange +import com.lambda.client.event.listener.listener import net.minecraft.entity.Entity import net.minecraft.entity.player.EntityPlayer import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/WaypointRender.kt b/src/main/kotlin/com/lambda/client/module/modules/render/WaypointRender.kt index 3585c8134..78ab844b1 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/WaypointRender.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/WaypointRender.kt @@ -16,7 +16,7 @@ import com.lambda.client.util.math.Vec2d import com.lambda.client.util.math.VectorUtils.distanceTo import com.lambda.client.util.math.VectorUtils.toVec3dCenter import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.util.math.AxisAlignedBB import net.minecraft.util.math.BlockPos import net.minecraftforge.fml.common.gameevent.TickEvent diff --git a/src/main/kotlin/com/lambda/client/plugin/PluginError.kt b/src/main/kotlin/com/lambda/client/plugin/PluginError.kt index 6fa37cca6..995099e3c 100644 --- a/src/main/kotlin/com/lambda/client/plugin/PluginError.kt +++ b/src/main/kotlin/com/lambda/client/plugin/PluginError.kt @@ -1,54 +1,57 @@ package com.lambda.client.plugin import com.lambda.client.LambdaMod -import com.lambda.client.util.text.MessageSendHelper +import com.lambda.client.manager.managers.NotificationManager +import java.io.File internal enum class PluginError { HOT_RELOAD, DUPLICATE, UNSUPPORTED, - REQUIRED_PLUGIN; - - fun handleError(loader: PluginLoader) { - val list = latestErrors ?: ArrayList>().also { latestErrors = it } - - if (latestErrors?.none { it.first.file.name == loader.file.name && it.second == this } == true) { - list.add(loader to this) - - when (this) { - HOT_RELOAD -> { - log("Plugin $loader cannot be hot reloaded.") - } - DUPLICATE -> { - log("Duplicate plugin ${loader}.") - } - UNSUPPORTED -> { - log("Unsupported plugin ${loader}. Minimum required Lambda version: ${loader.info.minApiVersion}") - } - REQUIRED_PLUGIN -> { - log("Missing required plugin for ${loader}. Required plugins: ${loader.info.requiredPlugins.joinToString()}") - } + REQUIRED_PLUGIN, + OUTDATED_PLUGIN, + CLASS_NOT_FOUND, + ILLEGAL_ACCESS, + MISSING_DEFINITION, + OTHERS; + + fun handleError(loader: PluginLoader, message: String? = null, throwable: Throwable? = null) { + when (this) { + HOT_RELOAD -> { + log("Plugin $loader cannot be hot reloaded.") + } + DUPLICATE -> { + log("Duplicate plugin $loader.") + } + UNSUPPORTED -> { + log("Unsupported plugin $loader. Minimum required Lambda version: ${loader.info.minApiVersion}") + } + REQUIRED_PLUGIN -> { + log("Missing required plugin for $loader. Required plugins: ${loader.info.requiredPlugins.joinToString()}") + } + OUTDATED_PLUGIN -> { + log("The in $loader used Lambda API is outdated. Please update the plugin or notify the developer ${loader.info.authors.joinToString()}") + } + CLASS_NOT_FOUND -> { + log("Main class not found", throwable) + } + ILLEGAL_ACCESS -> { + log("Illegal access violation", throwable) + } + MISSING_DEFINITION -> { + log("Missing definition. Please make sure compatible Lambda API is used.", throwable) + } + OTHERS -> { + log(message, throwable) } } - } - companion object { - private var latestErrors: ArrayList>? = null + loader.file.renameTo(File("${loader.file.path}.disabled")) + } - fun log(message: String?, shouldChat: Boolean = true, throwable: Throwable? = null) { - message?.let { - // DO NOT ACCESS MINECRAFT IN COREMODSPACE - if (shouldChat) { - MessageSendHelper.sendErrorMessage("[Plugin Manager] $it") - } + fun log(message: String?, throwable: Throwable? = null) { + message?.let { NotificationManager.registerNotification("[Plugin Manager] Failed to load plugin. $it") } - if (throwable != null) { - LambdaMod.LOG.error(message, throwable) - } else { - LambdaMod.LOG.error(message) - } - } - } + LambdaMod.LOG.error(message, throwable) } - } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/plugin/PluginInfo.kt b/src/main/kotlin/com/lambda/client/plugin/PluginInfo.kt index 7958db438..5e3ddae1b 100644 --- a/src/main/kotlin/com/lambda/client/plugin/PluginInfo.kt +++ b/src/main/kotlin/com/lambda/client/plugin/PluginInfo.kt @@ -3,7 +3,7 @@ package com.lambda.client.plugin import com.google.gson.Gson import com.google.gson.annotations.SerializedName import com.lambda.client.plugin.api.Plugin -import com.lambda.commons.interfaces.Nameable +import com.lambda.client.commons.interfaces.Nameable import java.io.InputStream class PluginInfo private constructor( diff --git a/src/main/kotlin/com/lambda/client/plugin/PluginLoader.kt b/src/main/kotlin/com/lambda/client/plugin/PluginLoader.kt index 0dbc91c80..b2830270e 100644 --- a/src/main/kotlin/com/lambda/client/plugin/PluginLoader.kt +++ b/src/main/kotlin/com/lambda/client/plugin/PluginLoader.kt @@ -4,8 +4,8 @@ import com.google.gson.Gson import com.google.gson.reflect.TypeToken import com.lambda.client.LambdaMod import com.lambda.client.plugin.api.Plugin -import com.lambda.commons.interfaces.Nameable -import com.lambda.commons.utils.ClassUtils.instance +import com.lambda.client.commons.interfaces.Nameable +import com.lambda.client.commons.utils.ClassUtils.instance import net.minecraft.launchwrapper.Launch import java.io.File import java.io.FileNotFoundException diff --git a/src/main/kotlin/com/lambda/client/plugin/PluginManager.kt b/src/main/kotlin/com/lambda/client/plugin/PluginManager.kt index 065208cee..547d08639 100644 --- a/src/main/kotlin/com/lambda/client/plugin/PluginManager.kt +++ b/src/main/kotlin/com/lambda/client/plugin/PluginManager.kt @@ -7,7 +7,7 @@ import com.lambda.client.gui.clickgui.component.PluginButton import com.lambda.client.plugin.api.Plugin import com.lambda.client.util.FolderUtils import com.lambda.client.util.text.MessageSendHelper -import com.lambda.commons.collections.NameableSet +import com.lambda.client.commons.collections.NameableSet import kotlinx.coroutines.Deferred import net.minecraft.util.text.TextFormatting import org.apache.maven.artifact.versioning.DefaultArtifactVersion @@ -160,29 +160,32 @@ internal object PluginManager : AsyncLoader> { val plugin = runCatching(loader::load).getOrElse { when (it) { is ClassNotFoundException -> { - PluginError.log("Main class not found in plugin $loader", throwable = it) + PluginError.CLASS_NOT_FOUND.handleError(loader, throwable = it) } is IllegalAccessException -> { - PluginError.log(it.message, throwable = it) + PluginError.ILLEGAL_ACCESS.handleError(loader, throwable = it) } else -> { - PluginError.log("Failed to load plugin $loader", throwable = it) + PluginError.OTHERS.handleError(loader, throwable = it) } } return } - val hotReload = plugin.mixins.isEmpty() try { plugin.onLoad() } catch (e: NoSuchFieldError) { - PluginError.log("Failed to load plugin $loader (NoSuchFieldError)", hotReload, e) + PluginError.MISSING_DEFINITION.handleError(loader, throwable = e) return } catch (e: NoSuchMethodError) { - PluginError.log("Failed to load plugin $loader (NoSuchMethodError)", hotReload, e) + if (e.message?.contains("getModules()Lcom") == true) { + PluginError.OUTDATED_PLUGIN.handleError(loader) + } else { + PluginError.MISSING_DEFINITION.handleError(loader, throwable = e) + } return } catch (e: NoClassDefFoundError) { - PluginError.log("Failed to load plugin $loader (NoClassDefFoundError)", hotReload, e) + PluginError.MISSING_DEFINITION.handleError(loader, throwable = e) return } @@ -210,7 +213,7 @@ internal object PluginManager : AsyncLoader> { fun unload(plugin: Plugin): Boolean { if (loadedPlugins.any { it.requiredPlugins.contains(plugin.name) }) { - throw IllegalArgumentException("Plugin $plugin is required by another plugin!") + MessageSendHelper.sendErrorMessage("Plugin ${plugin.name} is required by another plugin!") } return unloadWithoutCheck(plugin) @@ -219,7 +222,7 @@ internal object PluginManager : AsyncLoader> { private fun unloadWithoutCheck(plugin: Plugin): Boolean { // Necessary because of plugin GUI if (plugin.mixins.isNotEmpty()) { - PluginError.log("Plugin ${plugin.name} cannot be hot reloaded!") + MessageSendHelper.sendErrorMessage("Plugin ${plugin.name} cannot be hot reloaded because of contained mixins.") return false } diff --git a/src/main/kotlin/com/lambda/client/plugin/api/IPluginClass.kt b/src/main/kotlin/com/lambda/client/plugin/api/IPluginClass.kt index dca612603..17b4f95a8 100644 --- a/src/main/kotlin/com/lambda/client/plugin/api/IPluginClass.kt +++ b/src/main/kotlin/com/lambda/client/plugin/api/IPluginClass.kt @@ -1,6 +1,6 @@ package com.lambda.client.plugin.api -import com.lambda.commons.interfaces.Nameable +import com.lambda.client.commons.interfaces.Nameable interface IPluginClass : Nameable { val pluginMain: Plugin diff --git a/src/main/kotlin/com/lambda/client/plugin/api/Plugin.kt b/src/main/kotlin/com/lambda/client/plugin/api/Plugin.kt index af08c7dda..b5fdf9244 100644 --- a/src/main/kotlin/com/lambda/client/plugin/api/Plugin.kt +++ b/src/main/kotlin/com/lambda/client/plugin/api/Plugin.kt @@ -11,9 +11,9 @@ import com.lambda.client.setting.ConfigManager import com.lambda.client.setting.configs.PluginConfig import com.lambda.client.util.threads.BackgroundJob import com.lambda.client.util.threads.BackgroundScope -import com.lambda.commons.collections.CloseableList -import com.lambda.commons.interfaces.Nameable -import com.lambda.event.ListenerManager +import com.lambda.client.commons.collections.CloseableList +import com.lambda.client.commons.interfaces.Nameable +import com.lambda.client.event.ListenerManager /** * A plugin. All plugin main classes must extend this class. diff --git a/src/main/kotlin/com/lambda/client/setting/ConfigManager.kt b/src/main/kotlin/com/lambda/client/setting/ConfigManager.kt index 4da3a2cca..a9d448315 100644 --- a/src/main/kotlin/com/lambda/client/setting/ConfigManager.kt +++ b/src/main/kotlin/com/lambda/client/setting/ConfigManager.kt @@ -2,7 +2,7 @@ package com.lambda.client.setting import com.lambda.client.LambdaMod import com.lambda.client.setting.configs.IConfig -import com.lambda.commons.collections.NameableSet +import com.lambda.client.commons.collections.NameableSet internal object ConfigManager { private val configSet = NameableSet() diff --git a/src/main/kotlin/com/lambda/client/setting/GenericConfigClass.kt b/src/main/kotlin/com/lambda/client/setting/GenericConfigClass.kt index f56c0d45a..88e662d30 100644 --- a/src/main/kotlin/com/lambda/client/setting/GenericConfigClass.kt +++ b/src/main/kotlin/com/lambda/client/setting/GenericConfigClass.kt @@ -1,5 +1,5 @@ package com.lambda.client.setting -import com.lambda.commons.interfaces.Nameable +import com.lambda.client.commons.interfaces.Nameable interface GenericConfigClass : Nameable \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/client/setting/configs/IConfig.kt b/src/main/kotlin/com/lambda/client/setting/configs/IConfig.kt index de49dbaff..5813b6c5a 100644 --- a/src/main/kotlin/com/lambda/client/setting/configs/IConfig.kt +++ b/src/main/kotlin/com/lambda/client/setting/configs/IConfig.kt @@ -1,6 +1,6 @@ package com.lambda.client.setting.configs -import com.lambda.commons.interfaces.Nameable +import com.lambda.client.commons.interfaces.Nameable import java.io.File /** diff --git a/src/main/kotlin/com/lambda/client/setting/configs/NameableConfig.kt b/src/main/kotlin/com/lambda/client/setting/configs/NameableConfig.kt index 508c34b9c..952653e29 100644 --- a/src/main/kotlin/com/lambda/client/setting/configs/NameableConfig.kt +++ b/src/main/kotlin/com/lambda/client/setting/configs/NameableConfig.kt @@ -1,7 +1,7 @@ package com.lambda.client.setting.configs import com.lambda.client.setting.settings.AbstractSetting -import com.lambda.commons.interfaces.Nameable +import com.lambda.client.commons.interfaces.Nameable open class NameableConfig( name: String, diff --git a/src/main/kotlin/com/lambda/client/setting/groups/SettingGroup.kt b/src/main/kotlin/com/lambda/client/setting/groups/SettingGroup.kt index f339f32fa..8fe54a84a 100644 --- a/src/main/kotlin/com/lambda/client/setting/groups/SettingGroup.kt +++ b/src/main/kotlin/com/lambda/client/setting/groups/SettingGroup.kt @@ -4,7 +4,7 @@ import com.google.gson.JsonObject import com.google.gson.JsonPrimitive import com.lambda.client.LambdaMod import com.lambda.client.setting.settings.AbstractSetting -import com.lambda.commons.interfaces.Nameable +import com.lambda.client.commons.interfaces.Nameable open class SettingGroup( override val name: String diff --git a/src/main/kotlin/com/lambda/client/setting/settings/AbstractSetting.kt b/src/main/kotlin/com/lambda/client/setting/settings/AbstractSetting.kt index 90a384709..cfae8629e 100644 --- a/src/main/kotlin/com/lambda/client/setting/settings/AbstractSetting.kt +++ b/src/main/kotlin/com/lambda/client/setting/settings/AbstractSetting.kt @@ -4,7 +4,7 @@ import com.google.gson.Gson import com.google.gson.GsonBuilder import com.google.gson.JsonElement import com.google.gson.JsonParser -import com.lambda.commons.interfaces.Nameable +import com.lambda.client.commons.interfaces.Nameable import kotlin.reflect.KProperty abstract class AbstractSetting : Nameable { diff --git a/src/main/kotlin/com/lambda/client/setting/settings/impl/primitive/EnumSetting.kt b/src/main/kotlin/com/lambda/client/setting/settings/impl/primitive/EnumSetting.kt index 09efd2de8..e525c44fe 100644 --- a/src/main/kotlin/com/lambda/client/setting/settings/impl/primitive/EnumSetting.kt +++ b/src/main/kotlin/com/lambda/client/setting/settings/impl/primitive/EnumSetting.kt @@ -3,7 +3,7 @@ package com.lambda.client.setting.settings.impl.primitive import com.google.gson.JsonElement import com.google.gson.JsonPrimitive import com.lambda.client.setting.settings.MutableSetting -import com.lambda.commons.extension.next +import com.lambda.client.commons.extension.next class EnumSetting>( name: String, diff --git a/src/main/kotlin/com/lambda/client/util/EntityUtils.kt b/src/main/kotlin/com/lambda/client/util/EntityUtils.kt index e74517cd4..e935e7415 100644 --- a/src/main/kotlin/com/lambda/client/util/EntityUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/EntityUtils.kt @@ -5,8 +5,8 @@ import com.lambda.client.manager.managers.FriendManager import com.lambda.client.util.MovementUtils.calcMoveYaw import com.lambda.client.util.items.id import com.lambda.client.util.math.VectorUtils.toBlockPos -import com.lambda.commons.extension.ceilToInt -import com.lambda.commons.extension.floorToInt +import com.lambda.client.commons.extension.ceilToInt +import com.lambda.client.commons.extension.floorToInt import net.minecraft.block.BlockLiquid import net.minecraft.client.Minecraft import net.minecraft.entity.Entity diff --git a/src/main/kotlin/com/lambda/client/util/TpsCalculator.kt b/src/main/kotlin/com/lambda/client/util/TpsCalculator.kt index fd886ad2e..2adee8e07 100644 --- a/src/main/kotlin/com/lambda/client/util/TpsCalculator.kt +++ b/src/main/kotlin/com/lambda/client/util/TpsCalculator.kt @@ -4,7 +4,7 @@ import com.lambda.client.event.LambdaEventBus import com.lambda.client.event.events.ConnectionEvent import com.lambda.client.event.events.PacketEvent import com.lambda.client.util.CircularArray.Companion.average -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.network.play.server.SPacketTimeUpdate object TpsCalculator { diff --git a/src/main/kotlin/com/lambda/client/util/WebUtils.kt b/src/main/kotlin/com/lambda/client/util/WebUtils.kt index 0cea5e444..4d7ac6cde 100644 --- a/src/main/kotlin/com/lambda/client/util/WebUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/WebUtils.kt @@ -3,7 +3,7 @@ package com.lambda.client.util import com.google.gson.JsonParser import com.lambda.client.LambdaMod import com.lambda.client.util.threads.mainScope -import com.lambda.commons.utils.ConnectionUtils +import com.lambda.client.commons.utils.ConnectionUtils import kotlinx.coroutines.launch import org.apache.maven.artifact.versioning.DefaultArtifactVersion import java.awt.Desktop diff --git a/src/main/kotlin/com/lambda/client/util/color/ColorGradient.kt b/src/main/kotlin/com/lambda/client/util/color/ColorGradient.kt index 388020a8e..12251d637 100644 --- a/src/main/kotlin/com/lambda/client/util/color/ColorGradient.kt +++ b/src/main/kotlin/com/lambda/client/util/color/ColorGradient.kt @@ -1,6 +1,6 @@ package com.lambda.client.util.color -import com.lambda.commons.utils.MathUtils +import com.lambda.client.commons.utils.MathUtils import kotlin.math.max import kotlin.math.roundToInt diff --git a/src/main/kotlin/com/lambda/client/util/combat/CombatUtils.kt b/src/main/kotlin/com/lambda/client/util/combat/CombatUtils.kt index f54819e30..37b822f8b 100644 --- a/src/main/kotlin/com/lambda/client/util/combat/CombatUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/combat/CombatUtils.kt @@ -8,7 +8,7 @@ import com.lambda.client.util.items.filterByStack import com.lambda.client.util.items.hotbarSlots import com.lambda.client.util.items.swapToSlot import com.lambda.client.util.threads.safeListener -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.enchantment.Enchantment import net.minecraft.enchantment.EnchantmentHelper import net.minecraft.entity.EntityLivingBase diff --git a/src/main/kotlin/com/lambda/client/util/graphics/AnimationUtils.kt b/src/main/kotlin/com/lambda/client/util/graphics/AnimationUtils.kt index a5725d73b..978971ca7 100644 --- a/src/main/kotlin/com/lambda/client/util/graphics/AnimationUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/graphics/AnimationUtils.kt @@ -1,6 +1,6 @@ package com.lambda.client.util.graphics -import com.lambda.commons.utils.MathUtils +import com.lambda.client.commons.utils.MathUtils import kotlin.math.* object AnimationUtils { diff --git a/src/main/kotlin/com/lambda/client/util/graphics/RenderUtils2D.kt b/src/main/kotlin/com/lambda/client/util/graphics/RenderUtils2D.kt index 23ff8ef12..721043d26 100644 --- a/src/main/kotlin/com/lambda/client/util/graphics/RenderUtils2D.kt +++ b/src/main/kotlin/com/lambda/client/util/graphics/RenderUtils2D.kt @@ -3,7 +3,7 @@ package com.lambda.client.util.graphics import com.lambda.client.util.Wrapper import com.lambda.client.util.color.ColorHolder import com.lambda.client.util.math.Vec2d -import com.lambda.commons.utils.MathUtils +import com.lambda.client.commons.utils.MathUtils import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.RenderHelper import net.minecraft.item.ItemStack diff --git a/src/main/kotlin/com/lambda/client/util/graphics/ShaderHelper.kt b/src/main/kotlin/com/lambda/client/util/graphics/ShaderHelper.kt index 27bace79f..35b87df64 100644 --- a/src/main/kotlin/com/lambda/client/util/graphics/ShaderHelper.kt +++ b/src/main/kotlin/com/lambda/client/util/graphics/ShaderHelper.kt @@ -4,7 +4,7 @@ import com.lambda.client.LambdaMod import com.lambda.client.event.LambdaEventBus import com.lambda.client.event.events.ResolutionUpdateEvent import com.lambda.client.util.Wrapper -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.OpenGlHelper import net.minecraft.client.shader.Framebuffer diff --git a/src/main/kotlin/com/lambda/client/util/graphics/font/Alignment.kt b/src/main/kotlin/com/lambda/client/util/graphics/font/Alignment.kt index 1d56e03f2..203bf48cf 100644 --- a/src/main/kotlin/com/lambda/client/util/graphics/font/Alignment.kt +++ b/src/main/kotlin/com/lambda/client/util/graphics/font/Alignment.kt @@ -1,6 +1,6 @@ package com.lambda.client.util.graphics.font -import com.lambda.commons.interfaces.DisplayEnum +import com.lambda.client.commons.interfaces.DisplayEnum enum class HAlign(override val displayName: String, val multiplier: Float, val offset: Float) : DisplayEnum { LEFT("Left", 0.0f, -1.0f), diff --git a/src/main/kotlin/com/lambda/client/util/graphics/font/FontGlyphs.kt b/src/main/kotlin/com/lambda/client/util/graphics/font/FontGlyphs.kt index 5fcc62452..345fc6934 100644 --- a/src/main/kotlin/com/lambda/client/util/graphics/font/FontGlyphs.kt +++ b/src/main/kotlin/com/lambda/client/util/graphics/font/FontGlyphs.kt @@ -2,7 +2,7 @@ package com.lambda.client.util.graphics.font import com.lambda.client.LambdaMod import com.lambda.client.util.graphics.texture.MipmapTexture -import com.lambda.commons.utils.MathUtils +import com.lambda.client.commons.utils.MathUtils import org.lwjgl.opengl.GL11.* import org.lwjgl.opengl.GL12.GL_CLAMP_TO_EDGE import org.lwjgl.opengl.GL14.GL_TEXTURE_LOD_BIAS diff --git a/src/main/kotlin/com/lambda/client/util/math/Direction.kt b/src/main/kotlin/com/lambda/client/util/math/Direction.kt index c7c91298c..d25a41b7b 100644 --- a/src/main/kotlin/com/lambda/client/util/math/Direction.kt +++ b/src/main/kotlin/com/lambda/client/util/math/Direction.kt @@ -1,6 +1,6 @@ package com.lambda.client.util.math -import com.lambda.commons.interfaces.DisplayEnum +import com.lambda.client.commons.interfaces.DisplayEnum import net.minecraft.entity.Entity import net.minecraft.util.EnumFacing import net.minecraft.util.math.Vec3i diff --git a/src/main/kotlin/com/lambda/client/util/math/RotationUtils.kt b/src/main/kotlin/com/lambda/client/util/math/RotationUtils.kt index dd405bfac..899cfd177 100644 --- a/src/main/kotlin/com/lambda/client/util/math/RotationUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/math/RotationUtils.kt @@ -1,7 +1,7 @@ package com.lambda.client.util.math import com.lambda.client.event.SafeClientEvent -import com.lambda.commons.extension.toDegree +import com.lambda.client.commons.extension.toDegree import net.minecraft.entity.Entity import net.minecraft.util.math.Vec3d import kotlin.math.* diff --git a/src/main/kotlin/com/lambda/client/util/math/Vec2d.kt b/src/main/kotlin/com/lambda/client/util/math/Vec2d.kt index 99df5269b..fbf4eb6af 100644 --- a/src/main/kotlin/com/lambda/client/util/math/Vec2d.kt +++ b/src/main/kotlin/com/lambda/client/util/math/Vec2d.kt @@ -1,6 +1,6 @@ package com.lambda.client.util.math -import com.lambda.commons.extension.toRadian +import com.lambda.client.commons.extension.toRadian import net.minecraft.util.math.Vec3d import kotlin.math.hypot import kotlin.math.pow diff --git a/src/main/kotlin/com/lambda/client/util/math/Vec2f.kt b/src/main/kotlin/com/lambda/client/util/math/Vec2f.kt index 7263db7f4..1d2e798ab 100644 --- a/src/main/kotlin/com/lambda/client/util/math/Vec2f.kt +++ b/src/main/kotlin/com/lambda/client/util/math/Vec2f.kt @@ -1,6 +1,6 @@ package com.lambda.client.util.math -import com.lambda.commons.extension.toRadian +import com.lambda.client.commons.extension.toRadian import net.minecraft.entity.Entity import kotlin.math.hypot import kotlin.math.pow diff --git a/src/main/kotlin/com/lambda/client/util/math/VectorUtils.kt b/src/main/kotlin/com/lambda/client/util/math/VectorUtils.kt index 53d2eee13..ecf8cba9b 100644 --- a/src/main/kotlin/com/lambda/client/util/math/VectorUtils.kt +++ b/src/main/kotlin/com/lambda/client/util/math/VectorUtils.kt @@ -1,8 +1,8 @@ package com.lambda.client.util.math -import com.lambda.commons.extension.PI_FLOAT -import com.lambda.commons.extension.ceilToInt -import com.lambda.commons.extension.floorToInt +import com.lambda.client.commons.extension.PI_FLOAT +import com.lambda.client.commons.extension.ceilToInt +import com.lambda.client.commons.extension.floorToInt import net.minecraft.entity.Entity import net.minecraft.util.math.BlockPos import net.minecraft.util.math.ChunkPos diff --git a/src/main/kotlin/com/lambda/client/util/threads/MainThreadExecutor.kt b/src/main/kotlin/com/lambda/client/util/threads/MainThreadExecutor.kt index 4332cade2..58f48ffee 100644 --- a/src/main/kotlin/com/lambda/client/util/threads/MainThreadExecutor.kt +++ b/src/main/kotlin/com/lambda/client/util/threads/MainThreadExecutor.kt @@ -3,7 +3,7 @@ package com.lambda.client.util.threads import com.lambda.client.event.LambdaEventBus import com.lambda.client.event.events.RunGameLoopEvent import com.lambda.client.util.Wrapper -import com.lambda.event.listener.listener +import com.lambda.client.event.listener.listener import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.completeWith import kotlinx.coroutines.runBlocking diff --git a/src/main/kotlin/com/lambda/client/util/threads/ThreadSafety.kt b/src/main/kotlin/com/lambda/client/util/threads/ThreadSafety.kt index 78e7c680a..fca0c8f7f 100644 --- a/src/main/kotlin/com/lambda/client/util/threads/ThreadSafety.kt +++ b/src/main/kotlin/com/lambda/client/util/threads/ThreadSafety.kt @@ -4,10 +4,10 @@ import com.lambda.client.event.ClientEvent import com.lambda.client.event.ClientExecuteEvent import com.lambda.client.event.SafeClientEvent import com.lambda.client.event.SafeExecuteEvent -import com.lambda.event.ListenerManager -import com.lambda.event.listener.AsyncListener -import com.lambda.event.listener.DEFAULT_PRIORITY -import com.lambda.event.listener.Listener +import com.lambda.client.event.ListenerManager +import com.lambda.client.event.listener.AsyncListener +import com.lambda.client.event.listener.DEFAULT_PRIORITY +import com.lambda.client.event.listener.Listener import kotlinx.coroutines.CompletableDeferred inline fun Any.safeAsyncListener(noinline function: suspend SafeClientEvent.(T) -> Unit) {