From 63da778880cc522a23976c192ff0cce909fbf1f1 Mon Sep 17 00:00:00 2001 From: qingshu-ui Date: Tue, 15 Oct 2024 05:08:22 +0800 Subject: [PATCH 1/6] Change DSL to kotlin and fixed AutoEnchant --- build.gradle | 97 ------------- build.gradle.kts | 130 ++++++++++++++++++ gradle.properties | 7 +- settings.gradle | 9 -- settings.gradle.kts | 8 ++ .../anticope/rejects/modules/AutoEnchant.java | 66 +++++---- .../anticope/rejects/modules/CoordLogger.java | 4 +- src/main/resources/fabric.mod.json | 3 +- 8 files changed, 178 insertions(+), 146 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 30d2476d..00000000 --- a/build.gradle +++ /dev/null @@ -1,97 +0,0 @@ -plugins { - id 'fabric-loom' version '1.7-SNAPSHOT' -} - -sourceCompatibility = targetCompatibility = JavaVersion.VERSION_21 - -archivesBaseName = project.archives_base_name -version = project.mod_version -group = project.maven_group - -repositories { - mavenCentral() - mavenLocal() - maven { url "https://maven.meteordev.org/releases"} - maven { url "https://maven.meteordev.org/snapshots" } - maven { url "https://maven.seedfinding.com/" } - maven { url "https://maven-snapshots.seedfinding.com/" } - maven { url 'https://jitpack.io' } - maven { url 'https://maven.duti.dev/releases' } -} -configurations { - // configuration that holds jars to include in the jar - extraLibs -} - -dependencies { - // This will make it work on most platforms. It automatically chooses the right dependencies at runtime. - extraLibs('dev.duti.acheong:cubiomes:1.22.3') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.22.3:linux64') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.22.3:osx') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.22.3:windows64') { transitive = false } - // To change the versions see the gradle.properties file - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_version}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - - modImplementation("meteordevelopment:meteor-client:${project.meteor_version}-SNAPSHOT") - modCompileOnly "meteordevelopment:baritone:${project.baritone_version}-SNAPSHOT" - - // seed .locate and ore sim - extraLibs('com.seedfinding:mc_math:ffd2edcfcc0d18147549c88cc7d8ec6cf21b5b91') { transitive = false } - extraLibs('com.seedfinding:mc_seed:1ead6fcefe7e8de4b3d60cd6c4e993f1e8f33409') { transitive = false } - extraLibs('com.seedfinding:mc_core:d64d5f90be66300da41ef58f4f1736db2499784f') { transitive = false } - extraLibs('com.seedfinding:mc_noise:7e3ba65e181796c4a2a1c8881d840b2254b92962') { transitive = false } - extraLibs('com.seedfinding:mc_biome:41a42cb9019a552598f12089059538853e18ec78') { transitive = false } - extraLibs('com.seedfinding:mc_terrain:b4246cbd5880c4f8745ccb90e1b102bde3448126') { transitive = false } - extraLibs('com.seedfinding:mc_feature:919b7e513cc1e87e029a9cd703fc4e2dc8686229') { transitive = false } - - // seedcracker api - implementation (include('com.github.19MisterX98.SeedcrackerX:seedcrackerx-api:2.10.1')) {transitive = false} -// implementation (include('com.github.19MisterX98.SeedcrackerX:seedcrackerx-api:master-SNAPSHOT')) {transitive = false} - - configurations.implementation.extendsFrom(configurations.extraLibs) -} - -loom { - accessWidenerPath = file("src/main/resources/meteor-rejects.accesswidener") -} - -processResources { - inputs.property "version", project.version - - - filesMatching("fabric.mod.json") { - expand "version": project.version, - "mc_version": project.minecraft_version, - "gh_hash": (System.getenv("GITHUB_SHA") ?: "") - } -} - -jar { - from("LICENSE") { - rename { "${it}_${project.archivesBaseName}"} - } - from { - configurations.extraLibs.collect { it.isDirectory() ? it : zipTree(it) } - } -} -tasks.withType(Jar) { - duplicatesStrategy = DuplicatesStrategy.EXCLUDE -} - -tasks.withType(JavaCompile).configureEach { - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - // If Javadoc is generated, this must be specified in that task too. - it.options.encoding = "UTF-8" - - // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too - // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. - // We'll use that if it's available, but otherwise we'll use the older option. - def targetVersion = 21 - if (JavaVersion.current().isJava9Compatible()) { - it.options.release = targetVersion - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..4c269d1d --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,130 @@ +@file:Suppress("PropertyName") + +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +val minecraft_version: String by project +val yarn_version: String by project +val loader_version: String by project +val meteor_version: String by project +val baritone_version: String by project +val kotlin_loader_version: String by project + +plugins { + kotlin("jvm") version "2.0.21" + id("fabric-loom") version "1.7-SNAPSHOT" +} + +version = project.property("mod_version") as String +group = project.property("maven_group") as String + +base { + archivesName.set(project.property("archives_base_name") as String) +} + +val targetJavaVersion = 21 +java { + toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) + withSourcesJar() +} + +repositories { + mavenCentral() + mavenLocal() + maven { url = uri("https://maven.meteordev.org/releases") } + maven { url = uri("https://maven.meteordev.org/snapshots") } + maven { url = uri("https://maven.seedfinding.com/") } + maven { url = uri("https://maven-snapshots.seedfinding.com/") } + maven { url = uri("https://jitpack.io") } + maven { url = uri("https://maven.duti.dev/releases") } +} +configurations { + // configuration that holds jars to include in the jar + create("extraLibs") +} + +configurations { + named("implementation") { + extendsFrom(getByName("extraLibs")) + } +} + +dependencies { + // This will make it work on most platforms. It automatically chooses the right dependencies at runtime. + "extraLibs"("dev.duti.acheong:cubiomes:1.22.3") { isTransitive = false } + "extraLibs"("dev.duti.acheong:cubiomes:1.22.3:linux64") { isTransitive = false } + "extraLibs"("dev.duti.acheong:cubiomes:1.22.3:osx") { isTransitive = false } + "extraLibs"("dev.duti.acheong:cubiomes:1.22.3:windows64") { isTransitive = false } + // To change the versions see the gradle.properties file + minecraft("com.mojang:minecraft:$minecraft_version") + mappings("net.fabricmc:yarn:$yarn_version:v2") + modImplementation("net.fabricmc:fabric-loader:$loader_version") + modImplementation("net.fabricmc:fabric-language-kotlin:$kotlin_loader_version") + + modImplementation("meteordevelopment:meteor-client:$meteor_version-SNAPSHOT") + modCompileOnly("meteordevelopment:baritone:$baritone_version-SNAPSHOT") + + // seed .locate and ore sim + "extraLibs"("com.seedfinding:mc_math:ffd2edcfcc0d18147549c88cc7d8ec6cf21b5b91") { isTransitive = false } + "extraLibs"("com.seedfinding:mc_seed:1ead6fcefe7e8de4b3d60cd6c4e993f1e8f33409") { isTransitive = false } + "extraLibs"("com.seedfinding:mc_core:d64d5f90be66300da41ef58f4f1736db2499784f") { isTransitive = false } + "extraLibs"("com.seedfinding:mc_noise:7e3ba65e181796c4a2a1c8881d840b2254b92962") { isTransitive = false } + "extraLibs"("com.seedfinding:mc_biome:41a42cb9019a552598f12089059538853e18ec78") { isTransitive = false } + "extraLibs"("com.seedfinding:mc_terrain:b4246cbd5880c4f8745ccb90e1b102bde3448126") { isTransitive = false } + "extraLibs"("com.seedfinding:mc_feature:919b7e513cc1e87e029a9cd703fc4e2dc8686229") { isTransitive = false } + + // seedcracker api + implementation("com.github.19MisterX98.SeedcrackerX:seedcrackerx-api:2.10.1") { isTransitive = false } +// implementation (include('com.github.19MisterX98.SeedcrackerX:seedcrackerx-api:master-SNAPSHOT')) {transitive = false} +} + +loom { + accessWidenerPath = file("src/main/resources/meteor-rejects.accesswidener") +} + +tasks.processResources { + inputs.property("version", project.version) + inputs.property("minecraft_version", project.property("minecraft_version")) + inputs.property("loader_version", project.property("loader_version")) + filteringCharset = "UTF-8" + + + filesMatching("fabric.mod.json") { + expand( + "version" to project.version, + "mc_version" to project.property("minecraft_version"), + "gh_hash" to (System.getenv("GITHUB_SHA") ?: ""), + "kotlin_loader_version" to project.property("kotlin_loader_version"), + ) + } +} + +tasks.jar { + from("LICENSE") { + rename { "${it}_${project.base.archivesName}" } + } + from(configurations["extraLibs"].map { if (it.isDirectory) it else zipTree(it) }) +} + +tasks.withType() { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE +} + +tasks.withType().configureEach { + compilerOptions.jvmTarget.set(JvmTarget.fromTarget(targetJavaVersion.toString())) +} + +tasks.withType().configureEach { + // ensure that the encoding is set to UTF-8, no matter what the system default is + // this fixes some edge cases with special characters not displaying correctly + // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html + // If Javadoc is generated, this must be specified in that task too. + options.encoding = "UTF-8" + + // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too + // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. + // We'll use that if it's available, but otherwise we'll use the older option. + if(JavaVersion.current().isJava9Compatible){ + options.release.set(targetJavaVersion) + } +} diff --git a/gradle.properties b/gradle.properties index 60b3865d..ecfc6106 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,11 @@ # Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx2G +org.gradle.jvmargs=-Xmx4G # Fabric Properties -minecraft_version=1.21 -yarn_version=1.21+build.2 +minecraft_version=1.21.1 +yarn_version=1.21.1+build.3 loader_version=0.15.11 +kotlin_loader_version=1.12.3+kotlin.2.0.21 # Mod Properties mod_version = 0.3 diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index f91a4fe7..00000000 --- a/settings.gradle +++ /dev/null @@ -1,9 +0,0 @@ -pluginManagement { - repositories { - maven { - name = 'Fabric' - url = 'https://maven.fabricmc.net/' - } - gradlePluginPortal() - } -} diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..05eb23d1 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,8 @@ +pluginManagement { + repositories { + maven("https://maven.fabricmc.net/") { + name = "Fabric" + } + gradlePluginPortal() + } +} diff --git a/src/main/java/anticope/rejects/modules/AutoEnchant.java b/src/main/java/anticope/rejects/modules/AutoEnchant.java index a633bcce..f42f6eb9 100644 --- a/src/main/java/anticope/rejects/modules/AutoEnchant.java +++ b/src/main/java/anticope/rejects/modules/AutoEnchant.java @@ -1,7 +1,6 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; - import meteordevelopment.meteorclient.events.game.OpenScreenEvent; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.utils.network.MeteorExecutor; @@ -17,6 +16,9 @@ import java.util.List; import java.util.Objects; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; public class AutoEnchant extends meteordevelopment.meteorclient.systems.modules.Module { @@ -66,47 +68,43 @@ private void onOpenScreen(OpenScreenEvent event) { MeteorExecutor.execute(this::autoEnchant); } - private void autoEnchant() { + private synchronized void autoEnchant() { if (!(Objects.requireNonNull(mc.player).currentScreenHandler instanceof EnchantmentScreenHandler handler)) return; if (mc.player.experienceLevel < 30) { info("You don't have enough experience levels"); return; } - while (getEmptySlotCount(handler) > 2 || drop.get()) { - if (!(mc.player.currentScreenHandler instanceof EnchantmentScreenHandler)) { - info("Enchanting table is closed."); - break; - } - if (handler.getLapisCount() < level.get() && !fillLapisItem()) { - info("Lapis lazuli is not found."); - break; - } - if (!fillCanEnchantItem()) { - info("No items found to enchant."); - break; - } - Objects.requireNonNull(mc.interactionManager).clickButton(handler.syncId, level.get() - 1); - if (getEmptySlotCount(handler) > 2) { - InvUtils.shiftClick().slotId(0); - } else if (drop.get() && handler.getSlot(0).hasStack()) { - // I don't know why an exception LegacyRandomSource is thrown here, - // so I used the main thread to drop items. - mc.execute(() -> InvUtils.drop().slotId(0)); - } - - /* - Although the description here indicates that the tick is the unit, - the actual delay is not the tick unit, - but it does not affect the normal operation in the game. - Perhaps we can ignore it - */ + ScheduledExecutorService executors = Executors.newSingleThreadScheduledExecutor(); + executors.scheduleAtFixedRate(() -> { try { - Thread.sleep(delay.get()); - } catch (InterruptedException e) { - throw new RuntimeException(e); + if (!(mc.player.currentScreenHandler instanceof EnchantmentScreenHandler)) { + info("Enchanting table is closed."); + executors.shutdown(); + return; + } + if (handler.getLapisCount() < level.get() && !fillLapisItem()) { + info("Lapis lazuli is not found."); + executors.shutdown(); + return; + } + if (!fillCanEnchantItem()) { + info("No items found to enchant."); + executors.shutdown(); + return; + } + + Objects.requireNonNull(mc.interactionManager).clickButton(handler.syncId, level.get() - 1); + if (getEmptySlotCount(handler) > 2) { + InvUtils.shiftClick().slotId(0); + } else if (drop.get() && handler.getSlot(0).hasStack()) { + mc.execute(() -> InvUtils.drop().slotId(0)); + } + }catch (Exception e) { + e.printStackTrace(); + executors.shutdown(); } - } + }, 0, delay.get(), TimeUnit.MILLISECONDS); } private boolean fillCanEnchantItem() { diff --git a/src/main/java/anticope/rejects/modules/CoordLogger.java b/src/main/java/anticope/rejects/modules/CoordLogger.java index b2d89cdc..0a05fb87 100644 --- a/src/main/java/anticope/rejects/modules/CoordLogger.java +++ b/src/main/java/anticope/rejects/modules/CoordLogger.java @@ -97,9 +97,9 @@ private void onPacketReceive(PacketEvent.Receive event) { // Teleports if (event.packet instanceof EntityPositionS2CPacket) { EntityPositionS2CPacket packet = (EntityPositionS2CPacket) event.packet; - + try { - Entity entity = mc.world.getEntityById(packet.getId()); + Entity entity = mc.world.getEntityById(packet.getEntityId()); // Player teleport if (entity.getType().equals(EntityType.PLAYER) && players.get()) { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 5b8ab2bb..91d3d5aa 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -38,6 +38,7 @@ "depends": { "java": ">=16", "minecraft": "~${mc_version}", - "meteor-client": "*" + "meteor-client": "*", + "fabric-language-kotlin": ">=${kotlin_loader_version}" } } From b5ad7810bba0aca21c7e07f6cd044a0a5508debf Mon Sep 17 00:00:00 2001 From: qingshu-ui Date: Tue, 15 Oct 2024 15:24:46 +0800 Subject: [PATCH 2/6] - Update version to 1.21.1 - Optimized the logic for adding modules and commands in the project. - Integrated Kotlin to enhance code readability and maintainability. - Reduced boilerplate code and improved expressiveness in the codebase. --- build.gradle.kts | 53 +++++++------ gradle.properties | 2 +- processor/build.gradle.kts | 15 ++++ .../com/github/shu/AutoRegisterProcessor.kt | 46 +++++++++++ ...ols.ksp.processing.SymbolProcessorProvider | 1 + settings.gradle.kts | 2 + .../anticope/rejects/MeteorRejectsAddon.java | 79 +------------------ .../rejects/commands/CenterCommand.java | 2 + .../rejects/commands/ClearChatCommand.java | 2 + .../rejects/commands/GhostCommand.java | 2 + .../rejects/commands/GiveCommand.java | 2 + .../rejects/commands/HeadsCommand.java | 2 + .../rejects/commands/KickCommand.java | 2 + .../rejects/commands/LocateCommand.java | 2 + .../rejects/commands/PanicCommand.java | 2 + .../rejects/commands/ReconnectCommand.java | 2 + .../rejects/commands/SaveSkinCommand.java | 2 + .../rejects/commands/SeedCommand.java | 2 + .../rejects/commands/ServerCommand.java | 2 + .../rejects/commands/SetBlockCommand.java | 2 + .../rejects/commands/SetVelocityCommand.java | 2 + .../rejects/commands/TeleportCommand.java | 2 + .../rejects/commands/TerrainExport.java | 2 + .../anticope/rejects/modules/AimAssist.java | 2 + .../anticope/rejects/modules/AntiBot.java | 3 +- .../anticope/rejects/modules/AntiCrash.java | 2 + .../rejects/modules/AntiSpawnpoint.java | 2 + .../anticope/rejects/modules/AntiVanish.java | 2 + .../anticope/rejects/modules/ArrowDmg.java | 2 + .../anticope/rejects/modules/AutoBedTrap.java | 2 + .../anticope/rejects/modules/AutoCraft.java | 2 + .../anticope/rejects/modules/AutoEnchant.java | 31 ++++---- .../rejects/modules/AutoExtinguish.java | 2 + .../anticope/rejects/modules/AutoFarm.java | 2 + .../anticope/rejects/modules/AutoGrind.java | 2 + .../anticope/rejects/modules/AutoLogin.java | 2 + .../anticope/rejects/modules/AutoPot.java | 2 + .../anticope/rejects/modules/AutoRename.java | 2 + .../anticope/rejects/modules/AutoSoup.java | 2 + .../anticope/rejects/modules/AutoTNT.java | 2 + .../anticope/rejects/modules/AutoWither.java | 2 + .../anticope/rejects/modules/BlockIn.java | 2 + .../anticope/rejects/modules/BoatGlitch.java | 2 + .../anticope/rejects/modules/BoatPhase.java | 2 + .../java/anticope/rejects/modules/Boost.java | 2 + .../rejects/modules/BungeeCordSpoof.java | 2 + .../anticope/rejects/modules/ChatBot.java | 2 + .../anticope/rejects/modules/ChestAura.java | 2 + .../rejects/modules/ChorusExploit.java | 2 + .../anticope/rejects/modules/ColorSigns.java | 2 + .../anticope/rejects/modules/Confuse.java | 2 + .../anticope/rejects/modules/CoordLogger.java | 2 + .../rejects/modules/CustomPackets.java | 2 + .../anticope/rejects/modules/ExtraElytra.java | 2 + .../anticope/rejects/modules/FullFlight.java | 2 + .../rejects/modules/GamemodeNotifier.java | 2 + .../anticope/rejects/modules/GhostMode.java | 2 + .../java/anticope/rejects/modules/Glide.java | 3 +- .../rejects/modules/InteractionMenu.java | 2 + .../rejects/modules/ItemGenerator.java | 2 + .../anticope/rejects/modules/Jetpack.java | 2 + .../rejects/modules/KnockbackPlus.java | 2 + .../anticope/rejects/modules/Lavacast.java | 3 +- .../anticope/rejects/modules/LawnBot.java | 2 + .../anticope/rejects/modules/MossBot.java | 2 + .../anticope/rejects/modules/NewChunks.java | 2 + .../anticope/rejects/modules/NoJumpDelay.java | 2 + .../rejects/modules/ObsidianFarm.java | 2 + .../java/anticope/rejects/modules/OreSim.java | 2 + .../anticope/rejects/modules/PacketFly.java | 2 + .../anticope/rejects/modules/Painter.java | 2 + .../anticope/rejects/modules/Rendering.java | 2 + .../anticope/rejects/modules/RoboWalk.java | 2 + .../rejects/modules/ShieldBypass.java | 2 + .../rejects/modules/SilentDisconnect.java | 2 + .../anticope/rejects/modules/SkeletonESP.java | 2 + .../rejects/modules/SoundLocator.java | 2 + .../anticope/rejects/modules/TreeAura.java | 2 + .../rejects/modules/VehicleOneHit.java | 2 + .../rejects/annotation/AutoRegister.kt | 20 +++++ .../anticope/rejects/utils/MeteorManager.kt | 67 ++++++++++++++++ .../anticope/rejects/utils/PackageScanner.kt | 70 ++++++++++++++++ 82 files changed, 412 insertions(+), 119 deletions(-) create mode 100644 processor/build.gradle.kts create mode 100644 processor/src/main/kotlin/com/github/shu/AutoRegisterProcessor.kt create mode 100644 processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider create mode 100644 src/main/kotlin/anticope/rejects/annotation/AutoRegister.kt create mode 100644 src/main/kotlin/anticope/rejects/utils/MeteorManager.kt create mode 100644 src/main/kotlin/anticope/rejects/utils/PackageScanner.kt diff --git a/build.gradle.kts b/build.gradle.kts index 4c269d1d..1d50625a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,6 +13,7 @@ val kotlin_loader_version: String by project plugins { kotlin("jvm") version "2.0.21" id("fabric-loom") version "1.7-SNAPSHOT" + id("com.google.devtools.ksp") version "2.0.21-1.0.25" } version = project.property("mod_version") as String @@ -49,12 +50,17 @@ configurations { } } +fun DependencyHandlerScope.extraLibs(dependencyNotation: String, configure: ModuleDependency.() -> Unit = {}) { + add("extraLibs", dependencyNotation, configure) +} + dependencies { // This will make it work on most platforms. It automatically chooses the right dependencies at runtime. - "extraLibs"("dev.duti.acheong:cubiomes:1.22.3") { isTransitive = false } - "extraLibs"("dev.duti.acheong:cubiomes:1.22.3:linux64") { isTransitive = false } - "extraLibs"("dev.duti.acheong:cubiomes:1.22.3:osx") { isTransitive = false } - "extraLibs"("dev.duti.acheong:cubiomes:1.22.3:windows64") { isTransitive = false } + val cubiomesVersion = "dev.duti.acheong:cubiomes:1.22.3" + listOf("linux64", "osx", "windows64").forEach { os -> + extraLibs("$cubiomesVersion:$os") { isTransitive = false } + } + extraLibs(cubiomesVersion) { isTransitive = false } // To change the versions see the gradle.properties file minecraft("com.mojang:minecraft:$minecraft_version") mappings("net.fabricmc:yarn:$yarn_version:v2") @@ -65,17 +71,22 @@ dependencies { modCompileOnly("meteordevelopment:baritone:$baritone_version-SNAPSHOT") // seed .locate and ore sim - "extraLibs"("com.seedfinding:mc_math:ffd2edcfcc0d18147549c88cc7d8ec6cf21b5b91") { isTransitive = false } - "extraLibs"("com.seedfinding:mc_seed:1ead6fcefe7e8de4b3d60cd6c4e993f1e8f33409") { isTransitive = false } - "extraLibs"("com.seedfinding:mc_core:d64d5f90be66300da41ef58f4f1736db2499784f") { isTransitive = false } - "extraLibs"("com.seedfinding:mc_noise:7e3ba65e181796c4a2a1c8881d840b2254b92962") { isTransitive = false } - "extraLibs"("com.seedfinding:mc_biome:41a42cb9019a552598f12089059538853e18ec78") { isTransitive = false } - "extraLibs"("com.seedfinding:mc_terrain:b4246cbd5880c4f8745ccb90e1b102bde3448126") { isTransitive = false } - "extraLibs"("com.seedfinding:mc_feature:919b7e513cc1e87e029a9cd703fc4e2dc8686229") { isTransitive = false } - + val seedFindingDependencies = setOf( + "com.seedfinding:mc_math:ffd2edcfcc0d18147549c88cc7d8ec6cf21b5b91", + "com.seedfinding:mc_seed:1ead6fcefe7e8de4b3d60cd6c4e993f1e8f33409", + "com.seedfinding:mc_core:d64d5f90be66300da41ef58f4f1736db2499784f", + "com.seedfinding:mc_noise:7e3ba65e181796c4a2a1c8881d840b2254b92962", + "com.seedfinding:mc_biome:41a42cb9019a552598f12089059538853e18ec78", + "com.seedfinding:mc_terrain:b4246cbd5880c4f8745ccb90e1b102bde3448126", + "com.seedfinding:mc_feature:919b7e513cc1e87e029a9cd703fc4e2dc8686229" + ) + seedFindingDependencies.forEach { dependency -> + extraLibs(dependency) { isTransitive = false } + } // seedcracker api implementation("com.github.19MisterX98.SeedcrackerX:seedcrackerx-api:2.10.1") { isTransitive = false } -// implementation (include('com.github.19MisterX98.SeedcrackerX:seedcrackerx-api:master-SNAPSHOT')) {transitive = false} + // implementation (include('com.github.19MisterX98.SeedcrackerX:seedcrackerx-api:master-SNAPSHOT')) {transitive = false} + ksp(project(":processor")) } loom { @@ -84,17 +95,17 @@ loom { tasks.processResources { inputs.property("version", project.version) - inputs.property("minecraft_version", project.property("minecraft_version")) - inputs.property("loader_version", project.property("loader_version")) + inputs.property("minecraft_version", minecraft_version) + inputs.property("loader_version", loader_version) filteringCharset = "UTF-8" filesMatching("fabric.mod.json") { expand( "version" to project.version, - "mc_version" to project.property("minecraft_version"), + "mc_version" to minecraft_version, "gh_hash" to (System.getenv("GITHUB_SHA") ?: ""), - "kotlin_loader_version" to project.property("kotlin_loader_version"), + "kotlin_loader_version" to kotlin_loader_version, ) } } @@ -115,15 +126,7 @@ tasks.withType().configureEach { } tasks.withType().configureEach { - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - // If Javadoc is generated, this must be specified in that task too. options.encoding = "UTF-8" - - // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too - // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. - // We'll use that if it's available, but otherwise we'll use the older option. if(JavaVersion.current().isJava9Compatible){ options.release.set(targetJavaVersion) } diff --git a/gradle.properties b/gradle.properties index ecfc6106..0fcee3cb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,4 +13,4 @@ maven_group = anticope.rejects archives_base_name = meteor-rejects-addon meteor_version=0.5.8 -baritone_version=1.20.6 +baritone_version=1.21.1 diff --git a/processor/build.gradle.kts b/processor/build.gradle.kts new file mode 100644 index 00000000..58af1850 --- /dev/null +++ b/processor/build.gradle.kts @@ -0,0 +1,15 @@ +plugins { + kotlin("jvm") + id("com.google.devtools.ksp") +} + +group = "com.github.shu" +version = "0.0.1" + +repositories { + mavenCentral() +} + +dependencies { + implementation("com.google.devtools.ksp:symbol-processing-api:2.0.21-1.0.25") +} \ No newline at end of file diff --git a/processor/src/main/kotlin/com/github/shu/AutoRegisterProcessor.kt b/processor/src/main/kotlin/com/github/shu/AutoRegisterProcessor.kt new file mode 100644 index 00000000..461310d7 --- /dev/null +++ b/processor/src/main/kotlin/com/github/shu/AutoRegisterProcessor.kt @@ -0,0 +1,46 @@ +package com.github.shu + +import com.google.devtools.ksp.getConstructors +import com.google.devtools.ksp.processing.* +import com.google.devtools.ksp.symbol.KSAnnotated +import com.google.devtools.ksp.symbol.KSClassDeclaration + +/** + * A KSP (Kotlin Symbol Processing) processor that processes class annotated with `@AutoRegister`. + * This processor checks if the annotated classes have a no-argument constructor or if all their + * constructor parameters hava default values. If neither condition is met, an error is logged. + * + * @param logger The KSP logger used for logging errors during processing. + */ +class AutoRegisterProcessor(private val logger: KSPLogger) : SymbolProcessor { + + override fun process(resolver: Resolver): List { + val autoRegisterClasses = resolver.getSymbolsWithAnnotation("anticope.rejects.annotation.AutoRegister") + autoRegisterClasses.forEach { classSymbol -> + if (classSymbol is KSClassDeclaration) { + validateClass(classSymbol) + } + } + return emptyList() + } + + private fun validateClass(classSymbol: KSClassDeclaration) { + val constructors = classSymbol.getConstructors() + val hasDefaultConstructor = constructors.any { constructor -> + constructor.parameters.isEmpty() || constructor.parameters.all { it.hasDefault } + } + if (!hasDefaultConstructor) { + val message = + "${classSymbol.simpleName.asString()} must have a no-arg constructor or " + + "all parameters must have default values" + logger.error(message) + } + } +} + +class AutoRegisterProcessorProvider : SymbolProcessorProvider { + + override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor { + return AutoRegisterProcessor(environment.logger) + } +} \ No newline at end of file diff --git a/processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider b/processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider new file mode 100644 index 00000000..6198fffe --- /dev/null +++ b/processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider @@ -0,0 +1 @@ +com.github.shu.AutoRegisterProcessorProvider \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 05eb23d1..7285a6f6 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -4,5 +4,7 @@ pluginManagement { name = "Fabric" } gradlePluginPortal() + google() } } +include("processor") diff --git a/src/main/java/anticope/rejects/MeteorRejectsAddon.java b/src/main/java/anticope/rejects/MeteorRejectsAddon.java index 6098d03f..a8653778 100644 --- a/src/main/java/anticope/rejects/MeteorRejectsAddon.java +++ b/src/main/java/anticope/rejects/MeteorRejectsAddon.java @@ -1,12 +1,10 @@ package anticope.rejects; -import anticope.rejects.commands.*; import anticope.rejects.gui.hud.RadarHud; import anticope.rejects.gui.themes.rounded.MeteorRoundedGuiTheme; -import anticope.rejects.modules.*; +import anticope.rejects.utils.MeteorManagerKt; import meteordevelopment.meteorclient.addons.GithubRepo; import meteordevelopment.meteorclient.addons.MeteorAddon; -import meteordevelopment.meteorclient.commands.Commands; import meteordevelopment.meteorclient.gui.GuiThemes; import meteordevelopment.meteorclient.systems.Systems; import meteordevelopment.meteorclient.systems.hud.Hud; @@ -28,81 +26,10 @@ public void onInitialize() { LOG.info("Initializing Meteor Rejects Addon"); // Modules - Modules modules = Modules.get(); - modules.add(new AimAssist()); - modules.add(new AntiBot()); - modules.add(new AntiCrash()); - modules.add(new AntiSpawnpoint()); - modules.add(new AntiVanish()); - modules.add(new ArrowDmg()); - modules.add(new AutoBedTrap()); - modules.add(new AutoCraft()); - modules.add(new AutoExtinguish()); - modules.add(new AutoFarm()); - modules.add(new AutoGrind()); - modules.add(new AutoLogin()); - modules.add(new AutoPot()); - modules.add(new AutoSoup()); - modules.add(new AutoTNT()); - modules.add(new AutoWither()); - modules.add(new BoatGlitch()); - modules.add(new BlockIn()); - modules.add(new BoatPhase()); - modules.add(new Boost()); - modules.add(new BungeeCordSpoof()); - modules.add(new ChatBot()); - modules.add(new ChestAura()); - modules.add(new ChorusExploit()); - modules.add(new ColorSigns()); - modules.add(new Confuse()); - modules.add(new CoordLogger()); - modules.add(new CustomPackets()); - modules.add(new ExtraElytra()); - modules.add(new FullFlight()); - modules.add(new GamemodeNotifier()); - modules.add(new GhostMode()); - modules.add(new Glide()); - modules.add(new ItemGenerator()); - modules.add(new InteractionMenu()); - modules.add(new Jetpack()); - modules.add(new KnockbackPlus()); - modules.add(new LawnBot()); - modules.add(new Lavacast()); - modules.add(new MossBot()); - modules.add(new NewChunks()); - modules.add(new NoJumpDelay()); - modules.add(new ObsidianFarm()); - modules.add(new OreSim()); - modules.add(new PacketFly()); - modules.add(new Painter()); - modules.add(new Rendering()); - modules.add(new RoboWalk()); - modules.add(new ShieldBypass()); - modules.add(new SilentDisconnect()); - modules.add(new SkeletonESP()); - modules.add(new SoundLocator()); - modules.add(new TreeAura()); - modules.add(new VehicleOneHit()); - modules.add(new AutoEnchant()); - modules.add(new AutoRename()); + MeteorManagerKt.moduleRegister("anticope.rejects.modules"); // Commands - Commands.add(new CenterCommand()); - Commands.add(new ClearChatCommand()); - Commands.add(new GhostCommand()); - Commands.add(new GiveCommand()); - Commands.add(new HeadsCommand()); - Commands.add(new KickCommand()); - Commands.add(new LocateCommand()); - Commands.add(new PanicCommand()); - Commands.add(new ReconnectCommand()); - Commands.add(new ServerCommand()); - Commands.add(new SaveSkinCommand()); - Commands.add(new SeedCommand()); - Commands.add(new SetBlockCommand()); - Commands.add(new SetVelocityCommand()); - Commands.add(new TeleportCommand()); - Commands.add(new TerrainExport()); + MeteorManagerKt.commandRegister("anticope.rejects.commands"); // HUD Hud hud = Systems.get(Hud.class); diff --git a/src/main/java/anticope/rejects/commands/CenterCommand.java b/src/main/java/anticope/rejects/commands/CenterCommand.java index bf11c56e..b2951554 100644 --- a/src/main/java/anticope/rejects/commands/CenterCommand.java +++ b/src/main/java/anticope/rejects/commands/CenterCommand.java @@ -1,11 +1,13 @@ package anticope.rejects.commands; +import anticope.rejects.annotation.AutoRegister; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import meteordevelopment.meteorclient.commands.Command; import net.minecraft.command.CommandSource; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.util.math.MathHelper; +@AutoRegister public class CenterCommand extends Command { public CenterCommand() { super("center", "Centers the player on a block."); diff --git a/src/main/java/anticope/rejects/commands/ClearChatCommand.java b/src/main/java/anticope/rejects/commands/ClearChatCommand.java index a8d15b3e..63987e44 100644 --- a/src/main/java/anticope/rejects/commands/ClearChatCommand.java +++ b/src/main/java/anticope/rejects/commands/ClearChatCommand.java @@ -1,9 +1,11 @@ package anticope.rejects.commands; +import anticope.rejects.annotation.AutoRegister; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import meteordevelopment.meteorclient.commands.Command; import net.minecraft.command.CommandSource; +@AutoRegister public class ClearChatCommand extends Command { public ClearChatCommand() { super("clear-chat", "Clears your chat.", "clear", "cls"); diff --git a/src/main/java/anticope/rejects/commands/GhostCommand.java b/src/main/java/anticope/rejects/commands/GhostCommand.java index b37b58f2..877fbeeb 100644 --- a/src/main/java/anticope/rejects/commands/GhostCommand.java +++ b/src/main/java/anticope/rejects/commands/GhostCommand.java @@ -1,5 +1,6 @@ package anticope.rejects.commands; +import anticope.rejects.annotation.AutoRegister; import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import meteordevelopment.meteorclient.commands.Command; @@ -9,6 +10,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; +@AutoRegister public class GhostCommand extends Command { public GhostCommand() { super("ghost", "Remove ghost blocks & bypass AntiXray", "aax", "anti-anti-xray"); diff --git a/src/main/java/anticope/rejects/commands/GiveCommand.java b/src/main/java/anticope/rejects/commands/GiveCommand.java index 7c51ed3f..397e2776 100644 --- a/src/main/java/anticope/rejects/commands/GiveCommand.java +++ b/src/main/java/anticope/rejects/commands/GiveCommand.java @@ -1,5 +1,6 @@ package anticope.rejects.commands; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.arguments.EnumStringArgumentType; import anticope.rejects.utils.GiveUtils; import com.mojang.authlib.GameProfile; @@ -25,6 +26,7 @@ import static anticope.rejects.utils.accounts.GetPlayerUUID.getUUID; +@AutoRegister public class GiveCommand extends Command { private final Collection PRESETS = GiveUtils.PRESETS.keySet(); diff --git a/src/main/java/anticope/rejects/commands/HeadsCommand.java b/src/main/java/anticope/rejects/commands/HeadsCommand.java index 7cc3f375..fcb06b68 100644 --- a/src/main/java/anticope/rejects/commands/HeadsCommand.java +++ b/src/main/java/anticope/rejects/commands/HeadsCommand.java @@ -1,5 +1,6 @@ package anticope.rejects.commands; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.gui.screens.HeadScreen; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import meteordevelopment.meteorclient.commands.Command; @@ -7,6 +8,7 @@ import meteordevelopment.meteorclient.utils.Utils; import net.minecraft.command.CommandSource; +@AutoRegister public class HeadsCommand extends Command { public HeadsCommand() { diff --git a/src/main/java/anticope/rejects/commands/KickCommand.java b/src/main/java/anticope/rejects/commands/KickCommand.java index 19a54d0e..64046624 100644 --- a/src/main/java/anticope/rejects/commands/KickCommand.java +++ b/src/main/java/anticope/rejects/commands/KickCommand.java @@ -1,5 +1,6 @@ package anticope.rejects.commands; +import anticope.rejects.annotation.AutoRegister; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import meteordevelopment.meteorclient.commands.Command; import meteordevelopment.meteorclient.utils.player.ChatUtils; @@ -11,6 +12,7 @@ import net.minecraft.text.Text; import org.apache.commons.lang3.SystemUtils; +@AutoRegister public class KickCommand extends Command { public KickCommand() { diff --git a/src/main/java/anticope/rejects/commands/LocateCommand.java b/src/main/java/anticope/rejects/commands/LocateCommand.java index 0b1c1290..ddeadd3b 100644 --- a/src/main/java/anticope/rejects/commands/LocateCommand.java +++ b/src/main/java/anticope/rejects/commands/LocateCommand.java @@ -1,5 +1,6 @@ package anticope.rejects.commands; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.arguments.EnumArgumentType; import anticope.rejects.utils.WorldGenUtils; import anticope.rejects.utils.seeds.Seeds; @@ -19,6 +20,7 @@ import cubitect.Cubiomes; import cubitect.Cubiomes.Pos; +@AutoRegister public class LocateCommand extends Command { private final static DynamicCommandExceptionType NOT_FOUND = new DynamicCommandExceptionType(o -> { diff --git a/src/main/java/anticope/rejects/commands/PanicCommand.java b/src/main/java/anticope/rejects/commands/PanicCommand.java index c2967505..21077077 100644 --- a/src/main/java/anticope/rejects/commands/PanicCommand.java +++ b/src/main/java/anticope/rejects/commands/PanicCommand.java @@ -1,5 +1,6 @@ package anticope.rejects.commands; +import anticope.rejects.annotation.AutoRegister; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import meteordevelopment.meteorclient.commands.Command; import meteordevelopment.meteorclient.systems.modules.Module; @@ -8,6 +9,7 @@ import java.util.ArrayList; +@AutoRegister public class PanicCommand extends Command { public PanicCommand() { super("panic", "Disables all modules.", "disable-all"); diff --git a/src/main/java/anticope/rejects/commands/ReconnectCommand.java b/src/main/java/anticope/rejects/commands/ReconnectCommand.java index 30fa33d0..89f0b915 100644 --- a/src/main/java/anticope/rejects/commands/ReconnectCommand.java +++ b/src/main/java/anticope/rejects/commands/ReconnectCommand.java @@ -1,5 +1,6 @@ package anticope.rejects.commands; +import anticope.rejects.annotation.AutoRegister; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import meteordevelopment.meteorclient.commands.Command; import net.minecraft.client.gui.screen.multiplayer.ConnectScreen; @@ -9,6 +10,7 @@ import net.minecraft.client.network.ServerInfo; import net.minecraft.command.CommandSource; +@AutoRegister public class ReconnectCommand extends Command { public ReconnectCommand() { super("reconnect", "Reconnects server."); diff --git a/src/main/java/anticope/rejects/commands/SaveSkinCommand.java b/src/main/java/anticope/rejects/commands/SaveSkinCommand.java index b0ce77a0..fc43188d 100644 --- a/src/main/java/anticope/rejects/commands/SaveSkinCommand.java +++ b/src/main/java/anticope/rejects/commands/SaveSkinCommand.java @@ -1,5 +1,6 @@ package anticope.rejects.commands; +import anticope.rejects.annotation.AutoRegister; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonObject; @@ -23,6 +24,7 @@ import java.nio.charset.StandardCharsets; import java.util.UUID; +@AutoRegister public class SaveSkinCommand extends Command { private final static SimpleCommandExceptionType IO_EXCEPTION = new SimpleCommandExceptionType(Text.literal("An exception occurred")); diff --git a/src/main/java/anticope/rejects/commands/SeedCommand.java b/src/main/java/anticope/rejects/commands/SeedCommand.java index 995b5b96..76ad7055 100644 --- a/src/main/java/anticope/rejects/commands/SeedCommand.java +++ b/src/main/java/anticope/rejects/commands/SeedCommand.java @@ -1,5 +1,6 @@ package anticope.rejects.commands; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.arguments.EnumArgumentType; import anticope.rejects.utils.seeds.Seed; import anticope.rejects.utils.seeds.Seeds; @@ -13,6 +14,7 @@ import net.minecraft.text.MutableText; import net.minecraft.text.Text; +@AutoRegister public class SeedCommand extends Command { private final static SimpleCommandExceptionType NO_SEED = new SimpleCommandExceptionType(Text.literal("No seed for current world saved.")); diff --git a/src/main/java/anticope/rejects/commands/ServerCommand.java b/src/main/java/anticope/rejects/commands/ServerCommand.java index f783a7fd..d28b0d28 100644 --- a/src/main/java/anticope/rejects/commands/ServerCommand.java +++ b/src/main/java/anticope/rejects/commands/ServerCommand.java @@ -1,5 +1,6 @@ package anticope.rejects.commands; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.utils.portscanner.PScanRunner; import anticope.rejects.utils.portscanner.PortScannerManager; import com.mojang.brigadier.arguments.IntegerArgumentType; @@ -24,6 +25,7 @@ Ported from Cornos https://github.com/cornos/Cornos/blob/master/src/main/java/me/zeroX150/cornos/features/command/impl/Scan.java */ +@AutoRegister public class ServerCommand extends Command { private final static SimpleCommandExceptionType ADDRESS_ERROR = new SimpleCommandExceptionType(Text.literal("Couldn't obtain server address")); diff --git a/src/main/java/anticope/rejects/commands/SetBlockCommand.java b/src/main/java/anticope/rejects/commands/SetBlockCommand.java index b835a9cf..fd39f092 100644 --- a/src/main/java/anticope/rejects/commands/SetBlockCommand.java +++ b/src/main/java/anticope/rejects/commands/SetBlockCommand.java @@ -1,5 +1,6 @@ package anticope.rejects.commands; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.arguments.ClientPosArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import meteordevelopment.meteorclient.commands.Command; @@ -10,6 +11,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; +@AutoRegister public class SetBlockCommand extends Command { public SetBlockCommand() { super("setblock", "Sets client side blocks", "sblk"); diff --git a/src/main/java/anticope/rejects/commands/SetVelocityCommand.java b/src/main/java/anticope/rejects/commands/SetVelocityCommand.java index 71b6d3b7..48e992a1 100644 --- a/src/main/java/anticope/rejects/commands/SetVelocityCommand.java +++ b/src/main/java/anticope/rejects/commands/SetVelocityCommand.java @@ -1,10 +1,12 @@ package anticope.rejects.commands; +import anticope.rejects.annotation.AutoRegister; import com.mojang.brigadier.arguments.DoubleArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import meteordevelopment.meteorclient.commands.Command; import net.minecraft.command.CommandSource; +@AutoRegister public class SetVelocityCommand extends Command { public SetVelocityCommand() { super("set-velocity", "Sets player velocity", "velocity", "vel"); diff --git a/src/main/java/anticope/rejects/commands/TeleportCommand.java b/src/main/java/anticope/rejects/commands/TeleportCommand.java index 3dbcd9fe..adc0d622 100644 --- a/src/main/java/anticope/rejects/commands/TeleportCommand.java +++ b/src/main/java/anticope/rejects/commands/TeleportCommand.java @@ -1,5 +1,6 @@ package anticope.rejects.commands; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.arguments.ClientPosArgumentType; import com.mojang.brigadier.arguments.FloatArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; @@ -7,6 +8,7 @@ import net.minecraft.command.CommandSource; import net.minecraft.util.math.Vec3d; +@AutoRegister public class TeleportCommand extends Command { diff --git a/src/main/java/anticope/rejects/commands/TerrainExport.java b/src/main/java/anticope/rejects/commands/TerrainExport.java index 2fdbf0a2..ad11e52c 100644 --- a/src/main/java/anticope/rejects/commands/TerrainExport.java +++ b/src/main/java/anticope/rejects/commands/TerrainExport.java @@ -1,5 +1,6 @@ package anticope.rejects.commands; +import anticope.rejects.annotation.AutoRegister; import com.mojang.brigadier.arguments.IntegerArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; @@ -16,6 +17,7 @@ import java.io.IOException; import java.nio.ByteBuffer; +@AutoRegister public class TerrainExport extends Command { private final static SimpleCommandExceptionType IO_EXCEPTION = new SimpleCommandExceptionType(Text.literal("An IOException occurred")); diff --git a/src/main/java/anticope/rejects/modules/AimAssist.java b/src/main/java/anticope/rejects/modules/AimAssist.java index f0b5c9bd..262597c2 100644 --- a/src/main/java/anticope/rejects/modules/AimAssist.java +++ b/src/main/java/anticope/rejects/modules/AimAssist.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.utils.RejectsUtils; import meteordevelopment.meteorclient.events.render.Render3DEvent; import meteordevelopment.meteorclient.events.world.TickEvent; @@ -22,6 +23,7 @@ import java.util.Set; +@AutoRegister public class AimAssist extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgSpeed = settings.createGroup("Aim Speed"); diff --git a/src/main/java/anticope/rejects/modules/AntiBot.java b/src/main/java/anticope/rejects/modules/AntiBot.java index 4c28345b..84ac48bc 100644 --- a/src/main/java/anticope/rejects/modules/AntiBot.java +++ b/src/main/java/anticope/rejects/modules/AntiBot.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.Setting; @@ -11,7 +12,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; - +@AutoRegister public class AntiBot extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/AntiCrash.java b/src/main/java/anticope/rejects/modules/AntiCrash.java index 166ea913..d00c9959 100644 --- a/src/main/java/anticope/rejects/modules/AntiCrash.java +++ b/src/main/java/anticope/rejects/modules/AntiCrash.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.packets.PacketEvent; import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.Setting; @@ -12,6 +13,7 @@ import net.minecraft.network.packet.s2c.play.ParticleS2CPacket; import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket; +@AutoRegister public class AntiCrash extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/AntiSpawnpoint.java b/src/main/java/anticope/rejects/modules/AntiSpawnpoint.java index 06d8049a..2370ae60 100644 --- a/src/main/java/anticope/rejects/modules/AntiSpawnpoint.java +++ b/src/main/java/anticope/rejects/modules/AntiSpawnpoint.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.packets.PacketEvent; import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.Setting; @@ -13,6 +14,7 @@ import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; +@AutoRegister public class AntiSpawnpoint extends Module { private SettingGroup sgDefault = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/AntiVanish.java b/src/main/java/anticope/rejects/modules/AntiVanish.java index aa6e84ae..f15a577e 100644 --- a/src/main/java/anticope/rejects/modules/AntiVanish.java +++ b/src/main/java/anticope/rejects/modules/AntiVanish.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import com.mojang.brigadier.suggestion.Suggestion; import meteordevelopment.meteorclient.events.game.ReceiveMessageEvent; import meteordevelopment.meteorclient.events.packets.PacketEvent; @@ -18,6 +19,7 @@ import java.util.function.Predicate; import java.util.stream.Collectors; +@AutoRegister public class AntiVanish extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/ArrowDmg.java b/src/main/java/anticope/rejects/modules/ArrowDmg.java index 02c8488f..80c8e30d 100644 --- a/src/main/java/anticope/rejects/modules/ArrowDmg.java +++ b/src/main/java/anticope/rejects/modules/ArrowDmg.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.events.StopUsingItemEvent; import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.IntSetting; @@ -14,6 +15,7 @@ import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; +@AutoRegister public class ArrowDmg extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/AutoBedTrap.java b/src/main/java/anticope/rejects/modules/AutoBedTrap.java index 5aa08cd2..da3552b9 100644 --- a/src/main/java/anticope/rejects/modules/AutoBedTrap.java +++ b/src/main/java/anticope/rejects/modules/AutoBedTrap.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Module; @@ -20,6 +21,7 @@ import java.util.Arrays; import java.util.List; +@AutoRegister public class AutoBedTrap extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/AutoCraft.java b/src/main/java/anticope/rejects/modules/AutoCraft.java index f87e5823..fde079f6 100644 --- a/src/main/java/anticope/rejects/modules/AutoCraft.java +++ b/src/main/java/anticope/rejects/modules/AutoCraft.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.ItemListSetting; @@ -17,6 +18,7 @@ import java.util.Arrays; import java.util.List; +@AutoRegister public class AutoCraft extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/AutoEnchant.java b/src/main/java/anticope/rejects/modules/AutoEnchant.java index f42f6eb9..39c00306 100644 --- a/src/main/java/anticope/rejects/modules/AutoEnchant.java +++ b/src/main/java/anticope/rejects/modules/AutoEnchant.java @@ -1,9 +1,9 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.game.OpenScreenEvent; import meteordevelopment.meteorclient.settings.*; -import meteordevelopment.meteorclient.utils.network.MeteorExecutor; import meteordevelopment.meteorclient.utils.player.FindItemResult; import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.orbit.EventHandler; @@ -18,12 +18,17 @@ import java.util.Objects; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; +@AutoRegister public class AutoEnchant extends meteordevelopment.meteorclient.systems.modules.Module { public final SettingGroup sgGeneral = settings.getDefaultGroup(); + private final ScheduledExecutorService executors = Executors.newSingleThreadScheduledExecutor(); + private final Setting delay = sgGeneral.add(new IntSetting.Builder() .name("delay") .description("The tick delay between enchanting items.") @@ -65,32 +70,32 @@ public AutoEnchant() { private void onOpenScreen(OpenScreenEvent event) { if (!(Objects.requireNonNull(mc.player).currentScreenHandler instanceof EnchantmentScreenHandler)) return; - MeteorExecutor.execute(this::autoEnchant); + this.autoEnchant(); } - private synchronized void autoEnchant() { + private void autoEnchant() { if (!(Objects.requireNonNull(mc.player).currentScreenHandler instanceof EnchantmentScreenHandler handler)) return; if (mc.player.experienceLevel < 30) { info("You don't have enough experience levels"); return; } - ScheduledExecutorService executors = Executors.newSingleThreadScheduledExecutor(); - executors.scheduleAtFixedRate(() -> { + AtomicReference> task = new AtomicReference<>(); + task.set(executors.scheduleAtFixedRate(() -> { try { if (!(mc.player.currentScreenHandler instanceof EnchantmentScreenHandler)) { info("Enchanting table is closed."); - executors.shutdown(); + task.get().cancel(true); return; } if (handler.getLapisCount() < level.get() && !fillLapisItem()) { info("Lapis lazuli is not found."); - executors.shutdown(); + task.get().cancel(true); return; } if (!fillCanEnchantItem()) { info("No items found to enchant."); - executors.shutdown(); + task.get().cancel(true); return; } @@ -98,13 +103,12 @@ private synchronized void autoEnchant() { if (getEmptySlotCount(handler) > 2) { InvUtils.shiftClick().slotId(0); } else if (drop.get() && handler.getSlot(0).hasStack()) { - mc.execute(() -> InvUtils.drop().slotId(0)); + mc.executeSync(() -> InvUtils.drop().slotId(0)); } - }catch (Exception e) { - e.printStackTrace(); - executors.shutdown(); + } catch (Exception ignored) { + task.get().cancel(true); } - }, 0, delay.get(), TimeUnit.MILLISECONDS); + }, 0, delay.get(), TimeUnit.MILLISECONDS)); } private boolean fillCanEnchantItem() { @@ -130,5 +134,4 @@ private int getEmptySlotCount(ScreenHandler handler) { } return emptySlotCount; } - } diff --git a/src/main/java/anticope/rejects/modules/AutoExtinguish.java b/src/main/java/anticope/rejects/modules/AutoExtinguish.java index d4c0f9da..6788eed2 100644 --- a/src/main/java/anticope/rejects/modules/AutoExtinguish.java +++ b/src/main/java/anticope/rejects/modules/AutoExtinguish.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.IntSetting; @@ -25,6 +26,7 @@ import java.util.concurrent.atomic.AtomicInteger; +@AutoRegister public class AutoExtinguish extends Module { private final SettingGroup sgGeneral = settings.createGroup("Extinguish Fire around you"); private final SettingGroup sgBucket = settings.createGroup("Extinguish yourself"); diff --git a/src/main/java/anticope/rejects/modules/AutoFarm.java b/src/main/java/anticope/rejects/modules/AutoFarm.java index 2109f2db..27ca83f2 100644 --- a/src/main/java/anticope/rejects/modules/AutoFarm.java +++ b/src/main/java/anticope/rejects/modules/AutoFarm.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.utils.WorldUtils; import meteordevelopment.meteorclient.events.entity.player.BreakBlockEvent; import meteordevelopment.meteorclient.events.world.TickEvent; @@ -27,6 +28,7 @@ import java.util.*; +@AutoRegister public class AutoFarm extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgTill = settings.createGroup("Till"); diff --git a/src/main/java/anticope/rejects/modules/AutoGrind.java b/src/main/java/anticope/rejects/modules/AutoGrind.java index 2075f0e0..f2c742f0 100644 --- a/src/main/java/anticope/rejects/modules/AutoGrind.java +++ b/src/main/java/anticope/rejects/modules/AutoGrind.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.game.OpenScreenEvent; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Module; @@ -21,6 +22,7 @@ import java.util.List; import java.util.Set; +@AutoRegister public class AutoGrind extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/AutoLogin.java b/src/main/java/anticope/rejects/modules/AutoLogin.java index 2d5f93bd..fd564251 100644 --- a/src/main/java/anticope/rejects/modules/AutoLogin.java +++ b/src/main/java/anticope/rejects/modules/AutoLogin.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.settings.StringMapSetting; import anticope.rejects.utils.RejectsUtils; import meteordevelopment.meteorclient.events.game.GameJoinedEvent; @@ -25,6 +26,7 @@ import java.util.*; +@AutoRegister public class AutoLogin extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/AutoPot.java b/src/main/java/anticope/rejects/modules/AutoPot.java index f44ba702..e3d67d83 100644 --- a/src/main/java/anticope/rejects/modules/AutoPot.java +++ b/src/main/java/anticope/rejects/modules/AutoPot.java @@ -3,6 +3,7 @@ //import baritone.api.BaritoneAPI; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import baritone.api.BaritoneAPI; import meteordevelopment.meteorclient.events.entity.player.ItemUseCrosshairTargetEvent; import meteordevelopment.meteorclient.events.world.TickEvent; @@ -29,6 +30,7 @@ import java.util.ArrayList; import java.util.List; +@AutoRegister public class AutoPot extends Module { private static final Class[] AURAS = new Class[]{KillAura.class, CrystalAura.class, AnchorAura.class, BedAura.class}; diff --git a/src/main/java/anticope/rejects/modules/AutoRename.java b/src/main/java/anticope/rejects/modules/AutoRename.java index b3903aa0..8ac6bb65 100644 --- a/src/main/java/anticope/rejects/modules/AutoRename.java +++ b/src/main/java/anticope/rejects/modules/AutoRename.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Module; @@ -20,6 +21,7 @@ import java.util.List; +@AutoRegister public class AutoRename extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/AutoSoup.java b/src/main/java/anticope/rejects/modules/AutoSoup.java index b33db9e4..767f240b 100644 --- a/src/main/java/anticope/rejects/modules/AutoSoup.java +++ b/src/main/java/anticope/rejects/modules/AutoSoup.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.DoubleSetting; import meteordevelopment.meteorclient.settings.Setting; @@ -25,6 +26,7 @@ import java.util.List; +@AutoRegister public class AutoSoup extends Module { private static final String desc = "Automatically eats soup when your health is low on some servers."; diff --git a/src/main/java/anticope/rejects/modules/AutoTNT.java b/src/main/java/anticope/rejects/modules/AutoTNT.java index 82ffb8d9..8794ff2b 100644 --- a/src/main/java/anticope/rejects/modules/AutoTNT.java +++ b/src/main/java/anticope/rejects/modules/AutoTNT.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.IntSetting; @@ -26,6 +27,7 @@ import java.util.Comparator; import java.util.List; +@AutoRegister public class AutoTNT extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/AutoWither.java b/src/main/java/anticope/rejects/modules/AutoWither.java index ab5185ae..df8e2deb 100644 --- a/src/main/java/anticope/rejects/modules/AutoWither.java +++ b/src/main/java/anticope/rejects/modules/AutoWither.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.render.Render3DEvent; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.renderer.ShapeMode; @@ -25,6 +26,7 @@ import java.util.Collections; import java.util.Comparator; +@AutoRegister public class AutoWither extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgRender = settings.createGroup("Render"); diff --git a/src/main/java/anticope/rejects/modules/BlockIn.java b/src/main/java/anticope/rejects/modules/BlockIn.java index a2f7b78a..ef913e70 100644 --- a/src/main/java/anticope/rejects/modules/BlockIn.java +++ b/src/main/java/anticope/rejects/modules/BlockIn.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.Setting; @@ -19,6 +20,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; +@AutoRegister public class BlockIn extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/BoatGlitch.java b/src/main/java/anticope/rejects/modules/BoatGlitch.java index 21c217b2..0bde389b 100644 --- a/src/main/java/anticope/rejects/modules/BoatGlitch.java +++ b/src/main/java/anticope/rejects/modules/BoatGlitch.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.entity.BoatMoveEvent; import meteordevelopment.meteorclient.events.meteor.KeyEvent; import meteordevelopment.meteorclient.events.world.TickEvent; @@ -16,6 +17,7 @@ import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket; import net.minecraft.util.Hand; +@AutoRegister public class BoatGlitch extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/BoatPhase.java b/src/main/java/anticope/rejects/modules/BoatPhase.java index adf54a17..8f1af11d 100644 --- a/src/main/java/anticope/rejects/modules/BoatPhase.java +++ b/src/main/java/anticope/rejects/modules/BoatPhase.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.entity.BoatMoveEvent; import meteordevelopment.meteorclient.mixininterface.IVec3d; import meteordevelopment.meteorclient.settings.BoolSetting; @@ -14,6 +15,7 @@ import net.minecraft.entity.vehicle.BoatEntity; import net.minecraft.util.math.Vec3d; +@AutoRegister public class BoatPhase extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgSpeeds = settings.createGroup("Speeds"); diff --git a/src/main/java/anticope/rejects/modules/Boost.java b/src/main/java/anticope/rejects/modules/Boost.java index 1b2581a9..66242365 100644 --- a/src/main/java/anticope/rejects/modules/Boost.java +++ b/src/main/java/anticope/rejects/modules/Boost.java @@ -1,12 +1,14 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.orbit.EventHandler; import net.minecraft.util.math.Vec3d; +@AutoRegister public class Boost extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/BungeeCordSpoof.java b/src/main/java/anticope/rejects/modules/BungeeCordSpoof.java index 4a6b0f7d..7e7f930d 100644 --- a/src/main/java/anticope/rejects/modules/BungeeCordSpoof.java +++ b/src/main/java/anticope/rejects/modules/BungeeCordSpoof.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.mixin.HandshakeC2SPacketAccessor; import com.google.gson.Gson; import com.mojang.authlib.properties.PropertyMap; @@ -14,6 +15,7 @@ import java.util.List; +@AutoRegister public class BungeeCordSpoof extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/ChatBot.java b/src/main/java/anticope/rejects/modules/ChatBot.java index 4674c2a2..4f011df1 100644 --- a/src/main/java/anticope/rejects/modules/ChatBot.java +++ b/src/main/java/anticope/rejects/modules/ChatBot.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.settings.StringMapSetting; import meteordevelopment.meteorclient.events.game.ReceiveMessageEvent; import meteordevelopment.meteorclient.gui.utils.StarscriptTextBoxRenderer; @@ -20,6 +21,7 @@ import java.util.LinkedHashMap; import java.util.Map; +@AutoRegister public class ChatBot extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/ChestAura.java b/src/main/java/anticope/rejects/modules/ChestAura.java index 435f6b75..1ad8458b 100644 --- a/src/main/java/anticope/rejects/modules/ChestAura.java +++ b/src/main/java/anticope/rejects/modules/ChestAura.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.mixininterface.IInventoryTweaks; import com.mojang.blaze3d.systems.RenderSystem; import meteordevelopment.meteorclient.MeteorClient; @@ -34,6 +35,7 @@ import java.util.Map; import java.util.stream.IntStream; +@AutoRegister public class ChestAura extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/ChorusExploit.java b/src/main/java/anticope/rejects/modules/ChorusExploit.java index 54555ad8..895c618f 100644 --- a/src/main/java/anticope/rejects/modules/ChorusExploit.java +++ b/src/main/java/anticope/rejects/modules/ChorusExploit.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.events.TeleportParticleEvent; import meteordevelopment.meteorclient.events.entity.player.FinishUsingItemEvent; import meteordevelopment.meteorclient.events.packets.PacketEvent; @@ -21,6 +22,7 @@ import java.util.LinkedList; import java.util.Queue; +@AutoRegister public class ChorusExploit extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgRender = settings.createGroup("Render"); diff --git a/src/main/java/anticope/rejects/modules/ColorSigns.java b/src/main/java/anticope/rejects/modules/ColorSigns.java index 708171c6..e9b786d8 100644 --- a/src/main/java/anticope/rejects/modules/ColorSigns.java +++ b/src/main/java/anticope/rejects/modules/ColorSigns.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.packets.PacketEvent; import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.Setting; @@ -14,6 +15,7 @@ import java.util.List; +@AutoRegister public class ColorSigns extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/Confuse.java b/src/main/java/anticope/rejects/modules/Confuse.java index 7484e612..fb9636c0 100644 --- a/src/main/java/anticope/rejects/modules/Confuse.java +++ b/src/main/java/anticope/rejects/modules/Confuse.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.render.Render3DEvent; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.*; @@ -23,6 +24,7 @@ // Too much much spaghetti! // -StormyBytes +@AutoRegister public class Confuse extends Module { public enum Mode { diff --git a/src/main/java/anticope/rejects/modules/CoordLogger.java b/src/main/java/anticope/rejects/modules/CoordLogger.java index 0a05fb87..ca57c79d 100644 --- a/src/main/java/anticope/rejects/modules/CoordLogger.java +++ b/src/main/java/anticope/rejects/modules/CoordLogger.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.packets.PacketEvent; import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.DoubleSetting; @@ -23,6 +24,7 @@ import java.util.UUID; +@AutoRegister public class CoordLogger extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgTeleports = settings.createGroup("Teleports"); diff --git a/src/main/java/anticope/rejects/modules/CustomPackets.java b/src/main/java/anticope/rejects/modules/CustomPackets.java index 0225a41f..8cf46d9d 100644 --- a/src/main/java/anticope/rejects/modules/CustomPackets.java +++ b/src/main/java/anticope/rejects/modules/CustomPackets.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; @@ -24,6 +25,7 @@ import java.nio.charset.StandardCharsets; import java.util.Map; +@AutoRegister public class CustomPackets extends Module { private static final Gson GSON_NON_PRETTY = new GsonBuilder().enableComplexMapKeySerialization().disableHtmlEscaping().create(); private static final Type BADLION_MODS_TYPE = new TypeToken>() { diff --git a/src/main/java/anticope/rejects/modules/ExtraElytra.java b/src/main/java/anticope/rejects/modules/ExtraElytra.java index a2fdb16f..5ade57b2 100644 --- a/src/main/java/anticope/rejects/modules/ExtraElytra.java +++ b/src/main/java/anticope/rejects/modules/ExtraElytra.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.Setting; @@ -15,6 +16,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; +@AutoRegister public class ExtraElytra extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/FullFlight.java b/src/main/java/anticope/rejects/modules/FullFlight.java index f20e723d..657c760f 100644 --- a/src/main/java/anticope/rejects/modules/FullFlight.java +++ b/src/main/java/anticope/rejects/modules/FullFlight.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.utils.RejectsUtils; import com.google.common.collect.Streams; import meteordevelopment.meteorclient.events.entity.player.PlayerMoveEvent; @@ -18,6 +19,7 @@ import java.util.stream.Stream; +@AutoRegister public class FullFlight extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgAntiKick = settings.createGroup("Anti Kick"); diff --git a/src/main/java/anticope/rejects/modules/GamemodeNotifier.java b/src/main/java/anticope/rejects/modules/GamemodeNotifier.java index 0a42362f..79060cd6 100644 --- a/src/main/java/anticope/rejects/modules/GamemodeNotifier.java +++ b/src/main/java/anticope/rejects/modules/GamemodeNotifier.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.settings.GameModeListSetting; import meteordevelopment.meteorclient.events.packets.PacketEvent; import meteordevelopment.meteorclient.settings.Setting; @@ -13,6 +14,7 @@ import java.util.List; +@AutoRegister public class GamemodeNotifier extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final Setting> gamemodes = sgGeneral.add(new GameModeListSetting.Builder() diff --git a/src/main/java/anticope/rejects/modules/GhostMode.java b/src/main/java/anticope/rejects/modules/GhostMode.java index 8d29a999..6cd8e2f9 100644 --- a/src/main/java/anticope/rejects/modules/GhostMode.java +++ b/src/main/java/anticope/rejects/modules/GhostMode.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.game.GameJoinedEvent; import meteordevelopment.meteorclient.events.game.OpenScreenEvent; import meteordevelopment.meteorclient.events.world.TickEvent; @@ -11,6 +12,7 @@ import meteordevelopment.orbit.EventHandler; import net.minecraft.client.gui.screen.DeathScreen; +@AutoRegister public class GhostMode extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/Glide.java b/src/main/java/anticope/rejects/modules/Glide.java index 9c1def7f..208d6494 100644 --- a/src/main/java/anticope/rejects/modules/Glide.java +++ b/src/main/java/anticope/rejects/modules/Glide.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.events.OffGroundSpeedEvent; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.DoubleSetting; @@ -12,7 +13,7 @@ import net.minecraft.util.math.Box; import net.minecraft.util.math.Vec3d; - +@AutoRegister public class Glide extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/InteractionMenu.java b/src/main/java/anticope/rejects/modules/InteractionMenu.java index 460ec43d..d58bc250 100644 --- a/src/main/java/anticope/rejects/modules/InteractionMenu.java +++ b/src/main/java/anticope/rejects/modules/InteractionMenu.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.gui.screens.InteractionScreen; import anticope.rejects.settings.StringMapSetting; import meteordevelopment.meteorclient.gui.utils.StarscriptTextBoxRenderer; @@ -20,6 +21,7 @@ import java.util.Optional; import java.util.Set; +@AutoRegister public class InteractionMenu extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/ItemGenerator.java b/src/main/java/anticope/rejects/modules/ItemGenerator.java index a5b04038..4e496bc5 100644 --- a/src/main/java/anticope/rejects/modules/ItemGenerator.java +++ b/src/main/java/anticope/rejects/modules/ItemGenerator.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.IntSetting; import meteordevelopment.meteorclient.settings.Setting; @@ -15,6 +16,7 @@ import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.math.random.Random; +@AutoRegister public class ItemGenerator extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final Setting speed = sgGeneral.add(new IntSetting.Builder() diff --git a/src/main/java/anticope/rejects/modules/Jetpack.java b/src/main/java/anticope/rejects/modules/Jetpack.java index 93ca1b32..93e622b5 100644 --- a/src/main/java/anticope/rejects/modules/Jetpack.java +++ b/src/main/java/anticope/rejects/modules/Jetpack.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.events.OffGroundSpeedEvent; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.mixininterface.IVec3d; @@ -10,6 +11,7 @@ import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.orbit.EventHandler; +@AutoRegister public class Jetpack extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/KnockbackPlus.java b/src/main/java/anticope/rejects/modules/KnockbackPlus.java index 4e73513b..678a4736 100644 --- a/src/main/java/anticope/rejects/modules/KnockbackPlus.java +++ b/src/main/java/anticope/rejects/modules/KnockbackPlus.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.packets.PacketEvent; import meteordevelopment.meteorclient.mixininterface.IPlayerInteractEntityC2SPacket; import meteordevelopment.meteorclient.settings.BoolSetting; @@ -15,6 +16,7 @@ import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket; +@AutoRegister public class KnockbackPlus extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/Lavacast.java b/src/main/java/anticope/rejects/modules/Lavacast.java index 63269fee..aaf8234f 100644 --- a/src/main/java/anticope/rejects/modules/Lavacast.java +++ b/src/main/java/anticope/rejects/modules/Lavacast.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.render.Render3DEvent; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.renderer.ShapeMode; @@ -24,7 +25,7 @@ import net.minecraft.util.math.Vec3i; import net.minecraft.world.RaycastContext; - +@AutoRegister public class Lavacast extends Module { private enum Stage { diff --git a/src/main/java/anticope/rejects/modules/LawnBot.java b/src/main/java/anticope/rejects/modules/LawnBot.java index d2d0c11c..05fdb8d8 100644 --- a/src/main/java/anticope/rejects/modules/LawnBot.java +++ b/src/main/java/anticope/rejects/modules/LawnBot.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Module; @@ -21,6 +22,7 @@ //TODO: add settings to find/use shovel, delay, range ? //https://github.com/DustinRepo/JexClient/blob/main/src/main/java/me/dustin/jex/feature/mod/impl/world/LawnBot.java +@AutoRegister public class LawnBot extends Module { private final ArrayList myceliumSpots = new ArrayList<>(); private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/MossBot.java b/src/main/java/anticope/rejects/modules/MossBot.java index 83bfa1de..c10f7124 100644 --- a/src/main/java/anticope/rejects/modules/MossBot.java +++ b/src/main/java/anticope/rejects/modules/MossBot.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.utils.WorldUtils; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.BoolSetting; @@ -23,6 +24,7 @@ import java.util.HashMap; import java.util.Map; +@AutoRegister public class MossBot extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/NewChunks.java b/src/main/java/anticope/rejects/modules/NewChunks.java index 8834251c..32c7cd6f 100644 --- a/src/main/java/anticope/rejects/modules/NewChunks.java +++ b/src/main/java/anticope/rejects/modules/NewChunks.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.packets.PacketEvent; import meteordevelopment.meteorclient.events.render.Render3DEvent; import meteordevelopment.meteorclient.renderer.ShapeMode; @@ -29,6 +30,7 @@ /* Ported from: https://github.com/BleachDrinker420/BleachHack/blob/master/BleachHack-Fabric-1.16/src/main/java/bleach/hack/module/mods/NewChunks.java */ +@AutoRegister public class NewChunks extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/NoJumpDelay.java b/src/main/java/anticope/rejects/modules/NoJumpDelay.java index 4f381416..1b007ba3 100644 --- a/src/main/java/anticope/rejects/modules/NoJumpDelay.java +++ b/src/main/java/anticope/rejects/modules/NoJumpDelay.java @@ -1,11 +1,13 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.mixin.LivingEntityAccessor; import meteordevelopment.orbit.EventHandler; import meteordevelopment.meteorclient.systems.modules.Module; +@AutoRegister public class NoJumpDelay extends Module { public NoJumpDelay() { diff --git a/src/main/java/anticope/rejects/modules/ObsidianFarm.java b/src/main/java/anticope/rejects/modules/ObsidianFarm.java index d628b755..77b131dc 100644 --- a/src/main/java/anticope/rejects/modules/ObsidianFarm.java +++ b/src/main/java/anticope/rejects/modules/ObsidianFarm.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.systems.modules.Modules; @@ -18,6 +19,7 @@ import java.util.List; import java.util.Optional; +@AutoRegister public class ObsidianFarm extends Module { private boolean allowBreakAgain; diff --git a/src/main/java/anticope/rejects/modules/OreSim.java b/src/main/java/anticope/rejects/modules/OreSim.java index 6e137893..7622966e 100755 --- a/src/main/java/anticope/rejects/modules/OreSim.java +++ b/src/main/java/anticope/rejects/modules/OreSim.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.events.PlayerRespawnEvent; import anticope.rejects.events.SeedChangedEvent; import anticope.rejects.utils.Ore; @@ -31,6 +32,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; +@AutoRegister public class OreSim extends Module { private final Map>> chunkRenderers = new ConcurrentHashMap<>(); diff --git a/src/main/java/anticope/rejects/modules/PacketFly.java b/src/main/java/anticope/rejects/modules/PacketFly.java index 16339740..22c7cf93 100644 --- a/src/main/java/anticope/rejects/modules/PacketFly.java +++ b/src/main/java/anticope/rejects/modules/PacketFly.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.entity.player.PlayerMoveEvent; import meteordevelopment.meteorclient.events.entity.player.SendMovementPacketsEvent; import meteordevelopment.meteorclient.events.packets.PacketEvent; @@ -16,6 +17,7 @@ import java.util.HashSet; +@AutoRegister public class PacketFly extends Module { private final HashSet packets = new HashSet<>(); private final SettingGroup sgMovement = settings.createGroup("movement"); diff --git a/src/main/java/anticope/rejects/modules/Painter.java b/src/main/java/anticope/rejects/modules/Painter.java index f5fe81d4..fd2d407a 100644 --- a/src/main/java/anticope/rejects/modules/Painter.java +++ b/src/main/java/anticope/rejects/modules/Painter.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.utils.WorldUtils; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.*; @@ -14,6 +15,7 @@ import net.minecraft.block.Blocks; import net.minecraft.util.math.BlockPos; +@AutoRegister public class Painter extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/Rendering.java b/src/main/java/anticope/rejects/modules/Rendering.java index 960ad3f3..bd2ba4a9 100644 --- a/src/main/java/anticope/rejects/modules/Rendering.java +++ b/src/main/java/anticope/rejects/modules/Rendering.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.EnumSetting; import meteordevelopment.meteorclient.settings.Setting; @@ -11,6 +12,7 @@ import java.io.IOException; +@AutoRegister public class Rendering extends Module { public enum Shader { diff --git a/src/main/java/anticope/rejects/modules/RoboWalk.java b/src/main/java/anticope/rejects/modules/RoboWalk.java index 23208cbe..ed929be4 100644 --- a/src/main/java/anticope/rejects/modules/RoboWalk.java +++ b/src/main/java/anticope/rejects/modules/RoboWalk.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import anticope.rejects.mixin.PlayerMoveC2SPacketAccessor; import anticope.rejects.mixin.VehicleMoveC2SPacketAccessor; import meteordevelopment.meteorclient.events.packets.PacketEvent; @@ -9,6 +10,7 @@ import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.network.packet.c2s.play.VehicleMoveC2SPacket; +@AutoRegister public class RoboWalk extends Module { public RoboWalk() { super(MeteorRejectsAddon.CATEGORY, "robo-walk", "Bypasses LiveOverflow movement check."); diff --git a/src/main/java/anticope/rejects/modules/ShieldBypass.java b/src/main/java/anticope/rejects/modules/ShieldBypass.java index 36e8f2b1..89a0f955 100644 --- a/src/main/java/anticope/rejects/modules/ShieldBypass.java +++ b/src/main/java/anticope/rejects/modules/ShieldBypass.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.Cancellable; import meteordevelopment.meteorclient.events.meteor.MouseButtonEvent; import meteordevelopment.meteorclient.settings.BoolSetting; @@ -23,6 +24,7 @@ import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_LEFT; +@AutoRegister public class ShieldBypass extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/SilentDisconnect.java b/src/main/java/anticope/rejects/modules/SilentDisconnect.java index 3999a2e5..b6377987 100644 --- a/src/main/java/anticope/rejects/modules/SilentDisconnect.java +++ b/src/main/java/anticope/rejects/modules/SilentDisconnect.java @@ -1,8 +1,10 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.systems.modules.Module; +@AutoRegister public class SilentDisconnect extends Module { public SilentDisconnect() { super(MeteorRejectsAddon.CATEGORY, "silent-disconnect", "Won't show a disconnect screen when you disconnect."); diff --git a/src/main/java/anticope/rejects/modules/SkeletonESP.java b/src/main/java/anticope/rejects/modules/SkeletonESP.java index c56ad1dc..6e64c4ff 100644 --- a/src/main/java/anticope/rejects/modules/SkeletonESP.java +++ b/src/main/java/anticope/rejects/modules/SkeletonESP.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import com.mojang.blaze3d.systems.RenderSystem; import meteordevelopment.meteorclient.events.render.Render3DEvent; import meteordevelopment.meteorclient.settings.BoolSetting; @@ -32,6 +33,7 @@ import org.joml.Matrix4f; import org.joml.Quaternionf; +@AutoRegister public class SkeletonESP extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/SoundLocator.java b/src/main/java/anticope/rejects/modules/SoundLocator.java index cb3b8783..df27af01 100644 --- a/src/main/java/anticope/rejects/modules/SoundLocator.java +++ b/src/main/java/anticope/rejects/modules/SoundLocator.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.render.Render3DEvent; import meteordevelopment.meteorclient.events.world.PlaySoundEvent; import meteordevelopment.meteorclient.events.world.TickEvent; @@ -23,6 +24,7 @@ import java.util.Iterator; import java.util.List; +@AutoRegister public class SoundLocator extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/TreeAura.java b/src/main/java/anticope/rejects/modules/TreeAura.java index 559a7589..053d3580 100644 --- a/src/main/java/anticope/rejects/modules/TreeAura.java +++ b/src/main/java/anticope/rejects/modules/TreeAura.java @@ -1,6 +1,7 @@ package anticope.rejects.modules; import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Module; @@ -29,6 +30,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.IntStream; +@AutoRegister public class TreeAura extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/java/anticope/rejects/modules/VehicleOneHit.java b/src/main/java/anticope/rejects/modules/VehicleOneHit.java index da88c031..0088a861 100644 --- a/src/main/java/anticope/rejects/modules/VehicleOneHit.java +++ b/src/main/java/anticope/rejects/modules/VehicleOneHit.java @@ -2,6 +2,7 @@ import anticope.rejects.MeteorRejectsAddon; +import anticope.rejects.annotation.AutoRegister; import meteordevelopment.meteorclient.events.packets.PacketEvent; import meteordevelopment.meteorclient.settings.IntSetting; import meteordevelopment.meteorclient.settings.Setting; @@ -13,6 +14,7 @@ import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket; import net.minecraft.util.hit.EntityHitResult; +@AutoRegister public class VehicleOneHit extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); diff --git a/src/main/kotlin/anticope/rejects/annotation/AutoRegister.kt b/src/main/kotlin/anticope/rejects/annotation/AutoRegister.kt new file mode 100644 index 00000000..9b83f2e4 --- /dev/null +++ b/src/main/kotlin/anticope/rejects/annotation/AutoRegister.kt @@ -0,0 +1,20 @@ +package anticope.rejects.annotation + +/** + * Annotation used to mark classes that should be automatically registered + * into the Meteor Commands and Modules systems. Classes annotated with this will + * be processed at runtime to ensure they are included in both command and + * module management systems. + * + * Usage example: + * ``` + * @AutoRegister + * class ExampleModule: Module(MeteorAddon.CATEGORY, "example-module", "The description") + * // This module will be automatically registered + * // No need to manually add it to the Modules + * // Modules.get().add(ExampleModule()) + * ``` + */ +@Retention(AnnotationRetention.RUNTIME) +@Target(AnnotationTarget.CLASS) +annotation class AutoRegister diff --git a/src/main/kotlin/anticope/rejects/utils/MeteorManager.kt b/src/main/kotlin/anticope/rejects/utils/MeteorManager.kt new file mode 100644 index 00000000..0cc80df8 --- /dev/null +++ b/src/main/kotlin/anticope/rejects/utils/MeteorManager.kt @@ -0,0 +1,67 @@ +package anticope.rejects.utils + +import anticope.rejects.annotation.AutoRegister +import meteordevelopment.meteorclient.commands.Command +import meteordevelopment.meteorclient.commands.Commands +import meteordevelopment.meteorclient.systems.modules.Module +import meteordevelopment.meteorclient.systems.modules.Modules +import kotlin.reflect.KClass +import kotlin.reflect.full.createInstance +import kotlin.reflect.full.isSubclassOf + +private typealias Condition = (KClass<*>) -> Boolean + +private inline fun findKClasses(pkg: String, crossinline condition: Condition = { true }) = + PackageScanner.findKClasses(pkg) { kClass -> + kClass.isSubclassOf(T::class) && condition(kClass) + } + +private inline fun registerClasses(packageName: String, addInstance: (T) -> Unit) { + val result = findKClasses(packageName) { kClass -> + kClass.annotations.any { it is AutoRegister } && !kClass.isAbstract + } + result.forEach { clazz -> + val instance = clazz.createInstance() + addInstance(instance as T) + } +} + +/** + * Registers all modules in the specified package that are annotated with @AutoRegister. + * + * This function scans the given package for classes that extend [Module] and have the @AutoRegister annotation, + * creating instances of those classes and adding them to the [Modules] system. + * + * @param packageName The name of the package to search for modules, formatted as "com.example.module". + * + * @throws ClassNotFoundException If the classes in the specified package cannot be found. + * + * Usage example: + * ``` + * moduleRegister("com.github.shu.module") + * ``` + * This will register all auto-registered modules from the "com.github.shu.module" package. + */ +fun moduleRegister(packageName: String) { + registerClasses(packageName, Modules.get()::add) +} + +/** + * Registers all commands in the specified package that are annotated with @AutoRegister. + * + * This function scans the given package for classes that extend [Command] and have the @AutoRegister annotation, + * creating instances of those classes and adding them to the [Commands] system. + * + * @param packageName The name of the package to search for commands, formatted as "com.example.command". + * + * @throws ClassNotFoundException If the classes in the specified package cannot be found. + * + * Usage example: + * ``` + * commandRegister("com.github.shu.command") + * ``` + * This will register all auto-registered commands from the "com.github.shu.command" package. + */ +fun commandRegister(packageName: String) { + registerClasses(packageName, Commands::add) +} \ No newline at end of file diff --git a/src/main/kotlin/anticope/rejects/utils/PackageScanner.kt b/src/main/kotlin/anticope/rejects/utils/PackageScanner.kt new file mode 100644 index 00000000..a4dadd78 --- /dev/null +++ b/src/main/kotlin/anticope/rejects/utils/PackageScanner.kt @@ -0,0 +1,70 @@ +package anticope.rejects.utils + +import org.slf4j.LoggerFactory +import java.io.File +import java.net.JarURLConnection +import java.util.jar.JarFile +import kotlin.reflect.KClass + +class PackageScanner { + companion object { + private val log = LoggerFactory.getLogger(PackageScanner::class.java) + private val loader = Thread.currentThread().contextClassLoader + + /** + * Finds all Kotlin classes in the specified package and filters them based on the provided criteria. + * + * @param packageName The name of the package to search, formatted as "com.example.package". + * @param filter An optional filtering function that takes a [KClass] parameter and returns a boolean value. + * Only classes for which this function returns `true` will be included in the results. + * Defaults to a filter that accepts all classes (returns `true`). + * @return A list of [KClass] objects that match the specified criteria. + * + * @throws ClassNotFoundException If the classes in the specified package cannot be found. + * + * Usage example: + * ``` + * val classes = findKClasses("com.example") { it.annotations.any { annotation -> annotation is MyAnnotation } } + * ``` + * This will return all classes in the "com.example" package that are annotated with `@MyAnnotation`. + */ + @JvmStatic + fun findKClasses(packageName: String, filter: (KClass<*>) -> Boolean = { true }): List> { + return PackageScanner().findKClasses(packageName).filter(filter) + } + } + + private fun findKClasses(packageName: String): List> { + val result = mutableListOf>() + val path = packageName.replace('.', '/') + loader.getResources(path).asSequence().forEach { url -> + result.addAll(when (url.protocol) { + "file" -> findKClassInFile(File(url.path), packageName) + "jar" -> (url.openConnection() as JarURLConnection).jarFile.use { findKClassInJar(it, path) } + else -> emptyList() + }) + } + return result + } + + private fun findKClassInFile(file: File, packageName: String): List> = + file.walkTopDown() + .filter { it.isFile && it.name.endsWith(".class") } + .mapNotNull { + it.name.toClassName(packageName).let { className -> loader.loadClass(className).kotlinOrNull() } + } + .toList() + + private fun findKClassInJar(jarFile: JarFile, path: String): List> = + jarFile.entries().asSequence() + .filter { it.name.startsWith(path) && it.name.endsWith(".class") } + .mapNotNull { loader.loadClass(it.name.toClassName()).kotlinOrNull() } + .toList() + + private fun String.toClassName(prefix: String = "") = + "$prefix.${substringBeforeLast(".class").replace('/', '.')}".removePrefix(".") + + private fun Class<*>.kotlinOrNull(): KClass<*>? = + runCatching { kotlin }.onFailure { log.error(it.message) }.getOrNull() +} + From 262a0414492396af8b5b14df578ff115511cfd3f Mon Sep 17 00:00:00 2001 From: qingshu-ui Date: Tue, 15 Oct 2024 20:32:31 +0800 Subject: [PATCH 3/6] Update build.gradle.kts --- build.gradle.kts | 18 ++++++------------ .../anticope/rejects/utils/MeteorManager.kt | 16 ++++++++-------- .../anticope/rejects/utils/PackageScanner.kt | 4 ++-- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 1d50625a..4c0cff8f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -39,21 +39,15 @@ repositories { maven { url = uri("https://jitpack.io") } maven { url = uri("https://maven.duti.dev/releases") } } -configurations { - // configuration that holds jars to include in the jar - create("extraLibs") -} +val extraLibs: Configuration by configurations.creating configurations { - named("implementation") { - extendsFrom(getByName("extraLibs")) + // configuration that holds jars to include in the jar + implementation { + extendsFrom(extraLibs) } } -fun DependencyHandlerScope.extraLibs(dependencyNotation: String, configure: ModuleDependency.() -> Unit = {}) { - add("extraLibs", dependencyNotation, configure) -} - dependencies { // This will make it work on most platforms. It automatically chooses the right dependencies at runtime. val cubiomesVersion = "dev.duti.acheong:cubiomes:1.22.3" @@ -78,7 +72,7 @@ dependencies { "com.seedfinding:mc_noise:7e3ba65e181796c4a2a1c8881d840b2254b92962", "com.seedfinding:mc_biome:41a42cb9019a552598f12089059538853e18ec78", "com.seedfinding:mc_terrain:b4246cbd5880c4f8745ccb90e1b102bde3448126", - "com.seedfinding:mc_feature:919b7e513cc1e87e029a9cd703fc4e2dc8686229" + "com.seedfinding:mc_feature:919b7e513cc1e87e029a9cd703fc4e2dc8686229", ) seedFindingDependencies.forEach { dependency -> extraLibs(dependency) { isTransitive = false } @@ -114,7 +108,7 @@ tasks.jar { from("LICENSE") { rename { "${it}_${project.base.archivesName}" } } - from(configurations["extraLibs"].map { if (it.isDirectory) it else zipTree(it) }) + from(extraLibs.map { if (it.isDirectory) it else zipTree(it) }) } tasks.withType() { diff --git a/src/main/kotlin/anticope/rejects/utils/MeteorManager.kt b/src/main/kotlin/anticope/rejects/utils/MeteorManager.kt index 0cc80df8..0962635a 100644 --- a/src/main/kotlin/anticope/rejects/utils/MeteorManager.kt +++ b/src/main/kotlin/anticope/rejects/utils/MeteorManager.kt @@ -27,12 +27,12 @@ private inline fun registerClasses(packageName: String, addInstance: } /** - * Registers all modules in the specified package that are annotated with @AutoRegister. + * Registers all modules in the specified package that are annotated with `@AutoRegister`. * - * This function scans the given package for classes that extend [Module] and have the @AutoRegister annotation, + * This function scans the given package for classes that extend [Module] and have the `@AutoRegister` annotation, * creating instances of those classes and adding them to the [Modules] system. * - * @param packageName The name of the package to search for modules, formatted as "com.example.module". + * @param packageName The name of the package to search for modules, formatted as `com.example.module`. * * @throws ClassNotFoundException If the classes in the specified package cannot be found. * @@ -40,19 +40,19 @@ private inline fun registerClasses(packageName: String, addInstance: * ``` * moduleRegister("com.github.shu.module") * ``` - * This will register all auto-registered modules from the "com.github.shu.module" package. + * This will register all auto-registered modules from the `com.github.shu.module` package. */ fun moduleRegister(packageName: String) { registerClasses(packageName, Modules.get()::add) } /** - * Registers all commands in the specified package that are annotated with @AutoRegister. + * Registers all commands in the specified package that are annotated with `@AutoRegister`. * - * This function scans the given package for classes that extend [Command] and have the @AutoRegister annotation, + * This function scans the given package for classes that extend [Command] and have the `@AutoRegister` annotation, * creating instances of those classes and adding them to the [Commands] system. * - * @param packageName The name of the package to search for commands, formatted as "com.example.command". + * @param packageName The name of the package to search for commands, formatted as `com.example.command`. * * @throws ClassNotFoundException If the classes in the specified package cannot be found. * @@ -60,7 +60,7 @@ fun moduleRegister(packageName: String) { * ``` * commandRegister("com.github.shu.command") * ``` - * This will register all auto-registered commands from the "com.github.shu.command" package. + * This will register all auto-registered commands from the `com.github.shu.command` package. */ fun commandRegister(packageName: String) { registerClasses(packageName, Commands::add) diff --git a/src/main/kotlin/anticope/rejects/utils/PackageScanner.kt b/src/main/kotlin/anticope/rejects/utils/PackageScanner.kt index a4dadd78..56b27089 100644 --- a/src/main/kotlin/anticope/rejects/utils/PackageScanner.kt +++ b/src/main/kotlin/anticope/rejects/utils/PackageScanner.kt @@ -14,7 +14,7 @@ class PackageScanner { /** * Finds all Kotlin classes in the specified package and filters them based on the provided criteria. * - * @param packageName The name of the package to search, formatted as "com.example.package". + * @param packageName The name of the package to search, formatted as `com.example.package`. * @param filter An optional filtering function that takes a [KClass] parameter and returns a boolean value. * Only classes for which this function returns `true` will be included in the results. * Defaults to a filter that accepts all classes (returns `true`). @@ -26,7 +26,7 @@ class PackageScanner { * ``` * val classes = findKClasses("com.example") { it.annotations.any { annotation -> annotation is MyAnnotation } } * ``` - * This will return all classes in the "com.example" package that are annotated with `@MyAnnotation`. + * This will return all classes in the `com.example` package that are annotated with `@MyAnnotation`. */ @JvmStatic fun findKClasses(packageName: String, filter: (KClass<*>) -> Boolean = { true }): List> { From 356c6ef4bdb9c3155f66ad21a382f180427a30ce Mon Sep 17 00:00:00 2001 From: qingshu-ui Date: Tue, 15 Oct 2024 21:46:02 +0800 Subject: [PATCH 4/6] fix #352, Avoid game crash, This feature may not work in future release. --- .../anticope/rejects/commands/LocateCommand.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/anticope/rejects/commands/LocateCommand.java b/src/main/java/anticope/rejects/commands/LocateCommand.java index ddeadd3b..457cbadb 100644 --- a/src/main/java/anticope/rejects/commands/LocateCommand.java +++ b/src/main/java/anticope/rejects/commands/LocateCommand.java @@ -3,12 +3,13 @@ import anticope.rejects.annotation.AutoRegister; import anticope.rejects.arguments.EnumArgumentType; import anticope.rejects.utils.WorldGenUtils; +import anticope.rejects.utils.seeds.Seed; import anticope.rejects.utils.seeds.Seeds; - import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; import com.seedfinding.mccore.version.MCVersion; - +import cubitect.Cubiomes; +import cubitect.Cubiomes.Pos; import meteordevelopment.meteorclient.commands.Command; import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.player.ChatUtils; @@ -17,8 +18,6 @@ import net.minecraft.text.Text; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -import cubitect.Cubiomes; -import cubitect.Cubiomes.Pos; @AutoRegister public class LocateCommand extends Command { @@ -42,8 +41,13 @@ public void build(LiteralArgumentBuilder builder) { .then(argument("feature", EnumArgumentType.enumArgument(Cubiomes.StructureType.Village)).executes(ctx -> { Cubiomes.StructureType feature = EnumArgumentType.getEnum(ctx, "feature", Cubiomes.StructureType.Village); BlockPos playerPos = mc.player.getBlockPos(); - long seed = Seeds.get().getSeed().seed; - MCVersion version = Seeds.get().getSeed().version; + Seed seedObj = Seeds.get().getSeed(); + if (null == seedObj) { + info(Text.literal("No seed found or seed is null")); + return SINGLE_SUCCESS; + } + long seed = seedObj.seed; + MCVersion version = seedObj.version; Cubiomes.MCVersion cubiomesVersion = null; if (version.isNewerOrEqualTo(MCVersion.v1_20)) { cubiomesVersion = Cubiomes.MCVersion.MC_1_20; From 24b148b07ce3e346dac3d384b0dab82aa08bcadb Mon Sep 17 00:00:00 2001 From: qingshu-ui Date: Wed, 16 Oct 2024 16:20:33 +0800 Subject: [PATCH 5/6] fix #385 --- src/main/java/anticope/rejects/modules/VehicleOneHit.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/anticope/rejects/modules/VehicleOneHit.java b/src/main/java/anticope/rejects/modules/VehicleOneHit.java index 0088a861..12028f6e 100644 --- a/src/main/java/anticope/rejects/modules/VehicleOneHit.java +++ b/src/main/java/anticope/rejects/modules/VehicleOneHit.java @@ -31,15 +31,20 @@ public VehicleOneHit() { super(MeteorRejectsAddon.CATEGORY, "vehicle-one-hit", "Destroy vehicles with one hit."); } + private boolean isManualSend = false; + @EventHandler private void onPacketSend(PacketEvent.Send event) { + if (isManualSend) return; if (!(event.packet instanceof PlayerInteractEntityC2SPacket) || !(mc.crosshairTarget instanceof EntityHitResult ehr) || (!(ehr.getEntity() instanceof AbstractMinecartEntity) && !(ehr.getEntity() instanceof BoatEntity)) ) return; + isManualSend = true; for (int i = 0; i < amount.get() - 1; i++) { mc.player.networkHandler.getConnection().send(event.packet, null); } + isManualSend = false; } } \ No newline at end of file From 1e9643bff6f38b2cd11e96d2b3c521fd75fbe2da Mon Sep 17 00:00:00 2001 From: qingshu-ui Date: Sun, 20 Oct 2024 01:25:44 +0800 Subject: [PATCH 6/6] fix #387, Fixed game crash when meteor-client version is 2188 --- .gitignore | 1 + src/main/java/anticope/rejects/mixin/meteor/ModuleMixin.java | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 09cd281f..d86ff2a3 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ bin/ # fabric run/ +.kotlin diff --git a/src/main/java/anticope/rejects/mixin/meteor/ModuleMixin.java b/src/main/java/anticope/rejects/mixin/meteor/ModuleMixin.java index 2cc1eb41..5e4fa501 100644 --- a/src/main/java/anticope/rejects/mixin/meteor/ModuleMixin.java +++ b/src/main/java/anticope/rejects/mixin/meteor/ModuleMixin.java @@ -18,7 +18,10 @@ public class ModuleMixin { @Mutable @Shadow public String title; - @Inject(method = "", at = @At("TAIL")) + @Inject( + method = "(Lmeteordevelopment/meteorclient/systems/modules/Category;Ljava/lang/String;Ljava/lang/String;)V", + at = @At("TAIL") + ) private void onInit(Category category, String name, String description, CallbackInfo info) { if (RejectsConfig.get().duplicateModuleNames) { this.name = RejectsUtils.getModuleName(name);