From 00404daddd1aa820ec8bb18cd4730650ffe9c6e3 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Sun, 26 Apr 2026 22:48:26 +0100 Subject: [PATCH 01/40] cleanup --- .../lambda/mixin/MinecraftClientMixin.java | 8 +- .../baritone/BaritonePlayerContextMixin.java | 4 +- .../mixin/baritone/LookBehaviourMixin.java | 8 +- .../render/BlockEntityRenderManagerMixin.java | 4 +- .../render/BlockEntityRendererMixin.java | 4 +- .../render/CapeFeatureRendererMixin.java | 6 +- .../mixin/render/ChatInputSuggestorMixin.java | 6 +- .../lambda/mixin/render/ChatScreenMixin.java | 6 +- .../render/ElytraFeatureRendererMixin.java | 6 +- .../render/EntityRenderManagerMixin.java | 4 +- .../mixin/render/EntityRendererMixin.java | 4 +- .../mixin/render/PlayerListHudMixin.java | 8 +- .../mixin/render/WorldRendererMixin.java | 10 +-- src/main/kotlin/com/lambda/Lambda.kt | 4 +- .../{CommandManager.kt => CommandHandler.kt} | 6 +- .../com/lambda/command/CommandRegistry.kt | 2 +- .../com/lambda/command/LambdaCommand.kt | 2 +- .../lambda/command/commands/CapeCommand.kt | 4 +- .../lambda/command/commands/FriendCommand.kt | 48 +++++----- .../command/commands/TransferCommand.kt | 10 +-- .../config/groups/EntityColorSettings.kt | 2 +- .../com/lambda/config/groups/Targeting.kt | 2 +- .../{ColorSerializer.kt => ColorCodec.kt} | 2 +- .../core/{PingManager.kt => PingHandler.kt} | 15 ++-- .../core/{TimerManager.kt => TimerHandler.kt} | 2 +- .../{FriendManager.kt => FriendHandler.kt} | 2 +- .../kotlin/com/lambda/graphics/RenderMain.kt | 4 +- .../com/lambda/graphics/mc/RenderBuilder.kt | 10 +-- .../{OutlineManager.kt => OutlineHandler.kt} | 2 +- .../graphics/outline/OutlineIdPassRenderer.kt | 2 +- .../graphics/outline/OutlineRenderer.kt | 12 +-- src/main/kotlin/com/lambda/gui/MenuBar.kt | 4 +- .../lambda/gui/components/ClickGuiLayout.kt | 16 ++-- .../com/lambda/gui/components/HudGuiLayout.kt | 16 ++-- .../snap/{SnapManager.kt => SnapHandler.kt} | 2 +- ...{BaritoneManager.kt => BaritoneHandler.kt} | 2 +- .../simulation/checks/BreakSim.kt | 8 +- .../simulation/checks/InteractSim.kt | 2 +- .../placement/post/ChestPostProcessor.kt | 1 - .../placement/post/PoweredPostProcessor.kt | 1 - .../placement/post/SlabPostProcessor.kt | 1 - .../post/StandardInteractPostProcessor.kt | 1 - .../placement/pre/AttachmentPreProcessor.kt | 1 - .../placement/pre/AxisPreProcessor.kt | 1 - .../placement/pre/BlockFacePreProcessor.kt | 1 - .../placement/pre/BlockHalfPreProcessor.kt | 1 - .../placement/pre/ChestPreProcessor.kt | 1 - .../placement/pre/DoorHingePreProcessor.kt | 1 - .../placement/pre/HopperFacingPreProcessor.kt | 1 - .../placement/pre/SlabPreProcessor.kt | 1 - .../state/BambooStateProcessor.kt | 1 - .../preprocessors/state/FireStateProcessor.kt | 1 - .../state/FlowerPotStateProcessor.kt | 1 - .../simulation/result/results/BreakResult.kt | 2 +- .../result/results/GenericResult.kt | 2 +- .../construction/verify/TargetState.kt | 2 +- .../managers/rotating/RotationManager.kt | 4 +- ...ontainerManager.kt => ContainerHandler.kt} | 2 +- .../container/containers/ChestContainer.kt | 4 +- .../containers/EnderChestContainer.kt | 6 +- .../containers/ShulkerBoxContainer.kt | 4 +- src/main/kotlin/com/lambda/module/Module.kt | 2 +- .../kotlin/com/lambda/module/hud/Baritone.kt | 6 +- .../lambda/module/modules/chat/AntiSpam.kt | 5 +- .../module/modules/chat/ChatTimestamp.kt | 1 + .../lambda/module/modules/chat/CustomChat.kt | 5 +- .../lambda/module/modules/chat/FancyChat.kt | 5 +- .../module/modules/chat/FriendHighlight.kt | 9 +- .../lambda/module/modules/client/Discord.kt | 3 +- .../lambda/module/modules/combat/AutoArmor.kt | 1 + .../module/modules/combat/AutoDisconnect.kt | 7 +- .../lambda/module/modules/combat/AutoTotem.kt | 5 +- .../lambda/module/modules/combat/Criticals.kt | 1 + .../module/modules/combat/CrystalAura.kt | 3 +- .../module/modules/combat/FakePlayer.kt | 1 + .../module/modules/combat/PlayerTrap.kt | 3 +- .../lambda/module/modules/combat/Surround.kt | 2 +- .../module/modules/debug/BaritoneTest.kt | 7 +- .../lambda/module/modules/debug/BlockTest.kt | 2 +- .../module/modules/debug/ContainerTest.kt | 1 + .../modules/debug/DebugRendererModule.kt | 5 +- .../lambda/module/modules/debug/FallTest.kt | 1 + .../module/modules/debug/InventoryDebug.kt | 1 + .../module/modules/debug/PropertyPrinter.kt | 1 + .../lambda/module/modules/debug/RenderTest.kt | 1 + .../modules/debug/RendererTestModule.kt | 8 +- .../module/modules/debug/RotationTest.kt | 1 + .../modules/debug/SettingsTestModule.kt | 1 + .../lambda/module/modules/debug/TimerTest.kt | 1 + .../module/modules/movement/AutoSpiral.kt | 9 +- .../module/modules/movement/AutoWalk.kt | 1 + .../module/modules/movement/BackTrack.kt | 1 + .../modules/movement/ElytraAltitudeControl.kt | 3 +- .../module/modules/movement/ElytraFly.kt | 10 +-- .../module/modules/movement/EntityControl.kt | 1 + .../lambda/module/modules/movement/Jesus.kt | 1 + .../lambda/module/modules/movement/NoFall.kt | 1 + .../lambda/module/modules/movement/Timer.kt | 1 + .../module/modules/network/PacketDelay.kt | 1 + .../lambda/module/modules/player/AntiAFK.kt | 1 + .../lambda/module/modules/player/AntiAim.kt | 1 + .../lambda/module/modules/player/AutoEat.kt | 1 + .../module/modules/player/ClickFriend.kt | 13 +-- .../lambda/module/modules/player/FastBreak.kt | 1 + .../lambda/module/modules/player/Replay.kt | 6 +- .../module/modules/player/RotationLock.kt | 1 + .../module/modules/player/StackReplenish.kt | 1 + .../lambda/module/modules/player/ToolSaver.kt | 1 + .../com/lambda/module/modules/render/ESP.kt | 1 + .../lambda/module/modules/render/Nametags.kt | 2 +- .../lambda/module/modules/render/RadiusESP.kt | 1 + .../lambda/module/modules/render/Search.kt | 1 + .../lambda/module/modules/render/Tracers.kt | 3 +- .../module/modules/render/WorldColors.kt | 1 + .../lambda/module/modules/world/AirPlace.kt | 1 + .../lambda/module/modules/world/AutoPortal.kt | 4 +- .../module/modules/world/AutoVillagerCycle.kt | 3 +- .../module/modules/world/HighwayTools.kt | 4 +- .../module/modules/world/MapDownloader.kt | 1 + .../com/lambda/module/modules/world/Nuker.kt | 1 + .../lambda/module/modules/world/Printer.kt | 1 + .../lambda/module/modules/world/StashMover.kt | 15 ++-- .../lambda/module/modules/world/WorldEater.kt | 87 ------------------- .../{CapeManager.kt => CapeHandler.kt} | 2 +- .../kotlin/com/lambda/network/LambdaAPI.kt | 4 +- .../{NetworkManager.kt => NetworkHandler.kt} | 2 +- .../network/api/v1/endpoints/LinkDiscord.kt | 4 +- .../network/api/v1/endpoints/SetCape.kt | 4 +- .../{SoundManager.kt => SoundHandler.kt} | 2 +- .../lambda/task/tasks/AcquireMaterialTask.kt | 6 +- .../kotlin/com/lambda/task/tasks/BuildTask.kt | 10 +-- .../kotlin/com/lambda/task/tasks/EatTask.kt | 2 - .../lambda/task/tasks/OpenContainerTask.kt | 4 +- src/main/kotlin/com/lambda/util/InputUtils.kt | 2 +- .../com/lambda/util/PlayerBuildLayerUtils.kt | 4 +- 135 files changed, 272 insertions(+), 344 deletions(-) rename src/main/kotlin/com/lambda/command/{CommandManager.kt => CommandHandler.kt} (96%) rename src/main/kotlin/com/lambda/config/serializer/{ColorSerializer.kt => ColorCodec.kt} (96%) rename src/main/kotlin/com/lambda/core/{PingManager.kt => PingHandler.kt} (93%) rename src/main/kotlin/com/lambda/core/{TimerManager.kt => TimerHandler.kt} (97%) rename src/main/kotlin/com/lambda/friend/{FriendManager.kt => FriendHandler.kt} (98%) rename src/main/kotlin/com/lambda/graphics/outline/{OutlineManager.kt => OutlineHandler.kt} (99%) rename src/main/kotlin/com/lambda/gui/snap/{SnapManager.kt => SnapHandler.kt} (99%) rename src/main/kotlin/com/lambda/interaction/{BaritoneManager.kt => BaritoneHandler.kt} (99%) rename src/main/kotlin/com/lambda/interaction/material/container/{ContainerManager.kt => ContainerHandler.kt} (99%) delete mode 100644 src/main/kotlin/com/lambda/module/modules/world/WorldEater.kt rename src/main/kotlin/com/lambda/network/{CapeManager.kt => CapeHandler.kt} (98%) rename src/main/kotlin/com/lambda/network/{NetworkManager.kt => NetworkHandler.kt} (97%) rename src/main/kotlin/com/lambda/sound/{SoundManager.kt => SoundHandler.kt} (98%) diff --git a/src/main/java/com/lambda/mixin/MinecraftClientMixin.java b/src/main/java/com/lambda/mixin/MinecraftClientMixin.java index 309ec2dfb..2c7c4a8c6 100644 --- a/src/main/java/com/lambda/mixin/MinecraftClientMixin.java +++ b/src/main/java/com/lambda/mixin/MinecraftClientMixin.java @@ -17,7 +17,7 @@ package com.lambda.mixin; -import com.lambda.core.TimerManager; +import com.lambda.core.TimerHandler; import com.lambda.event.EventFlow; import com.lambda.event.events.ClientEvent; import com.lambda.event.events.GuiEvent; @@ -194,10 +194,10 @@ void injectItemPick(Operation original) { @WrapMethod(method = "getTargetMillisPerTick") float getTargetMillisPerTick(float millis, Operation original) { - var length = TimerManager.INSTANCE.getLength(); + var length = TimerHandler.INSTANCE.getLength(); - if (length == TimerManager.DEFAULT_LENGTH) return original.call(millis); - else return (float) TimerManager.INSTANCE.getLength(); + if (length == TimerHandler.DEFAULT_LENGTH) return original.call(millis); + else return (float) TimerHandler.INSTANCE.getLength(); } @Inject(method = "updateWindowTitle", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/com/lambda/mixin/baritone/BaritonePlayerContextMixin.java b/src/main/java/com/lambda/mixin/baritone/BaritonePlayerContextMixin.java index 0bc8f1b00..2e0a86d85 100644 --- a/src/main/java/com/lambda/mixin/baritone/BaritonePlayerContextMixin.java +++ b/src/main/java/com/lambda/mixin/baritone/BaritonePlayerContextMixin.java @@ -20,7 +20,7 @@ import baritone.Baritone; import baritone.api.utils.Rotation; import baritone.utils.player.BaritonePlayerContext; -import com.lambda.interaction.BaritoneManager; +import com.lambda.interaction.BaritoneHandler; import com.lambda.interaction.managers.rotating.RotationManager; import com.llamalad7.mixinextras.injector.ModifyReturnValue; import org.spongepowered.asm.mixin.Final; @@ -37,7 +37,7 @@ public class BaritonePlayerContextMixin { // Let baritone know the actual rotation @ModifyReturnValue(method = "playerRotations", at = @At("RETURN"), remap = false) Rotation syncRotationWithBaritone(Rotation original) { - if (baritone != BaritoneManager.getPrimary()) + if (baritone != BaritoneHandler.getPrimary()) return original; float yaw = (float) RotationManager.getActiveRotation().getYaw(); diff --git a/src/main/java/com/lambda/mixin/baritone/LookBehaviourMixin.java b/src/main/java/com/lambda/mixin/baritone/LookBehaviourMixin.java index 41eea516b..86ba59cd0 100644 --- a/src/main/java/com/lambda/mixin/baritone/LookBehaviourMixin.java +++ b/src/main/java/com/lambda/mixin/baritone/LookBehaviourMixin.java @@ -21,7 +21,7 @@ import baritone.api.event.events.RotationMoveEvent; import baritone.api.utils.Rotation; import baritone.behavior.LookBehavior; -import com.lambda.interaction.BaritoneManager; +import com.lambda.interaction.BaritoneHandler; import com.lambda.interaction.managers.rotating.RotationManager; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -37,7 +37,7 @@ public class LookBehaviourMixin { // Redirect baritone's rotations into our rotation engine @Inject(method = "updateTarget", at = @At("HEAD"), cancellable = true) void onTargetUpdate(Rotation rotation, boolean blockInteract, CallbackInfo ci) { - if (instance.baritone != BaritoneManager.getPrimary()) return; + if (instance.baritone != BaritoneHandler.getPrimary()) return; RotationManager.handleBaritoneRotation(rotation.getYaw(), rotation.getPitch()); ci.cancel(); @@ -45,14 +45,14 @@ void onTargetUpdate(Rotation rotation, boolean blockInteract, CallbackInfo ci) { @Inject(method = "onPlayerUpdate", at = @At("HEAD"), cancellable = true) void onUpdate(PlayerUpdateEvent event, CallbackInfo ci) { - if (instance.baritone != BaritoneManager.getPrimary()) return; + if (instance.baritone != BaritoneHandler.getPrimary()) return; ci.cancel(); } @Inject(method = "onPlayerRotationMove", at = @At("HEAD"), cancellable = true) void onMovementUpdate(RotationMoveEvent event, CallbackInfo ci) { - if (instance.baritone != BaritoneManager.getPrimary()) return; + if (instance.baritone != BaritoneHandler.getPrimary()) return; ci.cancel(); } diff --git a/src/main/java/com/lambda/mixin/render/BlockEntityRenderManagerMixin.java b/src/main/java/com/lambda/mixin/render/BlockEntityRenderManagerMixin.java index d67129b26..036d0881a 100644 --- a/src/main/java/com/lambda/mixin/render/BlockEntityRenderManagerMixin.java +++ b/src/main/java/com/lambda/mixin/render/BlockEntityRenderManagerMixin.java @@ -17,7 +17,7 @@ package com.lambda.mixin.render; -import com.lambda.graphics.outline.OutlineManager; +import com.lambda.graphics.outline.OutlineHandler; import com.lambda.graphics.outline.OutlineCapturingQueue; import com.lambda.graphics.outline.VertexCapture; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; @@ -42,7 +42,7 @@ private void wrapRenderQueue(BlockEntityRende Operation original) { BlockPos pos = renderState.pos; - if (pos != null && OutlineManager.shouldCapture(pos)) { + if (pos != null && OutlineHandler.shouldCapture(pos)) { VertexCapture.INSTANCE.beginCapture(pos); boolean outlineOnly = !Vec3d.ofCenter(pos).isInRange(cameraState.pos, renderer.getRenderDistance()); diff --git a/src/main/java/com/lambda/mixin/render/BlockEntityRendererMixin.java b/src/main/java/com/lambda/mixin/render/BlockEntityRendererMixin.java index d33c9fee4..dca20ca93 100644 --- a/src/main/java/com/lambda/mixin/render/BlockEntityRendererMixin.java +++ b/src/main/java/com/lambda/mixin/render/BlockEntityRendererMixin.java @@ -17,7 +17,7 @@ package com.lambda.mixin.render; -import com.lambda.graphics.outline.OutlineManager; +import com.lambda.graphics.outline.OutlineHandler; import net.minecraft.block.entity.BlockEntity; import net.minecraft.client.render.block.entity.BlockEntityRenderer; import net.minecraft.util.math.Vec3d; @@ -31,7 +31,7 @@ public interface BlockEntityRendererMixin { @Inject(method = "isInRenderDistance", at = @At("HEAD"), cancellable = true) default void forceOutlineRenderDistance(T blockEntity, Vec3d pos, CallbackInfoReturnable cir) { - if (OutlineManager.INSTANCE.shouldCapture(blockEntity.getPos())) { + if (OutlineHandler.INSTANCE.shouldCapture(blockEntity.getPos())) { cir.setReturnValue(true); } } diff --git a/src/main/java/com/lambda/mixin/render/CapeFeatureRendererMixin.java b/src/main/java/com/lambda/mixin/render/CapeFeatureRendererMixin.java index bc81be503..94997a075 100644 --- a/src/main/java/com/lambda/mixin/render/CapeFeatureRendererMixin.java +++ b/src/main/java/com/lambda/mixin/render/CapeFeatureRendererMixin.java @@ -19,7 +19,7 @@ import com.lambda.Lambda; import com.lambda.module.modules.client.Capes; -import com.lambda.network.CapeManager; +import com.lambda.network.CapeHandler; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import net.minecraft.client.render.command.OrderedRenderCommandQueue; import net.minecraft.client.render.entity.feature.CapeFeatureRenderer; @@ -43,8 +43,8 @@ Identifier renderCape(Identifier original, MatrixStack matrixStack, OrderedRende if (entry == null) return original; var profile = entry.getProfile(); - if (!Capes.INSTANCE.isEnabled() || !CapeManager.INSTANCE.getCache().containsKey(profile.id())) return original; + if (!Capes.INSTANCE.isEnabled() || !CapeHandler.INSTANCE.getCache().containsKey(profile.id())) return original; - return Identifier.of("lambda", CapeManager.INSTANCE.getCache().get(profile.id())); + return Identifier.of("lambda", CapeHandler.INSTANCE.getCache().get(profile.id())); } } diff --git a/src/main/java/com/lambda/mixin/render/ChatInputSuggestorMixin.java b/src/main/java/com/lambda/mixin/render/ChatInputSuggestorMixin.java index 83ac008b9..f7cd5a5c9 100644 --- a/src/main/java/com/lambda/mixin/render/ChatInputSuggestorMixin.java +++ b/src/main/java/com/lambda/mixin/render/ChatInputSuggestorMixin.java @@ -17,7 +17,7 @@ package com.lambda.mixin.render; -import com.lambda.command.CommandManager; +import com.lambda.command.CommandHandler; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.mojang.brigadier.CommandDispatcher; @@ -40,12 +40,12 @@ public abstract class ChatInputSuggestorMixin { @ModifyVariable(method = "refresh", at = @At(value = "STORE"), index = 3) private boolean refreshModify(boolean showCompletions) { - return CommandManager.INSTANCE.isCommand(textField.getText()); + return CommandHandler.INSTANCE.isCommand(textField.getText()); } @SuppressWarnings("unchecked") @WrapOperation(method = "refresh", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;getCommandDispatcher()Lcom/mojang/brigadier/CommandDispatcher;")) private CommandDispatcher wrapRefresh(ClientPlayNetworkHandler instance, Operation> original) { - return (CommandDispatcher) CommandManager.INSTANCE.currentDispatcher(textField.getText()); + return (CommandDispatcher) CommandHandler.INSTANCE.currentDispatcher(textField.getText()); } } diff --git a/src/main/java/com/lambda/mixin/render/ChatScreenMixin.java b/src/main/java/com/lambda/mixin/render/ChatScreenMixin.java index 4215fc37c..c3e22e955 100644 --- a/src/main/java/com/lambda/mixin/render/ChatScreenMixin.java +++ b/src/main/java/com/lambda/mixin/render/ChatScreenMixin.java @@ -17,7 +17,7 @@ package com.lambda.mixin.render; -import com.lambda.command.CommandManager; +import com.lambda.command.CommandHandler; import net.minecraft.client.gui.screen.ChatScreen; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -28,8 +28,8 @@ public abstract class ChatScreenMixin { @Inject(method = "sendMessage", at = @At("HEAD"), cancellable = true) void sendMessageInject(String chatText, boolean addToHistory, CallbackInfo ci) { - if (!CommandManager.INSTANCE.isLambdaCommand(chatText)) return; - CommandManager.INSTANCE.executeCommand(chatText); + if (!CommandHandler.INSTANCE.isLambdaCommand(chatText)) return; + CommandHandler.INSTANCE.executeCommand(chatText); ci.cancel(); } } diff --git a/src/main/java/com/lambda/mixin/render/ElytraFeatureRendererMixin.java b/src/main/java/com/lambda/mixin/render/ElytraFeatureRendererMixin.java index f9fad2c82..511ab3671 100644 --- a/src/main/java/com/lambda/mixin/render/ElytraFeatureRendererMixin.java +++ b/src/main/java/com/lambda/mixin/render/ElytraFeatureRendererMixin.java @@ -20,7 +20,7 @@ import com.lambda.Lambda; import com.lambda.module.modules.client.Capes; import com.lambda.module.modules.render.NoRender; -import com.lambda.network.CapeManager; +import com.lambda.network.CapeHandler; import com.llamalad7.mixinextras.injector.ModifyReturnValue; import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; @@ -50,10 +50,10 @@ private static Identifier injectElytra(Identifier original, BipedEntityRenderSta var profile = entry.getProfile(); - if (!Capes.INSTANCE.isEnabled() || !CapeManager.INSTANCE.getCache().containsKey(profile.id())) + if (!Capes.INSTANCE.isEnabled() || !CapeHandler.INSTANCE.getCache().containsKey(profile.id())) return original; - return Identifier.of("lambda", CapeManager.INSTANCE.getCache().get(profile.id())); + return Identifier.of("lambda", CapeHandler.INSTANCE.getCache().get(profile.id())); } @WrapMethod(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;ILnet/minecraft/client/render/entity/state/BipedEntityRenderState;FF)V") diff --git a/src/main/java/com/lambda/mixin/render/EntityRenderManagerMixin.java b/src/main/java/com/lambda/mixin/render/EntityRenderManagerMixin.java index f9c12ea60..b0c0cdc4b 100644 --- a/src/main/java/com/lambda/mixin/render/EntityRenderManagerMixin.java +++ b/src/main/java/com/lambda/mixin/render/EntityRenderManagerMixin.java @@ -18,7 +18,7 @@ package com.lambda.mixin.render; import com.lambda.graphics.outline.IEntityRenderState; -import com.lambda.graphics.outline.OutlineManager; +import com.lambda.graphics.outline.OutlineHandler; import com.lambda.graphics.outline.OutlineCapturingQueue; import com.lambda.graphics.outline.VertexCapture; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; @@ -51,7 +51,7 @@ private void wrapRenderQueue(EntityRenderer entityId = lambdaState.lambda$getEntityId(); } - if (entityId != -1 && OutlineManager.shouldCapture(entityId)) { + if (entityId != -1 && OutlineHandler.shouldCapture(entityId)) { VertexCapture.INSTANCE.beginCapture(entityId); OrderedRenderCommandQueueImpl wrappedQueue = new OutlineCapturingQueue((OrderedRenderCommandQueueImpl) queue, entityId); diff --git a/src/main/java/com/lambda/mixin/render/EntityRendererMixin.java b/src/main/java/com/lambda/mixin/render/EntityRendererMixin.java index 0de330752..5eba1041d 100644 --- a/src/main/java/com/lambda/mixin/render/EntityRendererMixin.java +++ b/src/main/java/com/lambda/mixin/render/EntityRendererMixin.java @@ -17,7 +17,7 @@ package com.lambda.mixin.render; -import com.lambda.graphics.outline.OutlineManager; +import com.lambda.graphics.outline.OutlineHandler; import com.lambda.module.modules.render.NoRender; import net.minecraft.client.render.Frustum; import net.minecraft.client.render.command.OrderedRenderCommandQueue; @@ -37,7 +37,7 @@ public class EntityRendererMixin { @Inject(method = "shouldRender(Lnet/minecraft/entity/Entity;Lnet/minecraft/client/render/Frustum;DDD)Z", at = @At("HEAD"), cancellable = true) private void injectShouldRender(Entity entity, Frustum frustum, double x, double y, double z, CallbackInfoReturnable cir) { if (NoRender.shouldOmitEntity(entity)) cir.cancel(); - else if (OutlineManager.shouldCapture(entity.getId())) cir.setReturnValue(true); + else if (OutlineHandler.shouldCapture(entity.getId())) cir.setReturnValue(true); } @Inject(method = "renderLabelIfPresent", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/com/lambda/mixin/render/PlayerListHudMixin.java b/src/main/java/com/lambda/mixin/render/PlayerListHudMixin.java index 31734c602..972b27d58 100644 --- a/src/main/java/com/lambda/mixin/render/PlayerListHudMixin.java +++ b/src/main/java/com/lambda/mixin/render/PlayerListHudMixin.java @@ -17,7 +17,7 @@ package com.lambda.mixin.render; -import com.lambda.friend.FriendManager; +import com.lambda.friend.FriendHandler; import com.lambda.module.modules.render.ExtraTab; import com.lambda.util.text.TextBuilder; import com.lambda.util.text.TextDslKt; @@ -49,7 +49,7 @@ public class PlayerListHudMixin { @Shadow @Final private static Comparator ENTRY_ORDERING; @Unique private static final Comparator FRIENDS_FIRST_ENTRY_ORDERING = Comparator - .comparingInt((PlayerListEntry entry) -> FriendManager.INSTANCE.isFriend(entry.getProfile().name()) ? 0 : 1) + .comparingInt((PlayerListEntry entry) -> FriendHandler.INSTANCE.isFriend(entry.getProfile().name()) ? 0 : 1) .thenComparingInt(entry -> -entry.getListOrder()) .thenComparingInt((entry) -> entry.getGameMode() == GameMode.SPECTATOR ? 1 : 0) .thenComparing((entry) -> Nullables.mapOrElse(entry.getScoreboardTeam(), Team::getName, "")) @@ -65,7 +65,7 @@ private void onCollectPlayerEntriesHead(CallbackInfoReturnable !ExtraTab.getFriendsOnly() || FriendManager.INSTANCE.isFriend(entry.getProfile())) + .filter(entry -> !ExtraTab.getFriendsOnly() || FriendHandler.INSTANCE.isFriend(entry.getProfile())) .sorted(ExtraTab.getSortFriendsFirst() ? FRIENDS_FIRST_ENTRY_ORDERING : ENTRY_ORDERING) .limit(ExtraTab.getTabEntries()) .toList() @@ -87,7 +87,7 @@ private int modifyRowLimit(int original) { private @Nullable MutableText modifyName(Text original) { if (ExtraTab.INSTANCE.isDisabled() || !ExtraTab.getHighlightFriends() || - !FriendManager.INSTANCE.isFriend(original.getString())) return original.copy(); + !FriendHandler.INSTANCE.isFriend(original.getString())) return original.copy(); var newText = original.copy(); var textBuilder = new TextBuilder(); TextDslKt.color(textBuilder, ExtraTab.getFriendColor(), builder -> { diff --git a/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java b/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java index f614aec49..c0a591c45 100644 --- a/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java +++ b/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java @@ -21,7 +21,7 @@ import com.lambda.event.EventFlow; import com.lambda.event.events.RenderEvent; import com.lambda.graphics.RenderMain; -import com.lambda.graphics.outline.OutlineManager; +import com.lambda.graphics.outline.OutlineHandler; import com.lambda.module.modules.render.Freecam; import com.lambda.module.modules.render.CameraTweaks; import com.lambda.module.modules.render.NoRender; @@ -102,7 +102,7 @@ private void injectFillEntityRenderStates(Camera camera, Frustum frustum, Render @ModifyExpressionValue(method = "fillEntityRenderStates", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;isRenderingReady(Lnet/minecraft/util/math/BlockPos;)Z")) private boolean lambda$bypassIsRenderingReady(boolean original) { - if (this.lambda$currentEntity != null && OutlineManager.shouldCapture(this.lambda$currentEntity.getId())) + if (this.lambda$currentEntity != null && OutlineHandler.shouldCapture(this.lambda$currentEntity.getId())) return true; return original; } @@ -122,10 +122,10 @@ boolean modHasBlindnessOrDarkness(boolean original) { @Inject(method = "fillBlockEntityRenderStates", at = @At("TAIL")) private void injectOutlineBlockEntities(Camera camera, float tickProgress, WorldRenderState renderStates, CallbackInfo ci) { - if (!OutlineManager.INSTANCE.hasBlockOutlines()) return; + if (!OutlineHandler.INSTANCE.hasBlockOutlines()) return; - Set xRayTargets = OutlineManager.INSTANCE.getXrayBlockStyles().keySet(); - Set depthTargets = OutlineManager.INSTANCE.getDepthTestedBlockStyles().keySet(); + Set xRayTargets = OutlineHandler.INSTANCE.getXrayBlockStyles().keySet(); + Set depthTargets = OutlineHandler.INSTANCE.getDepthTestedBlockStyles().keySet(); for (BlockPos target : Sets.union(xRayTargets, depthTargets)) { if (!this.world.getChunkManager().isChunkLoaded(target.getX() >> 4, target.getZ() >> 4)) continue; diff --git a/src/main/kotlin/com/lambda/Lambda.kt b/src/main/kotlin/com/lambda/Lambda.kt index 305a829c5..35f3cd622 100644 --- a/src/main/kotlin/com/lambda/Lambda.kt +++ b/src/main/kotlin/com/lambda/Lambda.kt @@ -21,7 +21,7 @@ import com.google.gson.Gson import com.google.gson.GsonBuilder import com.lambda.config.serializer.BlockCodec import com.lambda.config.serializer.BlockPosCodec -import com.lambda.config.serializer.ColorSerializer +import com.lambda.config.serializer.ColorCodec import com.lambda.config.serializer.GameProfileCodec import com.lambda.config.serializer.ItemCodec import com.lambda.config.serializer.ItemStackCodec @@ -75,7 +75,7 @@ object Lambda : ClientModInitializer { .setPrettyPrinting() .registerTypeAdapter(UUID::class.java, UUIDCodec) .registerTypeAdapter(KeyCode::class.java, KeyCodeCodec) - .registerTypeAdapter(Color::class.java, ColorSerializer) + .registerTypeAdapter(Color::class.java, ColorCodec) .registerTypeAdapter(BlockPos::class.java, BlockPosCodec) .registerTypeAdapter(Block::class.java, BlockCodec) .registerTypeAdapter(GameProfile::class.java, GameProfileCodec) diff --git a/src/main/kotlin/com/lambda/command/CommandManager.kt b/src/main/kotlin/com/lambda/command/CommandHandler.kt similarity index 96% rename from src/main/kotlin/com/lambda/command/CommandManager.kt rename to src/main/kotlin/com/lambda/command/CommandHandler.kt index 78abe4f90..e9e1e1a69 100644 --- a/src/main/kotlin/com/lambda/command/CommandManager.kt +++ b/src/main/kotlin/com/lambda/command/CommandHandler.kt @@ -39,7 +39,7 @@ import kotlin.math.max import kotlin.math.min -object CommandManager { +object CommandHandler { private const val ERROR_PADDING = 10 val dispatcher by lazy { CommandDispatcher() } @@ -58,7 +58,7 @@ object CommandManager { } catch (syntax: CommandSyntaxException) { createFeedback(syntax, reader) } catch (e: CommandException) { - this@CommandManager.logError(e.info) + this@CommandHandler.logError(e.info) } } } @@ -89,7 +89,7 @@ object CommandManager { ) { val debugMessage = syntax.message ?: return - this@CommandManager.logError(debugMessage) + this@CommandHandler.logError(debugMessage) if (syntax.input == null || syntax.cursor < 0) { return } diff --git a/src/main/kotlin/com/lambda/command/CommandRegistry.kt b/src/main/kotlin/com/lambda/command/CommandRegistry.kt index eefbd62a2..aba5f0d45 100644 --- a/src/main/kotlin/com/lambda/command/CommandRegistry.kt +++ b/src/main/kotlin/com/lambda/command/CommandRegistry.kt @@ -17,7 +17,7 @@ package com.lambda.command -import com.lambda.command.CommandManager.dispatcher +import com.lambda.command.CommandHandler.dispatcher import com.lambda.config.Configurable import com.lambda.config.configurations.LambdaConfig import com.lambda.core.Loadable diff --git a/src/main/kotlin/com/lambda/command/LambdaCommand.kt b/src/main/kotlin/com/lambda/command/LambdaCommand.kt index 6e3e24b10..9092c3a52 100644 --- a/src/main/kotlin/com/lambda/command/LambdaCommand.kt +++ b/src/main/kotlin/com/lambda/command/LambdaCommand.kt @@ -20,7 +20,7 @@ package com.lambda.command import com.lambda.brigadier.argument.literal import com.lambda.brigadier.execute import com.lambda.brigadier.required -import com.lambda.command.CommandManager.dispatcher +import com.lambda.command.CommandHandler.dispatcher import com.lambda.core.Loadable import com.lambda.util.Communication.info import com.lambda.util.Nameable diff --git a/src/main/kotlin/com/lambda/command/commands/CapeCommand.kt b/src/main/kotlin/com/lambda/command/commands/CapeCommand.kt index bf84956c0..f7e054f95 100644 --- a/src/main/kotlin/com/lambda/command/commands/CapeCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/CapeCommand.kt @@ -23,8 +23,8 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required import com.lambda.command.LambdaCommand -import com.lambda.network.CapeManager.availableCapes -import com.lambda.network.CapeManager.updateCape +import com.lambda.network.CapeHandler.availableCapes +import com.lambda.network.CapeHandler.updateCape import com.lambda.util.Communication.info import com.lambda.util.Communication.logError import com.lambda.util.extension.CommandBuilder diff --git a/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt b/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt index e187327a5..2d22d4987 100644 --- a/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt @@ -29,7 +29,7 @@ import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required import com.lambda.command.LambdaCommand import com.lambda.config.configurations.FriendConfig -import com.lambda.friend.FriendManager +import com.lambda.friend.FriendHandler import com.lambda.network.mojang.getProfile import com.lambda.threading.runIO import com.lambda.util.Communication.info @@ -53,13 +53,13 @@ object FriendCommand : LambdaCommand( runIO { info( buildText { - if (FriendManager.friends.isEmpty()) { + if (FriendHandler.friends.isEmpty()) { literal("You have no friends yet. Go make some! :3\n") } else { - literal("Your friends (${FriendManager.friends.size}):\n") + literal("Your friends (${FriendHandler.friends.size}):\n") - FriendManager.friends.forEachIndexed { index, uuid -> - val profile = FriendManager.latestGameProfile(uuid) + FriendHandler.friends.forEachIndexed { index, uuid -> + val profile = FriendHandler.latestGameProfile(uuid) val displayName = profile?.name ?: uuid.toString() literal(" ${index + 1}. $displayName ") @@ -100,15 +100,15 @@ object FriendCommand : LambdaCommand( val name = player().value() runBlocking { - val profile = FriendManager.latestGameProfile(name) + val profile = FriendHandler.latestGameProfile(name) ?: return@runBlocking failure("Could not find the player") - if (FriendManager.isFriend(profile.id)) + if (FriendHandler.isFriend(profile.id)) return@runBlocking failure("This player is already in your friend list") - FriendManager.befriend(profile) + FriendHandler.befriend(profile) - info(FriendManager.befriendedText(profile.name)) + info(FriendHandler.befriendedText(profile.name)) success() } } @@ -129,18 +129,18 @@ object FriendCommand : LambdaCommand( executeWithResult { val uuid = player().value() - if (FriendManager.isFriend(uuid)) + if (FriendHandler.isFriend(uuid)) return@executeWithResult failure("This player is already in your friend list") runBlocking { - val profile = FriendManager.latestGameProfile(uuid) + val profile = FriendHandler.latestGameProfile(uuid) if (profile != null) { - FriendManager.befriend(profile) - info(FriendManager.befriendedText(profile.name)) + FriendHandler.befriend(profile) + info(FriendHandler.befriendedText(profile.name)) } else { - FriendManager.befriend(uuid) - info(FriendManager.befriendedText(uuid.toString())) + FriendHandler.befriend(uuid) + info(FriendHandler.befriendedText(uuid.toString())) } success() @@ -152,7 +152,7 @@ object FriendCommand : LambdaCommand( required(literal("remove")) { required(string("player name")) { player -> suggests { _, builder -> - val playerNames = FriendManager.friends.map { FriendManager.friendDisplayName(it) } + val playerNames = FriendHandler.friends.map { FriendHandler.friendDisplayName(it) } suggestMatching(playerNames, builder) } @@ -160,17 +160,17 @@ object FriendCommand : LambdaCommand( val name = player().value() runBlocking { - val uuid = FriendManager.gameProfile(name)?.id + val uuid = FriendHandler.gameProfile(name)?.id ?: getProfile(name).getOrNull()?.id ?: runCatching { UUID.fromString(name) }.getOrNull() ?: return@runBlocking failure("Could not resolve the player name") - if (!FriendManager.isFriend(uuid)) + if (!FriendHandler.isFriend(uuid)) return@runBlocking failure("This player is not in your friend list") - FriendManager.unfriend(uuid) + FriendHandler.unfriend(uuid) - info(FriendManager.unfriendedText(name)) + info(FriendHandler.unfriendedText(name)) success() } } @@ -191,13 +191,13 @@ object FriendCommand : LambdaCommand( executeWithResult { val uuid = player().value() - if (!FriendManager.isFriend(uuid)) + if (!FriendHandler.isFriend(uuid)) return@executeWithResult failure("This player is not in your friend list") - val displayName = FriendManager.friendDisplayName(uuid) - FriendManager.unfriend(uuid) + val displayName = FriendHandler.friendDisplayName(uuid) + FriendHandler.unfriend(uuid) - info(FriendManager.unfriendedText(displayName)) + info(FriendHandler.unfriendedText(displayName)) success() } } diff --git a/src/main/kotlin/com/lambda/command/commands/TransferCommand.kt b/src/main/kotlin/com/lambda/command/commands/TransferCommand.kt index 8c11ab082..08086d1ff 100644 --- a/src/main/kotlin/com/lambda/command/commands/TransferCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/TransferCommand.kt @@ -29,9 +29,9 @@ import com.lambda.brigadier.required import com.lambda.command.LambdaCommand import com.lambda.config.AutomationConfig import com.lambda.interaction.material.StackSelection.Companion.selectStack -import com.lambda.interaction.material.container.ContainerManager -import com.lambda.interaction.material.container.ContainerManager.findContainersWithMaterial -import com.lambda.interaction.material.container.ContainerManager.findContainersWithSpace +import com.lambda.interaction.material.container.ContainerHandler +import com.lambda.interaction.material.container.ContainerHandler.findContainersWithMaterial +import com.lambda.interaction.material.container.ContainerHandler.findContainersWithSpace import com.lambda.task.RootTask import com.lambda.task.Task import com.lambda.threading.runSafeAutomated @@ -96,11 +96,11 @@ object TransferCommand : LambdaCommand( isItem(stack().value().item) } AutomationConfig.Companion.DEFAULT.runSafeAutomated { - val fromContainer = ContainerManager.containers().find { + val fromContainer = ContainerHandler.containers().find { it.name == from().value().split(".").last().trim() } ?: return@executeWithResult failure("From container not found") - val toContainer = ContainerManager.containers().find { + val toContainer = ContainerHandler.containers().find { it.name == to().value().split(".").last().trim() } ?: return@executeWithResult failure("To container not found") diff --git a/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt b/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt index f6f7aed07..a62671fd9 100644 --- a/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt @@ -20,7 +20,7 @@ package com.lambda.config.groups import com.lambda.config.Configurable import com.lambda.config.SettingGroup import com.lambda.context.SafeContext -import com.lambda.friend.FriendManager.isFriend +import com.lambda.friend.FriendHandler.isFriend import com.lambda.util.EntityUtils import com.lambda.util.EntityUtils.entityGroup import com.lambda.util.NamedEnum diff --git a/src/main/kotlin/com/lambda/config/groups/Targeting.kt b/src/main/kotlin/com/lambda/config/groups/Targeting.kt index 8c385e117..d505a657e 100644 --- a/src/main/kotlin/com/lambda/config/groups/Targeting.kt +++ b/src/main/kotlin/com/lambda/config/groups/Targeting.kt @@ -21,7 +21,7 @@ import com.lambda.config.Configurable import com.lambda.config.SettingGroup import com.lambda.config.applyEdits import com.lambda.context.SafeContext -import com.lambda.friend.FriendManager.isFriend +import com.lambda.friend.FriendHandler.isFriend import com.lambda.interaction.managers.rotating.Rotation.Companion.dist import com.lambda.interaction.managers.rotating.Rotation.Companion.rotation import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo diff --git a/src/main/kotlin/com/lambda/config/serializer/ColorSerializer.kt b/src/main/kotlin/com/lambda/config/serializer/ColorCodec.kt similarity index 96% rename from src/main/kotlin/com/lambda/config/serializer/ColorSerializer.kt rename to src/main/kotlin/com/lambda/config/serializer/ColorCodec.kt index 134d59c3b..2bf3afdf2 100644 --- a/src/main/kotlin/com/lambda/config/serializer/ColorSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializer/ColorCodec.kt @@ -27,7 +27,7 @@ import com.lambda.config.Stringifiable import java.awt.Color import java.lang.reflect.Type -object ColorSerializer : Codec, Stringifiable { +object ColorCodec : Codec, Stringifiable { override fun serialize( src: Color, typeOfSrc: Type, diff --git a/src/main/kotlin/com/lambda/core/PingManager.kt b/src/main/kotlin/com/lambda/core/PingHandler.kt similarity index 93% rename from src/main/kotlin/com/lambda/core/PingManager.kt rename to src/main/kotlin/com/lambda/core/PingHandler.kt index 788445e70..e54cba9c2 100644 --- a/src/main/kotlin/com/lambda/core/PingManager.kt +++ b/src/main/kotlin/com/lambda/core/PingHandler.kt @@ -25,24 +25,23 @@ import net.minecraft.network.packet.c2s.query.QueryPingC2SPacket import net.minecraft.network.packet.s2c.query.PingResultS2CPacket import net.minecraft.util.Util -object PingManager : Loadable { +object PingHandler : Loadable { private val pings: LimitedOrderedSet = LimitedOrderedSet(100) private const val INTERVAL = 1 - override fun load() = "Loaded Ping Manager" - - val lastPing: Long - get() = pings.lastOrNull() ?: 0 - - init { + override fun load(): String { listen { connection.sendPacket(QueryPingC2SPacket(Util.getMeasuringTimeMs())) } listen { event -> if (event.packet !is PingResultS2CPacket) return@listen - pings.add(Util.getMeasuringTimeMs() - event.packet.startTime) } + + return "Loaded Ping Manager" } + + val lastPing: Long + get() = pings.lastOrNull() ?: 0 } diff --git a/src/main/kotlin/com/lambda/core/TimerManager.kt b/src/main/kotlin/com/lambda/core/TimerHandler.kt similarity index 97% rename from src/main/kotlin/com/lambda/core/TimerManager.kt rename to src/main/kotlin/com/lambda/core/TimerHandler.kt index 69f385029..c7c9ea83f 100644 --- a/src/main/kotlin/com/lambda/core/TimerManager.kt +++ b/src/main/kotlin/com/lambda/core/TimerHandler.kt @@ -22,7 +22,7 @@ import com.lambda.event.events.ClientEvent import kotlin.concurrent.fixedRateTimer import kotlin.time.Duration.Companion.milliseconds -object TimerManager : Loadable { +object TimerHandler : Loadable { const val DEFAULT_LENGTH = 50.0 var lastTickLength = 50.0 diff --git a/src/main/kotlin/com/lambda/friend/FriendManager.kt b/src/main/kotlin/com/lambda/friend/FriendHandler.kt similarity index 98% rename from src/main/kotlin/com/lambda/friend/FriendManager.kt rename to src/main/kotlin/com/lambda/friend/FriendHandler.kt index 240bda5de..224e4175e 100644 --- a/src/main/kotlin/com/lambda/friend/FriendManager.kt +++ b/src/main/kotlin/com/lambda/friend/FriendHandler.kt @@ -34,7 +34,7 @@ import net.minecraft.text.Text import java.awt.Color import java.util.* -object FriendManager : Configurable(FriendConfig), Loadable { +object FriendHandler : Configurable(FriendConfig), Loadable { override val name = "friends" val friends by setting("friends", emptySet(), serialize = true) diff --git a/src/main/kotlin/com/lambda/graphics/RenderMain.kt b/src/main/kotlin/com/lambda/graphics/RenderMain.kt index 3f251ae27..334b050de 100644 --- a/src/main/kotlin/com/lambda/graphics/RenderMain.kt +++ b/src/main/kotlin/com/lambda/graphics/RenderMain.kt @@ -21,7 +21,7 @@ import com.lambda.event.EventFlow.post import com.lambda.event.events.RenderEvent import com.lambda.graphics.mc.renderer.RendererUtils import com.lambda.graphics.outline.OutlineIdBuffer -import com.lambda.graphics.outline.OutlineManager +import com.lambda.graphics.outline.OutlineHandler import com.lambda.graphics.outline.OutlineRenderer import com.lambda.graphics.outline.VertexCapture import org.joml.Matrix4f @@ -36,7 +36,7 @@ object RenderMain { @JvmStatic fun preRender() { - OutlineManager.clear() + OutlineHandler.clear() VertexCapture.clear() OutlineIdBuffer.beginFrame() } diff --git a/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt b/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt index ece277047..856f1796a 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt @@ -20,7 +20,7 @@ package com.lambda.graphics.mc import com.lambda.Lambda.mc import com.lambda.config.groups.LineConfig import com.lambda.context.SafeContext -import com.lambda.graphics.outline.OutlineManager +import com.lambda.graphics.outline.OutlineHandler import com.lambda.graphics.outline.OutlineStyle import com.lambda.graphics.text.FontHandler import com.lambda.graphics.text.SDFFontAtlas @@ -277,28 +277,28 @@ class RenderBuilder(private val cameraPos: Vec3d, var depthTest: Boolean = false fun worldOutline( entity: Entity, style: OutlineStyle - ) = OutlineManager.setEntityOutline(entity.id, style, depthTest = depthTest) + ) = OutlineHandler.setEntityOutline(entity.id, style, depthTest = depthTest) @JvmName("worldOutlines1") fun worldOutlines( entities: Iterable, style: OutlineStyle ) = entities.forEach { - OutlineManager.setEntityOutline(it.id, style, depthTest = depthTest) + OutlineHandler.setEntityOutline(it.id, style, depthTest = depthTest) } @JvmName("worldOutline2") fun worldOutline( pos: BlockPos, style: OutlineStyle - ) = OutlineManager.setBlockOutline(pos, style, depthTest = depthTest) + ) = OutlineHandler.setBlockOutline(pos, style, depthTest = depthTest) @JvmName("worldOutlines2") fun worldOutlines( positions: Iterable, style: OutlineStyle ) = positions.forEach { - OutlineManager.setBlockOutline(it, style, depthTest = depthTest) + OutlineHandler.setBlockOutline(it, style, depthTest = depthTest) } fun withOutline(style: OutlineStyle, block: RenderBuilder.() -> Unit) { diff --git a/src/main/kotlin/com/lambda/graphics/outline/OutlineManager.kt b/src/main/kotlin/com/lambda/graphics/outline/OutlineHandler.kt similarity index 99% rename from src/main/kotlin/com/lambda/graphics/outline/OutlineManager.kt rename to src/main/kotlin/com/lambda/graphics/outline/OutlineHandler.kt index 6bd602c67..726a4c813 100644 --- a/src/main/kotlin/com/lambda/graphics/outline/OutlineManager.kt +++ b/src/main/kotlin/com/lambda/graphics/outline/OutlineHandler.kt @@ -19,7 +19,7 @@ package com.lambda.graphics.outline import net.minecraft.util.math.BlockPos -object OutlineManager { +object OutlineHandler { private val depthTestedEntityOutlines = mutableMapOf() private val xrayEntityOutlines = mutableMapOf() diff --git a/src/main/kotlin/com/lambda/graphics/outline/OutlineIdPassRenderer.kt b/src/main/kotlin/com/lambda/graphics/outline/OutlineIdPassRenderer.kt index bf1d35e87..12d7d61b1 100644 --- a/src/main/kotlin/com/lambda/graphics/outline/OutlineIdPassRenderer.kt +++ b/src/main/kotlin/com/lambda/graphics/outline/OutlineIdPassRenderer.kt @@ -61,7 +61,7 @@ object OutlineIdPassRenderer { val colorView = OutlineIdBuffer.getTextureView() ?: return - val outlines = if (useMcDepth) OutlineManager.getDepthTestedEntityStyles() else OutlineManager.getXrayEntityStyles() + val outlines = if (useMcDepth) OutlineHandler.getDepthTestedEntityStyles() else OutlineHandler.getXrayEntityStyles() val filteredOutlines = outlines.filter { (id, _) -> id in entityIds } if (filteredOutlines.isNotEmpty()) { diff --git a/src/main/kotlin/com/lambda/graphics/outline/OutlineRenderer.kt b/src/main/kotlin/com/lambda/graphics/outline/OutlineRenderer.kt index f7b012fa2..758a05bf4 100644 --- a/src/main/kotlin/com/lambda/graphics/outline/OutlineRenderer.kt +++ b/src/main/kotlin/com/lambda/graphics/outline/OutlineRenderer.kt @@ -185,11 +185,11 @@ object OutlineRenderer { private fun OutlineStyle.toKey() = StyleKey(color, thickness, glowIntensity, glowRadius, fill, fillOpacity) fun renderAllIDPasses() { - val depthTestedEntityStyles = OutlineManager.getDepthTestedEntityStyles() - val xrayEntityStyles = OutlineManager.getXrayEntityStyles() + val depthTestedEntityStyles = OutlineHandler.getDepthTestedEntityStyles() + val xrayEntityStyles = OutlineHandler.getXrayEntityStyles() - val depthTestedBlockStyles = OutlineManager.getDepthTestedBlockStyles() - val xrayBlockStyles = OutlineManager.getXrayBlockStyles() + val depthTestedBlockStyles = OutlineHandler.getDepthTestedBlockStyles() + val xrayBlockStyles = OutlineHandler.getXrayBlockStyles() val depthTestedEntityGroups = depthTestedEntityStyles.entries.groupBy({ it.value.toKey() }, { it.key }) val xrayEntityGroups = xrayEntityStyles.entries.groupBy({ it.value.toKey() }, { it.key }) @@ -225,8 +225,8 @@ object OutlineRenderer { if (OutlineIdBuffer.hasData) { val representativeStyle = when { - !depthTestedIds.isNullOrEmpty() -> OutlineManager.getEntityOutlineStyle(depthTestedIds.first()) - !xrayIds.isNullOrEmpty() -> OutlineManager.getEntityOutlineStyle(xrayIds.first()) + !depthTestedIds.isNullOrEmpty() -> OutlineHandler.getEntityOutlineStyle(depthTestedIds.first()) + !xrayIds.isNullOrEmpty() -> OutlineHandler.getEntityOutlineStyle(xrayIds.first()) !depthTestedBlocks.isNullOrEmpty() -> depthTestedBlocks.first().second !xrayBlocks.isNullOrEmpty() -> xrayBlocks.first().second else -> null diff --git a/src/main/kotlin/com/lambda/gui/MenuBar.kt b/src/main/kotlin/com/lambda/gui/MenuBar.kt index 2ff59a143..ae90d6c1d 100644 --- a/src/main/kotlin/com/lambda/gui/MenuBar.kt +++ b/src/main/kotlin/com/lambda/gui/MenuBar.kt @@ -35,7 +35,7 @@ import com.lambda.gui.components.HudGuiLayout import com.lambda.gui.components.QuickSearch import com.lambda.gui.components.SettingsWidget.buildConfigSettingsContext import com.lambda.gui.dsl.ImGuiBuilder -import com.lambda.interaction.BaritoneManager +import com.lambda.interaction.BaritoneHandler import com.lambda.module.ModuleRegistry import com.lambda.module.ModuleRegistry.moduleNameMap import com.lambda.module.tag.ModuleTag @@ -152,7 +152,7 @@ object MenuBar { buildConfigSettingsContext(LambdaAPI) } menu("Baritone Settings") { - buildConfigSettingsContext(BaritoneManager) + buildConfigSettingsContext(BaritoneHandler) } } separator() diff --git a/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt b/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt index 342f5c58b..dd59496f5 100644 --- a/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt +++ b/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt @@ -31,16 +31,16 @@ import com.lambda.gui.MenuBar.buildMenuBar import com.lambda.gui.components.QuickSearch.renderQuickSearch import com.lambda.gui.dsl.ImGuiBuilder.buildLayout import com.lambda.gui.snap.RectF -import com.lambda.gui.snap.SnapManager -import com.lambda.gui.snap.SnapManager.drawDragGrid -import com.lambda.gui.snap.SnapManager.drawSnapLines -import com.lambda.gui.snap.SnapManager.updateDragAndSnapping +import com.lambda.gui.snap.SnapHandler +import com.lambda.gui.snap.SnapHandler.drawDragGrid +import com.lambda.gui.snap.SnapHandler.drawSnapLines +import com.lambda.gui.snap.SnapHandler.updateDragAndSnapping import com.lambda.module.ModuleRegistry import com.lambda.module.modules.client.Client import com.lambda.module.tag.ModuleTag import com.lambda.module.tag.ModuleTag.Companion.shownTags import com.lambda.sound.LambdaSound -import com.lambda.sound.SoundManager.play +import com.lambda.sound.SoundHandler.play import com.lambda.util.Describable import com.lambda.util.KeyCode import com.lambda.util.NamedEnum @@ -79,7 +79,7 @@ object ClickGuiLayout : Loadable, Configurable(GuiConfig) { private var dragOffsetY = 0f private val lastBounds = mutableMapOf() private val pendingPositions = mutableMapOf>() - private val snapOverlays = mutableMapOf() + private val snapOverlays = mutableMapOf() private enum class Group(override val displayName: String) : NamedEnum { General("General"), @@ -250,7 +250,7 @@ object ClickGuiLayout : Loadable, Configurable(GuiConfig) { buildLayout { buildMenuBar() val vp = ImGui.getMainViewport() - SnapManager.beginFrame(vp.sizeX, vp.sizeY, io.fontGlobalScale) + SnapHandler.beginFrame(vp.sizeX, vp.sizeY, io.fontGlobalScale) val mouseDown = io.mouseDown[0] val mousePressedThisFrame = mouseDown && !mouseWasDown @@ -330,7 +330,7 @@ object ClickGuiLayout : Loadable, Configurable(GuiConfig) { } val rect = RectF(windowPos.x, windowPos.y, windowSize.x, windowSize.y) - SnapManager.registerElement(tag.name, rect) + SnapHandler.registerElement(tag.name, rect) lastBounds[tag.name] = rect nextX += ImGui.getWindowWidth() + 20f diff --git a/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt b/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt index c192edb3c..2a056a937 100644 --- a/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt +++ b/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt @@ -26,10 +26,10 @@ import com.lambda.gui.components.SettingsWidget.buildConfigSettingsContext import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.gui.dsl.ImGuiBuilder.buildLayout import com.lambda.gui.snap.RectF -import com.lambda.gui.snap.SnapManager -import com.lambda.gui.snap.SnapManager.drawDragGrid -import com.lambda.gui.snap.SnapManager.drawSnapLines -import com.lambda.gui.snap.SnapManager.updateDragAndSnapping +import com.lambda.gui.snap.SnapHandler +import com.lambda.gui.snap.SnapHandler.drawDragGrid +import com.lambda.gui.snap.SnapHandler.drawSnapLines +import com.lambda.gui.snap.SnapHandler.updateDragAndSnapping import com.lambda.module.HudModule import com.lambda.module.ModuleRegistry import com.lambda.util.NamedEnum @@ -69,7 +69,7 @@ object HudGuiLayout : Loadable, Configurable(HudConfig) { private var dragOffsetY = 0f private val lastBounds = mutableMapOf() private val pendingPositions = mutableMapOf>() - private val snapOverlays = mutableMapOf() + private val snapOverlays = mutableMapOf() private var mousePressedThisFrameGlobal = false var isShownInGUI = true @@ -117,7 +117,7 @@ object HudGuiLayout : Loadable, Configurable(HudConfig) { val (huds, notShown) = ModuleRegistry.modules .filterIsInstance() .partition { it.isEnabled } - notShown.forEach { SnapManager.unregisterElement(it.name) } + notShown.forEach { SnapHandler.unregisterElement(it.name) } if (ClickGuiLayout.open) { registerContextMenu(notShown) @@ -180,7 +180,7 @@ object HudGuiLayout : Loadable, Configurable(HudConfig) { popupContextWindow("##ctx-${hud.name}") { menuItem("Remove HUD Element") { hud.disable() - SnapManager.unregisterElement(hud.name) + SnapHandler.unregisterElement(hud.name) } separator() buildConfigSettingsContext(hud) @@ -189,7 +189,7 @@ object HudGuiLayout : Loadable, Configurable(HudConfig) { if (!isLocked) drawHudCornerArcs(windowDrawList, windowPos.x, windowPos.y, windowSize.x, windowSize.y) } val rect = RectF(windowPos.x, windowPos.y, windowSize.x, windowSize.y) - SnapManager.registerElement(hud.name, rect) + SnapHandler.registerElement(hud.name, rect) lastBounds[hud.name] = rect } } diff --git a/src/main/kotlin/com/lambda/gui/snap/SnapManager.kt b/src/main/kotlin/com/lambda/gui/snap/SnapHandler.kt similarity index 99% rename from src/main/kotlin/com/lambda/gui/snap/SnapManager.kt rename to src/main/kotlin/com/lambda/gui/snap/SnapHandler.kt index 10115bdd9..0a4d8fa95 100644 --- a/src/main/kotlin/com/lambda/gui/snap/SnapManager.kt +++ b/src/main/kotlin/com/lambda/gui/snap/SnapHandler.kt @@ -37,7 +37,7 @@ import kotlin.collections.set import kotlin.math.abs import kotlin.math.max -object SnapManager : Loadable { +object SnapHandler : Loadable { private data class SnapGuide(val guide: Guide, val sourceId: String?) private val frameGuides = ArrayList(512) private val elementRects = LinkedHashMap() diff --git a/src/main/kotlin/com/lambda/interaction/BaritoneManager.kt b/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt similarity index 99% rename from src/main/kotlin/com/lambda/interaction/BaritoneManager.kt rename to src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt index e478ce96d..0c5ac699e 100644 --- a/src/main/kotlin/com/lambda/interaction/BaritoneManager.kt +++ b/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt @@ -30,7 +30,7 @@ import com.lambda.util.BlockUtils.blockPos import com.lambda.util.NamedEnum import net.fabricmc.loader.api.FabricLoader -object BaritoneManager : Configurable(LambdaConfig), Automated by AutomationConfig.Companion.DEFAULT { +object BaritoneHandler : Configurable(LambdaConfig), Automated by AutomationConfig.Companion.DEFAULT { override val name = "baritone" val isBaritoneLoaded = FabricLoader.getInstance().isModLoaded("baritone") diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt index c4b747f10..9645f8e6f 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt @@ -36,7 +36,7 @@ import com.lambda.interaction.material.ContainerSelection.Companion.selectContai import com.lambda.interaction.material.StackSelection import com.lambda.interaction.material.StackSelection.Companion.EVERYTHING import com.lambda.interaction.material.StackSelection.Companion.selectStack -import com.lambda.interaction.material.container.ContainerManager.findContainersWithMaterial +import com.lambda.interaction.material.container.ContainerHandler.findContainersWithMaterial import com.lambda.interaction.material.container.MaterialContainer import com.lambda.util.BlockUtils.blockState import com.lambda.util.BlockUtils.calcItemBlockBreakingDelta @@ -53,12 +53,6 @@ import net.minecraft.fluid.FlowableFluid import net.minecraft.fluid.LavaFluid import net.minecraft.fluid.WaterFluid import net.minecraft.item.ItemStack -import net.minecraft.registry.tag.ItemTags.DIAMOND_TOOL_MATERIALS -import net.minecraft.registry.tag.ItemTags.GOLD_TOOL_MATERIALS -import net.minecraft.registry.tag.ItemTags.IRON_TOOL_MATERIALS -import net.minecraft.registry.tag.ItemTags.NETHERITE_TOOL_MATERIALS -import net.minecraft.registry.tag.ItemTags.STONE_TOOL_MATERIALS -import net.minecraft.registry.tag.ItemTags.WOODEN_TOOL_MATERIALS import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction import kotlin.jvm.optionals.getOrNull diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt index 171461348..cd5880aff 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt @@ -37,7 +37,7 @@ import com.lambda.interaction.managers.rotating.visibilty.lookInDirection import com.lambda.interaction.material.ContainerSelection.Companion.selectContainer import com.lambda.interaction.material.StackSelection import com.lambda.interaction.material.StackSelection.Companion.select -import com.lambda.interaction.material.container.ContainerManager.findContainersWithMaterial +import com.lambda.interaction.material.container.ContainerHandler.findContainersWithMaterial import com.lambda.interaction.material.container.MaterialContainer import com.lambda.util.BlockUtils import com.lambda.util.BlockUtils.blockState diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/ChestPostProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/ChestPostProcessor.kt index 8da78566f..6973a2521 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/ChestPostProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/ChestPostProcessor.kt @@ -27,7 +27,6 @@ import net.minecraft.block.enums.ChestType import net.minecraft.state.property.Properties import net.minecraft.util.math.BlockPos -// Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") object ChestPostProcessor : PropertyPostProcessor { override fun acceptsState(state: BlockState, targetState: BlockState) = diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/PoweredPostProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/PoweredPostProcessor.kt index 69e9048c8..18a532cd6 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/PoweredPostProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/PoweredPostProcessor.kt @@ -26,7 +26,6 @@ import net.minecraft.block.LeverBlock import net.minecraft.state.property.Properties import net.minecraft.util.math.BlockPos -// Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") object PoweredPostProcessor : PropertyPostProcessor { override fun acceptsState(state: BlockState, targetState: BlockState) = diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/SlabPostProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/SlabPostProcessor.kt index 59655f073..986e99b4a 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/SlabPostProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/SlabPostProcessor.kt @@ -26,7 +26,6 @@ import net.minecraft.block.enums.SlabType import net.minecraft.state.property.Properties import net.minecraft.util.math.BlockPos -// Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") object SlabPostProcessor : PropertyPostProcessor { override fun acceptsState(state: BlockState, targetState: BlockState) = diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/StandardInteractPostProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/StandardInteractPostProcessor.kt index 2f0b5011e..e10147796 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/StandardInteractPostProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/StandardInteractPostProcessor.kt @@ -27,7 +27,6 @@ import net.minecraft.block.DoorBlock import net.minecraft.block.TrapdoorBlock import net.minecraft.util.math.BlockPos -// Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") object StandardInteractPostProcessor : PropertyPostProcessor { override fun acceptsState(state: BlockState, targetState: BlockState) = diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/AttachmentPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/AttachmentPreProcessor.kt index 9d4ee6122..a37876bfa 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/AttachmentPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/AttachmentPreProcessor.kt @@ -26,7 +26,6 @@ import net.minecraft.state.property.Properties import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction -// Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") object AttachmentPreProcessor : PropertyPreProcessor { override fun acceptsState(state: BlockState, targetState: BlockState) = diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/AxisPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/AxisPreProcessor.kt index 317a6a6e9..0877bdac5 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/AxisPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/AxisPreProcessor.kt @@ -24,7 +24,6 @@ import net.minecraft.block.BlockState import net.minecraft.state.property.Properties import net.minecraft.util.math.BlockPos -// Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") object AxisPreProcessor : PropertyPreProcessor { override fun acceptsState(state: BlockState, targetState: BlockState) = diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/BlockFacePreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/BlockFacePreProcessor.kt index 9c6c7fb81..d61b184a6 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/BlockFacePreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/BlockFacePreProcessor.kt @@ -26,7 +26,6 @@ import net.minecraft.state.property.Properties import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction -// Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") object BlockFacePreProcessor : PropertyPreProcessor { override fun acceptsState(state: BlockState, targetState: BlockState) = diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/BlockHalfPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/BlockHalfPreProcessor.kt index 0ea978439..47af759f2 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/BlockHalfPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/BlockHalfPreProcessor.kt @@ -28,7 +28,6 @@ import net.minecraft.state.property.Properties import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction -// Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") object BlockHalfPreProcessor : PropertyPreProcessor { override fun acceptsState(state: BlockState, targetState: BlockState) = diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/ChestPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/ChestPreProcessor.kt index e82691361..d0a70d09b 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/ChestPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/ChestPreProcessor.kt @@ -26,7 +26,6 @@ import net.minecraft.block.enums.ChestType import net.minecraft.state.property.Properties import net.minecraft.util.math.BlockPos -// Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") object ChestPreProcessor : PropertyPreProcessor { override fun acceptsState(state: BlockState, targetState: BlockState) = diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/DoorHingePreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/DoorHingePreProcessor.kt index 1602cba7c..3fc96466e 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/DoorHingePreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/DoorHingePreProcessor.kt @@ -28,7 +28,6 @@ import net.minecraft.state.property.Properties import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction -// Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") object DoorHingePreProcessor : PropertyPreProcessor { override fun acceptsState(state: BlockState, targetState: BlockState) = diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/HopperFacingPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/HopperFacingPreProcessor.kt index 25d733f6a..9cc3415ce 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/HopperFacingPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/HopperFacingPreProcessor.kt @@ -25,7 +25,6 @@ import net.minecraft.state.property.Properties import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction -// Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") object HopperFacingPreProcessor : PropertyPreProcessor { override fun acceptsState(state: BlockState, targetState: BlockState) = diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/SlabPreProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/SlabPreProcessor.kt index 4cdef28ed..3a3605604 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/SlabPreProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/pre/SlabPreProcessor.kt @@ -29,7 +29,6 @@ import net.minecraft.state.property.Properties import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction -// Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") object SlabPreProcessor : PropertyPreProcessor { override fun acceptsState(state: BlockState, targetState: BlockState) = targetState.block is SlabBlock diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/BambooStateProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/BambooStateProcessor.kt index 22a158f71..6f3ed7302 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/BambooStateProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/BambooStateProcessor.kt @@ -27,7 +27,6 @@ import net.minecraft.block.Blocks import net.minecraft.item.Items import net.minecraft.util.math.BlockPos -// Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") object BambooStateProcessor : StateProcessor { override fun acceptsState(state: BlockState, targetState: BlockState) = diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/FireStateProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/FireStateProcessor.kt index 078e09ae4..f2123d2cb 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/FireStateProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/FireStateProcessor.kt @@ -25,7 +25,6 @@ import net.minecraft.block.Blocks import net.minecraft.item.Items import net.minecraft.util.math.BlockPos -// Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") object FireStateProcessor : StateProcessor { override fun acceptsState(state: BlockState, targetState: BlockState) = diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/FlowerPotStateProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/FlowerPotStateProcessor.kt index 981a41b33..c6a649fc6 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/FlowerPotStateProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/state/FlowerPotStateProcessor.kt @@ -26,7 +26,6 @@ import net.minecraft.block.FlowerPotBlock import net.minecraft.item.Items import net.minecraft.util.math.BlockPos -// Collected using reflections and then accessed from a collection in ProcessorRegistry @Suppress("unused") object FlowerPotStateProcessor : StateProcessor { override fun acceptsState(state: BlockState, targetState: BlockState) = diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/BreakResult.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/BreakResult.kt index 28005dab2..0c8632122 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/BreakResult.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/BreakResult.kt @@ -32,7 +32,7 @@ import com.lambda.interaction.construction.simulation.result.Navigable import com.lambda.interaction.construction.simulation.result.Rank import com.lambda.interaction.construction.simulation.result.Resolvable import com.lambda.interaction.material.StackSelection.Companion.selectStack -import com.lambda.interaction.material.container.ContainerManager.transferByTask +import com.lambda.interaction.material.container.ContainerHandler.transferByTask import com.lambda.interaction.material.container.containers.HotbarContainer import com.lambda.task.Task import net.minecraft.block.BlockState diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/GenericResult.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/GenericResult.kt index 31c5ced68..73a77da9e 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/GenericResult.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/GenericResult.kt @@ -27,7 +27,7 @@ import com.lambda.interaction.construction.simulation.result.Navigable import com.lambda.interaction.construction.simulation.result.Rank import com.lambda.interaction.construction.simulation.result.Resolvable import com.lambda.interaction.material.StackSelection -import com.lambda.interaction.material.container.ContainerManager.transferByTask +import com.lambda.interaction.material.container.ContainerHandler.transferByTask import com.lambda.interaction.material.container.containers.HotbarContainer import com.lambda.task.Task import net.minecraft.client.data.TextureMap.side diff --git a/src/main/kotlin/com/lambda/interaction/construction/verify/TargetState.kt b/src/main/kotlin/com/lambda/interaction/construction/verify/TargetState.kt index e7f41c57f..167040608 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/verify/TargetState.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/verify/TargetState.kt @@ -19,7 +19,7 @@ package com.lambda.interaction.construction.verify import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext -import com.lambda.interaction.material.container.ContainerManager.findDisposable +import com.lambda.interaction.material.container.ContainerHandler.findDisposable import com.lambda.util.BlockUtils.blockState import com.lambda.util.BlockUtils.emptyState import com.lambda.util.BlockUtils.isEmpty diff --git a/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt index ddb15812f..ede45a22a 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt @@ -28,7 +28,7 @@ import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe -import com.lambda.interaction.BaritoneManager +import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.managers.Manager import com.lambda.interaction.managers.rotating.Rotation.Companion.slerpPitch import com.lambda.interaction.managers.rotating.Rotation.Companion.slerpYaw @@ -206,7 +206,7 @@ object RotationManager : Manager( fun handleBaritoneRotation(yaw: Double, pitch: Double) { runSafe { usingBaritoneRotation = true - val request = IRotationRequest.Full(BaritoneManager) { Rotation(yaw, pitch) } + val request = IRotationRequest.Full(BaritoneHandler) { Rotation(yaw, pitch) } yawRequest = request pitchRequest = request updateActiveRotation() diff --git a/src/main/kotlin/com/lambda/interaction/material/container/ContainerManager.kt b/src/main/kotlin/com/lambda/interaction/material/container/ContainerHandler.kt similarity index 99% rename from src/main/kotlin/com/lambda/interaction/material/container/ContainerManager.kt rename to src/main/kotlin/com/lambda/interaction/material/container/ContainerHandler.kt index d5e60cc91..122966eb5 100644 --- a/src/main/kotlin/com/lambda/interaction/material/container/ContainerManager.kt +++ b/src/main/kotlin/com/lambda/interaction/material/container/ContainerHandler.kt @@ -39,7 +39,7 @@ import net.minecraft.screen.ScreenHandlerType import net.minecraft.screen.slot.Slot // ToDo: Make this a Configurable to save container caches. Should use a cached region based storage system. -object ContainerManager : Loadable { +object ContainerHandler : Loadable { private val containers: List get() = compileContainers + runtimeContainers diff --git a/src/main/kotlin/com/lambda/interaction/material/container/containers/ChestContainer.kt b/src/main/kotlin/com/lambda/interaction/material/container/containers/ChestContainer.kt index 18cc96534..20014a240 100644 --- a/src/main/kotlin/com/lambda/interaction/material/container/containers/ChestContainer.kt +++ b/src/main/kotlin/com/lambda/interaction/material/container/containers/ChestContainer.kt @@ -19,7 +19,7 @@ package com.lambda.interaction.material.container.containers import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext -import com.lambda.interaction.material.container.ContainerManager +import com.lambda.interaction.material.container.ContainerHandler import com.lambda.interaction.material.container.ExternalContainer import com.lambda.interaction.material.container.MaterialContainer import com.lambda.task.Task @@ -42,7 +42,7 @@ data class ChestContainer( context(safeContext: SafeContext) override val slots get(): List = - if (ContainerManager.lastInteractedBlockEntity is ChestBlockEntity) + if (ContainerHandler.lastInteractedBlockEntity is ChestBlockEntity) safeContext.player.currentScreenHandler.containerSlots else emptyList() diff --git a/src/main/kotlin/com/lambda/interaction/material/container/containers/EnderChestContainer.kt b/src/main/kotlin/com/lambda/interaction/material/container/containers/EnderChestContainer.kt index ea70d15d0..ace829524 100644 --- a/src/main/kotlin/com/lambda/interaction/material/container/containers/EnderChestContainer.kt +++ b/src/main/kotlin/com/lambda/interaction/material/container/containers/EnderChestContainer.kt @@ -20,8 +20,8 @@ package com.lambda.interaction.material.container.containers import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext import com.lambda.interaction.material.StackSelection.Companion.select -import com.lambda.interaction.material.container.ContainerManager -import com.lambda.interaction.material.container.ContainerManager.findSlotsWithMaterial +import com.lambda.interaction.material.container.ContainerHandler +import com.lambda.interaction.material.container.ContainerHandler.findSlotsWithMaterial import com.lambda.interaction.material.container.ExternalContainer import com.lambda.interaction.material.container.MaterialContainer import com.lambda.task.TaskGenerator @@ -40,7 +40,7 @@ object EnderChestContainer : MaterialContainer(Rank.EnderChest), ExternalContain context(safeContext: SafeContext) override val slots get() = - if (ContainerManager.lastInteractedBlockEntity is EnderChestBlockEntity) + if (ContainerHandler.lastInteractedBlockEntity is EnderChestBlockEntity) safeContext.player.currentScreenHandler.containerSlots else emptyList() override var stacks = emptyList() diff --git a/src/main/kotlin/com/lambda/interaction/material/container/containers/ShulkerBoxContainer.kt b/src/main/kotlin/com/lambda/interaction/material/container/containers/ShulkerBoxContainer.kt index 78b2717bb..37b268635 100644 --- a/src/main/kotlin/com/lambda/interaction/material/container/containers/ShulkerBoxContainer.kt +++ b/src/main/kotlin/com/lambda/interaction/material/container/containers/ShulkerBoxContainer.kt @@ -19,7 +19,7 @@ package com.lambda.interaction.material.container.containers import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext -import com.lambda.interaction.material.container.ContainerManager +import com.lambda.interaction.material.container.ContainerHandler import com.lambda.interaction.material.container.ExternalContainer import com.lambda.interaction.material.container.MaterialContainer import com.lambda.task.TaskGenerator @@ -44,7 +44,7 @@ data class ShulkerBoxContainer( context(safeContext: SafeContext) override val slots get(): List = - if (ContainerManager.lastInteractedBlockEntity is ShulkerBoxBlockEntity) + if (ContainerHandler.lastInteractedBlockEntity is ShulkerBoxBlockEntity) safeContext.player.currentScreenHandler.containerSlots else emptyList() diff --git a/src/main/kotlin/com/lambda/module/Module.kt b/src/main/kotlin/com/lambda/module/Module.kt index 7e53e4817..f3c54082d 100644 --- a/src/main/kotlin/com/lambda/module/Module.kt +++ b/src/main/kotlin/com/lambda/module/Module.kt @@ -40,7 +40,7 @@ import com.lambda.event.listener.UnsafeListener import com.lambda.module.modules.client.Client import com.lambda.module.tag.ModuleTag import com.lambda.sound.LambdaSound -import com.lambda.sound.SoundManager.play +import com.lambda.sound.SoundHandler.play import com.lambda.util.KeyCode import com.lambda.util.Nameable diff --git a/src/main/kotlin/com/lambda/module/hud/Baritone.kt b/src/main/kotlin/com/lambda/module/hud/Baritone.kt index 581b6b1ad..7d44fb755 100644 --- a/src/main/kotlin/com/lambda/module/hud/Baritone.kt +++ b/src/main/kotlin/com/lambda/module/hud/Baritone.kt @@ -18,7 +18,7 @@ package com.lambda.module.hud import com.lambda.gui.dsl.ImGuiBuilder -import com.lambda.interaction.BaritoneManager +import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.construction.simulation.BuildGoal import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag @@ -29,12 +29,12 @@ object Baritone : HudModule( tag = ModuleTag.HUD, ) { override fun ImGuiBuilder.buildLayout() { - if (!BaritoneManager.isBaritoneLoaded) { + if (!BaritoneHandler.isBaritoneLoaded) { text("Baritone is not loaded") return } - BaritoneManager.primary?.customGoalProcess?.goal?.let { + BaritoneHandler.primary?.customGoalProcess?.goal?.let { when(it) { is BuildGoal -> text("Lambda Simulation: ${it.sim}") else -> text("Baritone: $it") diff --git a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt index 7d78cac8c..ce2a42fac 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt @@ -23,7 +23,7 @@ import com.lambda.config.applyEdits import com.lambda.config.groups.ReplaceConfig import com.lambda.event.events.ChatEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.friend.FriendManager +import com.lambda.friend.FriendHandler import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.ChatUtils.addresses @@ -40,6 +40,7 @@ import com.lambda.util.text.MessageParser import com.lambda.util.text.MessageType import net.minecraft.text.Text +@Suppress("unused") object AntiSpam : Module( name = "AntiSpam", description = "Keeps your chat clean", @@ -105,7 +106,7 @@ object AntiSpam : Module( cancelled || filterSystem && !MessageType.Both.matches(raw) && !DirectMessage.Both.matches(raw) || filterDms && DirectMessage.Receive.matches(raw) || - filterFriends && author?.let { FriendManager.isFriend(it) } == true || + filterFriends && author?.let { FriendHandler.isFriend(it) } == true || filterSelf && MessageType.Self.matches(raw) ) return diff --git a/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt b/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt index 43d1803be..85cd25c5c 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt @@ -36,6 +36,7 @@ import java.time.ZoneId import java.time.ZonedDateTime import java.time.temporal.ChronoUnit +@Suppress("unused") object ChatTimestamp : Module( name = "ChatTimestamp", description = "Displays the time a message was sent next to it", diff --git a/src/main/kotlin/com/lambda/module/modules/chat/CustomChat.kt b/src/main/kotlin/com/lambda/module/modules/chat/CustomChat.kt index 321e6ea45..8869f4b7d 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/CustomChat.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/CustomChat.kt @@ -21,11 +21,12 @@ import com.google.common.collect.Comparators.min import com.lambda.command.CommandRegistry.prefix import com.lambda.event.events.ChatEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.BaritoneManager +import com.lambda.interaction.BaritoneHandler import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.NamedEnum +@Suppress("unused") object CustomChat : Module( name = "CustomChat", description = "Adds a custom ending to your message", @@ -38,7 +39,7 @@ object CustomChat : Module( init { listen { - val isBaritone = BaritoneManager.baritoneSettings?.prefix?.value + val isBaritone = BaritoneHandler.baritoneSettings?.prefix?.value ?.let { setting -> it.message.startsWith(setting)} ?: false diff --git a/src/main/kotlin/com/lambda/module/modules/chat/FancyChat.kt b/src/main/kotlin/com/lambda/module/modules/chat/FancyChat.kt index b9ff4f25f..41f4728d3 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/FancyChat.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/FancyChat.kt @@ -20,7 +20,7 @@ package com.lambda.module.modules.chat import com.lambda.command.CommandRegistry.prefix import com.lambda.event.events.ChatEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.BaritoneManager +import com.lambda.interaction.BaritoneHandler import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.ChatUtils.toBlue @@ -28,6 +28,7 @@ import com.lambda.util.ChatUtils.toGreen import com.lambda.util.ChatUtils.toLeet import com.lambda.util.ChatUtils.toUwu +@Suppress("unused") object FancyChat : Module( name = "FancyChat", description = "Makes messages you send - fancy", @@ -40,7 +41,7 @@ object FancyChat : Module( init { listen { - val isBaritone = BaritoneManager.baritoneSettings?.prefix?.value + val isBaritone = BaritoneHandler.baritoneSettings?.prefix?.value ?.let { setting -> it.message.startsWith(setting)} ?: false diff --git a/src/main/kotlin/com/lambda/module/modules/chat/FriendHighlight.kt b/src/main/kotlin/com/lambda/module/modules/chat/FriendHighlight.kt index 6f624da47..5c8057fdc 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/FriendHighlight.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/FriendHighlight.kt @@ -19,10 +19,10 @@ package com.lambda.module.modules.chat import com.lambda.event.events.ChatEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.friend.FriendManager +import com.lambda.friend.FriendHandler import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.sound.SoundManager.playSound +import com.lambda.sound.SoundHandler.playSound import com.lambda.util.Communication.logError import com.lambda.util.text.MessageType import com.lambda.util.text.buildText @@ -32,6 +32,7 @@ import net.minecraft.sound.SoundEvents import net.minecraft.util.Formatting import java.awt.Color +@Suppress("unused") object FriendHighlight : Module( name = "FriendHighlight", description = "Highlights your friends names in chat", @@ -51,7 +52,7 @@ object FriendHighlight : Module( init { onEnable { - if (FriendManager.friends.isEmpty()) + if (FriendHandler.friends.isEmpty()) logError("You don't have any friends added, silly! Go add some friends before using the module") } @@ -60,7 +61,7 @@ object FriendHighlight : Module( val author = MessageType.Others.playerName(raw) ?: return@listen val content = MessageType.Others.removedOrNull(raw) ?: return@listen - if (!FriendManager.isFriend(author)) return@listen + if (!FriendHandler.isFriend(author)) return@listen if (ping) playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP) diff --git a/src/main/kotlin/com/lambda/module/modules/client/Discord.kt b/src/main/kotlin/com/lambda/module/modules/client/Discord.kt index 254a0eea4..7cfbf04ed 100644 --- a/src/main/kotlin/com/lambda/module/modules/client/Discord.kt +++ b/src/main/kotlin/com/lambda/module/modules/client/Discord.kt @@ -25,7 +25,7 @@ import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listenOnce import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.network.NetworkManager.updateToken +import com.lambda.network.NetworkHandler.updateToken import com.lambda.network.api.v1.endpoints.linkDiscord import com.lambda.threading.runConcurrent import com.lambda.util.Communication.warn @@ -40,6 +40,7 @@ import dev.cbyrne.kdiscordipc.data.activity.smallImage import dev.cbyrne.kdiscordipc.data.activity.timestamps import kotlinx.coroutines.delay +@Suppress("unused") object Discord : Module( name = "Discord", description = "Discord Rich Presence configuration", diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt index c80126edf..fb71dc197 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt @@ -40,6 +40,7 @@ import net.minecraft.registry.RegistryKey import net.minecraft.registry.tag.ItemTags import net.minecraft.screen.slot.Slot +@Suppress("unused") object AutoArmor : Module( name = "AutoArmor", description = "Automatically equips armor", diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoDisconnect.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoDisconnect.kt index ef5ab52c1..3337778f2 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoDisconnect.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoDisconnect.kt @@ -21,10 +21,10 @@ import com.lambda.context.SafeContext import com.lambda.event.events.PlayerEvent import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.friend.FriendManager +import com.lambda.friend.FriendHandler import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.sound.SoundManager.playSound +import com.lambda.sound.SoundHandler.playSound import com.lambda.util.Communication import com.lambda.util.Communication.prefix import com.lambda.util.Formatting.format @@ -50,6 +50,7 @@ import net.minecraft.text.Text import net.minecraft.world.GameMode import java.awt.Color +@Suppress("unused") object AutoDisconnect : Module( name = "AutoDisconnect", description = "Automatically disconnects when in danger or on low health", @@ -245,7 +246,7 @@ object AutoDisconnect : Module( fastEntitySearch(minPlayerDistance.toDouble()).find { otherPlayer -> otherPlayer != player && player.distanceTo(otherPlayer) <= minPlayerDistance - && (!friends || !FriendManager.isFriend(otherPlayer.uuid)) + && (!friends || !FriendHandler.isFriend(otherPlayer.uuid)) }?.let { otherPlayer -> buildText { literal("The player ") diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt index 5b4de1bce..e6ae22686 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt @@ -22,7 +22,7 @@ import com.lambda.config.applyEdits import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.friend.FriendManager +import com.lambda.friend.FriendHandler import com.lambda.interaction.managers.inventory.InventoryRequest.Companion.inventoryRequest import com.lambda.interaction.material.StackSelection.Companion.select import com.lambda.module.Module @@ -37,6 +37,7 @@ import net.minecraft.entity.mob.CreeperEntity import net.minecraft.entity.player.PlayerEntity import net.minecraft.item.Items +@Suppress("unused") object AutoTotem : Module( name = "AutoTotem", description = "Swaps the your off-hand item to a totem", @@ -91,7 +92,7 @@ object AutoTotem : Module( Player({ players && fastEntitySearch(minPlayerDistance.toDouble()).any { otherPlayer -> otherPlayer != player && player.distanceTo(otherPlayer) <= minPlayerDistance - && (!friends || !FriendManager.isFriend(otherPlayer.uuid)) + && (!friends || !FriendHandler.isFriend(otherPlayer.uuid)) } }), EndCrystal({ crystals && hasDeadlyCrystal() }), FallDamage({ falls && isFallDeadly() && player.fallDistance > fallDistance }) diff --git a/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt b/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt index ad0c69fcc..42a9e4ac3 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt @@ -35,6 +35,7 @@ import net.minecraft.util.Hand import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction +@Suppress("unused") object Criticals : Module( name = "Criticals", description = "Forces your hits to be critical", diff --git a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt index 9e0fb1a3b..a628c701b 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt @@ -30,7 +30,7 @@ import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo import com.lambda.interaction.managers.rotating.RotationManager import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.getVisibleSurfaces import com.lambda.interaction.material.StackSelection.Companion.selectStack -import com.lambda.interaction.material.container.ContainerManager.transfer +import com.lambda.interaction.material.container.ContainerHandler.transfer import com.lambda.interaction.material.container.containers.HotbarContainer import com.lambda.interaction.material.container.containers.OffHandContainer import com.lambda.module.Module @@ -72,6 +72,7 @@ import kotlin.concurrent.fixedRateTimer import kotlin.math.max import kotlin.time.Duration.Companion.milliseconds +@Suppress("unused") object CrystalAura : Module( name = "CrystalAura", description = "Automatically attacks entities with crystals", diff --git a/src/main/kotlin/com/lambda/module/modules/combat/FakePlayer.kt b/src/main/kotlin/com/lambda/module/modules/combat/FakePlayer.kt index bbc7152be..cdfc97aa9 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/FakePlayer.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/FakePlayer.kt @@ -37,6 +37,7 @@ import java.util.* import kotlin.jvm.optionals.getOrNull import kotlin.time.Duration.Companion.seconds +@Suppress("unused") object FakePlayer : Module( name = "FakePlayer", description = "Spawns a fake player", diff --git a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt index 67339b858..af1770b4d 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt @@ -20,10 +20,9 @@ package com.lambda.module.modules.combat import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.context.SafeContext -import com.lambda.friend.FriendManager.isFriend +import com.lambda.friend.FriendHandler.isFriend import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint import com.lambda.interaction.construction.verify.TargetState -import com.lambda.interaction.managers.interacting.InteractConfig import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.task.RootTask.run diff --git a/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt b/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt index 146eb87b4..5aae5107c 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt @@ -21,7 +21,6 @@ import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint import com.lambda.interaction.construction.verify.TargetState -import com.lambda.interaction.managers.interacting.InteractConfig import com.lambda.module.Module import com.lambda.module.modules.combat.PlayerTrap.getTrapPositions import com.lambda.module.tag.ModuleTag @@ -33,6 +32,7 @@ import com.lambda.util.player.SlotUtils.hotbarAndInventoryStacks import net.minecraft.block.Blocks import net.minecraft.item.BlockItem +@Suppress("unused") object Surround : Module( name = "Surround", description = "Surrounds your players feet with any given block", diff --git a/src/main/kotlin/com/lambda/module/modules/debug/BaritoneTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/BaritoneTest.kt index 9d1cc7500..b22323764 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/BaritoneTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/BaritoneTest.kt @@ -20,10 +20,11 @@ package com.lambda.module.modules.debug import baritone.api.pathing.goals.GoalXZ import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.BaritoneManager +import com.lambda.interaction.BaritoneHandler import com.lambda.module.Module import com.lambda.module.tag.ModuleTag +@Suppress("unused") object BaritoneTest : Module( name = "BaritoneTest", description = "Test Baritone", @@ -31,11 +32,11 @@ object BaritoneTest : Module( ) { init { listen { - BaritoneManager.setGoalAndPath(GoalXZ(0, 0)) + BaritoneHandler.setGoalAndPath(GoalXZ(0, 0)) } onDisable { - BaritoneManager.cancel() + BaritoneHandler.cancel() } } } diff --git a/src/main/kotlin/com/lambda/module/modules/debug/BlockTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/BlockTest.kt index 6ab25be12..125bd5f92 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/BlockTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/BlockTest.kt @@ -20,12 +20,12 @@ package com.lambda.module.modules.debug import com.lambda.graphics.mc.renderer.TickedRenderer.Companion.tickedRenderer import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.ChatUtils.colors import com.lambda.util.world.blockSearch import net.minecraft.block.Blocks import net.minecraft.util.math.Vec3i import java.awt.Color +@Suppress("unused") object BlockTest : Module( name = "BlockTest", description = "BlockTest", diff --git a/src/main/kotlin/com/lambda/module/modules/debug/ContainerTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/ContainerTest.kt index 3b452015e..fc9ceb73a 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/ContainerTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/ContainerTest.kt @@ -26,6 +26,7 @@ import com.lambda.task.RootTask.run import com.lambda.task.tasks.AcquireMaterialTask.Companion.acquire import net.minecraft.item.Items +@Suppress("unused") object ContainerTest : Module( name = "ContainerTest", description = "Test container", diff --git a/src/main/kotlin/com/lambda/module/modules/debug/DebugRendererModule.kt b/src/main/kotlin/com/lambda/module/modules/debug/DebugRendererModule.kt index 73bc7f569..3e417f071 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/DebugRendererModule.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/DebugRendererModule.kt @@ -17,13 +17,10 @@ package com.lambda.module.modules.debug -import com.lambda.Lambda.mc import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import net.minecraft.client.render.VertexConsumerProvider -import net.minecraft.client.render.debug.DebugRenderer -import net.minecraft.client.util.math.MatrixStack +@Suppress("unused") object DebugRendererModule: Module( name = "Debug Renderer", description = "Renders debug information of minecraft internals", diff --git a/src/main/kotlin/com/lambda/module/modules/debug/FallTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/FallTest.kt index 7a5bf4de2..e07485723 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/FallTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/FallTest.kt @@ -25,6 +25,7 @@ import com.lambda.util.Communication.info import com.lambda.util.combat.DamageUtils.fallDamage import com.lambda.util.combat.DamageUtils.isFallDeadly +@Suppress("unused") object FallTest : Module( name = "FallTest", tag = ModuleTag.DEBUG, diff --git a/src/main/kotlin/com/lambda/module/modules/debug/InventoryDebug.kt b/src/main/kotlin/com/lambda/module/modules/debug/InventoryDebug.kt index ccf7bed30..12319276b 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/InventoryDebug.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/InventoryDebug.kt @@ -34,6 +34,7 @@ import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket import net.minecraft.network.packet.s2c.play.InventoryS2CPacket import net.minecraft.network.packet.s2c.play.UpdateSelectedSlotS2CPacket +@Suppress("unused") object InventoryDebug : Module( name = "InventoryDebug", description = "Debugs the inventory", diff --git a/src/main/kotlin/com/lambda/module/modules/debug/PropertyPrinter.kt b/src/main/kotlin/com/lambda/module/modules/debug/PropertyPrinter.kt index c470aec00..c29a07ead 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/PropertyPrinter.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/PropertyPrinter.kt @@ -24,6 +24,7 @@ import com.lambda.util.extension.resolveFile import net.minecraft.block.Block import net.minecraft.block.Blocks +@Suppress("unused") object PropertyPrinter : Module( name = "PropertyPrinter", description = "Prints all properties coupled with all the states that use them into a text file", diff --git a/src/main/kotlin/com/lambda/module/modules/debug/RenderTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/RenderTest.kt index b7823bd35..8580bcdef 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/RenderTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/RenderTest.kt @@ -30,6 +30,7 @@ import net.minecraft.entity.LivingEntity import net.minecraft.util.math.Box import java.awt.Color +@Suppress("unused") object RenderTest : Module( name = "Render:shrimp:Test:canned_food:", description = "RenderTest", diff --git a/src/main/kotlin/com/lambda/module/modules/debug/RendererTestModule.kt b/src/main/kotlin/com/lambda/module/modules/debug/RendererTestModule.kt index 15523b179..12cb2363b 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/RendererTestModule.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/RendererTestModule.kt @@ -30,9 +30,7 @@ import com.lambda.graphics.mc.RenderBuilder.SDFStyle import com.lambda.graphics.mc.renderer.ChunkedRenderer.Companion.chunkedRenderer import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRenderer import com.lambda.graphics.mc.renderer.TickedRenderer.Companion.tickedRenderer -import com.lambda.graphics.outline.OutlineManager import com.lambda.graphics.outline.OutlineStyle -import com.lambda.graphics.outline.VertexCapture import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe @@ -40,9 +38,6 @@ import com.lambda.util.extension.prevPos import com.lambda.util.extension.tickDelta import com.lambda.util.math.lerp import com.lambda.util.world.toBlockPos -import net.minecraft.entity.mob.HostileEntity -import net.minecraft.entity.passive.PassiveEntity -import net.minecraft.entity.player.PlayerEntity import net.minecraft.item.ItemStack import net.minecraft.item.Items import net.minecraft.util.Identifier @@ -54,6 +49,7 @@ import net.minecraft.util.math.random.Random import org.joml.Quaternionf import java.awt.Color +@Suppress("unused") object ChunkedRendererTest : Module( name = "ChunkedRendererTest", description = "Test module for ChunkedRenderer", @@ -168,6 +164,7 @@ object ChunkedRendererTest : Module( } } +@Suppress("unused") object TickedRendererTest : Module( name = "TickedRendererTest", description = "Test module for TickedRenderer", @@ -274,6 +271,7 @@ object TickedRendererTest : Module( } } +@Suppress("unused") object ImmediateRendererTest : Module( name = "ImmediateRendererTest", description = "Test module for ImmediateRenderer", diff --git a/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt index 20375406d..43cfdd9ba 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt @@ -27,6 +27,7 @@ import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import net.minecraft.util.hit.HitResult +@Suppress("unused") object RotationTest : Module( name = "RotationTest", tag = ModuleTag.DEBUG, diff --git a/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt b/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt index 4b24ae97c..951d080f3 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt @@ -24,6 +24,7 @@ import com.lambda.config.groups.WorldTextSettings import com.lambda.module.Module import com.lambda.module.tag.ModuleTag +@Suppress("unused") object SettingsTestModule : Module( name = "SettingsTestModule", description = "Test module for Line and Text Config Settings", diff --git a/src/main/kotlin/com/lambda/module/modules/debug/TimerTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/TimerTest.kt index c38ca4ffc..63373bf32 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/TimerTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/TimerTest.kt @@ -24,6 +24,7 @@ import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.Communication.info +@Suppress("unused") object TimerTest : Module( name = "TimerTest", tag = ModuleTag.DEBUG, diff --git a/src/main/kotlin/com/lambda/module/modules/movement/AutoSpiral.kt b/src/main/kotlin/com/lambda/module/modules/movement/AutoSpiral.kt index f68c0a0da..9d4f4060e 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/AutoSpiral.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/AutoSpiral.kt @@ -21,12 +21,11 @@ import baritone.api.pathing.goals.GoalXZ import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.BaritoneManager +import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest import com.lambda.interaction.managers.rotating.visibilty.lookAt import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.threading.runSafe import com.lambda.util.BlockPosIterators import com.lambda.util.extension.isNether import net.minecraft.util.math.BlockPos @@ -61,7 +60,7 @@ object AutoSpiral : Module( onDisable { iterator = null currentWaypoint = null - BaritoneManager.cancel() + BaritoneHandler.cancel() } listen { @@ -97,9 +96,9 @@ object AutoSpiral : Module( val scaled = pos.multiply(spiralSpacing) val w = scaled.add(center) if (world.isNether) { - BaritoneManager.setGoalAndElytraPath(GoalXZ(w.x, w.z)) + BaritoneHandler.setGoalAndElytraPath(GoalXZ(w.x, w.z)) } else { - if (setBaritoneGoal) BaritoneManager.setGoal(GoalXZ(w.x, w.z)) + if (setBaritoneGoal) BaritoneHandler.setGoal(GoalXZ(w.x, w.z)) } currentWaypoint = w } diff --git a/src/main/kotlin/com/lambda/module/modules/movement/AutoWalk.kt b/src/main/kotlin/com/lambda/module/modules/movement/AutoWalk.kt index 711644a73..67f8ef592 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/AutoWalk.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/AutoWalk.kt @@ -30,6 +30,7 @@ import net.minecraft.util.math.Vec2f import kotlin.time.DurationUnit import kotlin.time.toDuration +@Suppress("unused") object AutoWalk : Module( name = "AutoWalk", description = "Automatically makes your character walk forward", diff --git a/src/main/kotlin/com/lambda/module/modules/movement/BackTrack.kt b/src/main/kotlin/com/lambda/module/modules/movement/BackTrack.kt index 70b0e687a..281766a82 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/BackTrack.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/BackTrack.kt @@ -54,6 +54,7 @@ import net.minecraft.util.math.Vec3d import java.awt.Color import java.util.concurrent.ConcurrentLinkedDeque +@Suppress("unused") object BackTrack : Module( name = "BackTrack", description = "Gives reach advantage by delaying your packets", diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt index 5852c0515..99d67d7bd 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt @@ -37,8 +37,9 @@ import net.minecraft.util.math.Vec3d import kotlin.time.Duration.Companion.seconds import kotlin.time.TimeSource +@Suppress("unused") object ElytraAltitudeControl : Module( - name = "ElytraAttitudeControl", + name = "ElytraAltitudeControl", description = "Automatically control attitude or speed while elytra flying", tag = ModuleTag.MOVEMENT, ) { diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt index 076b4f558..701c01000 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt @@ -26,7 +26,7 @@ import com.lambda.event.events.MovementEvent import com.lambda.event.events.PacketEvent import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.BaritoneManager +import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest import com.lambda.interaction.material.StackSelection.Companion.select import com.lambda.module.Module @@ -131,7 +131,7 @@ object ElytraFly : Module( onDisable { passingToPos = null - if (passObstacles) BaritoneManager.cancel() + if (passObstacles) BaritoneHandler.cancel() } listen { event -> @@ -201,7 +201,7 @@ object ElytraFly : Module( } private fun SafeContext.onTickBounce() { - if (!BaritoneManager.isActive) passingToPos = null + if (!BaritoneHandler.isActive) passingToPos = null val playerPos = player.pos if (passObstacles && playerPos.let { Vec3d(it.x, startPos.y, it.z) } dist startPos > 0.1) run obstacleChecks@{ @@ -265,7 +265,7 @@ object ElytraFly : Module( private fun passTo(pos: Vec3d) { passingToPos = pos - BaritoneManager.setGoalAndPath(GoalGetToBlock(pos.flooredBlockPos)) + BaritoneHandler.setGoalAndPath(GoalGetToBlock(pos.flooredBlockPos)) } context(safeContext: SafeContext) @@ -340,7 +340,7 @@ object ElytraFly : Module( mode == FlyMode.Bounce && previouslyFlying == true && glidePause <= 0 && - !BaritoneManager.isActive) true + !BaritoneHandler.isActive) true else { previouslyFlying = original original diff --git a/src/main/kotlin/com/lambda/module/modules/movement/EntityControl.kt b/src/main/kotlin/com/lambda/module/modules/movement/EntityControl.kt index a19a6ce11..03bff2f1d 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/EntityControl.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/EntityControl.kt @@ -26,6 +26,7 @@ import com.lambda.util.world.fastEntitySearch import net.minecraft.entity.passive.AbstractHorseEntity import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket +@Suppress("unused") object EntityControl : Module( name = "EntityControl", description = "Control mountable entities", diff --git a/src/main/kotlin/com/lambda/module/modules/movement/Jesus.kt b/src/main/kotlin/com/lambda/module/modules/movement/Jesus.kt index 990b85acb..7f024e4bb 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/Jesus.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/Jesus.kt @@ -38,6 +38,7 @@ import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Vec3d import net.minecraft.util.shape.VoxelShapes +@Suppress("unused") object Jesus : Module( name = "Jesus", description = "Allows to walk on water", diff --git a/src/main/kotlin/com/lambda/module/modules/movement/NoFall.kt b/src/main/kotlin/com/lambda/module/modules/movement/NoFall.kt index 9b19afc11..73bf81959 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/NoFall.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/NoFall.kt @@ -34,6 +34,7 @@ import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction import net.minecraft.util.math.Vec3d +@Suppress("unused") object NoFall : Module( name = "NoFall", description = "Reduces fall damage", diff --git a/src/main/kotlin/com/lambda/module/modules/movement/Timer.kt b/src/main/kotlin/com/lambda/module/modules/movement/Timer.kt index 3e89bd6ee..359f78bde 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/Timer.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/Timer.kt @@ -22,6 +22,7 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module import com.lambda.module.tag.ModuleTag +@Suppress("unused") object Timer : Module( name = "Timer", description = "Modify client tick speed.", diff --git a/src/main/kotlin/com/lambda/module/modules/network/PacketDelay.kt b/src/main/kotlin/com/lambda/module/modules/network/PacketDelay.kt index 6ee8d1479..73deeba44 100644 --- a/src/main/kotlin/com/lambda/module/modules/network/PacketDelay.kt +++ b/src/main/kotlin/com/lambda/module/modules/network/PacketDelay.kt @@ -36,6 +36,7 @@ import net.minecraft.network.packet.Packet import net.minecraft.network.packet.c2s.common.KeepAliveC2SPacket import java.util.concurrent.ConcurrentLinkedDeque +@Suppress("unused") object PacketDelay : Module( name = "PacketDelay", description = "Delays packets client-bound & server-bound", diff --git a/src/main/kotlin/com/lambda/module/modules/player/AntiAFK.kt b/src/main/kotlin/com/lambda/module/modules/player/AntiAFK.kt index a8386b7dd..25f485e17 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/AntiAFK.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/AntiAFK.kt @@ -23,6 +23,7 @@ import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import net.minecraft.util.Hand +@Suppress("unused") object AntiAFK : Module( name = "AntiAFK", description = "Keeps you from getting kicked", diff --git a/src/main/kotlin/com/lambda/module/modules/player/AntiAim.kt b/src/main/kotlin/com/lambda/module/modules/player/AntiAim.kt index b59b60528..4b4aa19b5 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/AntiAim.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/AntiAim.kt @@ -32,6 +32,7 @@ import net.minecraft.entity.player.PlayerEntity import net.minecraft.util.math.MathHelper.wrapDegrees import kotlin.random.Random +@Suppress("unused") object AntiAim : Module( name = "AntiAim", description = "Rotates the player using the given configs", diff --git a/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt b/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt index daa58072e..3ef6c4b50 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt @@ -29,6 +29,7 @@ import com.lambda.task.tasks.EatTask import com.lambda.task.tasks.EatTask.Companion.eat import com.lambda.threading.runSafeAutomated +@Suppress("unused") object AutoEat : Module( name = "AutoEat", description = "Eats food when you are hungry", diff --git a/src/main/kotlin/com/lambda/module/modules/player/ClickFriend.kt b/src/main/kotlin/com/lambda/module/modules/player/ClickFriend.kt index 48572de75..1344fc94b 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/ClickFriend.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/ClickFriend.kt @@ -20,10 +20,10 @@ package com.lambda.module.modules.player import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.context.SafeContext -import com.lambda.friend.FriendManager -import com.lambda.friend.FriendManager.befriend -import com.lambda.friend.FriendManager.isFriend -import com.lambda.friend.FriendManager.unfriend +import com.lambda.friend.FriendHandler +import com.lambda.friend.FriendHandler.befriend +import com.lambda.friend.FriendHandler.isFriend +import com.lambda.friend.FriendHandler.unfriend import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.Communication.info @@ -33,6 +33,7 @@ import net.minecraft.client.network.OtherClientPlayerEntity import org.lwjgl.glfw.GLFW import org.lwjgl.glfw.GLFW.GLFW_MOD_SHIFT +@Suppress("unused") object ClickFriend : Module( name = "ClickFriend", description = "Add or remove friends with a single click", @@ -52,8 +53,8 @@ object ClickFriend : Module( val target = mc.crosshairTarget?.entityResult?.entity as? OtherClientPlayerEntity ?: return false - if (friend && !target.isFriend && target.befriend()) info(FriendManager.befriendedText(target.name)) - else if (!friend && target.isFriend && target.unfriend()) info(FriendManager.unfriendedText(target.name)) + if (friend && !target.isFriend && target.befriend()) info(FriendHandler.befriendedText(target.name)) + else if (!friend && target.isFriend && target.unfriend()) info(FriendHandler.unfriendedText(target.name)) return true } } diff --git a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt index 561be16a2..9e466a7ec 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt @@ -29,6 +29,7 @@ import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafeAutomated import java.util.concurrent.ConcurrentLinkedQueue +@Suppress("unused") object FastBreak : Module( name = "FastBreak", description = "Break blocks faster.", diff --git a/src/main/kotlin/com/lambda/module/modules/player/Replay.kt b/src/main/kotlin/com/lambda/module/modules/player/Replay.kt index 896745547..16a7a8ad3 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/Replay.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/Replay.kt @@ -28,7 +28,7 @@ import com.google.gson.JsonSerializer import com.lambda.brigadier.CommandResult import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.context.SafeContext -import com.lambda.core.TimerManager +import com.lambda.core.TimerHandler import com.lambda.event.EventFlow.lambdaScope import com.lambda.event.events.MovementEvent import com.lambda.event.events.TickEvent @@ -41,7 +41,7 @@ import com.lambda.interaction.managers.rotating.RotationMode import com.lambda.module.Module import com.lambda.module.modules.player.Replay.InputAction.Companion.toAction import com.lambda.module.tag.ModuleTag -import com.lambda.sound.SoundManager.playSound +import com.lambda.sound.SoundHandler.playSound import com.lambda.util.Communication.info import com.lambda.util.Communication.logError import com.lambda.util.Communication.warn @@ -557,7 +557,7 @@ object Replay : Module( val size: Int get() = minOf(input.size, rotation.size, position.size) val duration: Duration - get() = (size * TimerManager.lastTickLength * 1.0).toDuration(DurationUnit.MILLISECONDS) + get() = (size * TimerHandler.lastTickLength * 1.0).toDuration(DurationUnit.MILLISECONDS) val startPos: Vec3d get() = position.firstOrNull() ?: Vec3d.ZERO val endPos: Vec3d diff --git a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt index ad1349288..a7a9694b4 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt @@ -28,6 +28,7 @@ import com.lambda.module.tag.ModuleTag import com.lambda.util.NamedEnum import kotlin.math.roundToInt +@Suppress("unused") object RotationLock : Module( name = "RotationLock", description = "Locks the player rotation to the given configuration", diff --git a/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt b/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt index 5823b5a5d..416040a5a 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt @@ -31,6 +31,7 @@ import com.lambda.util.player.SlotUtils.inventoryStacks import net.minecraft.item.ItemStack import net.minecraft.item.Items +@Suppress("unused") object StackReplenish : Module( name = "StackReplenish", description = "Automatically refills stacks from your inventory", diff --git a/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt b/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt index 54eae94ea..ce8c79eb2 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt @@ -33,6 +33,7 @@ import com.lambda.util.player.SlotUtils.inventorySlots import net.minecraft.item.ItemStack import net.minecraft.screen.slot.Slot +@Suppress("unused") object ToolSaver : Module( name = "ToolSaver", description = "Moves tools from your hotbar into your inventory when they get too damaged", diff --git a/src/main/kotlin/com/lambda/module/modules/render/ESP.kt b/src/main/kotlin/com/lambda/module/modules/render/ESP.kt index e6bceff29..cd1fddadc 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/ESP.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/ESP.kt @@ -34,6 +34,7 @@ import net.minecraft.entity.Entity import net.minecraft.util.math.Box import java.awt.Color +@Suppress("unused") object ESP : Module( name = "ESP", description = "Highlight entities with smooth interpolated rendering", diff --git a/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt b/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt index 2bffe53e5..e46005ba3 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt @@ -21,7 +21,7 @@ import com.lambda.Lambda.mc import com.lambda.config.applyEdits import com.lambda.config.groups.EntitySelectionSettings import com.lambda.config.groups.ScreenTextSettings -import com.lambda.friend.FriendManager.isFriend +import com.lambda.friend.FriendHandler.isFriend import com.lambda.graphics.mc.RenderBuilder import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRenderer import com.lambda.graphics.mc.renderer.RendererUtils.worldToScreenNormalized diff --git a/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt b/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt index a4249330f..c7995b0a9 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt @@ -35,6 +35,7 @@ import net.minecraft.block.entity.BeaconBlockEntity import net.minecraft.util.math.Box import java.awt.Color +@Suppress("unused") object RadiusESP : Module( name = "RadiusESP", description = "Shows the radius for blocks with abnormal functionality", diff --git a/src/main/kotlin/com/lambda/module/modules/render/Search.kt b/src/main/kotlin/com/lambda/module/modules/render/Search.kt index 99044c123..5b49d4a4e 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Search.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Search.kt @@ -52,6 +52,7 @@ import net.minecraft.util.math.Box import net.minecraft.util.math.Vec3d import java.awt.Color +@Suppress("unused") object Search : Module( name = "Search", description = "Highlight blocks within the rendered world", diff --git a/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt b/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt index 2eb352b8e..e3b9e0074 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt @@ -21,7 +21,7 @@ import com.lambda.config.applyEdits import com.lambda.config.groups.EntityColorSettings import com.lambda.config.groups.EntitySelectionSettings import com.lambda.config.groups.ScreenLineSettings -import com.lambda.friend.FriendManager.isFriend +import com.lambda.friend.FriendHandler.isFriend import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRenderer import com.lambda.graphics.mc.renderer.RendererUtils.worldToScreenNormalized import com.lambda.module.Module @@ -35,6 +35,7 @@ import org.joml.Vector2f import org.joml.component1 import org.joml.component2 +@Suppress("unused") object Tracers : Module( name = "Tracers", description = "Draws lines to entities within the world", diff --git a/src/main/kotlin/com/lambda/module/modules/render/WorldColors.kt b/src/main/kotlin/com/lambda/module/modules/render/WorldColors.kt index 4fb783aad..80b6bbba4 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/WorldColors.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/WorldColors.kt @@ -23,6 +23,7 @@ import com.lambda.util.math.vec3d import net.minecraft.util.math.Vec3d import java.awt.Color +@Suppress("unused") object WorldColors : Module( name = "WorldColors", description = "Changes the color of the sky, clouds and fog", diff --git a/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt b/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt index 59b87c19e..54710053f 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt @@ -56,6 +56,7 @@ import org.lwjgl.glfw.GLFW import java.awt.Color import java.util.concurrent.ConcurrentLinkedQueue +@Suppress("unused") object AirPlace : Module( name = "AirPlace", description = "Allows placing blocks in air", diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt index a3a2e3740..a7604d850 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt @@ -29,7 +29,7 @@ import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRenderer import com.lambda.graphics.util.DirectionMask -import com.lambda.interaction.BaritoneManager +import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.construction.verify.TargetState import com.lambda.interaction.managers.hotbar.HotbarRequest import com.lambda.interaction.managers.inventory.InventoryRequest.Companion.inventoryRequest @@ -295,7 +295,7 @@ object AutoPortal : Module( } swapPacket() if (walkIn) { - BaritoneManager.setGoalAndPath(GoalBlock(currAnchorPos.up())) + BaritoneHandler.setGoalAndPath(GoalBlock(currAnchorPos.up())) } success() } diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt index 4d2c9b7d4..8bdb4ddf6 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt @@ -32,7 +32,7 @@ import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotat import com.lambda.interaction.managers.rotating.visibilty.lookAtEntity import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.sound.SoundManager.playSound +import com.lambda.sound.SoundHandler.playSound import com.lambda.task.RootTask.run import com.lambda.task.Task import com.lambda.task.tasks.BuildTask.Companion.build @@ -56,6 +56,7 @@ import net.minecraft.util.Hand import net.minecraft.util.hit.EntityHitResult import net.minecraft.util.math.BlockPos +@Suppress("unused") object AutoVillagerCycle : Module( name = "AutoVillagerCycle", description = "Automatically cycles librarian villagers with lecterns until a desired enchanted book is found", diff --git a/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt b/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt index fdcb878b6..127653e5a 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt @@ -19,7 +19,7 @@ package com.lambda.module.modules.world import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits -import com.lambda.interaction.BaritoneManager +import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.construction.blueprint.Blueprint.Companion.emptyStructure import com.lambda.interaction.construction.blueprint.PropagatingBlueprint.Companion.propagatingBlueprint import com.lambda.interaction.construction.verify.TargetState @@ -108,7 +108,7 @@ object HighwayTools : Module( runningTask?.cancel() runningTask = null distanceMoved = 0 - BaritoneManager.cancel() + BaritoneHandler.cancel() } } diff --git a/src/main/kotlin/com/lambda/module/modules/world/MapDownloader.kt b/src/main/kotlin/com/lambda/module/modules/world/MapDownloader.kt index 20d1034ea..a351640eb 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/MapDownloader.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/MapDownloader.kt @@ -33,6 +33,7 @@ import net.minecraft.item.map.MapState import java.awt.image.BufferedImage import javax.imageio.ImageIO +@Suppress("unused") object MapDownloader : Module( name = "MapDownloader", description = "Save map data to your computer", diff --git a/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt b/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt index ed4466b0a..7a8c2327a 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt @@ -34,6 +34,7 @@ import com.lambda.util.PlayerBuildLayerUtils.FlattenMode import com.lambda.util.PlayerBuildLayerUtils.isInFlatten import com.lambda.util.PlayerBuildLayerUtils.isInBaritoneSelection +@Suppress("unused") object Nuker : Module( name = "Nuker", description = "Breaks blocks around you", diff --git a/src/main/kotlin/com/lambda/module/modules/world/Printer.kt b/src/main/kotlin/com/lambda/module/modules/world/Printer.kt index dad811865..fc43177d9 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Printer.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Printer.kt @@ -41,6 +41,7 @@ import fi.dy.masa.litematica.data.DataManager import fi.dy.masa.litematica.world.SchematicWorldHandler import net.minecraft.util.math.BlockPos +@Suppress("unused") object Printer : Module( name = "Printer", description = "Automatically prints schematics", diff --git a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt index 833f6b541..00f6ef81a 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt @@ -32,7 +32,7 @@ import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.graphics.mc.renderer.TickedRenderer.Companion.tickedRenderer -import com.lambda.interaction.BaritoneManager +import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.construction.verify.TargetState import com.lambda.interaction.managers.hotbar.HotbarRequest import com.lambda.interaction.managers.interacting.InteractConfig @@ -94,7 +94,6 @@ import kotlin.math.min import kotlin.run import kotlin.to -@Suppress("unused") object StashMover : Module( name = "StashMover", description = "Moves items from one stash location to another", @@ -602,10 +601,10 @@ object StashMover : Module( private fun SafeContext.handleDroppingItems() { val throwPos = itemThrowPos ?: run { failWithLog("No item throw pos set!"); return } if (player.blockPos != throwPos) { - BaritoneManager.setGoalAndPath(GoalBlock(throwPos)) + BaritoneHandler.setGoalAndPath(GoalBlock(throwPos)) return } - if (BaritoneManager.isActive) return + if (BaritoneHandler.isActive) return val rotation = itemThrowRotation ?: run { failWithLog("No item throw rotation set!"); return } val rotationRequest = rotationRequest { rotation(rotation) @@ -655,10 +654,10 @@ object StashMover : Module( private fun SafeContext.handleDispensingPearl() { val dispensePos = pearlDispensePos ?: run { failWithLog("No pearl button set!"); return } if (player.blockPos != dispensePos) { - BaritoneManager.setGoalAndPath(GoalBlock(dispensePos)) + BaritoneHandler.setGoalAndPath(GoalBlock(dispensePos)) return } - if (BaritoneManager.isActive) return + if (BaritoneHandler.isActive) return if (player.hotbarStacks.none { it.isEmpty }) { val firstSlot = player.hotbarSlots.getOrNull(0) ?: run { failWithLog("No first slot? This shouldn't occur."); return } if (player.inventoryStacks.any { it.isEmpty }) { @@ -682,10 +681,10 @@ object StashMover : Module( private fun SafeContext.handleThrowingPearl() { val throwPos = pearlThrowPos ?: run { failWithLog("No pearl throw pos set!"); return } if (player.blockPos != throwPos) { - BaritoneManager.setGoalAndPath(GoalBlock(throwPos)) + BaritoneHandler.setGoalAndPath(GoalBlock(throwPos)) return } - if (BaritoneManager.isActive) return + if (BaritoneHandler.isActive) return if (player.velocity.y < -0.08 || player.velocity.x !in -0.001..0.001 || player.velocity.z !in -0.001..0.001) return if (pearlThrown) { diff --git a/src/main/kotlin/com/lambda/module/modules/world/WorldEater.kt b/src/main/kotlin/com/lambda/module/modules/world/WorldEater.kt deleted file mode 100644 index 1de112cbc..000000000 --- a/src/main/kotlin/com/lambda/module/modules/world/WorldEater.kt +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.module.modules.world - -import com.lambda.graphics.mc.renderer.TickedRenderer.Companion.tickedRenderer -import com.lambda.interaction.BaritoneManager -import com.lambda.interaction.construction.blueprint.Blueprint.Companion.toStructure -import com.lambda.interaction.construction.blueprint.StaticBlueprint.Companion.toBlueprint -import com.lambda.interaction.construction.verify.TargetState -import com.lambda.module.Module -import com.lambda.module.tag.ModuleTag -import com.lambda.task.RootTask.run -import com.lambda.task.Task -import com.lambda.task.tasks.BuildTask.Companion.build -import net.minecraft.util.math.BlockBox -import net.minecraft.util.math.BlockPos -import net.minecraft.util.math.Box -import java.awt.Color - -object WorldEater : Module( - name = "WorldEater", - description = "Eats the world", - tag = ModuleTag.WORLD, -) { -// private val height by setting("Height", 4, 1..10, 1) -// private val width by setting("Width", 6, 1..30, 1) - private val pos1 by setting("Position 1", BlockPos(351, 104, 103)) - private val pos2 by setting("Position 2", BlockPos(361, 70, 113)) - private val layerSize by setting("Layer Size", 1, 1..10, 1) - private var runningTask: Task<*>? = null - private var area = BlockBox.create(pos1, pos2) - private val work = mutableListOf() - - init { - onEnable { - area = BlockBox.create(pos1, pos2) - val layerRanges = (area.minY..area.maxY step layerSize).reversed() - work.addAll(layerRanges.mapNotNull { y -> - if (y == area.minY) return@mapNotNull null - BlockBox(area.minX, y - layerSize, area.minZ, area.maxX, y, area.maxZ) - }) - - buildLayer() - } - - onDisable { - runningTask?.cancel() - runningTask = null - work.clear() - BaritoneManager.cancel() - } - - tickedRenderer("WorldEater Ticked Renderer") { - box(Box.enclosing(pos1, pos2)) { - hideFill() - outlineColor(Color.BLUE) - } - } - } - - private fun buildLayer() { - work.firstOrNull()?.let { box -> - runningTask = build { - box.toStructure(TargetState.Air) - .toBlueprint() - }.finally { - work.removeFirstOrNull() - buildLayer() - }.run() - } ?: disable() - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/network/CapeManager.kt b/src/main/kotlin/com/lambda/network/CapeHandler.kt similarity index 98% rename from src/main/kotlin/com/lambda/network/CapeManager.kt rename to src/main/kotlin/com/lambda/network/CapeHandler.kt index 4e2a7ca4a..fd83d9f3e 100644 --- a/src/main/kotlin/com/lambda/network/CapeManager.kt +++ b/src/main/kotlin/com/lambda/network/CapeHandler.kt @@ -48,7 +48,7 @@ import kotlin.concurrent.fixedRateTimer import kotlin.time.Duration.Companion.hours import kotlin.time.Duration.Companion.seconds -object CapeManager : Configurable(SecretsConfig), Loadable { +object CapeHandler : Configurable(SecretsConfig), Loadable { override val name: String = "capes" var currentCape by setting("cape", "") diff --git a/src/main/kotlin/com/lambda/network/LambdaAPI.kt b/src/main/kotlin/com/lambda/network/LambdaAPI.kt index f720edddc..c963b07b2 100644 --- a/src/main/kotlin/com/lambda/network/LambdaAPI.kt +++ b/src/main/kotlin/com/lambda/network/LambdaAPI.kt @@ -26,7 +26,7 @@ import com.lambda.event.events.ConnectionEvent import com.lambda.event.events.ConnectionEvent.Connect.Login.EncryptionResponse import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.event.listener.UnsafeListener.Companion.listenConcurrentlyUnsafe -import com.lambda.network.NetworkManager.updateToken +import com.lambda.network.NetworkHandler.updateToken import com.lambda.network.api.v1.endpoints.login import com.lambda.util.StringUtils.hash import com.lambda.util.extension.isOffline @@ -71,7 +71,7 @@ object LambdaAPI : Configurable(LambdaConfig) { listenConcurrentlyUnsafe { // FixMe: If the player have the properties but are invalid this doesn't work - if (NetworkManager.isValid || mc.gameProfile.isOffline) return@listenConcurrentlyUnsafe + if (NetworkHandler.isValid || mc.gameProfile.isOffline) return@listenConcurrentlyUnsafe // If we log in right as the client responds to the encryption request, we start // a race condition where the game server haven't acknowledged the packets diff --git a/src/main/kotlin/com/lambda/network/NetworkManager.kt b/src/main/kotlin/com/lambda/network/NetworkHandler.kt similarity index 97% rename from src/main/kotlin/com/lambda/network/NetworkManager.kt rename to src/main/kotlin/com/lambda/network/NetworkHandler.kt index 94103bff0..6b8a80661 100644 --- a/src/main/kotlin/com/lambda/network/NetworkManager.kt +++ b/src/main/kotlin/com/lambda/network/NetworkHandler.kt @@ -27,7 +27,7 @@ import com.lambda.util.StringUtils.base64UrlDecode import com.lambda.util.StringUtils.json import com.lambda.util.collections.updatableLazy -object NetworkManager : Configurable(SecretsConfig), Loadable { +object NetworkHandler : Configurable(SecretsConfig), Loadable { override val name = "network" var accessToken by setting("access_token", "") { false }; private set diff --git a/src/main/kotlin/com/lambda/network/api/v1/endpoints/LinkDiscord.kt b/src/main/kotlin/com/lambda/network/api/v1/endpoints/LinkDiscord.kt index 31c8a7ad2..5a87d79e8 100644 --- a/src/main/kotlin/com/lambda/network/api/v1/endpoints/LinkDiscord.kt +++ b/src/main/kotlin/com/lambda/network/api/v1/endpoints/LinkDiscord.kt @@ -20,7 +20,7 @@ package com.lambda.network.api.v1.endpoints import com.lambda.network.LambdaAPI.apiUrl import com.lambda.network.LambdaAPI.apiVersion import com.lambda.network.LambdaHttp -import com.lambda.network.NetworkManager +import com.lambda.network.NetworkHandler import com.lambda.network.api.v1.models.Authentication import io.ktor.client.call.* import io.ktor.client.request.* @@ -35,7 +35,7 @@ import io.ktor.http.* suspend fun linkDiscord(discordToken: String) = runCatching { LambdaHttp.post("${apiUrl}/api/$apiVersion/link/discord") { setBody("""{ "token": "$discordToken" }""") - bearerAuth(NetworkManager.accessToken) + bearerAuth(NetworkHandler.accessToken) contentType(ContentType.Application.Json) }.body() } diff --git a/src/main/kotlin/com/lambda/network/api/v1/endpoints/SetCape.kt b/src/main/kotlin/com/lambda/network/api/v1/endpoints/SetCape.kt index 16682bbcb..5086396e1 100644 --- a/src/main/kotlin/com/lambda/network/api/v1/endpoints/SetCape.kt +++ b/src/main/kotlin/com/lambda/network/api/v1/endpoints/SetCape.kt @@ -20,7 +20,7 @@ package com.lambda.network.api.v1.endpoints import com.lambda.network.LambdaAPI.apiUrl import com.lambda.network.LambdaAPI.apiVersion import com.lambda.network.LambdaHttp -import com.lambda.network.NetworkManager +import com.lambda.network.NetworkHandler import io.ktor.client.request.* import io.ktor.http.* @@ -32,7 +32,7 @@ import io.ktor.http.* */ suspend fun setCape(id: String) = runCatching { val resp = LambdaHttp.put("$apiUrl/api/$apiVersion/cape?id=$id") { - bearerAuth(NetworkManager.accessToken) + bearerAuth(NetworkHandler.accessToken) contentType(ContentType.Application.Json) } diff --git a/src/main/kotlin/com/lambda/sound/SoundManager.kt b/src/main/kotlin/com/lambda/sound/SoundHandler.kt similarity index 98% rename from src/main/kotlin/com/lambda/sound/SoundManager.kt rename to src/main/kotlin/com/lambda/sound/SoundHandler.kt index e2f63d11e..1125a5061 100644 --- a/src/main/kotlin/com/lambda/sound/SoundManager.kt +++ b/src/main/kotlin/com/lambda/sound/SoundHandler.kt @@ -26,7 +26,7 @@ import net.minecraft.registry.Registry import net.minecraft.registry.SimpleRegistry import net.minecraft.sound.SoundEvent -object SoundManager : Loadable { +object SoundHandler : Loadable { fun playSound(event: SoundEvent, pitch: Double = 1.0) { mc.soundManager.play( PositionedSoundInstance.master(event, pitch.toFloat()) diff --git a/src/main/kotlin/com/lambda/task/tasks/AcquireMaterialTask.kt b/src/main/kotlin/com/lambda/task/tasks/AcquireMaterialTask.kt index d4d139595..2041fe7db 100644 --- a/src/main/kotlin/com/lambda/task/tasks/AcquireMaterialTask.kt +++ b/src/main/kotlin/com/lambda/task/tasks/AcquireMaterialTask.kt @@ -20,8 +20,8 @@ package com.lambda.task.tasks import com.lambda.context.Automated import com.lambda.context.SafeContext import com.lambda.interaction.material.StackSelection -import com.lambda.interaction.material.container.ContainerManager -import com.lambda.interaction.material.container.ContainerManager.findContainerWithMaterial +import com.lambda.interaction.material.container.ContainerHandler +import com.lambda.interaction.material.container.ContainerHandler.findContainerWithMaterial import com.lambda.interaction.material.container.containers.HotbarContainer import com.lambda.task.Task import com.lambda.threading.runSafeAutomated @@ -40,7 +40,7 @@ class AcquireMaterialTask @Ta5kBuilder constructor( ?.finally { success(selection) }?.execute(this@AcquireMaterialTask) - ?: failure(ContainerManager.NoContainerFound(selection)) // ToDo: Create crafting path + ?: failure(ContainerHandler.NoContainerFound(selection)) // ToDo: Create crafting path } } diff --git a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt index ad38c2fee..cc564bea1 100644 --- a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt +++ b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt @@ -25,7 +25,7 @@ import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.BaritoneManager +import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.construction.blueprint.Blueprint import com.lambda.interaction.construction.blueprint.Blueprint.Companion.toStructure import com.lambda.interaction.construction.blueprint.PropagatingBlueprint @@ -166,11 +166,11 @@ class BuildTask private constructor( if (!buildConfig.pathing) return val sim = blueprint.simulation() val goal = BuildGoal(sim, player.blockPos) - BaritoneManager.setGoalAndPath(goal) + BaritoneHandler.setGoalAndPath(goal) } is Navigable -> { - if (buildConfig.pathing) BaritoneManager.setGoalAndPath(result.goal) + if (buildConfig.pathing) BaritoneHandler.setGoalAndPath(result.goal) } is Contextual -> { @@ -209,7 +209,7 @@ class BuildTask private constructor( if (!world.entities.contains(itemDrop)) { dropsToCollect.remove(itemDrop) - BaritoneManager.cancel() + BaritoneHandler.cancel() return@let true } @@ -226,7 +226,7 @@ class BuildTask private constructor( return@let true } - BaritoneManager.setGoalAndPath(GoalBlock(itemDrop.blockPos)) + BaritoneHandler.setGoalAndPath(GoalBlock(itemDrop.blockPos)) return@let true } ?: false diff --git a/src/main/kotlin/com/lambda/task/tasks/EatTask.kt b/src/main/kotlin/com/lambda/task/tasks/EatTask.kt index 9257c76a0..7927d3660 100644 --- a/src/main/kotlin/com/lambda/task/tasks/EatTask.kt +++ b/src/main/kotlin/com/lambda/task/tasks/EatTask.kt @@ -24,10 +24,8 @@ import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.hotbar.HotbarRequest -import com.lambda.interaction.material.container.ContainerManager.transfer import com.lambda.interaction.material.container.containers.HotbarContainer import com.lambda.interaction.material.container.containers.InventoryContainer -import com.lambda.interaction.material.container.containers.MainHandContainer import com.lambda.task.Task import com.lambda.threading.runSafeAutomated import net.minecraft.item.ItemStack diff --git a/src/main/kotlin/com/lambda/task/tasks/OpenContainerTask.kt b/src/main/kotlin/com/lambda/task/tasks/OpenContainerTask.kt index 9a1e9aaec..b425561e7 100644 --- a/src/main/kotlin/com/lambda/task/tasks/OpenContainerTask.kt +++ b/src/main/kotlin/com/lambda/task/tasks/OpenContainerTask.kt @@ -22,7 +22,7 @@ import com.lambda.context.Automated import com.lambda.event.events.InventoryEvent import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.interaction.BaritoneManager +import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest import com.lambda.interaction.managers.rotating.visibilty.lookAtBlock import com.lambda.task.Task @@ -98,7 +98,7 @@ class OpenContainerTask @Ta5kBuilder constructor( val checkedHit = runSafeAutomated { lookAtBlock(blockPos, sides) } ?: run { containerState = State.Pathing - if (!BaritoneManager.isActive) BaritoneManager.setGoalAndPath(GoalNear(blockPos, 3)) + if (!BaritoneHandler.isActive) BaritoneHandler.setGoalAndPath(GoalNear(blockPos, 3)) return@listen } if (interactConfig.rotate && !rotationRequest { rotation(checkedHit.rotation) }.submit().done) return@listen diff --git a/src/main/kotlin/com/lambda/util/InputUtils.kt b/src/main/kotlin/com/lambda/util/InputUtils.kt index bf8747c58..237621816 100644 --- a/src/main/kotlin/com/lambda/util/InputUtils.kt +++ b/src/main/kotlin/com/lambda/util/InputUtils.kt @@ -38,7 +38,7 @@ import org.lwjgl.glfw.GLFW.GLFW_PRESS import org.lwjgl.glfw.GLFW.glfwGetKey import org.lwjgl.glfw.GLFW.glfwGetMouseButton -object InputUtils : Loadable { +object InputUtils { private val lastPressedKeys = Int2IntArrayMap() // Keep track of the previously pressed keys to report GLFW_RELEASE states /** diff --git a/src/main/kotlin/com/lambda/util/PlayerBuildLayerUtils.kt b/src/main/kotlin/com/lambda/util/PlayerBuildLayerUtils.kt index e733a3c37..1d7d0fe5f 100644 --- a/src/main/kotlin/com/lambda/util/PlayerBuildLayerUtils.kt +++ b/src/main/kotlin/com/lambda/util/PlayerBuildLayerUtils.kt @@ -18,7 +18,7 @@ package com.lambda.util import com.lambda.context.SafeContext -import com.lambda.interaction.BaritoneManager +import com.lambda.interaction.BaritoneHandler import com.lambda.util.BlockUtils.blockState import com.lambda.util.BlockUtils.isNotEmpty import com.lambda.util.math.MathUtils.ceilToInt @@ -67,7 +67,7 @@ object PlayerBuildLayerUtils { } fun isInBaritoneSelection(pos: BlockPos) = - BaritoneManager.primary?.selectionManager?.selections?.any { + BaritoneHandler.primary?.selectionManager?.selections?.any { val min = it.min() val max = it.max() pos.x >= min.x && pos.x <= max.x From d6e2ba8cad56f3ac7078edd7ee9aaaa6453ea2b0 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Sun, 26 Apr 2026 23:12:30 +0100 Subject: [PATCH 02/40] cleanup unused imports and suppress more unnecessary warnings --- .../java/com/lambda/mixin/MinecraftClientMixin.java | 1 + .../mixin/render/BlockEntityRendererMixin.java | 2 +- .../com/lambda/mixin/render/PlayerListHudMixin.java | 3 +-- .../com/lambda/mixin/render/WorldRendererMixin.java | 13 ++++--------- .../com/lambda/command/commands/CapeCommand.kt | 1 + .../com/lambda/command/commands/FriendCommand.kt | 1 + src/main/kotlin/com/lambda/core/PingHandler.kt | 2 +- .../kotlin/com/lambda/graphics/mc/RenderBuilder.kt | 1 + .../com/lambda/graphics/outline/OutlineHandler.kt | 1 + .../com/lambda/graphics/outline/OutlineRenderer.kt | 6 +++--- .../com/lambda/gui/components/ClickGuiLayout.kt | 2 +- .../com/lambda/interaction/BaritoneHandler.kt | 1 + .../placement/post/StandardInteractPostProcessor.kt | 1 - .../managers/rotating/RotationManager.kt | 1 + .../material/container/ContainerHandler.kt | 1 + src/main/kotlin/com/lambda/module/Module.kt | 1 + .../com/lambda/module/modules/combat/AutoArmor.kt | 4 ++-- .../com/lambda/module/modules/debug/RenderTest.kt | 1 - .../com/lambda/module/modules/movement/AutoWalk.kt | 4 ---- .../com/lambda/module/modules/player/Replay.kt | 1 + .../com/lambda/module/modules/render/Nametags.kt | 2 ++ .../com/lambda/module/modules/world/AutoPortal.kt | 1 + .../com/lambda/module/modules/world/HighwayTools.kt | 1 + .../com/lambda/module/modules/world/StashMover.kt | 1 + src/main/kotlin/com/lambda/network/CapeHandler.kt | 1 + src/main/kotlin/com/lambda/util/InputUtils.kt | 1 - 26 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/lambda/mixin/MinecraftClientMixin.java b/src/main/java/com/lambda/mixin/MinecraftClientMixin.java index 2c7c4a8c6..97b83eafe 100644 --- a/src/main/java/com/lambda/mixin/MinecraftClientMixin.java +++ b/src/main/java/com/lambda/mixin/MinecraftClientMixin.java @@ -130,6 +130,7 @@ private void onShutdown(CallbackInfo ci) { * Inject after the thread field is set so that {@link ThreadExecutor#getThread} * is available */ + @SuppressWarnings("JavadocReference") @Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;thread:Ljava/lang/Thread;", shift = At.Shift.AFTER, ordinal = 0, opcode = Opcodes.PUTFIELD), method = "run") private void onStartup(CallbackInfo ci) { EventFlow.post(new ClientEvent.Startup()); diff --git a/src/main/java/com/lambda/mixin/render/BlockEntityRendererMixin.java b/src/main/java/com/lambda/mixin/render/BlockEntityRendererMixin.java index dca20ca93..f2a4d8286 100644 --- a/src/main/java/com/lambda/mixin/render/BlockEntityRendererMixin.java +++ b/src/main/java/com/lambda/mixin/render/BlockEntityRendererMixin.java @@ -31,7 +31,7 @@ public interface BlockEntityRendererMixin { @Inject(method = "isInRenderDistance", at = @At("HEAD"), cancellable = true) default void forceOutlineRenderDistance(T blockEntity, Vec3d pos, CallbackInfoReturnable cir) { - if (OutlineHandler.INSTANCE.shouldCapture(blockEntity.getPos())) { + if (OutlineHandler.shouldCapture(blockEntity.getPos())) { cir.setReturnValue(true); } } diff --git a/src/main/java/com/lambda/mixin/render/PlayerListHudMixin.java b/src/main/java/com/lambda/mixin/render/PlayerListHudMixin.java index 972b27d58..4da66895e 100644 --- a/src/main/java/com/lambda/mixin/render/PlayerListHudMixin.java +++ b/src/main/java/com/lambda/mixin/render/PlayerListHudMixin.java @@ -26,7 +26,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.hud.PlayerListHud; import net.minecraft.client.network.PlayerListEntry; -import net.minecraft.scoreboard.Team; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Nullables; @@ -52,7 +51,7 @@ public class PlayerListHudMixin { .comparingInt((PlayerListEntry entry) -> FriendHandler.INSTANCE.isFriend(entry.getProfile().name()) ? 0 : 1) .thenComparingInt(entry -> -entry.getListOrder()) .thenComparingInt((entry) -> entry.getGameMode() == GameMode.SPECTATOR ? 1 : 0) - .thenComparing((entry) -> Nullables.mapOrElse(entry.getScoreboardTeam(), Team::getName, "")) + .thenComparing((entry) -> Nullables.mapOrElse(entry.getScoreboardTeam(), team -> team != null ? team.getName() : "", "")) .thenComparing((entry) -> entry.getProfile().name(), String::compareToIgnoreCase); @Shadow @Final private MinecraftClient client; diff --git a/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java b/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java index c0a591c45..f27d89d79 100644 --- a/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java +++ b/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java @@ -25,6 +25,7 @@ import com.lambda.module.modules.render.Freecam; import com.lambda.module.modules.render.CameraTweaks; import com.lambda.module.modules.render.NoRender; +import com.llamalad7.mixinextras.sugar.Local; import net.minecraft.client.world.ClientWorld; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.ModifyReturnValue; @@ -35,8 +36,6 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.effect.StatusEffects; import com.mojang.blaze3d.buffers.GpuBufferSlice; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.tick.TickManager; import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; import org.joml.Vector4f; @@ -47,7 +46,6 @@ import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import net.minecraft.block.entity.BlockEntity; import net.minecraft.client.render.block.entity.BlockEntityRenderManager; import net.minecraft.client.render.block.entity.state.BlockEntityRenderState; @@ -56,8 +54,6 @@ import org.spongepowered.asm.mixin.Shadow; import java.util.Set; -import java.util.Iterator; - @Mixin(WorldRenderer.class) public abstract class WorldRendererMixin { @Shadow @@ -93,10 +89,9 @@ private boolean renderSetupTerrainModifyArg(boolean spectator) { return Freecam.INSTANCE.isEnabled() || CameraTweaks.INSTANCE.isEnabled() || spectator; } - @Inject(method = "fillEntityRenderStates", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/EntityRenderManager;shouldRender(Lnet/minecraft/entity/Entity;Lnet/minecraft/client/render/Frustum;DDD)Z", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD) - private void injectFillEntityRenderStates(Camera camera, Frustum frustum, RenderTickCounter tickCounter, - WorldRenderState renderStates, CallbackInfo ci, Vec3d vec3d, double d, double e, double f, - TickManager tickManager, boolean bl, Iterator var14, Entity entity) { + @SuppressWarnings("DiscouragedShift") + @Inject(method = "fillEntityRenderStates", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/EntityRenderManager;shouldRender(Lnet/minecraft/entity/Entity;Lnet/minecraft/client/render/Frustum;DDD)Z", shift = At.Shift.BEFORE)) + private void injectFillEntityRenderStates(Camera camera, Frustum frustum, RenderTickCounter tickCounter, WorldRenderState renderStates, CallbackInfo ci, @Local Entity entity) { this.lambda$currentEntity = entity; } diff --git a/src/main/kotlin/com/lambda/command/commands/CapeCommand.kt b/src/main/kotlin/com/lambda/command/commands/CapeCommand.kt index f7e054f95..bd705a92e 100644 --- a/src/main/kotlin/com/lambda/command/commands/CapeCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/CapeCommand.kt @@ -30,6 +30,7 @@ import com.lambda.util.Communication.logError import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandSource.suggestMatching +@Suppress("unused") object CapeCommand : LambdaCommand( name = "cape", usage = "set ", diff --git a/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt b/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt index 2d22d4987..48ce31135 100644 --- a/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt @@ -43,6 +43,7 @@ import net.minecraft.command.CommandSource.suggestMatching import java.awt.Color import java.util.UUID +@Suppress("unused") object FriendCommand : LambdaCommand( name = "friends", usage = "friends | add-uuid | remove | remove-uuid >", diff --git a/src/main/kotlin/com/lambda/core/PingHandler.kt b/src/main/kotlin/com/lambda/core/PingHandler.kt index e54cba9c2..8adaf819a 100644 --- a/src/main/kotlin/com/lambda/core/PingHandler.kt +++ b/src/main/kotlin/com/lambda/core/PingHandler.kt @@ -25,9 +25,9 @@ import net.minecraft.network.packet.c2s.query.QueryPingC2SPacket import net.minecraft.network.packet.s2c.query.PingResultS2CPacket import net.minecraft.util.Util +@Suppress("unused") object PingHandler : Loadable { private val pings: LimitedOrderedSet = LimitedOrderedSet(100) - private const val INTERVAL = 1 override fun load(): String { listen { diff --git a/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt b/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt index 856f1796a..0467ffb16 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt @@ -1477,6 +1477,7 @@ class RenderBuilder(private val cameraPos: Vec3d, var depthTest: Boolean = false collector.addEdgeVertex(rx2, ry2, rz2, color2, dx, dy, dz, width, dashStyle, activeOutlineId) } + @Suppress("SameParameterValue") private fun transformPoint(matrix: Matrix4f, x: Float, y: Float, z: Float): Vector3f { val result = Vector4f(x, y, z, 1f) matrix.transform(result) diff --git a/src/main/kotlin/com/lambda/graphics/outline/OutlineHandler.kt b/src/main/kotlin/com/lambda/graphics/outline/OutlineHandler.kt index 726a4c813..aaeced3f6 100644 --- a/src/main/kotlin/com/lambda/graphics/outline/OutlineHandler.kt +++ b/src/main/kotlin/com/lambda/graphics/outline/OutlineHandler.kt @@ -19,6 +19,7 @@ package com.lambda.graphics.outline import net.minecraft.util.math.BlockPos +@Suppress("unused") object OutlineHandler { private val depthTestedEntityOutlines = mutableMapOf() private val xrayEntityOutlines = mutableMapOf() diff --git a/src/main/kotlin/com/lambda/graphics/outline/OutlineRenderer.kt b/src/main/kotlin/com/lambda/graphics/outline/OutlineRenderer.kt index 758a05bf4..b2c930886 100644 --- a/src/main/kotlin/com/lambda/graphics/outline/OutlineRenderer.kt +++ b/src/main/kotlin/com/lambda/graphics/outline/OutlineRenderer.kt @@ -238,7 +238,7 @@ object OutlineRenderer { private fun applyEdgeDetection(style: OutlineStyle = OutlineStyle.DEFAULT) { val idBufferView = OutlineIdBuffer.getTextureView() ?: return - applySobel(idBufferView, "Lambda Global Outline Sobel Pass", style) + applySobel(idBufferView, style) } private fun buildStyleMatrix(style: OutlineStyle): Matrix4f { @@ -250,7 +250,7 @@ object OutlineRenderer { return mat } - private fun applySobel(textureView: GpuTextureView, label: String, style: OutlineStyle = OutlineStyle.DEFAULT) { + private fun applySobel(textureView: GpuTextureView, style: OutlineStyle = OutlineStyle.DEFAULT) { val framebuffer = mc.framebuffer ?: return ensureFullscreenQuad() @@ -264,7 +264,7 @@ object OutlineRenderer { RenderSystem.getDevice() .createCommandEncoder() .createRenderPass( - { label }, + { "Lambda Outline Sobel Pass" }, framebuffer.colorAttachmentView, OptionalInt.empty(), null, diff --git a/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt b/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt index dd59496f5..2f1b2815c 100644 --- a/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt +++ b/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt @@ -60,6 +60,7 @@ import net.minecraft.client.gui.screen.ingame.SignEditScreen import net.minecraft.client.util.Icons import java.awt.Color +@Suppress("unused") object ClickGuiLayout : Loadable, Configurable(GuiConfig) { override val name = "GUI" var open = false @@ -182,7 +183,6 @@ object ClickGuiLayout : Loadable, Configurable(GuiConfig) { val primaryColor by setting("Primary Color", Color(130, 200, 255)).group(Group.Colors) val secondaryColor by setting("Secondary Color", Color(225, 130, 225)).group(Group.Colors) - @Suppress("unused") val shade by setting("Shade", true).group(Group.Colors) val colorWidth by setting("Shade Width", 200.0, 10.0..1000.0, 10.0).group(Group.Colors) val colorHeight by setting("Shade Height", 200.0, 10.0..1000.0, 10.0).group(Group.Colors) diff --git a/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt b/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt index 0c5ac699e..a6c7fe12e 100644 --- a/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt @@ -30,6 +30,7 @@ import com.lambda.util.BlockUtils.blockPos import com.lambda.util.NamedEnum import net.fabricmc.loader.api.FabricLoader +@Suppress("unused") object BaritoneHandler : Configurable(LambdaConfig), Automated by AutomationConfig.Companion.DEFAULT { override val name = "baritone" diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/StandardInteractPostProcessor.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/StandardInteractPostProcessor.kt index e10147796..8ea4f4863 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/StandardInteractPostProcessor.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/preprocessors/property/placement/post/StandardInteractPostProcessor.kt @@ -22,7 +22,6 @@ import com.lambda.interaction.construction.simulation.processing.PreProcessingIn import com.lambda.interaction.construction.simulation.processing.ProcessorRegistry.standardInteractProperties import com.lambda.interaction.construction.simulation.processing.PropertyPostProcessor import net.minecraft.block.BlockState -import net.minecraft.block.Blocks import net.minecraft.block.DoorBlock import net.minecraft.block.TrapdoorBlock import net.minecraft.util.math.BlockPos diff --git a/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt index ede45a22a..8cdc035b4 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt @@ -55,6 +55,7 @@ import kotlin.math.sin /** * Manager designed to rotate the player and adjust movement input to match the camera's direction. */ +@Suppress("unused") object RotationManager : Manager( 1, *(ALL_STAGES.subList(ALL_STAGES.indexOf(TickEvent.Player.Post), ALL_STAGES.size - 1).toTypedArray()), diff --git a/src/main/kotlin/com/lambda/interaction/material/container/ContainerHandler.kt b/src/main/kotlin/com/lambda/interaction/material/container/ContainerHandler.kt index 122966eb5..bf14abcd2 100644 --- a/src/main/kotlin/com/lambda/interaction/material/container/ContainerHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/material/container/ContainerHandler.kt @@ -39,6 +39,7 @@ import net.minecraft.screen.ScreenHandlerType import net.minecraft.screen.slot.Slot // ToDo: Make this a Configurable to save container caches. Should use a cached region based storage system. +@Suppress("unused") object ContainerHandler : Loadable { private val containers: List get() = compileContainers + runtimeContainers diff --git a/src/main/kotlin/com/lambda/module/Module.kt b/src/main/kotlin/com/lambda/module/Module.kt index f3c54082d..ae47bf58f 100644 --- a/src/main/kotlin/com/lambda/module/Module.kt +++ b/src/main/kotlin/com/lambda/module/Module.kt @@ -114,6 +114,7 @@ import com.lambda.util.Nameable * * See [SafeListener] and [UnsafeListener] for more details. */ +@Suppress("unused") abstract class Module( override val name: String, val description: String = "", diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt index fb71dc197..9fffcb642 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt @@ -44,10 +44,10 @@ import net.minecraft.screen.slot.Slot object AutoArmor : Module( name = "AutoArmor", description = "Automatically equips armor", - tag = ModuleTag.Companion.COMBAT + tag = ModuleTag.COMBAT ) { private var elytraPriority by setting("Elytra Priority", true, "Prioritizes elytra's over other armor pieces in the chest slot") - private val toggleElytraPriority by setting("Toggle Elytra Priority", Bind.Companion.EMPTY) + private val toggleElytraPriority by setting("Toggle Elytra Priority", Bind.EMPTY) .onPress { elytraPriority = !elytraPriority } private val minDurabilityPercentage by setting("Min Durability", 5, 0..100, 1, "Minimum durability percentage before being swapped for a new piece", "%") private val headProtection by setting("Preferred Head Protection", Protection.Protection) diff --git a/src/main/kotlin/com/lambda/module/modules/debug/RenderTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/RenderTest.kt index 8580bcdef..190a70a84 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/RenderTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/RenderTest.kt @@ -22,7 +22,6 @@ import com.lambda.graphics.mc.renderer.TickedRenderer.Companion.tickedRenderer import com.lambda.graphics.util.DynamicAABB.Companion.dynamicBox import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.ChatUtils.colors import com.lambda.util.extension.tickDelta import com.lambda.util.math.setAlpha import com.lambda.util.world.entitySearch diff --git a/src/main/kotlin/com/lambda/module/modules/movement/AutoWalk.kt b/src/main/kotlin/com/lambda/module/modules/movement/AutoWalk.kt index 67f8ef592..8828eaf9f 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/AutoWalk.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/AutoWalk.kt @@ -18,17 +18,13 @@ package com.lambda.module.modules.movement import com.lambda.event.events.MovementEvent -import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.Timer import com.lambda.util.player.MovementUtils.forward import com.lambda.util.player.MovementUtils.strafe import com.lambda.util.player.MovementUtils.update import net.minecraft.util.math.Vec2f -import kotlin.time.DurationUnit -import kotlin.time.toDuration @Suppress("unused") object AutoWalk : Module( diff --git a/src/main/kotlin/com/lambda/module/modules/player/Replay.kt b/src/main/kotlin/com/lambda/module/modules/player/Replay.kt index 16a7a8ad3..0c03daa26 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/Replay.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/Replay.kt @@ -81,6 +81,7 @@ import kotlin.time.toDuration // - Record other types of inputs: (place, break, inventory, etc.) // - Add HUD for recording / replaying info // - Maybe use a custom binary format to store the data (Protobuf / DB?) +@Suppress("unused") object Replay : Module( name = "Replay", description = "Record gameplay actions and replay them like a TAS.", diff --git a/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt b/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt index e46005ba3..796275f63 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt @@ -51,6 +51,7 @@ object Nametags : Module( description = "Displays information about entities above them", tag = ModuleTag.RENDER ) { + @Suppress("unused") private enum class Group(override val displayName: String) : NamedEnum { General("General"), Entities("Entities"), @@ -249,6 +250,7 @@ object Nametags : Module( (entity !== mc.player || !mc.options.perspective.isFirstPerson) && entitySelectionSettings.isSelected(entity) && (entity !is LivingEntity || entity.isAlive) + @Suppress("unused") private enum class DurabilityMode(val text: Boolean, val bar: Boolean) { None(false, false), Text(true, false), diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt index a7604d850..087eafec8 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt @@ -66,6 +66,7 @@ import net.minecraft.util.math.Box import net.minecraft.util.math.Direction import net.minecraft.util.math.Vec3d +@Suppress("unused") object AutoPortal : Module( name = "AutoPortal", description = "Automatically places and lights a nether portal", diff --git a/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt b/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt index 127653e5a..df380304e 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt @@ -81,6 +81,7 @@ object HighwayTools : Module( Block("Block", "Paves the highway with a specific block. Will use the block you specified in the settings"), } + @Suppress("unused") enum class Corner( override val displayName: String, override val description: String diff --git a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt index 00f6ef81a..841879824 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt @@ -94,6 +94,7 @@ import kotlin.math.min import kotlin.run import kotlin.to +@Suppress("unused") object StashMover : Module( name = "StashMover", description = "Moves items from one stash location to another", diff --git a/src/main/kotlin/com/lambda/network/CapeHandler.kt b/src/main/kotlin/com/lambda/network/CapeHandler.kt index fd83d9f3e..9d38d557c 100644 --- a/src/main/kotlin/com/lambda/network/CapeHandler.kt +++ b/src/main/kotlin/com/lambda/network/CapeHandler.kt @@ -48,6 +48,7 @@ import kotlin.concurrent.fixedRateTimer import kotlin.time.Duration.Companion.hours import kotlin.time.Duration.Companion.seconds +@Suppress("unused") object CapeHandler : Configurable(SecretsConfig), Loadable { override val name: String = "capes" diff --git a/src/main/kotlin/com/lambda/util/InputUtils.kt b/src/main/kotlin/com/lambda/util/InputUtils.kt index 237621816..f4fd68bfa 100644 --- a/src/main/kotlin/com/lambda/util/InputUtils.kt +++ b/src/main/kotlin/com/lambda/util/InputUtils.kt @@ -20,7 +20,6 @@ package com.lambda.util import com.lambda.Lambda.mc import com.lambda.config.settings.complex.Bind import com.lambda.context.SafeContext -import com.lambda.core.Loadable import com.lambda.event.events.ButtonEvent import it.unimi.dsi.fastutil.ints.Int2IntArrayMap import org.lwjgl.glfw.GLFW From e74c21289f7a9839be09246c68d84188a1104e55 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Mon, 27 Apr 2026 15:17:06 +0100 Subject: [PATCH 03/40] optimize imports, both kotlin and java folder --- .../render/BlockEntityRenderManagerMixin.java | 2 +- .../com/lambda/mixin/render/CameraMixin.java | 2 +- .../render/EntityRenderManagerMixin.java | 2 +- .../mixin/render/GameRendererMixin.java | 4 +-- .../render/ItemFrameEntityRendererMixin.java | 4 +-- .../mixin/render/WorldRendererMixin.java | 26 +++++++++------- src/main/kotlin/com/lambda/Lambda.kt | 1 - .../lambda/command/commands/FriendCommand.kt | 2 +- .../lambda/command/commands/PrefixCommand.kt | 1 - .../kotlin/com/lambda/config/Configurable.kt | 5 ++-- .../kotlin/com/lambda/config/Configuration.kt | 2 +- .../lambda/config/serializer/BlockPosCodec.kt | 2 -- .../config/serializer/GameProfileCodec.kt | 3 -- .../lambda/config/serializer/KeyCodeCodec.kt | 2 -- .../lambda/config/serializer/OptionalCodec.kt | 2 -- .../lambda/config/settings/StringSetting.kt | 2 +- .../settings/collections/CollectionSetting.kt | 2 +- .../config/settings/complex/KeybindSetting.kt | 8 ++--- .../kotlin/com/lambda/graphics/RenderMain.kt | 2 +- .../com/lambda/graphics/mc/RegionRenderer.kt | 2 +- .../com/lambda/graphics/mc/RenderBuilder.kt | 14 ++++----- .../graphics/mc/renderer/AbstractRenderer.kt | 1 - .../graphics/outline/OutlineCapturingQueue.kt | 30 +++++++++---------- .../graphics/outline/OutlineIdBuffer.kt | 3 +- .../graphics/outline/OutlineIdPassRenderer.kt | 7 ++--- .../graphics/outline/OutlineRenderer.kt | 3 +- .../lambda/graphics/outline/VertexCapture.kt | 2 +- .../com/lambda/graphics/text/SDFFontAtlas.kt | 8 ++--- src/main/kotlin/com/lambda/gui/DearImGui.kt | 6 ++-- src/main/kotlin/com/lambda/gui/MenuBar.kt | 10 +++---- .../lambda/gui/components/ClickGuiLayout.kt | 12 ++++---- .../com/lambda/gui/components/HudGuiLayout.kt | 6 ++-- .../com/lambda/gui/components/ModuleEntry.kt | 2 +- .../com/lambda/gui/components/QuickSearch.kt | 10 +++---- .../lambda/gui/components/SettingsWidget.kt | 6 ++-- .../kotlin/com/lambda/gui/dsl/ImGuiBuilder.kt | 7 +++-- .../kotlin/com/lambda/gui/snap/SnapHandler.kt | 1 - .../construction/simulation/BuildSimulator.kt | 4 +-- .../construction/simulation/Simulation.kt | 1 - .../simulation/result/Drawable.kt | 1 - .../result/results/InteractResult.kt | 1 - .../managers/PacketLimitHandler.kt | 2 +- .../managers/breaking/BrokenBlockHandler.kt | 4 +-- .../managers/interacting/InteractManager.kt | 2 ++ .../interacting/InteractedBlockHandler.kt | 2 +- .../rotating/visibilty/PlaceDirection.kt | 1 - .../com/lambda/module/hud/ModuleList.kt | 2 +- src/main/kotlin/com/lambda/module/hud/TPS.kt | 2 +- .../kotlin/com/lambda/module/hud/Watermark.kt | 2 +- .../module/modules/client/AutoUpdater.kt | 4 +-- .../modules/debug/SettingsTestModule.kt | 2 +- .../module/modules/movement/ElytraFly.kt | 12 ++++---- .../lambda/module/modules/movement/Speed.kt | 2 -- .../module/modules/network/PacketLogger.kt | 3 +- .../module/modules/network/Rubberband.kt | 1 - .../module/modules/render/LightLevels.kt | 1 - .../lambda/module/modules/render/Search.kt | 2 +- .../com/lambda/module/modules/render/Zoom.kt | 1 - .../lambda/module/modules/world/AutoSign.kt | 2 +- .../com/lambda/module/modules/world/Nuker.kt | 6 ++-- .../lambda/module/modules/world/Printer.kt | 4 +-- .../lambda/module/modules/world/StashMover.kt | 2 -- .../kotlin/com/lambda/network/LambdaAPI.kt | 2 +- src/main/kotlin/com/lambda/task/Task.kt | 2 +- .../com/lambda/util/DynamicException.kt | 1 - .../kotlin/com/lambda/util/EntityUtils.kt | 2 +- .../kotlin/com/lambda/util/LambdaResource.kt | 1 - .../kotlin/com/lambda/util/StringUtils.kt | 2 +- .../kotlin/com/lambda/util/extension/World.kt | 1 - .../com/lambda/util/world/WorldUtils.kt | 2 -- 70 files changed, 128 insertions(+), 155 deletions(-) diff --git a/src/main/java/com/lambda/mixin/render/BlockEntityRenderManagerMixin.java b/src/main/java/com/lambda/mixin/render/BlockEntityRenderManagerMixin.java index 036d0881a..0bb9c2c3d 100644 --- a/src/main/java/com/lambda/mixin/render/BlockEntityRenderManagerMixin.java +++ b/src/main/java/com/lambda/mixin/render/BlockEntityRenderManagerMixin.java @@ -17,8 +17,8 @@ package com.lambda.mixin.render; -import com.lambda.graphics.outline.OutlineHandler; import com.lambda.graphics.outline.OutlineCapturingQueue; +import com.lambda.graphics.outline.OutlineHandler; import com.lambda.graphics.outline.VertexCapture; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; diff --git a/src/main/java/com/lambda/mixin/render/CameraMixin.java b/src/main/java/com/lambda/mixin/render/CameraMixin.java index 20c91d035..38f629489 100644 --- a/src/main/java/com/lambda/mixin/render/CameraMixin.java +++ b/src/main/java/com/lambda/mixin/render/CameraMixin.java @@ -18,9 +18,9 @@ package com.lambda.mixin.render; import com.lambda.interaction.managers.rotating.RotationManager; -import com.lambda.module.modules.render.Freecam; import com.lambda.module.modules.render.CameraTweaks; import com.lambda.module.modules.render.FreeLook; +import com.lambda.module.modules.render.Freecam; import com.lambda.module.modules.render.NoRender; import net.minecraft.block.enums.CameraSubmersionType; import net.minecraft.client.render.Camera; diff --git a/src/main/java/com/lambda/mixin/render/EntityRenderManagerMixin.java b/src/main/java/com/lambda/mixin/render/EntityRenderManagerMixin.java index b0c0cdc4b..81a864ae9 100644 --- a/src/main/java/com/lambda/mixin/render/EntityRenderManagerMixin.java +++ b/src/main/java/com/lambda/mixin/render/EntityRenderManagerMixin.java @@ -18,8 +18,8 @@ package com.lambda.mixin.render; import com.lambda.graphics.outline.IEntityRenderState; -import com.lambda.graphics.outline.OutlineHandler; import com.lambda.graphics.outline.OutlineCapturingQueue; +import com.lambda.graphics.outline.OutlineHandler; import com.lambda.graphics.outline.VertexCapture; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; diff --git a/src/main/java/com/lambda/mixin/render/GameRendererMixin.java b/src/main/java/com/lambda/mixin/render/GameRendererMixin.java index 6c5fb87d6..4925326d3 100644 --- a/src/main/java/com/lambda/mixin/render/GameRendererMixin.java +++ b/src/main/java/com/lambda/mixin/render/GameRendererMixin.java @@ -19,10 +19,9 @@ import com.lambda.event.EventFlow; import com.lambda.event.events.RenderEvent; -import com.lambda.gui.DearImGui; import com.lambda.graphics.RenderMain; import com.lambda.graphics.outline.OutlineCapturingQueue; -import net.minecraft.client.render.command.OrderedRenderCommandQueueImpl; +import com.lambda.gui.DearImGui; import com.lambda.module.modules.render.BlockOutline; import com.lambda.module.modules.render.Bobbing; import com.lambda.module.modules.render.NoRender; @@ -36,6 +35,7 @@ import net.minecraft.client.render.GameRenderer; import net.minecraft.client.render.RenderTickCounter; import net.minecraft.client.render.WorldRenderer; +import net.minecraft.client.render.command.OrderedRenderCommandQueueImpl; import net.minecraft.client.util.ObjectAllocator; import net.minecraft.item.ItemStack; import org.joml.Matrix4f; diff --git a/src/main/java/com/lambda/mixin/render/ItemFrameEntityRendererMixin.java b/src/main/java/com/lambda/mixin/render/ItemFrameEntityRendererMixin.java index 70c5269a9..4039a037d 100644 --- a/src/main/java/com/lambda/mixin/render/ItemFrameEntityRendererMixin.java +++ b/src/main/java/com/lambda/mixin/render/ItemFrameEntityRendererMixin.java @@ -18,6 +18,8 @@ package com.lambda.mixin.render; import com.lambda.graphics.outline.OutlineCapturingQueue; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.command.OrderedRenderCommandQueue; import net.minecraft.client.render.entity.ItemFrameEntityRenderer; @@ -25,8 +27,6 @@ import net.minecraft.client.util.math.MatrixStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; @Mixin(ItemFrameEntityRenderer.class) public class ItemFrameEntityRendererMixin { diff --git a/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java b/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java index f27d89d79..95a66dc3f 100644 --- a/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java +++ b/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java @@ -22,36 +22,40 @@ import com.lambda.event.events.RenderEvent; import com.lambda.graphics.RenderMain; import com.lambda.graphics.outline.OutlineHandler; -import com.lambda.module.modules.render.Freecam; import com.lambda.module.modules.render.CameraTweaks; +import com.lambda.module.modules.render.Freecam; import com.lambda.module.modules.render.NoRender; -import com.llamalad7.mixinextras.sugar.Local; -import net.minecraft.client.world.ClientWorld; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import net.minecraft.client.render.*; +import com.llamalad7.mixinextras.sugar.Local; +import com.mojang.blaze3d.buffers.GpuBufferSlice; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.client.render.Camera; +import net.minecraft.client.render.Frustum; +import net.minecraft.client.render.RenderTickCounter; +import net.minecraft.client.render.WorldRenderer; +import net.minecraft.client.render.block.entity.BlockEntityRenderManager; +import net.minecraft.client.render.block.entity.state.BlockEntityRenderState; import net.minecraft.client.render.state.WorldRenderState; import net.minecraft.client.util.ObjectAllocator; +import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.effect.StatusEffects; -import com.mojang.blaze3d.buffers.GpuBufferSlice; +import net.minecraft.util.math.BlockPos; import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; import org.joml.Vector4f; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.client.render.block.entity.BlockEntityRenderManager; -import net.minecraft.client.render.block.entity.state.BlockEntityRenderState; -import net.minecraft.util.math.BlockPos; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Shadow; + import java.util.Set; @Mixin(WorldRenderer.class) diff --git a/src/main/kotlin/com/lambda/Lambda.kt b/src/main/kotlin/com/lambda/Lambda.kt index 35f3cd622..864e18905 100644 --- a/src/main/kotlin/com/lambda/Lambda.kt +++ b/src/main/kotlin/com/lambda/Lambda.kt @@ -53,7 +53,6 @@ import org.apache.logging.log4j.Logger import java.awt.Color import java.util.* - object Lambda : ClientModInitializer { const val MOD_NAME = "Lambda" const val MOD_ID = "lambda" diff --git a/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt b/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt index 48ce31135..4630afacd 100644 --- a/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt @@ -41,7 +41,7 @@ import com.lambda.util.text.styled import kotlinx.coroutines.runBlocking import net.minecraft.command.CommandSource.suggestMatching import java.awt.Color -import java.util.UUID +import java.util.* @Suppress("unused") object FriendCommand : LambdaCommand( diff --git a/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt b/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt index 10db0f55d..8ac6230c9 100644 --- a/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt @@ -20,7 +20,6 @@ package com.lambda.command.commands import com.lambda.brigadier.CommandResult.Companion.failure import com.lambda.brigadier.CommandResult.Companion.success import com.lambda.brigadier.argument.greedyString -import com.lambda.brigadier.argument.string import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.executeWithResult diff --git a/src/main/kotlin/com/lambda/config/Configurable.kt b/src/main/kotlin/com/lambda/config/Configurable.kt index 7c5e1a8d4..021ef3448 100644 --- a/src/main/kotlin/com/lambda/config/Configurable.kt +++ b/src/main/kotlin/com/lambda/config/Configurable.kt @@ -43,10 +43,10 @@ import com.lambda.config.settings.numeric.FloatSetting import com.lambda.config.settings.numeric.IntegerSetting import com.lambda.config.settings.numeric.LongSetting import com.lambda.event.Muteable +import com.lambda.imgui.flag.ImGuiInputTextFlags import com.lambda.util.Communication.logError import com.lambda.util.KeyCode import com.lambda.util.Nameable -import com.lambda.imgui.flag.ImGuiInputTextFlags import net.minecraft.block.Block import net.minecraft.item.Item import net.minecraft.registry.Registries @@ -113,8 +113,7 @@ abstract class Configurable( name: String, defaultValue: T, description: String = "", - noinline - visibility: () -> Boolean = { true }, + noinline visibility: () -> Boolean = { true }, ) = Setting(name, description,EnumSetting(defaultValue), this, visibility).register() fun setting( diff --git a/src/main/kotlin/com/lambda/config/Configuration.kt b/src/main/kotlin/com/lambda/config/Configuration.kt index a8bdbfecf..8b70fca13 100644 --- a/src/main/kotlin/com/lambda/config/Configuration.kt +++ b/src/main/kotlin/com/lambda/config/Configuration.kt @@ -25,8 +25,8 @@ import com.google.gson.JsonSyntaxException import com.lambda.Lambda.LOG import com.lambda.Lambda.gson import com.lambda.config.Configuration.Companion.configurables -import com.lambda.config.migration.ConfigMigrations import com.lambda.config.configurations.ModuleConfigs +import com.lambda.config.migration.ConfigMigrations import com.lambda.core.Loadable import com.lambda.event.events.ClientEvent import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe diff --git a/src/main/kotlin/com/lambda/config/serializer/BlockPosCodec.kt b/src/main/kotlin/com/lambda/config/serializer/BlockPosCodec.kt index d120062e8..193d7b842 100644 --- a/src/main/kotlin/com/lambda/config/serializer/BlockPosCodec.kt +++ b/src/main/kotlin/com/lambda/config/serializer/BlockPosCodec.kt @@ -18,10 +18,8 @@ package com.lambda.config.serializer import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonDeserializer import com.google.gson.JsonElement import com.google.gson.JsonSerializationContext -import com.google.gson.JsonSerializer import com.lambda.config.Codec import com.lambda.config.Stringifiable import com.lambda.util.Formatting.format diff --git a/src/main/kotlin/com/lambda/config/serializer/GameProfileCodec.kt b/src/main/kotlin/com/lambda/config/serializer/GameProfileCodec.kt index bb0c2e4b4..24487397c 100644 --- a/src/main/kotlin/com/lambda/config/serializer/GameProfileCodec.kt +++ b/src/main/kotlin/com/lambda/config/serializer/GameProfileCodec.kt @@ -18,12 +18,9 @@ package com.lambda.config.serializer import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonDeserializer import com.google.gson.JsonElement -import com.google.gson.JsonNull import com.google.gson.JsonObject import com.google.gson.JsonSerializationContext -import com.google.gson.JsonSerializer import com.lambda.config.Codec import com.lambda.config.Stringifiable import com.mojang.authlib.GameProfile diff --git a/src/main/kotlin/com/lambda/config/serializer/KeyCodeCodec.kt b/src/main/kotlin/com/lambda/config/serializer/KeyCodeCodec.kt index 1114ff293..d7729412d 100644 --- a/src/main/kotlin/com/lambda/config/serializer/KeyCodeCodec.kt +++ b/src/main/kotlin/com/lambda/config/serializer/KeyCodeCodec.kt @@ -18,13 +18,11 @@ package com.lambda.config.serializer import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonDeserializer import com.google.gson.JsonElement import com.google.gson.JsonNull import com.google.gson.JsonParseException import com.google.gson.JsonPrimitive import com.google.gson.JsonSerializationContext -import com.google.gson.JsonSerializer import com.lambda.config.Codec import com.lambda.util.KeyCode import java.lang.reflect.Type diff --git a/src/main/kotlin/com/lambda/config/serializer/OptionalCodec.kt b/src/main/kotlin/com/lambda/config/serializer/OptionalCodec.kt index 4e4c66ef8..798120aaf 100644 --- a/src/main/kotlin/com/lambda/config/serializer/OptionalCodec.kt +++ b/src/main/kotlin/com/lambda/config/serializer/OptionalCodec.kt @@ -18,11 +18,9 @@ package com.lambda.config.serializer import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonDeserializer import com.google.gson.JsonElement import com.google.gson.JsonNull import com.google.gson.JsonSerializationContext -import com.google.gson.JsonSerializer import com.lambda.config.Codec import java.lang.reflect.Type import java.util.* diff --git a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt index d313dff90..7d03ec086 100644 --- a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt @@ -27,8 +27,8 @@ import com.lambda.config.SettingCore import com.lambda.config.SettingEditorDsl import com.lambda.config.SettingGroupEditor import com.lambda.gui.dsl.ImGuiBuilder -import com.lambda.util.extension.CommandBuilder import com.lambda.imgui.flag.ImGuiInputTextFlags +import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandRegistryAccess /** diff --git a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt index b8d1a310a..d4447898c 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt @@ -28,12 +28,12 @@ import com.lambda.context.SafeContext import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.ImGui import com.lambda.imgui.ImGui.getContentRegionAvail -import com.lambda.threading.runSafe import com.lambda.imgui.ImGuiListClipper import com.lambda.imgui.callback.ImListClipperCallback import com.lambda.imgui.flag.ImGuiChildFlags import com.lambda.imgui.flag.ImGuiPopupFlags import com.lambda.imgui.flag.ImGuiSelectableFlags.DontClosePopups +import com.lambda.threading.runSafe import java.lang.reflect.Type /** diff --git a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt index bf08927c3..5b0958724 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt @@ -33,15 +33,15 @@ import com.lambda.event.Muteable import com.lambda.event.events.ButtonEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.gui.dsl.ImGuiBuilder +import com.lambda.imgui.ImGui.isMouseClicked +import com.lambda.imgui.flag.ImGuiCol +import com.lambda.imgui.flag.ImGuiHoveredFlags +import com.lambda.imgui.flag.ImGuiMouseButton import com.lambda.util.InputUtils import com.lambda.util.KeyCode import com.lambda.util.Mouse import com.lambda.util.StringUtils.capitalize import com.lambda.util.extension.CommandBuilder -import com.lambda.imgui.ImGui.isMouseClicked -import com.lambda.imgui.flag.ImGuiCol -import com.lambda.imgui.flag.ImGuiHoveredFlags -import com.lambda.imgui.flag.ImGuiMouseButton import net.minecraft.command.CommandRegistryAccess import org.lwjgl.glfw.GLFW.GLFW_KEY_LEFT_SHIFT import org.lwjgl.glfw.GLFW.GLFW_KEY_RIGHT_SUPER diff --git a/src/main/kotlin/com/lambda/graphics/RenderMain.kt b/src/main/kotlin/com/lambda/graphics/RenderMain.kt index 334b050de..d14023f1a 100644 --- a/src/main/kotlin/com/lambda/graphics/RenderMain.kt +++ b/src/main/kotlin/com/lambda/graphics/RenderMain.kt @@ -20,8 +20,8 @@ package com.lambda.graphics import com.lambda.event.EventFlow.post import com.lambda.event.events.RenderEvent import com.lambda.graphics.mc.renderer.RendererUtils -import com.lambda.graphics.outline.OutlineIdBuffer import com.lambda.graphics.outline.OutlineHandler +import com.lambda.graphics.outline.OutlineIdBuffer import com.lambda.graphics.outline.OutlineRenderer import com.lambda.graphics.outline.VertexCapture import org.joml.Matrix4f diff --git a/src/main/kotlin/com/lambda/graphics/mc/RegionRenderer.kt b/src/main/kotlin/com/lambda/graphics/mc/RegionRenderer.kt index b71010199..ff802333d 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/RegionRenderer.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/RegionRenderer.kt @@ -18,9 +18,9 @@ package com.lambda.graphics.mc import com.lambda.Lambda.mc -import com.lambda.graphics.outline.OutlineStyle import com.lambda.graphics.mc.renderer.RendererUtils import com.lambda.graphics.mc.renderer.upload +import com.lambda.graphics.outline.OutlineStyle import com.mojang.blaze3d.buffers.GpuBuffer import com.mojang.blaze3d.systems.RenderPass import com.mojang.blaze3d.systems.RenderSystem diff --git a/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt b/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt index 0467ffb16..f810ed49f 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt @@ -32,12 +32,12 @@ import com.mojang.blaze3d.textures.GpuTextureView import net.minecraft.block.BlockState import net.minecraft.client.font.TextRenderer import net.minecraft.client.render.OverlayTexture -import net.minecraft.client.render.item.ItemRenderState -import net.minecraft.client.render.command.OrderedRenderCommandQueue -import net.minecraft.client.render.VertexConsumer import net.minecraft.client.render.RenderLayer +import net.minecraft.client.render.VertexConsumer import net.minecraft.client.render.command.ModelCommandRenderer +import net.minecraft.client.render.command.OrderedRenderCommandQueue import net.minecraft.client.render.entity.state.EntityRenderState +import net.minecraft.client.render.item.ItemRenderState import net.minecraft.client.render.model.BakedQuad import net.minecraft.client.render.model.BlockModelPart import net.minecraft.client.render.model.BlockStateModel @@ -45,14 +45,14 @@ import net.minecraft.client.render.state.CameraRenderState import net.minecraft.client.texture.Sprite import net.minecraft.client.util.math.MatrixStack import net.minecraft.entity.Entity -import net.minecraft.util.Identifier -import net.minecraft.util.math.BlockPos -import net.minecraft.util.math.Box -import net.minecraft.util.math.Vec3d import net.minecraft.item.ItemDisplayContext import net.minecraft.item.ItemStack import net.minecraft.text.OrderedText import net.minecraft.text.Text +import net.minecraft.util.Identifier +import net.minecraft.util.math.BlockPos +import net.minecraft.util.math.Box +import net.minecraft.util.math.Vec3d import net.minecraft.util.math.random.Random import org.joml.Matrix4f import org.joml.Quaternionf diff --git a/src/main/kotlin/com/lambda/graphics/mc/renderer/AbstractRenderer.kt b/src/main/kotlin/com/lambda/graphics/mc/renderer/AbstractRenderer.kt index a10933e02..7eec40d53 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/renderer/AbstractRenderer.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/renderer/AbstractRenderer.kt @@ -26,7 +26,6 @@ import com.mojang.blaze3d.buffers.GpuBufferSlice import com.mojang.blaze3d.systems.RenderPass import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.textures.FilterMode -import kotlin.collections.isNotEmpty abstract class AbstractRenderer(val name: String, var depthTest: SafeContext.() -> Boolean) { protected abstract fun getRendererTransforms(): List> diff --git a/src/main/kotlin/com/lambda/graphics/outline/OutlineCapturingQueue.kt b/src/main/kotlin/com/lambda/graphics/outline/OutlineCapturingQueue.kt index 2e88efcc6..3ee79d4f9 100644 --- a/src/main/kotlin/com/lambda/graphics/outline/OutlineCapturingQueue.kt +++ b/src/main/kotlin/com/lambda/graphics/outline/OutlineCapturingQueue.kt @@ -19,39 +19,39 @@ package com.lambda.graphics.outline import com.lambda.Lambda.mc import com.lambda.graphics.RenderMain -import net.minecraft.client.model.Model -import net.minecraft.client.model.ModelPart -import net.minecraft.client.render.RenderLayer -import net.minecraft.client.render.VertexConsumer -import net.minecraft.client.render.model.BakedQuad -import net.minecraft.client.render.state.CameraRenderState -import net.minecraft.client.texture.Sprite -import net.minecraft.client.util.math.MatrixStack -import net.minecraft.item.ItemDisplayContext -import net.minecraft.util.math.Vec3d -import org.joml.Matrix4f -import org.joml.Vector3f -import org.joml.Vector4f import com.mojang.blaze3d.textures.GpuTextureView import net.minecraft.block.BlockState import net.minecraft.client.font.TextRenderer +import net.minecraft.client.model.Model +import net.minecraft.client.model.ModelPart +import net.minecraft.client.render.RenderLayer import net.minecraft.client.render.SpriteTexturedVertexConsumer +import net.minecraft.client.render.VertexConsumer import net.minecraft.client.render.block.BlockModelRenderer import net.minecraft.client.render.block.MovingBlockRenderState import net.minecraft.client.render.command.BatchingRenderCommandQueue import net.minecraft.client.render.command.CustomCommandRenderer import net.minecraft.client.render.command.LabelCommandRenderer -import net.minecraft.client.render.command.OrderedRenderCommandQueue -import net.minecraft.client.render.command.OrderedRenderCommandQueueImpl import net.minecraft.client.render.command.ModelCommandRenderer import net.minecraft.client.render.command.ModelPartCommandRenderer +import net.minecraft.client.render.command.OrderedRenderCommandQueue +import net.minecraft.client.render.command.OrderedRenderCommandQueueImpl import net.minecraft.client.render.entity.state.EntityRenderState import net.minecraft.client.render.item.ItemRenderState +import net.minecraft.client.render.model.BakedQuad import net.minecraft.client.render.model.BlockStateModel +import net.minecraft.client.render.state.CameraRenderState +import net.minecraft.client.texture.Sprite +import net.minecraft.client.util.math.MatrixStack +import net.minecraft.item.ItemDisplayContext import net.minecraft.text.OrderedText import net.minecraft.text.Text +import net.minecraft.util.math.Vec3d +import org.joml.Matrix4f import org.joml.Matrix4fStack import org.joml.Quaternionf +import org.joml.Vector3f +import org.joml.Vector4f class OutlineCapturingQueue @JvmOverloads constructor( private val delegate: OrderedRenderCommandQueueImpl, diff --git a/src/main/kotlin/com/lambda/graphics/outline/OutlineIdBuffer.kt b/src/main/kotlin/com/lambda/graphics/outline/OutlineIdBuffer.kt index 592f6969b..9d2c9c699 100644 --- a/src/main/kotlin/com/lambda/graphics/outline/OutlineIdBuffer.kt +++ b/src/main/kotlin/com/lambda/graphics/outline/OutlineIdBuffer.kt @@ -22,8 +22,7 @@ import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.textures.GpuTexture import com.mojang.blaze3d.textures.GpuTextureView import com.mojang.blaze3d.textures.TextureFormat -import java.util.OptionalDouble -import java.util.OptionalInt +import java.util.* object OutlineIdBuffer { private var idTexture: GpuTexture? = null diff --git a/src/main/kotlin/com/lambda/graphics/outline/OutlineIdPassRenderer.kt b/src/main/kotlin/com/lambda/graphics/outline/OutlineIdPassRenderer.kt index 12d7d61b1..4fd408900 100644 --- a/src/main/kotlin/com/lambda/graphics/outline/OutlineIdPassRenderer.kt +++ b/src/main/kotlin/com/lambda/graphics/outline/OutlineIdPassRenderer.kt @@ -24,20 +24,19 @@ import com.lambda.graphics.mc.renderer.upload import com.mojang.blaze3d.buffers.GpuBuffer import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.textures.GpuTextureView -import net.minecraft.util.Identifier import net.minecraft.client.render.model.BakedQuad import net.minecraft.client.render.model.BlockModelPart import net.minecraft.client.util.math.Vector2f +import net.minecraft.util.Identifier +import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction import net.minecraft.util.math.random.Random -import net.minecraft.util.math.BlockPos import org.joml.Matrix4f import org.joml.Vector3f import org.joml.Vector4f import org.lwjgl.system.MemoryUtil import java.nio.ByteOrder -import java.util.OptionalDouble -import java.util.OptionalInt +import java.util.* object OutlineIdPassRenderer { private val vertexSize = 28 diff --git a/src/main/kotlin/com/lambda/graphics/outline/OutlineRenderer.kt b/src/main/kotlin/com/lambda/graphics/outline/OutlineRenderer.kt index b2c930886..90ff102f7 100644 --- a/src/main/kotlin/com/lambda/graphics/outline/OutlineRenderer.kt +++ b/src/main/kotlin/com/lambda/graphics/outline/OutlineRenderer.kt @@ -30,8 +30,7 @@ import org.joml.Matrix4f import org.joml.Vector3f import org.joml.Vector4f import org.lwjgl.system.MemoryUtil -import java.util.OptionalDouble -import java.util.OptionalInt +import java.util.* object OutlineRenderer { private var silhouetteTexture: GpuTexture? = null diff --git a/src/main/kotlin/com/lambda/graphics/outline/VertexCapture.kt b/src/main/kotlin/com/lambda/graphics/outline/VertexCapture.kt index d1ed2d195..e467a4535 100644 --- a/src/main/kotlin/com/lambda/graphics/outline/VertexCapture.kt +++ b/src/main/kotlin/com/lambda/graphics/outline/VertexCapture.kt @@ -18,8 +18,8 @@ package com.lambda.graphics.outline import com.mojang.blaze3d.textures.GpuTextureView -import kotlin.collections.find +@Suppress("unused") object VertexCapture { private val entityGeometries = mutableMapOf>() diff --git a/src/main/kotlin/com/lambda/graphics/text/SDFFontAtlas.kt b/src/main/kotlin/com/lambda/graphics/text/SDFFontAtlas.kt index 79948ce22..d97a31c7e 100644 --- a/src/main/kotlin/com/lambda/graphics/text/SDFFontAtlas.kt +++ b/src/main/kotlin/com/lambda/graphics/text/SDFFontAtlas.kt @@ -24,6 +24,9 @@ import com.mojang.blaze3d.textures.FilterMode import com.mojang.blaze3d.textures.GpuTexture import com.mojang.blaze3d.textures.GpuTextureView import com.mojang.blaze3d.textures.TextureFormat +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking import net.minecraft.client.gl.GpuSampler import net.minecraft.client.texture.NativeImage import org.lwjgl.stb.STBTTFontinfo @@ -43,12 +46,9 @@ import org.lwjgl.stb.STBTruetype.stbtt_ScaleForPixelHeight import org.lwjgl.system.MemoryStack import org.lwjgl.system.MemoryUtil import java.nio.ByteBuffer -import kotlin.math.sqrt -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking import java.nio.file.Path import kotlin.io.path.readBytes +import kotlin.math.sqrt class SDFFontAtlas( fontPath: String, diff --git a/src/main/kotlin/com/lambda/gui/DearImGui.kt b/src/main/kotlin/com/lambda/gui/DearImGui.kt index 32d71dcbd..69bc256fd 100644 --- a/src/main/kotlin/com/lambda/gui/DearImGui.kt +++ b/src/main/kotlin/com/lambda/gui/DearImGui.kt @@ -22,9 +22,6 @@ import com.lambda.core.Loadable import com.lambda.event.EventFlow.post import com.lambda.event.events.GuiEvent import com.lambda.gui.components.ClickGuiLayout -import com.lambda.util.stream -import com.mojang.blaze3d.opengl.GlStateManager -import com.mojang.blaze3d.systems.RenderSystem import com.lambda.imgui.ImFontConfig import com.lambda.imgui.ImFontGlyphRangesBuilder import com.lambda.imgui.ImGui @@ -33,6 +30,9 @@ import com.lambda.imgui.extension.implot.ImPlot import com.lambda.imgui.flag.ImGuiConfigFlags import com.lambda.imgui.gl3.ImGuiImplGl3 import com.lambda.imgui.glfw.ImGuiImplGlfw +import com.lambda.util.stream +import com.mojang.blaze3d.opengl.GlStateManager +import com.mojang.blaze3d.systems.RenderSystem import net.minecraft.client.gl.GlBackend import net.minecraft.client.texture.GlTexture import org.lwjgl.opengl.GL30.GL_FRAMEBUFFER diff --git a/src/main/kotlin/com/lambda/gui/MenuBar.kt b/src/main/kotlin/com/lambda/gui/MenuBar.kt index ae90d6c1d..c496a03e4 100644 --- a/src/main/kotlin/com/lambda/gui/MenuBar.kt +++ b/src/main/kotlin/com/lambda/gui/MenuBar.kt @@ -35,6 +35,11 @@ import com.lambda.gui.components.HudGuiLayout import com.lambda.gui.components.QuickSearch import com.lambda.gui.components.SettingsWidget.buildConfigSettingsContext import com.lambda.gui.dsl.ImGuiBuilder +import com.lambda.imgui.ImGui +import com.lambda.imgui.ImGui.closeCurrentPopup +import com.lambda.imgui.flag.ImGuiCol +import com.lambda.imgui.flag.ImGuiStyleVar +import com.lambda.imgui.flag.ImGuiWindowFlags import com.lambda.interaction.BaritoneHandler import com.lambda.module.ModuleRegistry import com.lambda.module.ModuleRegistry.moduleNameMap @@ -46,11 +51,6 @@ import com.lambda.util.Diagnostics.gatherDiagnostics import com.lambda.util.FolderRegister import com.lambda.util.FolderRegister.minecraft import com.mojang.blaze3d.platform.TextureUtil -import com.lambda.imgui.ImGui -import com.lambda.imgui.ImGui.closeCurrentPopup -import com.lambda.imgui.flag.ImGuiCol -import com.lambda.imgui.flag.ImGuiStyleVar -import com.lambda.imgui.flag.ImGuiWindowFlags import net.fabricmc.loader.api.FabricLoader import net.minecraft.client.gui.screen.DebugOptionsScreen import net.minecraft.network.packet.c2s.play.ChangeGameModeC2SPacket diff --git a/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt b/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt index 2f1b2815c..a5b023466 100644 --- a/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt +++ b/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt @@ -35,6 +35,12 @@ import com.lambda.gui.snap.SnapHandler import com.lambda.gui.snap.SnapHandler.drawDragGrid import com.lambda.gui.snap.SnapHandler.drawSnapLines import com.lambda.gui.snap.SnapHandler.updateDragAndSnapping +import com.lambda.imgui.ImGui +import com.lambda.imgui.extension.implot.ImPlot +import com.lambda.imgui.flag.ImGuiCol +import com.lambda.imgui.flag.ImGuiCond +import com.lambda.imgui.flag.ImGuiHoveredFlags +import com.lambda.imgui.flag.ImGuiWindowFlags import com.lambda.module.ModuleRegistry import com.lambda.module.modules.client.Client import com.lambda.module.tag.ModuleTag @@ -45,12 +51,6 @@ import com.lambda.util.Describable import com.lambda.util.KeyCode import com.lambda.util.NamedEnum import com.lambda.util.WindowUtils.setLambdaWindowIcon -import com.lambda.imgui.ImGui -import com.lambda.imgui.extension.implot.ImPlot -import com.lambda.imgui.flag.ImGuiCol -import com.lambda.imgui.flag.ImGuiCond -import com.lambda.imgui.flag.ImGuiHoveredFlags -import com.lambda.imgui.flag.ImGuiWindowFlags import net.minecraft.SharedConstants import net.minecraft.client.gui.screen.ChatScreen import net.minecraft.client.gui.screen.Screen diff --git a/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt b/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt index 2a056a937..aaf27ebc3 100644 --- a/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt +++ b/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt @@ -30,9 +30,6 @@ import com.lambda.gui.snap.SnapHandler import com.lambda.gui.snap.SnapHandler.drawDragGrid import com.lambda.gui.snap.SnapHandler.drawSnapLines import com.lambda.gui.snap.SnapHandler.updateDragAndSnapping -import com.lambda.module.HudModule -import com.lambda.module.ModuleRegistry -import com.lambda.util.NamedEnum import com.lambda.imgui.ImColor import com.lambda.imgui.ImDrawList import com.lambda.imgui.ImGui @@ -40,6 +37,9 @@ import com.lambda.imgui.flag.ImDrawListFlags import com.lambda.imgui.flag.ImGuiCol import com.lambda.imgui.flag.ImGuiStyleVar import com.lambda.imgui.flag.ImGuiWindowFlags +import com.lambda.module.HudModule +import com.lambda.module.ModuleRegistry +import com.lambda.util.NamedEnum import java.awt.Color import kotlin.math.PI diff --git a/src/main/kotlin/com/lambda/gui/components/ModuleEntry.kt b/src/main/kotlin/com/lambda/gui/components/ModuleEntry.kt index 8a8b2cac0..44f715906 100644 --- a/src/main/kotlin/com/lambda/gui/components/ModuleEntry.kt +++ b/src/main/kotlin/com/lambda/gui/components/ModuleEntry.kt @@ -20,8 +20,8 @@ package com.lambda.gui.components import com.lambda.gui.Layout import com.lambda.gui.components.SettingsWidget.buildConfigSettingsContext import com.lambda.gui.dsl.ImGuiBuilder -import com.lambda.module.Module import com.lambda.imgui.ImGui +import com.lambda.module.Module class ModuleEntry(val module: Module): Layout { override fun ImGuiBuilder.buildLayout() { diff --git a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt index 6c2175de4..3b810cc0e 100644 --- a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt +++ b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt @@ -28,6 +28,11 @@ import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.gui.LambdaScreen import com.lambda.gui.Layout import com.lambda.gui.dsl.ImGuiBuilder +import com.lambda.imgui.ImGui +import com.lambda.imgui.flag.ImGuiInputTextFlags +import com.lambda.imgui.flag.ImGuiStyleVar +import com.lambda.imgui.flag.ImGuiWindowFlags +import com.lambda.imgui.type.ImString import com.lambda.module.HudModule import com.lambda.module.Module import com.lambda.module.ModuleRegistry @@ -35,11 +40,6 @@ import com.lambda.module.modules.client.AutoUpdater import com.lambda.util.KeyCode import com.lambda.util.StringUtils.capitalize import com.lambda.util.StringUtils.levenshteinDistance -import com.lambda.imgui.ImGui -import com.lambda.imgui.flag.ImGuiInputTextFlags -import com.lambda.imgui.flag.ImGuiStyleVar -import com.lambda.imgui.flag.ImGuiWindowFlags -import com.lambda.imgui.type.ImString import net.minecraft.client.gui.screen.ChatScreen import kotlin.math.max diff --git a/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt b/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt index 1dc397721..a691888ac 100644 --- a/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt +++ b/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt @@ -24,13 +24,13 @@ import com.lambda.config.Setting import com.lambda.config.UserAutomationConfig import com.lambda.config.configurations.UserAutomationConfigs import com.lambda.gui.dsl.ImGuiBuilder +import com.lambda.imgui.ImGui +import com.lambda.imgui.flag.ImGuiPopupFlags +import com.lambda.imgui.flag.ImGuiTabBarFlags import com.lambda.module.HudModule import com.lambda.module.Module import com.lambda.module.modules.client.AutoUpdater import com.lambda.util.NamedEnum -import com.lambda.imgui.ImGui -import com.lambda.imgui.flag.ImGuiPopupFlags -import com.lambda.imgui.flag.ImGuiTabBarFlags object SettingsWidget { /** diff --git a/src/main/kotlin/com/lambda/gui/dsl/ImGuiBuilder.kt b/src/main/kotlin/com/lambda/gui/dsl/ImGuiBuilder.kt index 865688cab..063f2bd7e 100644 --- a/src/main/kotlin/com/lambda/gui/dsl/ImGuiBuilder.kt +++ b/src/main/kotlin/com/lambda/gui/dsl/ImGuiBuilder.kt @@ -37,8 +37,8 @@ package com.lambda.gui.dsl import com.lambda.gui.components.ClickGuiLayout +import com.lambda.gui.dsl.ImGuiBuilder.openPopup import com.lambda.gui.dsl.ImGuiBuilder.text -import com.lambda.util.math.Vec2d import com.lambda.imgui.ImDrawList import com.lambda.imgui.ImFont import com.lambda.imgui.ImGui @@ -130,6 +130,7 @@ import com.lambda.imgui.ImGui.isWindowAppearing import com.lambda.imgui.ImGui.isWindowCollapsed import com.lambda.imgui.ImGui.isWindowHovered import com.lambda.imgui.ImGui.plotHistogram +import com.lambda.imgui.ImGui.plotLines import com.lambda.imgui.ImGui.popFont import com.lambda.imgui.ImGui.popID import com.lambda.imgui.ImGui.popItemWidth @@ -157,6 +158,7 @@ import com.lambda.imgui.ImGuiTextFilter import com.lambda.imgui.ImGuiViewport import com.lambda.imgui.ImVec2 import com.lambda.imgui.flag.ImDrawListFlags +import com.lambda.imgui.flag.ImGuiChildFlags import com.lambda.imgui.flag.ImGuiCol import com.lambda.imgui.flag.ImGuiColorEditFlags import com.lambda.imgui.flag.ImGuiComboFlags @@ -174,13 +176,12 @@ import com.lambda.imgui.type.ImDouble import com.lambda.imgui.type.ImFloat import com.lambda.imgui.type.ImInt import com.lambda.imgui.type.ImString +import com.lambda.util.math.Vec2d import net.minecraft.util.math.Vec2f import net.minecraft.util.math.Vec3d import net.minecraft.util.math.Vec3i import java.awt.Color import kotlin.reflect.KMutableProperty0 -import com.lambda.imgui.ImGui.plotLines -import com.lambda.imgui.flag.ImGuiChildFlags typealias ProcedureBlock = ImGuiBuilder.() -> Unit typealias WrappedBlock = ImGuiBuilder.(In) -> Out diff --git a/src/main/kotlin/com/lambda/gui/snap/SnapHandler.kt b/src/main/kotlin/com/lambda/gui/snap/SnapHandler.kt index 0a4d8fa95..77dbae460 100644 --- a/src/main/kotlin/com/lambda/gui/snap/SnapHandler.kt +++ b/src/main/kotlin/com/lambda/gui/snap/SnapHandler.kt @@ -33,7 +33,6 @@ import com.lambda.gui.components.ClickGuiLayout.snapToScreenCenter import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.ImColor import com.lambda.imgui.ImGui -import kotlin.collections.set import kotlin.math.abs import kotlin.math.max diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt index 8babe3199..4f68fb872 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt @@ -18,11 +18,11 @@ package com.lambda.interaction.construction.simulation import com.lambda.context.AutomatedSafeContext -import com.lambda.interaction.construction.simulation.result.BuildResult -import com.lambda.interaction.construction.simulation.result.results.PostSimResult import com.lambda.interaction.construction.simulation.SimInfo.Companion.sim import com.lambda.interaction.construction.simulation.checks.BreakSim.Companion.simBreak import com.lambda.interaction.construction.simulation.checks.InteractSim.Companion.simInteraction +import com.lambda.interaction.construction.simulation.result.BuildResult +import com.lambda.interaction.construction.simulation.result.results.PostSimResult import com.lambda.util.BlockUtils.blockState import com.lambda.util.extension.Structure import io.ktor.util.collections.* diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/Simulation.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/Simulation.kt index 20cf9fdd8..828a33e6e 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/Simulation.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/Simulation.kt @@ -20,7 +20,6 @@ package com.lambda.interaction.construction.simulation import com.lambda.context.Automated import com.lambda.context.SafeContext import com.lambda.graphics.mc.RenderBuilder -import com.lambda.graphics.mc.renderer.TickedRenderer import com.lambda.interaction.construction.blueprint.Blueprint import com.lambda.interaction.construction.simulation.BuildSimulator.simulate import com.lambda.interaction.construction.simulation.result.BuildResult diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Drawable.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Drawable.kt index 517a29518..57fdae135 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Drawable.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Drawable.kt @@ -18,7 +18,6 @@ package com.lambda.interaction.construction.simulation.result import com.lambda.graphics.mc.RenderBuilder -import com.lambda.graphics.mc.renderer.TickedRenderer /** * Represents a [BuildResult] that can be rendered in-game. diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/InteractResult.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/InteractResult.kt index 817c96658..f399b7c45 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/InteractResult.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/InteractResult.kt @@ -20,7 +20,6 @@ package com.lambda.interaction.construction.simulation.result.results import baritone.api.pathing.goals.GoalBlock import baritone.api.pathing.goals.GoalInverted import com.lambda.graphics.mc.RenderBuilder -import com.lambda.graphics.mc.renderer.TickedRenderer import com.lambda.interaction.construction.simulation.context.InteractContext import com.lambda.interaction.construction.simulation.result.BuildResult import com.lambda.interaction.construction.simulation.result.Contextual diff --git a/src/main/kotlin/com/lambda/interaction/managers/PacketLimitHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/PacketLimitHandler.kt index bd0407a22..40526582e 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/PacketLimitHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/PacketLimitHandler.kt @@ -21,9 +21,9 @@ import com.lambda.config.groups.BuildConfig import com.lambda.context.Automated import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen +import kotlin.time.ComparableTimeMark import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds -import kotlin.time.ComparableTimeMark import kotlin.time.TimeSource object PacketLimitHandler { diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt index fdd3db098..abb45b1f9 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt @@ -18,8 +18,6 @@ package com.lambda.interaction.managers.breaking import com.lambda.config.AutomationConfig.Companion.DEFAULT -import com.lambda.module.modules.client.Client -import com.lambda.module.modules.client.Client.verboseDebug import com.lambda.context.SafeContext import com.lambda.event.events.EntityEvent import com.lambda.event.events.WorldEvent @@ -30,6 +28,8 @@ import com.lambda.interaction.managers.breaking.BreakConfig.BreakConfirmationMod import com.lambda.interaction.managers.breaking.BreakManager.lastPosStarted import com.lambda.interaction.managers.breaking.BreakManager.matchesBlockItem import com.lambda.interaction.managers.breaking.RebreakHandler.rebreak +import com.lambda.module.modules.client.Client +import com.lambda.module.modules.client.Client.verboseDebug import com.lambda.threading.runSafe import com.lambda.util.BlockUtils.emptyState import com.lambda.util.BlockUtils.fluidState diff --git a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt index fb0a23952..271c2c578 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt @@ -36,7 +36,9 @@ import com.lambda.interaction.managers.breaking.BreakManager import com.lambda.interaction.managers.hotbar.HotbarRequest import com.lambda.interaction.managers.interacting.InteractConfig.AirPlaceMode import com.lambda.interaction.managers.interacting.InteractManager.activeRequest +import com.lambda.interaction.managers.interacting.InteractManager.maxInteractionsThisTick import com.lambda.interaction.managers.interacting.InteractManager.populateFrom +import com.lambda.interaction.managers.interacting.InteractManager.potentialInteractions import com.lambda.interaction.managers.interacting.InteractManager.processRequest import com.lambda.interaction.managers.interacting.InteractedBlockHandler.pendingActions import com.lambda.interaction.managers.interacting.InteractedBlockHandler.setPendingConfigs diff --git a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt index 031267e9d..7472b431b 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt @@ -18,11 +18,11 @@ package com.lambda.interaction.managers.interacting import com.lambda.config.AutomationConfig.Companion.DEFAULT -import com.lambda.module.modules.client.Client.verboseDebug import com.lambda.event.events.WorldEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.PostActionHandler import com.lambda.interaction.managers.interacting.InteractManager.placeSound +import com.lambda.module.modules.client.Client.verboseDebug import com.lambda.threading.runSafe import com.lambda.util.BlockUtils.matches import com.lambda.util.Communication.warn diff --git a/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PlaceDirection.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PlaceDirection.kt index fb7c9b17f..a85429a90 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PlaceDirection.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PlaceDirection.kt @@ -22,7 +22,6 @@ import net.minecraft.entity.Entity import net.minecraft.util.math.Direction import net.minecraft.util.math.MathHelper import net.minecraft.util.math.Vec3i -import kotlin.math.sin enum class PlaceDirection( val rotation: Rotation, diff --git a/src/main/kotlin/com/lambda/module/hud/ModuleList.kt b/src/main/kotlin/com/lambda/module/hud/ModuleList.kt index c676874a8..ba87c8064 100644 --- a/src/main/kotlin/com/lambda/module/hud/ModuleList.kt +++ b/src/main/kotlin/com/lambda/module/hud/ModuleList.kt @@ -18,10 +18,10 @@ package com.lambda.module.hud import com.lambda.gui.dsl.ImGuiBuilder +import com.lambda.imgui.flag.ImGuiCol import com.lambda.module.HudModule import com.lambda.module.ModuleRegistry import com.lambda.module.tag.ModuleTag -import com.lambda.imgui.flag.ImGuiCol import java.awt.Color object ModuleList : HudModule( diff --git a/src/main/kotlin/com/lambda/module/hud/TPS.kt b/src/main/kotlin/com/lambda/module/hud/TPS.kt index 1f7992ab6..228b43c7a 100644 --- a/src/main/kotlin/com/lambda/module/hud/TPS.kt +++ b/src/main/kotlin/com/lambda/module/hud/TPS.kt @@ -18,12 +18,12 @@ package com.lambda.module.hud import com.lambda.gui.dsl.ImGuiBuilder +import com.lambda.imgui.ImVec2 import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag import com.lambda.util.Formatting.format import com.lambda.util.ServerTPS import com.lambda.util.ServerTPS.recentData -import com.lambda.imgui.ImVec2 object TPS : HudModule( name = "TPS", diff --git a/src/main/kotlin/com/lambda/module/hud/Watermark.kt b/src/main/kotlin/com/lambda/module/hud/Watermark.kt index 3de4c0f41..c89a63f3a 100644 --- a/src/main/kotlin/com/lambda/module/hud/Watermark.kt +++ b/src/main/kotlin/com/lambda/module/hud/Watermark.kt @@ -19,9 +19,9 @@ package com.lambda.module.hud import com.lambda.graphics.texture.TextureOwner.upload import com.lambda.gui.dsl.ImGuiBuilder +import com.lambda.imgui.ImGui import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag -import com.lambda.imgui.ImGui object Watermark : HudModule( name = "Watermark", diff --git a/src/main/kotlin/com/lambda/module/modules/client/AutoUpdater.kt b/src/main/kotlin/com/lambda/module/modules/client/AutoUpdater.kt index e31076fc3..371e5a79e 100644 --- a/src/main/kotlin/com/lambda/module/modules/client/AutoUpdater.kt +++ b/src/main/kotlin/com/lambda/module/modules/client/AutoUpdater.kt @@ -23,14 +23,14 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.gui.LambdaScreen import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.gui.dsl.ImGuiBuilder.popupModal +import com.lambda.imgui.ImGui +import com.lambda.imgui.flag.ImGuiWindowFlags import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runIO import com.lambda.util.Communication.debug import com.lambda.util.Communication.logError import com.lambda.util.Communication.warn -import com.lambda.imgui.ImGui -import com.lambda.imgui.flag.ImGuiWindowFlags import net.fabricmc.loader.api.FabricLoader import net.minecraft.SharedConstants import java.net.URI diff --git a/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt b/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt index 951d080f3..7691b8ff4 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt @@ -18,8 +18,8 @@ package com.lambda.module.modules.debug import com.lambda.config.groups.ScreenLineSettings -import com.lambda.config.groups.WorldLineSettings import com.lambda.config.groups.ScreenTextSettings +import com.lambda.config.groups.WorldLineSettings import com.lambda.config.groups.WorldTextSettings import com.lambda.module.Module import com.lambda.module.tag.ModuleTag diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt index 701c01000..6c2db1696 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt @@ -30,23 +30,23 @@ import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest import com.lambda.interaction.material.StackSelection.Companion.select import com.lambda.module.Module +import com.lambda.module.hud.Speedometer import com.lambda.module.modules.movement.BetterFirework.canOpenElytra import com.lambda.module.modules.movement.BetterFirework.canTakeoff import com.lambda.module.modules.movement.BetterFirework.startFirework import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe -import com.lambda.util.Timer -import com.lambda.util.extension.isElytraFlying -import com.lambda.util.player.MovementUtils.addSpeed -import com.lambda.util.player.SlotUtils.hotbarStacks -import com.lambda.util.player.hasFirework -import com.lambda.module.hud.Speedometer import com.lambda.util.BlockUtils.blockState import com.lambda.util.SpeedUnit +import com.lambda.util.Timer +import com.lambda.util.extension.isElytraFlying import com.lambda.util.math.dist import com.lambda.util.math.flooredBlockPos import com.lambda.util.math.isLoaded +import com.lambda.util.player.MovementUtils.addSpeed +import com.lambda.util.player.SlotUtils.hotbarStacks import com.lambda.util.player.SlotUtils.inventoryStacks +import com.lambda.util.player.hasFirework import com.lambda.util.world.raycast.InteractionMask import com.lambda.util.world.raycast.RayCastUtils.blockResult import com.lambda.util.world.raycast.RayCastUtils.rayCast diff --git a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt index 9c220061f..d84c9e787 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt @@ -23,10 +23,8 @@ import com.lambda.event.events.MovementEvent import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest -import com.lambda.interaction.managers.rotating.Rotation import com.lambda.interaction.managers.rotating.RotationConfig import com.lambda.interaction.managers.rotating.RotationMode -import com.lambda.interaction.managers.rotating.RotationRequest import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.NamedEnum diff --git a/src/main/kotlin/com/lambda/module/modules/network/PacketLogger.kt b/src/main/kotlin/com/lambda/module/modules/network/PacketLogger.kt index 901b5a769..d44e84c77 100644 --- a/src/main/kotlin/com/lambda/module/modules/network/PacketLogger.kt +++ b/src/main/kotlin/com/lambda/module/modules/network/PacketLogger.kt @@ -21,8 +21,8 @@ import com.lambda.Lambda import com.lambda.Lambda.mc import com.lambda.event.events.PacketEvent import com.lambda.event.events.TickEvent -import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.event.listener.UnsafeListener.Companion.listenConcurrentlyUnsafe +import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runIO @@ -32,7 +32,6 @@ import com.lambda.util.DynamicReflectionSerializer.dynamicString import com.lambda.util.FolderRegister import com.lambda.util.FolderRegister.relativeMCPath import com.lambda.util.Formatting.getTime -import com.lambda.util.reflections.getInstances import com.lambda.util.text.ClickEvents import com.lambda.util.text.buildText import com.lambda.util.text.clickEvent diff --git a/src/main/kotlin/com/lambda/module/modules/network/Rubberband.kt b/src/main/kotlin/com/lambda/module/modules/network/Rubberband.kt index 245d0b1e4..2d11549ed 100644 --- a/src/main/kotlin/com/lambda/module/modules/network/Rubberband.kt +++ b/src/main/kotlin/com/lambda/module/modules/network/Rubberband.kt @@ -29,7 +29,6 @@ import com.lambda.util.math.distSq import com.lambda.util.text.buildText import com.lambda.util.text.color import com.lambda.util.text.literal -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket import net.minecraft.util.math.Vec3d import java.awt.Color diff --git a/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt b/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt index e1254aa10..919d7d27b 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt @@ -40,7 +40,6 @@ import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction import net.minecraft.world.LightType import java.awt.Color -import kotlin.collections.forEach object LightLevels : Module( name = "LightLevels", diff --git a/src/main/kotlin/com/lambda/module/modules/render/Search.kt b/src/main/kotlin/com/lambda/module/modules/render/Search.kt index 5b49d4a4e..6e193ff0a 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Search.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Search.kt @@ -43,7 +43,7 @@ import com.lambda.util.extension.entityColor import com.lambda.util.extension.getBlockState import com.lambda.util.math.setAlpha import com.lambda.util.world.toBlockPos -import io.ktor.util.collections.ConcurrentMap +import io.ktor.util.collections.* import net.minecraft.block.BlockState import net.minecraft.block.Blocks import net.minecraft.entity.Entity diff --git a/src/main/kotlin/com/lambda/module/modules/render/Zoom.kt b/src/main/kotlin/com/lambda/module/modules/render/Zoom.kt index 432684807..9b43ba327 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Zoom.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Zoom.kt @@ -18,7 +18,6 @@ package com.lambda.module.modules.render import com.lambda.event.events.ButtonEvent -import com.lambda.event.events.RenderEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module import com.lambda.module.tag.ModuleTag diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoSign.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoSign.kt index 3b2a05508..5adc4af1d 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoSign.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoSign.kt @@ -30,7 +30,7 @@ import net.minecraft.client.gui.screen.ingame.AbstractSignEditScreen import net.minecraft.client.gui.screen.ingame.HangingSignEditScreen import net.minecraft.client.gui.screen.ingame.SignEditScreen import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket -import java.util.Date +import java.util.* @Suppress("unused") object AutoSign : Module( diff --git a/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt b/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt index 7a8c2327a..77e09f623 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt @@ -28,11 +28,11 @@ import com.lambda.task.RootTask.run import com.lambda.task.Task import com.lambda.task.tasks.BuildTask.Companion.build import com.lambda.util.BlockUtils.blockPos -import net.minecraft.block.Blocks -import net.minecraft.util.math.BlockPos import com.lambda.util.PlayerBuildLayerUtils.FlattenMode -import com.lambda.util.PlayerBuildLayerUtils.isInFlatten import com.lambda.util.PlayerBuildLayerUtils.isInBaritoneSelection +import com.lambda.util.PlayerBuildLayerUtils.isInFlatten +import net.minecraft.block.Blocks +import net.minecraft.util.math.BlockPos @Suppress("unused") object Nuker : Module( diff --git a/src/main/kotlin/com/lambda/module/modules/world/Printer.kt b/src/main/kotlin/com/lambda/module/modules/world/Printer.kt index fc43177d9..98d27b554 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Printer.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Printer.kt @@ -33,10 +33,10 @@ import com.lambda.util.BlockUtils.blockPos import com.lambda.util.Communication.logError import com.lambda.util.Describable import com.lambda.util.NamedEnum -import com.lambda.util.PlayerBuildLayerUtils.isInBaritoneSelection -import com.lambda.util.PlayerBuildLayerUtils.isInFlatten import com.lambda.util.PlayerBuildLayerUtils.FlattenMode import com.lambda.util.PlayerBuildLayerUtils.inSchematic +import com.lambda.util.PlayerBuildLayerUtils.isInBaritoneSelection +import com.lambda.util.PlayerBuildLayerUtils.isInFlatten import fi.dy.masa.litematica.data.DataManager import fi.dy.masa.litematica.world.SchematicWorldHandler import net.minecraft.util.math.BlockPos diff --git a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt index 841879824..e5483dfe2 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt @@ -91,8 +91,6 @@ import net.minecraft.util.math.Box import org.lwjgl.glfw.GLFW import java.awt.Color import kotlin.math.min -import kotlin.run -import kotlin.to @Suppress("unused") object StashMover : Module( diff --git a/src/main/kotlin/com/lambda/network/LambdaAPI.kt b/src/main/kotlin/com/lambda/network/LambdaAPI.kt index c963b07b2..43cc6e470 100644 --- a/src/main/kotlin/com/lambda/network/LambdaAPI.kt +++ b/src/main/kotlin/com/lambda/network/LambdaAPI.kt @@ -24,8 +24,8 @@ import com.lambda.config.configurations.LambdaConfig import com.lambda.event.events.ClientEvent import com.lambda.event.events.ConnectionEvent import com.lambda.event.events.ConnectionEvent.Connect.Login.EncryptionResponse -import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.event.listener.UnsafeListener.Companion.listenConcurrentlyUnsafe +import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.network.NetworkHandler.updateToken import com.lambda.network.api.v1.endpoints.login import com.lambda.util.StringUtils.hash diff --git a/src/main/kotlin/com/lambda/task/Task.kt b/src/main/kotlin/com/lambda/task/Task.kt index e36f62778..4be66c5e0 100644 --- a/src/main/kotlin/com/lambda/task/Task.kt +++ b/src/main/kotlin/com/lambda/task/Task.kt @@ -18,13 +18,13 @@ package com.lambda.task import com.lambda.Lambda.LOG -import com.lambda.module.modules.client.Client.verboseDebug import com.lambda.context.SafeContext import com.lambda.event.EventFlow.unsubscribe import com.lambda.event.Muteable import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.modules.client.Client +import com.lambda.module.modules.client.Client.verboseDebug import com.lambda.threading.runSafe import com.lambda.util.Communication.logError import com.lambda.util.Nameable diff --git a/src/main/kotlin/com/lambda/util/DynamicException.kt b/src/main/kotlin/com/lambda/util/DynamicException.kt index 0461eafbd..75c7a6116 100644 --- a/src/main/kotlin/com/lambda/util/DynamicException.kt +++ b/src/main/kotlin/com/lambda/util/DynamicException.kt @@ -18,7 +18,6 @@ package com.lambda.util import com.lambda.util.DynamicReflectionSerializer.simpleRemappedName -import kotlin.collections.toTypedArray /** * Remaps the stacktrace in production to have readable, class, method and field names diff --git a/src/main/kotlin/com/lambda/util/EntityUtils.kt b/src/main/kotlin/com/lambda/util/EntityUtils.kt index cc6e4d1dd..601c27c4e 100644 --- a/src/main/kotlin/com/lambda/util/EntityUtils.kt +++ b/src/main/kotlin/com/lambda/util/EntityUtils.kt @@ -24,8 +24,8 @@ import io.github.classgraph.ClassInfo import net.minecraft.block.entity.BlockEntity import net.minecraft.entity.Entity import net.minecraft.util.math.BlockPos -import kotlin.jvm.java +@Suppress("unused") object EntityUtils { val entities: Collection = scanResult .getSubclasses(Entity::class.java) diff --git a/src/main/kotlin/com/lambda/util/LambdaResource.kt b/src/main/kotlin/com/lambda/util/LambdaResource.kt index 4920339c9..d9406f0c4 100644 --- a/src/main/kotlin/com/lambda/util/LambdaResource.kt +++ b/src/main/kotlin/com/lambda/util/LambdaResource.kt @@ -22,7 +22,6 @@ import java.awt.image.BufferedImage import java.io.FileNotFoundException import java.io.InputStream import java.net.URL -import java.nio.file.Paths import javax.imageio.ImageIO typealias LambdaResource = String diff --git a/src/main/kotlin/com/lambda/util/StringUtils.kt b/src/main/kotlin/com/lambda/util/StringUtils.kt index 5120fad8d..737212a48 100644 --- a/src/main/kotlin/com/lambda/util/StringUtils.kt +++ b/src/main/kotlin/com/lambda/util/StringUtils.kt @@ -21,7 +21,7 @@ import com.lambda.Lambda import com.lambda.Lambda.gson import net.minecraft.util.Identifier import java.security.MessageDigest -import java.util.Base64 +import java.util.* object StringUtils { fun String.sanitizeForFilename() = diff --git a/src/main/kotlin/com/lambda/util/extension/World.kt b/src/main/kotlin/com/lambda/util/extension/World.kt index eeead30f2..53bd7bef8 100644 --- a/src/main/kotlin/com/lambda/util/extension/World.kt +++ b/src/main/kotlin/com/lambda/util/extension/World.kt @@ -19,7 +19,6 @@ package com.lambda.util.extension import com.lambda.Lambda.mc import com.lambda.context.SafeContext -import com.lambda.util.extension.paintingColorCache import com.lambda.util.world.FastVector import com.lambda.util.world.toBlockPos import com.lambda.util.world.x diff --git a/src/main/kotlin/com/lambda/util/world/WorldUtils.kt b/src/main/kotlin/com/lambda/util/world/WorldUtils.kt index fb9bed16c..4ca52ec1b 100644 --- a/src/main/kotlin/com/lambda/util/world/WorldUtils.kt +++ b/src/main/kotlin/com/lambda/util/world/WorldUtils.kt @@ -29,9 +29,7 @@ import net.minecraft.fluid.Fluid import net.minecraft.fluid.FluidState import net.minecraft.util.math.BlockPos import net.minecraft.util.math.ChunkSectionPos -import kotlin.collections.asSequence import kotlin.math.ceil -import kotlin.sequences.filter object WorldUtils { fun SafeContext.isLoaded(pos: BlockPos) = From e5627e6316578e77dce1fae5e3705e1f44522ea3 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Mon, 27 Apr 2026 16:57:31 +0100 Subject: [PATCH 04/40] more suppression for unused (used) stuff --- .../kotlin/com/lambda/command/commands/PrefixCommand.kt | 1 + .../kotlin/com/lambda/config/settings/StringSetting.kt | 3 +-- .../config/settings/collections/CollectionSetting.kt | 1 + .../com/lambda/config/settings/complex/KeybindSetting.kt | 8 +++++--- src/main/kotlin/com/lambda/graphics/mc/RegionRenderer.kt | 2 -- .../kotlin/com/lambda/graphics/outline/OutlineIdBuffer.kt | 5 +---- src/main/kotlin/com/lambda/graphics/text/SDFFontAtlas.kt | 5 ----- src/main/kotlin/com/lambda/gui/components/QuickSearch.kt | 1 + src/main/kotlin/com/lambda/gui/dsl/ImGuiBuilder.kt | 2 +- .../interaction/construction/simulation/Simulation.kt | 1 + .../managers/rotating/visibilty/PlaceDirection.kt | 1 + src/main/kotlin/com/lambda/module/hud/AccountName.kt | 1 + src/main/kotlin/com/lambda/module/hud/Baritone.kt | 1 + src/main/kotlin/com/lambda/module/hud/Coordinates.kt | 1 + src/main/kotlin/com/lambda/module/hud/FPS.kt | 1 + src/main/kotlin/com/lambda/module/hud/ModuleList.kt | 3 ++- src/main/kotlin/com/lambda/module/hud/Rotation.kt | 1 + src/main/kotlin/com/lambda/module/hud/TPS.kt | 1 + src/main/kotlin/com/lambda/module/hud/TaskFlowHUD.kt | 1 + src/main/kotlin/com/lambda/module/hud/Watermark.kt | 1 + .../com/lambda/module/modules/network/PacketLogger.kt | 1 + .../com/lambda/module/modules/render/LightLevels.kt | 2 ++ src/main/kotlin/com/lambda/module/modules/render/Zoom.kt | 1 + src/main/kotlin/com/lambda/task/Task.kt | 1 + src/main/kotlin/com/lambda/util/InputUtils.kt | 2 +- src/main/kotlin/com/lambda/util/LambdaResource.kt | 2 ++ src/main/kotlin/com/lambda/util/StringUtils.kt | 1 + src/main/kotlin/com/lambda/util/extension/World.kt | 2 ++ 28 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt b/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt index 8ac6230c9..03b434ae8 100644 --- a/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt @@ -34,6 +34,7 @@ import com.lambda.util.extension.CommandBuilder import com.lambda.util.text.buildText import com.lambda.util.text.literal +@Suppress("unused") object PrefixCommand : LambdaCommand( "prefix", usage = "prefix ", diff --git a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt index 7d03ec086..5c2a27ccb 100644 --- a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt @@ -61,15 +61,14 @@ class StringSetting( } } + @Suppress("unused", "unchecked_cast") companion object { @SettingEditorDsl - @Suppress("unchecked_cast") fun SettingGroupEditor.TypedEditBuilder.multiline(multiline: Boolean) { (settings as Collection).forEach { it.multiline = multiline } } @SettingEditorDsl - @Suppress("unchecked_cast") fun SettingGroupEditor.TypedEditBuilder.flags(flags: Int) { (settings as Collection).forEach { it.flags = flags } } diff --git a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt index d4447898c..6eb4c140c 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt @@ -182,6 +182,7 @@ open class CollectionSetting( value = strList } + @Suppress("unused") companion object { fun , R : Any> Setting>.onSelect(block: SafeContext.(R) -> Unit) = apply { core.selectListeners.add(block) diff --git a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt index 5b0958724..6d82e74c3 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt @@ -195,6 +195,7 @@ class KeybindSetting( } } + @Suppress("unused") companion object { fun Setting.onPress(block: SafeContext.(ButtonEvent) -> Unit) = apply { core.pressListeners.add(block) @@ -210,12 +211,13 @@ class KeybindSetting( } } +@Suppress("unused") data class Bind( val key: Int, val modifiers: Int, val mouse: Int = -1, ) { - val truemods = buildList { + val trueMods = buildList { if (modifiers and GLFW_MOD_SHIFT != 0) add(KeyCode.LeftShift) if (modifiers and GLFW_MOD_CONTROL != 0) add(KeyCode.LeftControl) if (modifiers and GLFW_MOD_ALT != 0) add(KeyCode.LeftAlt) @@ -237,14 +239,14 @@ data class Bind( val list = mutableListOf() if (mouse >= 0) list.add(Mouse.entries[mouse]) - if (modifiers > 0) list.add(truemods.joinToString(separator = "+") { it.name }) + if (modifiers > 0) list.add(trueMods.joinToString(separator = "+") { it.name }) if (key > 0) list.add(KeyCode.fromKeyCode(key)) return list.joinToString(separator = "+") { it.toString() } } override fun toString() = - "Key Code: $key, Modifiers: ${truemods.joinToString(separator = "+") { it.name }}, Mouse Button: ${Mouse.entries.getOrNull(mouse) ?: "None"}" + "Key Code: $key, Modifiers: ${trueMods.joinToString(separator = "+") { it.name }}, Mouse Button: ${Mouse.entries.getOrNull(mouse) ?: "None"}" companion object { val EMPTY = Bind(0, 0, -1) diff --git a/src/main/kotlin/com/lambda/graphics/mc/RegionRenderer.kt b/src/main/kotlin/com/lambda/graphics/mc/RegionRenderer.kt index ff802333d..09ad03afa 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/RegionRenderer.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/RegionRenderer.kt @@ -409,8 +409,6 @@ class RegionRenderer { fun hasData(): Boolean = hasWorldData companion object { - fun createRenderPass(label: String): RenderPass? = createRenderPass(label, useMcDepth = true) - fun createRenderPass(label: String, useMcDepth: Boolean): RenderPass? { val framebuffer = mc.framebuffer ?: return null diff --git a/src/main/kotlin/com/lambda/graphics/outline/OutlineIdBuffer.kt b/src/main/kotlin/com/lambda/graphics/outline/OutlineIdBuffer.kt index 9d2c9c699..d888dabd9 100644 --- a/src/main/kotlin/com/lambda/graphics/outline/OutlineIdBuffer.kt +++ b/src/main/kotlin/com/lambda/graphics/outline/OutlineIdBuffer.kt @@ -100,10 +100,7 @@ object OutlineIdBuffer { fun getSilhouetteDepthView(): GpuTextureView? = depthTextureView fun getTextureView(): GpuTextureView? = idTextureView - - fun getWidth(): Int = bufferWidth - fun getHeight(): Int = bufferHeight - + fun cleanup() { idTextureView?.close() idTexture?.close() diff --git a/src/main/kotlin/com/lambda/graphics/text/SDFFontAtlas.kt b/src/main/kotlin/com/lambda/graphics/text/SDFFontAtlas.kt index d97a31c7e..f8aa51997 100644 --- a/src/main/kotlin/com/lambda/graphics/text/SDFFontAtlas.kt +++ b/src/main/kotlin/com/lambda/graphics/text/SDFFontAtlas.kt @@ -94,14 +94,9 @@ class SDFFontAtlas( val descent: Float val scale: Float - val sdfPixelRange: Float get() = (sdfSpread * 2).toFloat() - val textureView: GpuTextureView? get() = glTextureView - val sampler: GpuSampler? get() = gpuSampler - val isUploaded: Boolean get() = glTexture != null - init { val fontBytes = if (userFont) Path.of(fontPath).readBytes() diff --git a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt index 3b810cc0e..a33b93581 100644 --- a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt +++ b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt @@ -44,6 +44,7 @@ import net.minecraft.client.gui.screen.ChatScreen import kotlin.math.max // ToDo: Add support for searching of menu bar entries +@Suppress("unused") object QuickSearch { private val searchInput = ImString(256) var isOpen = false diff --git a/src/main/kotlin/com/lambda/gui/dsl/ImGuiBuilder.kt b/src/main/kotlin/com/lambda/gui/dsl/ImGuiBuilder.kt index 063f2bd7e..2c027be27 100644 --- a/src/main/kotlin/com/lambda/gui/dsl/ImGuiBuilder.kt +++ b/src/main/kotlin/com/lambda/gui/dsl/ImGuiBuilder.kt @@ -1965,7 +1965,7 @@ object ImGuiBuilder { * @param value Float value * @param block Content of the scope * - * @see imgui.flag.ImGuiStyleVar + * @see com.lambda.imgui.flag.ImGuiStyleVar */ @ImGuiDsl inline fun withStyleVar(styleVar: Int, value: Float, block: ProcedureBlock) { diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/Simulation.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/Simulation.kt index 828a33e6e..817de2a3c 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/Simulation.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/Simulation.kt @@ -36,6 +36,7 @@ import net.minecraft.util.math.Direction import net.minecraft.util.math.Vec3d import java.awt.Color +@Suppress("unused") data class Simulation( val blueprint: Blueprint, private val automated: Automated diff --git a/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PlaceDirection.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PlaceDirection.kt index a85429a90..aa7b4ecdf 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PlaceDirection.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PlaceDirection.kt @@ -23,6 +23,7 @@ import net.minecraft.util.math.Direction import net.minecraft.util.math.MathHelper import net.minecraft.util.math.Vec3i +@Suppress("unused") enum class PlaceDirection( val rotation: Rotation, val vector: Vec3i, diff --git a/src/main/kotlin/com/lambda/module/hud/AccountName.kt b/src/main/kotlin/com/lambda/module/hud/AccountName.kt index 50bdb26a2..7b81bdaa3 100644 --- a/src/main/kotlin/com/lambda/module/hud/AccountName.kt +++ b/src/main/kotlin/com/lambda/module/hud/AccountName.kt @@ -22,6 +22,7 @@ import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe +@Suppress("unused") object AccountName : HudModule( name = "AccountName", description = "Displays the current accounts name", diff --git a/src/main/kotlin/com/lambda/module/hud/Baritone.kt b/src/main/kotlin/com/lambda/module/hud/Baritone.kt index 7d44fb755..2dc0d0771 100644 --- a/src/main/kotlin/com/lambda/module/hud/Baritone.kt +++ b/src/main/kotlin/com/lambda/module/hud/Baritone.kt @@ -23,6 +23,7 @@ import com.lambda.interaction.construction.simulation.BuildGoal import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag +@Suppress("unused") object Baritone : HudModule( name = "Baritone", description = "Look inside of Baritones head", diff --git a/src/main/kotlin/com/lambda/module/hud/Coordinates.kt b/src/main/kotlin/com/lambda/module/hud/Coordinates.kt index dcc9b7360..7162b5da0 100644 --- a/src/main/kotlin/com/lambda/module/hud/Coordinates.kt +++ b/src/main/kotlin/com/lambda/module/hud/Coordinates.kt @@ -31,6 +31,7 @@ import com.lambda.util.math.Vec2d import com.lambda.util.math.netherCoord import com.lambda.util.math.overworldCoord +@Suppress("unused") object Coordinates : HudModule( name = "Coordinates", description = "Show your coordinates", diff --git a/src/main/kotlin/com/lambda/module/hud/FPS.kt b/src/main/kotlin/com/lambda/module/hud/FPS.kt index e8846fa96..02a400ef1 100644 --- a/src/main/kotlin/com/lambda/module/hud/FPS.kt +++ b/src/main/kotlin/com/lambda/module/hud/FPS.kt @@ -25,6 +25,7 @@ import com.lambda.module.tag.ModuleTag import com.lambda.util.collections.LimitedDecayQueue import kotlin.time.Duration.Companion.seconds +@Suppress("unused") object FPS : HudModule( name = "FPS", description = "Displays your games frames per second", diff --git a/src/main/kotlin/com/lambda/module/hud/ModuleList.kt b/src/main/kotlin/com/lambda/module/hud/ModuleList.kt index ba87c8064..cd438fbc2 100644 --- a/src/main/kotlin/com/lambda/module/hud/ModuleList.kt +++ b/src/main/kotlin/com/lambda/module/hud/ModuleList.kt @@ -24,6 +24,7 @@ import com.lambda.module.ModuleRegistry import com.lambda.module.tag.ModuleTag import java.awt.Color +@Suppress("unused") object ModuleList : HudModule( name = "ModuleList", tag = ModuleTag.HUD, @@ -41,7 +42,7 @@ object ModuleList : HudModule( enabled.forEach { val bound = it.keybind.key != 0 || it.keybind.mouse != -1 if (onlyBound && !bound) return@forEach - text(it.name); + text(it.name) if (showKeybind) { val color = if (!bound) Color.RED else Color.GREEN diff --git a/src/main/kotlin/com/lambda/module/hud/Rotation.kt b/src/main/kotlin/com/lambda/module/hud/Rotation.kt index c79ff7b0e..22f244658 100644 --- a/src/main/kotlin/com/lambda/module/hud/Rotation.kt +++ b/src/main/kotlin/com/lambda/module/hud/Rotation.kt @@ -25,6 +25,7 @@ import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe import com.lambda.util.Formatting.format +@Suppress("unused") object Rotation : HudModule( name = "Rotation", description = "Show your rotation", diff --git a/src/main/kotlin/com/lambda/module/hud/TPS.kt b/src/main/kotlin/com/lambda/module/hud/TPS.kt index 228b43c7a..2198a7a21 100644 --- a/src/main/kotlin/com/lambda/module/hud/TPS.kt +++ b/src/main/kotlin/com/lambda/module/hud/TPS.kt @@ -25,6 +25,7 @@ import com.lambda.util.Formatting.format import com.lambda.util.ServerTPS import com.lambda.util.ServerTPS.recentData +@Suppress("unused") object TPS : HudModule( name = "TPS", description = "Display the server's tick rate", diff --git a/src/main/kotlin/com/lambda/module/hud/TaskFlowHUD.kt b/src/main/kotlin/com/lambda/module/hud/TaskFlowHUD.kt index a9577b1c2..eb9b4a789 100644 --- a/src/main/kotlin/com/lambda/module/hud/TaskFlowHUD.kt +++ b/src/main/kotlin/com/lambda/module/hud/TaskFlowHUD.kt @@ -22,6 +22,7 @@ import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag import com.lambda.task.RootTask +@Suppress("unused") object TaskFlowHUD : HudModule( name = "TaskFlowHud", tag = ModuleTag.HUD, diff --git a/src/main/kotlin/com/lambda/module/hud/Watermark.kt b/src/main/kotlin/com/lambda/module/hud/Watermark.kt index c89a63f3a..fa46da254 100644 --- a/src/main/kotlin/com/lambda/module/hud/Watermark.kt +++ b/src/main/kotlin/com/lambda/module/hud/Watermark.kt @@ -23,6 +23,7 @@ import com.lambda.imgui.ImGui import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag +@Suppress("unused") object Watermark : HudModule( name = "Watermark", tag = ModuleTag.HUD, diff --git a/src/main/kotlin/com/lambda/module/modules/network/PacketLogger.kt b/src/main/kotlin/com/lambda/module/modules/network/PacketLogger.kt index d44e84c77..3adb35d9c 100644 --- a/src/main/kotlin/com/lambda/module/modules/network/PacketLogger.kt +++ b/src/main/kotlin/com/lambda/module/modules/network/PacketLogger.kt @@ -80,6 +80,7 @@ object PacketLogger : Module( enum class Scope { Any, Whitelist, Blacklist; + @Suppress("unused") fun shouldLog(packet: Packet<*>) = when (this) { Any -> true Whitelist -> false//packet::class.simpleName in whitelist diff --git a/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt b/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt index 919d7d27b..1295bcb5a 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt @@ -150,6 +150,7 @@ object LightLevels : Module( if (mode == Mode.Chunked) chunkedRenderer.rebuildChunk(x, z) } + @Suppress("unused") private fun refreshChunkedRenderer(ctx: SafeContext, from: Any? = null, to: Any? = null) { if (mode == Mode.Chunked) chunkedRenderer.rebuild() } @@ -165,6 +166,7 @@ object LightLevels : Module( Circle } + @Suppress("unused") private enum class AreaMode(val player: Boolean, val camera: Boolean) { Both(true, true), Camera(false, true), diff --git a/src/main/kotlin/com/lambda/module/modules/render/Zoom.kt b/src/main/kotlin/com/lambda/module/modules/render/Zoom.kt index 9b43ba327..d991feb93 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Zoom.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Zoom.kt @@ -82,6 +82,7 @@ object Zoom : Module( if (lerpedZoom == targetZoom) lerpedZoom = targetZoom } + @Suppress("unused") private enum class ZoomStyle( override val displayName: String, val apply: (Float, Float, Float) -> Float, diff --git a/src/main/kotlin/com/lambda/task/Task.kt b/src/main/kotlin/com/lambda/task/Task.kt index 4be66c5e0..53eb08812 100644 --- a/src/main/kotlin/com/lambda/task/Task.kt +++ b/src/main/kotlin/com/lambda/task/Task.kt @@ -37,6 +37,7 @@ typealias TaskGenerator = SafeContext.(R) -> Task<*> typealias TaskGeneratorOrNull = SafeContext.(R) -> Task<*>? typealias TaskGeneratorUnit = SafeContext.(R) -> Unit +@Suppress("unused") abstract class Task : Nameable, Muteable { var parent: Task<*>? = null var parentPausing = false diff --git a/src/main/kotlin/com/lambda/util/InputUtils.kt b/src/main/kotlin/com/lambda/util/InputUtils.kt index f4fd68bfa..7152bf075 100644 --- a/src/main/kotlin/com/lambda/util/InputUtils.kt +++ b/src/main/kotlin/com/lambda/util/InputUtils.kt @@ -88,7 +88,7 @@ object InputUtils { fun Bind.isSatisfied(): Boolean = (key == -1 || glfwGetKey(mc.window.handle, key).pressedOrRepeated) && (mouse == -1 || glfwGetMouseButton(mc.window.handle, mouse).pressedOrRepeated) && - truemods.all { glfwGetKey(mc.window.handle, it.code).pressedOrRepeated } + trueMods.all { glfwGetKey(mc.window.handle, it.code).pressedOrRepeated } private val Int.pressedOrRepeated get() = this == 1 || this == 2 diff --git a/src/main/kotlin/com/lambda/util/LambdaResource.kt b/src/main/kotlin/com/lambda/util/LambdaResource.kt index d9406f0c4..6bfd43650 100644 --- a/src/main/kotlin/com/lambda/util/LambdaResource.kt +++ b/src/main/kotlin/com/lambda/util/LambdaResource.kt @@ -15,6 +15,8 @@ * along with this program. If not, see . */ +@file:Suppress("unused") + package com.lambda.util import com.lambda.Lambda diff --git a/src/main/kotlin/com/lambda/util/StringUtils.kt b/src/main/kotlin/com/lambda/util/StringUtils.kt index 737212a48..c3426b1e5 100644 --- a/src/main/kotlin/com/lambda/util/StringUtils.kt +++ b/src/main/kotlin/com/lambda/util/StringUtils.kt @@ -23,6 +23,7 @@ import net.minecraft.util.Identifier import java.security.MessageDigest import java.util.* +@Suppress("unused") object StringUtils { fun String.sanitizeForFilename() = replace(Regex("[\\\\/:*?\"<>|]"), "_") diff --git a/src/main/kotlin/com/lambda/util/extension/World.kt b/src/main/kotlin/com/lambda/util/extension/World.kt index 53bd7bef8..781b5c0b1 100644 --- a/src/main/kotlin/com/lambda/util/extension/World.kt +++ b/src/main/kotlin/com/lambda/util/extension/World.kt @@ -15,6 +15,8 @@ * along with this program. If not, see . */ +@file:Suppress("unused") + package com.lambda.util.extension import com.lambda.Lambda.mc From 6c74d35d7fa654cc29529a229d1d20a74a1de73a Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Thu, 30 Apr 2026 18:26:18 +0100 Subject: [PATCH 05/40] checkpoint; doesnt compile in the slightest. About a million errors --- src/main/kotlin/com/lambda/Lambda.kt | 45 +----- .../com/lambda/brigadier/CommandExecution.kt | 4 +- .../com/lambda/command/CommandHandler.kt | 8 +- .../com/lambda/command/CommandRegistry.kt | 8 +- .../com/lambda/command/LambdaCommand.kt | 2 +- .../lambda/command/commands/BuildCommand.kt | 4 +- .../lambda/command/commands/CapeCommand.kt | 4 +- .../lambda/command/commands/ConfigCommand.kt | 38 +++-- .../lambda/command/commands/FriendCommand.kt | 6 +- .../lambda/command/commands/ModuleCommand.kt | 6 +- .../lambda/command/commands/PrefixCommand.kt | 12 +- .../lambda/command/commands/ReplayCommand.kt | 6 +- .../lambda/command/commands/TaskCommand.kt | 2 +- .../command/commands/TransferCommand.kt | 4 +- src/main/kotlin/com/lambda/config/Codec.kt | 7 +- .../config/{Configurable.kt => Config.kt} | 87 ++++++----- .../{Configuration.kt => ConfigCategory.kt} | 61 +++----- .../kotlin/com/lambda/config/ConfigEditor.kt | 8 +- .../{configurations => }/ConfigLoader.kt | 23 ++- src/main/kotlin/com/lambda/config/Setting.kt | 143 ++++++++---------- .../kotlin/com/lambda/config/SettingGroup.kt | 2 +- .../{ => automation}/AutomationConfig.kt | 10 +- .../IMutableAutomationConfig.kt | 14 +- .../{ => automation}/UserAutomationConfig.kt | 6 +- .../AutomationCategory.kt} | 10 +- .../FontCategory.kt} | 11 +- .../FriendCategory.kt} | 10 +- .../GuiCategory.kt} | 10 +- .../HudCategory.kt} | 10 +- .../LambdaCategory.kt} | 10 +- .../ModuleCategory.kt} | 16 +- .../SecretsCategory.kt} | 10 +- .../UserAutomationCategory.kt} | 14 +- .../{serializer => codecs}/BlockCodec.kt | 4 +- .../{serializer => codecs}/BlockPosCodec.kt | 7 +- .../{serializer => codecs}/ColorCodec.kt | 6 +- .../GameProfileCodec.kt | 5 +- .../{serializer => codecs}/ItemCodec.kt | 4 +- .../{serializer => codecs}/ItemStackCodec.kt | 5 +- .../{serializer => codecs}/KeyCodeCodec.kt | 6 +- .../{serializer => codecs}/OptionalCodec.kt | 5 +- .../{serializer => codecs}/TextCodec.kt | 5 +- .../{serializer => codecs}/UUIDCodec.kt | 6 +- .../breaking => config/groups}/BreakConfig.kt | 7 +- .../com/lambda/config/groups/BreakSettings.kt | 16 +- .../com/lambda/config/groups/BuildSettings.kt | 10 +- .../com/lambda/config/groups/EatSettings.kt | 10 +- .../config/groups/EntityColorSettings.kt | 4 +- .../config/groups/EntitySelectionSettings.kt | 4 +- .../lambda/config/groups/FormatterSettings.kt | 10 +- .../hotbar => config/groups}/HotbarConfig.kt | 2 +- .../lambda/config/groups/HotbarSettings.kt | 12 +- .../groups}/InteractConfig.kt | 19 +-- .../lambda/config/groups/InteractSettings.kt | 16 +- .../groups}/InventoryConfig.kt | 4 +- .../lambda/config/groups/InventorySettings.kt | 12 +- .../lambda/config/groups/OutlineSettings.kt | 4 +- .../groups}/RotationConfig.kt | 43 +++++- .../lambda/config/groups/RotationSettings.kt | 12 +- .../config/groups/ScreenLineSettings.kt | 4 +- .../config/groups/ScreenTextSettings.kt | 10 +- .../{Targeting.kt => TargetingSettings.kt} | 16 +- .../lambda/config/groups/WorldLineSettings.kt | 10 +- .../lambda/config/groups/WorldTextSettings.kt | 4 +- .../com/lambda/config/migration/Migrations.kt | 2 +- .../migrations/FriendConfigMigration.kt | 7 +- .../com/lambda/config/settings/CharSetting.kt | 2 +- .../lambda/config/settings/FunctionSetting.kt | 2 - .../lambda/config/settings/NumericSetting.kt | 2 +- .../lambda/config/settings/StringSetting.kt | 2 +- .../collections/BlockCollectionSetting.kt | 2 +- .../collections/ClassCollectionSetting.kt | 6 +- .../settings/collections/CollectionSetting.kt | 4 +- .../collections/ItemCollectionSetting.kt | 2 +- .../config/settings/collections/MapSetting.kt | 2 +- .../settings/comparable/BooleanSetting.kt | 2 +- .../config/settings/comparable/EnumSetting.kt | 3 +- .../settings/complex/BlockPosSetting.kt | 4 +- .../config/settings/complex/BlockSetting.kt | 2 +- .../config/settings/complex/ColorSetting.kt | 2 +- .../config/settings/numeric/DoubleSetting.kt | 2 +- .../config/settings/numeric/FloatSetting.kt | 2 +- .../config/settings/numeric/IntegerSetting.kt | 2 +- .../config/settings/numeric/LongSetting.kt | 2 +- .../kotlin/com/lambda/context/Automated.kt | 10 +- src/main/kotlin/com/lambda/core/Loader.kt | 4 +- .../kotlin/com/lambda/friend/FriendHandler.kt | 6 +- .../com/lambda/graphics/text/FontHandler.kt | 10 +- src/main/kotlin/com/lambda/gui/MenuBar.kt | 55 ++++--- .../lambda/gui/components/ClickGuiLayout.kt | 6 +- .../com/lambda/gui/components/HudGuiLayout.kt | 6 +- .../com/lambda/gui/components/QuickSearch.kt | 22 +-- .../lambda/gui/components/SettingsWidget.kt | 19 +-- .../com/lambda/interaction/BaritoneHandler.kt | 8 +- .../construction/StructureRegistry.kt | 6 +- .../construction/simulation/Sim.kt | 6 +- .../simulation/checks/BasicChecker.kt | 2 +- .../simulation/checks/InteractSim.kt | 4 +- .../processing/ProcessorRegistry.kt | 2 +- .../interaction/managers/ManagerUtils.kt | 2 +- .../managers/breaking/BreakInfo.kt | 1 + .../managers/breaking/BreakManager.kt | 5 +- .../managers/breaking/BrokenBlockHandler.kt | 6 +- .../managers/breaking/RebreakHandler.kt | 1 + .../interaction/managers/breaking/SwapInfo.kt | 3 +- .../managers/hotbar/HotbarManager.kt | 4 +- .../managers/interacting/InteractInfo.kt | 1 + .../managers/interacting/InteractManager.kt | 8 +- .../interacting/InteractedBlockHandler.kt | 5 +- .../managers/inventory/InventoryRequest.kt | 5 +- .../rotating/visibilty/PointSelection.kt | 53 ------- .../rotating/visibilty/RotationTargets.kt | 67 -------- .../material/container/ContainerHandler.kt | 2 +- src/main/kotlin/com/lambda/module/Module.kt | 18 +-- .../com/lambda/module/ModuleRegistry.kt | 3 +- .../com/lambda/module/hud/Coordinates.kt | 2 +- .../kotlin/com/lambda/module/hud/Rotation.kt | 2 +- src/main/kotlin/com/lambda/module/hud/TPS.kt | 8 +- .../lambda/module/modules/chat/AntiSpam.kt | 4 +- .../module/modules/chat/ChatTimestamp.kt | 2 +- .../module/modules/chat/FriendHighlight.kt | 2 +- .../module/modules/client/AutoUpdater.kt | 6 +- .../lambda/module/modules/client/Discord.kt | 2 +- .../lambda/module/modules/combat/AutoArmor.kt | 2 +- .../module/modules/combat/AutoDisconnect.kt | 10 +- .../lambda/module/modules/combat/AutoTotem.kt | 2 +- .../lambda/module/modules/combat/Criticals.kt | 5 +- .../module/modules/combat/CrystalAura.kt | 12 +- .../lambda/module/modules/combat/KillAura.kt | 8 +- .../module/modules/combat/PlayerTrap.kt | 2 +- .../lambda/module/modules/combat/Surround.kt | 2 +- .../lambda/module/modules/debug/FallTest.kt | 2 +- .../module/modules/debug/InventoryDebug.kt | 2 +- .../module/modules/debug/PropertyPrinter.kt | 4 +- .../module/modules/debug/RotationTest.kt | 2 +- .../lambda/module/modules/debug/SilentSwap.kt | 2 +- .../lambda/module/modules/debug/StateInfo.kt | 2 +- .../lambda/module/modules/debug/TimerTest.kt | 2 +- .../module/modules/movement/BetterFirework.kt | 4 +- .../modules/movement/ElytraAltitudeControl.kt | 4 +- .../module/modules/movement/ElytraFly.kt | 2 +- .../lambda/module/modules/movement/NoFall.kt | 5 +- .../lambda/module/modules/movement/Speed.kt | 2 +- .../module/modules/movement/TickShift.kt | 2 +- .../module/modules/network/PacketLimiter.kt | 4 +- .../module/modules/network/PacketLogger.kt | 14 +- .../module/modules/network/Rubberband.kt | 2 +- .../module/modules/network/ServerSpoof.kt | 2 +- .../lambda/module/modules/player/AutoEat.kt | 2 +- .../module/modules/player/ClickFriend.kt | 2 +- .../lambda/module/modules/player/FastBreak.kt | 2 +- .../module/modules/player/InventoryMove.kt | 2 +- .../module/modules/player/InventoryTweaks.kt | 2 +- .../module/modules/player/PacketMine.kt | 4 +- .../lambda/module/modules/player/Replay.kt | 16 +- .../module/modules/player/StackReplenish.kt | 2 +- .../lambda/module/modules/player/ToolSaver.kt | 2 +- .../lambda/module/modules/render/Freecam.kt | 2 +- .../lambda/module/modules/render/NoRender.kt | 2 +- .../lambda/module/modules/render/Tracers.kt | 12 +- .../lambda/module/modules/world/AirPlace.kt | 2 +- .../lambda/module/modules/world/AutoPortal.kt | 7 +- .../lambda/module/modules/world/AutoSign.kt | 5 +- .../module/modules/world/AutoVillagerCycle.kt | 6 +- .../module/modules/world/HighwayTools.kt | 4 +- .../module/modules/world/MapDownloader.kt | 4 +- .../com/lambda/module/modules/world/Nuker.kt | 2 +- .../lambda/module/modules/world/Printer.kt | 4 +- .../lambda/module/modules/world/Scaffold.kt | 4 +- .../lambda/module/modules/world/StashMover.kt | 10 +- .../kotlin/com/lambda/network/CapeHandler.kt | 8 +- .../kotlin/com/lambda/network/LambdaAPI.kt | 6 +- .../com/lambda/network/NetworkHandler.kt | 6 +- src/main/kotlin/com/lambda/task/Task.kt | 2 +- .../kotlin/com/lambda/task/tasks/BuildTask.kt | 2 +- ...Communication.kt => CommunicationUtils.kt} | 9 +- .../kotlin/com/lambda/util/DebugInfoHud.kt | 62 -------- .../util/DynamicReflectionSerializer.kt | 2 +- .../kotlin/com/lambda/util/EntityUtils.kt | 1 - .../{FolderRegister.kt => FolderRegistry.kt} | 4 +- .../{Formatting.kt => FormattingUtils.kt} | 2 +- .../visibilty => util}/PlaceDirection.kt | 10 +- .../kotlin/com/lambda/util/ReflectionUtils.kt | 103 +++++++++++++ .../util/{ServerTPS.kt => ServerTPSUtils.kt} | 2 +- .../player/RotationUtils.kt} | 46 +++++- .../lambda/util/reflections/Reflections.kt | 96 ------------ src/test/kotlin/PlaceDirectionTest.kt | 2 +- 187 files changed, 886 insertions(+), 1000 deletions(-) rename src/main/kotlin/com/lambda/config/{Configurable.kt => Config.kt} (85%) rename src/main/kotlin/com/lambda/config/{Configuration.kt => ConfigCategory.kt} (77%) rename src/main/kotlin/com/lambda/config/{configurations => }/ConfigLoader.kt (53%) rename src/main/kotlin/com/lambda/config/{ => automation}/AutomationConfig.kt (90%) rename src/main/kotlin/com/lambda/config/{ => automation}/IMutableAutomationConfig.kt (88%) rename src/main/kotlin/com/lambda/config/{ => automation}/UserAutomationConfig.kt (92%) rename src/main/kotlin/com/lambda/config/{configurations/AutomationConfigs.kt => categories/AutomationCategory.kt} (77%) rename src/main/kotlin/com/lambda/config/{configurations/FontConfig.kt => categories/FontCategory.kt} (77%) rename src/main/kotlin/com/lambda/config/{configurations/FriendConfig.kt => categories/FriendCategory.kt} (77%) rename src/main/kotlin/com/lambda/config/{configurations/GuiConfig.kt => categories/GuiCategory.kt} (81%) rename src/main/kotlin/com/lambda/config/{configurations/HudConfig.kt => categories/HudCategory.kt} (77%) rename src/main/kotlin/com/lambda/config/{configurations/LambdaConfig.kt => categories/LambdaCategory.kt} (77%) rename src/main/kotlin/com/lambda/config/{configurations/ModuleConfigs.kt => categories/ModuleCategory.kt} (69%) rename src/main/kotlin/com/lambda/config/{configurations/SecretsConfig.kt => categories/SecretsCategory.kt} (77%) rename src/main/kotlin/com/lambda/config/{configurations/UserAutomationConfigs.kt => categories/UserAutomationCategory.kt} (81%) rename src/main/kotlin/com/lambda/config/{serializer => codecs}/BlockCodec.kt (95%) rename src/main/kotlin/com/lambda/config/{serializer => codecs}/BlockPosCodec.kt (91%) rename src/main/kotlin/com/lambda/config/{serializer => codecs}/ColorCodec.kt (91%) rename src/main/kotlin/com/lambda/config/{serializer => codecs}/GameProfileCodec.kt (95%) rename src/main/kotlin/com/lambda/config/{serializer => codecs}/ItemCodec.kt (95%) rename src/main/kotlin/com/lambda/config/{serializer => codecs}/ItemStackCodec.kt (94%) rename src/main/kotlin/com/lambda/config/{serializer => codecs}/KeyCodeCodec.kt (89%) rename src/main/kotlin/com/lambda/config/{serializer => codecs}/OptionalCodec.kt (93%) rename src/main/kotlin/com/lambda/config/{serializer => codecs}/TextCodec.kt (94%) rename src/main/kotlin/com/lambda/config/{serializer => codecs}/UUIDCodec.kt (92%) rename src/main/kotlin/com/lambda/{interaction/managers/breaking => config/groups}/BreakConfig.kt (96%) rename src/main/kotlin/com/lambda/{interaction/managers/hotbar => config/groups}/HotbarConfig.kt (97%) rename src/main/kotlin/com/lambda/{interaction/managers/interacting => config/groups}/InteractConfig.kt (81%) rename src/main/kotlin/com/lambda/{interaction/managers/inventory => config/groups}/InventoryConfig.kt (98%) rename src/main/kotlin/com/lambda/{interaction/managers/rotating => config/groups}/RotationConfig.kt (54%) rename src/main/kotlin/com/lambda/config/groups/{Targeting.kt => TargetingSettings.kt} (95%) delete mode 100644 src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PointSelection.kt delete mode 100644 src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/RotationTargets.kt rename src/main/kotlin/com/lambda/util/{Communication.kt => CommunicationUtils.kt} (97%) delete mode 100644 src/main/kotlin/com/lambda/util/DebugInfoHud.kt rename src/main/kotlin/com/lambda/util/{FolderRegister.kt => FolderRegistry.kt} (93%) rename src/main/kotlin/com/lambda/util/{Formatting.kt => FormattingUtils.kt} (99%) rename src/main/kotlin/com/lambda/{interaction/managers/rotating/visibilty => util}/PlaceDirection.kt (93%) create mode 100644 src/main/kotlin/com/lambda/util/ReflectionUtils.kt rename src/main/kotlin/com/lambda/util/{ServerTPS.kt => ServerTPSUtils.kt} (98%) rename src/main/kotlin/com/lambda/{interaction/managers/rotating/visibilty/VisibilityChecker.kt => util/player/RotationUtils.kt} (89%) delete mode 100644 src/main/kotlin/com/lambda/util/reflections/Reflections.kt diff --git a/src/main/kotlin/com/lambda/Lambda.kt b/src/main/kotlin/com/lambda/Lambda.kt index 864e18905..10893ab4b 100644 --- a/src/main/kotlin/com/lambda/Lambda.kt +++ b/src/main/kotlin/com/lambda/Lambda.kt @@ -19,39 +19,18 @@ package com.lambda import com.google.gson.Gson import com.google.gson.GsonBuilder -import com.lambda.config.serializer.BlockCodec -import com.lambda.config.serializer.BlockPosCodec -import com.lambda.config.serializer.ColorCodec -import com.lambda.config.serializer.GameProfileCodec -import com.lambda.config.serializer.ItemCodec -import com.lambda.config.serializer.ItemStackCodec -import com.lambda.config.serializer.KeyCodeCodec -import com.lambda.config.serializer.OptionalCodec -import com.lambda.config.serializer.TextCodec -import com.lambda.config.serializer.UUIDCodec +import com.lambda.config.Codec import com.lambda.core.Loader import com.lambda.event.events.ClientEvent import com.lambda.event.listener.UnsafeListener.Companion.listenOnceUnsafe import com.lambda.gui.components.ClickGuiLayout -import com.lambda.util.KeyCode +import com.lambda.util.ReflectionUtils.getInstances import com.lambda.util.WindowUtils.setLambdaWindowIcon -import com.mojang.authlib.GameProfile import net.fabricmc.api.ClientModInitializer import net.fabricmc.loader.api.FabricLoader -import net.minecraft.block.Block import net.minecraft.client.MinecraftClient -import net.minecraft.item.ArrowItem -import net.minecraft.item.BlockItem -import net.minecraft.item.Item -import net.minecraft.item.ItemStack -import net.minecraft.item.PotionItem -import net.minecraft.item.RangedWeaponItem -import net.minecraft.text.Text -import net.minecraft.util.math.BlockPos import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger -import java.awt.Color -import java.util.* object Lambda : ClientModInitializer { const val MOD_NAME = "Lambda" @@ -72,20 +51,12 @@ object Lambda : ClientModInitializer { val gson: Gson = GsonBuilder() .setPrettyPrinting() - .registerTypeAdapter(UUID::class.java, UUIDCodec) - .registerTypeAdapter(KeyCode::class.java, KeyCodeCodec) - .registerTypeAdapter(Color::class.java, ColorCodec) - .registerTypeAdapter(BlockPos::class.java, BlockPosCodec) - .registerTypeAdapter(Block::class.java, BlockCodec) - .registerTypeAdapter(GameProfile::class.java, GameProfileCodec) - .registerTypeAdapter(Optional::class.java, OptionalCodec) - .registerTypeAdapter(ItemStack::class.java, ItemStackCodec) - .registerTypeAdapter(Text::class.java, TextCodec) // ToDo: Find out if needed - .registerTypeAdapter(Item::class.java, ItemCodec) - .registerTypeAdapter(BlockItem::class.java, ItemCodec) - .registerTypeAdapter(ArrowItem::class.java, ItemCodec) - .registerTypeAdapter(PotionItem::class.java, ItemCodec) - .registerTypeAdapter(RangedWeaponItem::class.java, ItemCodec) + .apply { + getInstances>() + .forEach { codec -> + registerTypeAdapter(codec.type, codec) + } + } .create() override fun onInitializeClient() {} // nop diff --git a/src/main/kotlin/com/lambda/brigadier/CommandExecution.kt b/src/main/kotlin/com/lambda/brigadier/CommandExecution.kt index 18f9db656..b709f961c 100644 --- a/src/main/kotlin/com/lambda/brigadier/CommandExecution.kt +++ b/src/main/kotlin/com/lambda/brigadier/CommandExecution.kt @@ -17,7 +17,7 @@ package com.lambda.brigadier -import com.lambda.util.Communication +import com.lambda.util.CommunicationUtils import com.mojang.brigadier.Command import com.mojang.brigadier.builder.ArgumentBuilder import com.mojang.brigadier.context.CommandContext @@ -53,7 +53,7 @@ sealed class CommandResult { } fun failure(message: String): Failure { - return Failure(Communication.LogLevel.Error.text(message)) + return Failure(CommunicationUtils.LogLevel.Error.text(message)) } /** Creates a [CommandResult.Failure] with the given throwable [t]. */ diff --git a/src/main/kotlin/com/lambda/command/CommandHandler.kt b/src/main/kotlin/com/lambda/command/CommandHandler.kt index e9e1e1a69..881abc037 100644 --- a/src/main/kotlin/com/lambda/command/CommandHandler.kt +++ b/src/main/kotlin/com/lambda/command/CommandHandler.kt @@ -21,8 +21,8 @@ import com.lambda.brigadier.CommandException import com.lambda.command.CommandRegistry.prefix import com.lambda.context.SafeContext import com.lambda.threading.runSafe -import com.lambda.util.Communication -import com.lambda.util.Communication.logError +import com.lambda.util.CommunicationUtils +import com.lambda.util.CommunicationUtils.logError import com.lambda.util.text.ClickEvents.suggestCommand import com.lambda.util.text.buildText import com.lambda.util.text.clickEvent @@ -103,11 +103,11 @@ object CommandHandler { literal(syntax.input.substring(max(0, (position - ERROR_PADDING)), position)) } if (position < syntax.input.length) { - styled(color = Communication.LogLevel.Error.logoColor, underlined = true) { + styled(color = CommunicationUtils.LogLevel.Error.logoColor, underlined = true) { literal(syntax.input.substring(position)) } } - styled(color = Communication.LogLevel.Error.logoColor, italic = true) { + styled(color = CommunicationUtils.LogLevel.Error.logoColor, italic = true) { translatable("command.context.here") } } diff --git a/src/main/kotlin/com/lambda/command/CommandRegistry.kt b/src/main/kotlin/com/lambda/command/CommandRegistry.kt index aba5f0d45..a784a0e33 100644 --- a/src/main/kotlin/com/lambda/command/CommandRegistry.kt +++ b/src/main/kotlin/com/lambda/command/CommandRegistry.kt @@ -18,16 +18,16 @@ package com.lambda.command import com.lambda.command.CommandHandler.dispatcher -import com.lambda.config.Configurable -import com.lambda.config.configurations.LambdaConfig +import com.lambda.config.Config +import com.lambda.config.categories.LambdaCategory import com.lambda.core.Loadable -import com.lambda.util.reflections.getInstances +import com.lambda.util.ReflectionUtils.getInstances import com.mojang.brigadier.tree.CommandNode /** * The [CommandRegistry] object is responsible for managing all [LambdaCommand] instances in the system. */ -object CommandRegistry : Configurable(LambdaConfig), Loadable { +object CommandRegistry : Config(LambdaCategory), Loadable { override val priority get() = -2 override val name = "command" val prefix by setting("prefix", ';') diff --git a/src/main/kotlin/com/lambda/command/LambdaCommand.kt b/src/main/kotlin/com/lambda/command/LambdaCommand.kt index 9092c3a52..6410f8fcb 100644 --- a/src/main/kotlin/com/lambda/command/LambdaCommand.kt +++ b/src/main/kotlin/com/lambda/command/LambdaCommand.kt @@ -22,7 +22,7 @@ import com.lambda.brigadier.execute import com.lambda.brigadier.required import com.lambda.command.CommandHandler.dispatcher import com.lambda.core.Loadable -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.Nameable import com.lambda.util.extension.CommandBuilder import com.lambda.util.text.ClickEvents diff --git a/src/main/kotlin/com/lambda/command/commands/BuildCommand.kt b/src/main/kotlin/com/lambda/command/commands/BuildCommand.kt index 3da8b5c0e..51e93f749 100644 --- a/src/main/kotlin/com/lambda/command/commands/BuildCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/BuildCommand.kt @@ -25,7 +25,7 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required import com.lambda.command.LambdaCommand -import com.lambda.config.AutomationConfig +import com.lambda.config.automation.AutomationConfig import com.lambda.interaction.construction.StructureRegistry import com.lambda.interaction.construction.blueprint.Blueprint.Companion.toStructure import com.lambda.interaction.construction.blueprint.StaticBlueprint.Companion.toBlueprint @@ -33,7 +33,7 @@ import com.lambda.task.RootTask.run import com.lambda.task.tasks.BuildTask import com.lambda.task.tasks.BuildTask.Companion.build import com.lambda.threading.runSafe -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.extension.CommandBuilder import com.lambda.util.extension.move import net.minecraft.command.CommandSource.suggestMatching diff --git a/src/main/kotlin/com/lambda/command/commands/CapeCommand.kt b/src/main/kotlin/com/lambda/command/commands/CapeCommand.kt index bd705a92e..654384223 100644 --- a/src/main/kotlin/com/lambda/command/commands/CapeCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/CapeCommand.kt @@ -25,8 +25,8 @@ import com.lambda.brigadier.required import com.lambda.command.LambdaCommand import com.lambda.network.CapeHandler.availableCapes import com.lambda.network.CapeHandler.updateCape -import com.lambda.util.Communication.info -import com.lambda.util.Communication.logError +import com.lambda.util.CommunicationUtils.info +import com.lambda.util.CommunicationUtils.logError import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandSource.suggestMatching diff --git a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt index 306289c48..610b7b2c0 100644 --- a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt @@ -25,58 +25,56 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required import com.lambda.command.LambdaCommand -import com.lambda.config.Configuration -import com.lambda.util.Communication.info +import com.lambda.config.ConfigLoader +import com.lambda.util.CommunicationUtils.info import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandSource.suggestMatching object ConfigCommand : LambdaCommand( name = "config", aliases = setOf("cfg", "settings", "setting"), - usage = "config ", + usage = "config ", description = "Save or load configuration files, or set any settings value", examples = listOf("config save", "config load", "config set HighwayTools Pavement_Material minecraft:obsidian") ) { override fun CommandBuilder.create() { required(literal("save")) { executeWithResult { - Configuration.configurations.forEach { config -> + ConfigLoader.configCategories.forEach { config -> config.trySave(true) } - this@ConfigCommand.info("Saved ${Configuration.configurations.size} configuration files.") + this@ConfigCommand.info("Saved ${ConfigLoader.configCategories.size} configuration files.") return@executeWithResult success() } } required(literal("load")) { executeWithResult { - Configuration.configurations.forEach { config -> + ConfigLoader.configCategories.forEach { config -> config.tryLoad() } - this@ConfigCommand.info("Loaded ${Configuration.configurations.size} configuration files.") + this@ConfigCommand.info("Loaded ${ConfigLoader.configCategories.size} configuration files.") return@executeWithResult success() } } required(literal("reset")) { required(string("config")) { config -> suggests { _, builder -> - suggestMatching(Configuration.configurables.map { it.commandName }, builder) + suggestMatching(ConfigLoader.configs.map { it.commandName }, builder) } required(string("setting")) { setting -> suggests { ctx, builder -> val conf = config(ctx).value() - Configuration.configurableByName(conf)?.let { configurable -> - suggestMatching(configurable.settings.map { it.commandName }, builder) + ConfigLoader.configByName(conf)?.let { config -> + suggestMatching(config.settings.map { it.commandName }, builder) } ?: builder.buildFuture() } executeWithResult { - val confName = config().value() + val confName = this.config().value() val settingName = setting().value() - val configurable = Configuration.configurableByCommandName(confName) ?: run { - return@executeWithResult failure("$confName is not a valid configurable.") - } - val setting = Configuration.settingByCommandName(configurable, settingName) ?: run { - return@executeWithResult failure("$settingName is not a valid setting for $confName.") - } + val config = ConfigLoader.configByCommandName(confName) + ?: return@executeWithResult failure("$confName is not a valid config.") + val setting = ConfigLoader.settingByCommandName(config, settingName) + ?: return@executeWithResult failure("$settingName is not a valid setting for $confName.") setting.reset() return@executeWithResult success() } @@ -84,9 +82,9 @@ object ConfigCommand : LambdaCommand( } } required(literal("set")) { - Configuration.configurables.forEach { configurable -> - required(literal(configurable.commandName)) { - configurable.settings.forEach { setting -> + ConfigLoader.configs.forEach { config -> + required(literal(config.commandName)) { + config.settings.forEach { setting -> required(literal(setting.commandName)) { with(setting) { buildCommand(registry) diff --git a/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt b/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt index 4630afacd..3b0a1fa26 100644 --- a/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt @@ -28,11 +28,11 @@ import com.lambda.brigadier.execute import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required import com.lambda.command.LambdaCommand -import com.lambda.config.configurations.FriendConfig +import com.lambda.config.categories.FriendCategory import com.lambda.friend.FriendHandler import com.lambda.network.mojang.getProfile import com.lambda.threading.runIO -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.extension.CommandBuilder import com.lambda.util.text.ClickEvents import com.lambda.util.text.buildText @@ -77,7 +77,7 @@ object FriendCommand : LambdaCommand( styled( color = Color.CYAN, underlined = true, - clickEvent = ClickEvents.openFile(FriendConfig.primary.path), + clickEvent = ClickEvents.openFile(FriendCategory.primary.path), ) { literal("Click to open your friends list as a file") } diff --git a/src/main/kotlin/com/lambda/command/commands/ModuleCommand.kt b/src/main/kotlin/com/lambda/command/commands/ModuleCommand.kt index 7ede06976..a4dfd4a6d 100644 --- a/src/main/kotlin/com/lambda/command/commands/ModuleCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/ModuleCommand.kt @@ -29,9 +29,9 @@ import com.lambda.command.CommandRegistry.prefix import com.lambda.command.LambdaCommand import com.lambda.module.ModuleRegistry import com.lambda.threading.runSafe -import com.lambda.util.Communication.info -import com.lambda.util.Communication.joinToText -import com.lambda.util.Communication.warn +import com.lambda.util.CommunicationUtils.info +import com.lambda.util.CommunicationUtils.joinToText +import com.lambda.util.CommunicationUtils.warn import com.lambda.util.StringUtils.findSimilarStrings import com.lambda.util.extension.CommandBuilder import com.lambda.util.text.ClickEvents.suggestCommand diff --git a/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt b/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt index 03b434ae8..6b98509fd 100644 --- a/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt @@ -26,10 +26,10 @@ import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required import com.lambda.command.CommandRegistry import com.lambda.command.LambdaCommand -import com.lambda.config.Configuration +import com.lambda.config.ConfigLoader import com.lambda.config.Setting import com.lambda.config.SettingCore -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.extension.CommandBuilder import com.lambda.util.text.buildText import com.lambda.util.text.literal @@ -42,19 +42,19 @@ object PrefixCommand : LambdaCommand( ) { // i have no idea why someone would want to use some of these as a prefix // but ig the people who run 20 clients at once could benefit from this - val ptrn = Regex("^[!\"#$%&'()*+,\\-./:;<=>?@\\[\\\\\\]^_`{|}~]$") + val pattern = Regex("^[!\"#$%&'()*+,\\-./:;<=>?@\\[\\\\\\]^_`{|}~]$") override fun CommandBuilder.create() { required(greedyString("prefix")) { prefixStr -> executeWithResult { val prefix = prefixStr().value() - if (!ptrn.matches(prefix)) { + if (!pattern.matches(prefix)) { return@executeWithResult failure("Prefix must be a single non-alphanumeric ASCII character, excluding spaces.") } val prefixChar = prefix.first() - val configurable = Configuration.configurableByName("command") ?: return@executeWithResult failure("No command configurable found.") + val config = ConfigLoader.configByName("command") ?: return@executeWithResult failure("No command config found.") @Suppress("UNCHECKED_CAST") - val setting = configurable.settings.find { it.name == "prefix" } as? Setting, Char> + val setting = config.settings.find { it.name == "prefix" } as? Setting, Char> ?: return@executeWithResult failure("Prefix setting is not a Char or can not be found.") setting.trySetValue(prefixChar) return@executeWithResult success() diff --git a/src/main/kotlin/com/lambda/command/commands/ReplayCommand.kt b/src/main/kotlin/com/lambda/command/commands/ReplayCommand.kt index 3d3685dc4..5aca80603 100644 --- a/src/main/kotlin/com/lambda/command/commands/ReplayCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/ReplayCommand.kt @@ -28,7 +28,7 @@ import com.lambda.brigadier.required import com.lambda.command.LambdaCommand import com.lambda.module.modules.player.Replay import com.lambda.util.FileUtils.listRecursive -import com.lambda.util.FolderRegister +import com.lambda.util.FolderRegistry import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandSource.suggestMatching import kotlin.io.path.exists @@ -50,7 +50,7 @@ object ReplayCommand : LambdaCommand( required(literal("load")) { required(greedyString("replay filepath")) { replayName -> suggests { _, builder -> - val dir = FolderRegister.replay.toFile() + val dir = FolderRegistry.replay.toFile() val paths = dir .listRecursive { it.isFile } .map { it.relativeTo(dir).path } @@ -59,7 +59,7 @@ object ReplayCommand : LambdaCommand( } executeWithResult { - val replayFile = FolderRegister.replay.resolve(replayName().value()) + val replayFile = FolderRegistry.replay.resolve(replayName().value()) if (!replayFile.exists()) { return@executeWithResult CommandResult.failure("Replay file does not exist") diff --git a/src/main/kotlin/com/lambda/command/commands/TaskCommand.kt b/src/main/kotlin/com/lambda/command/commands/TaskCommand.kt index 026eae3fc..75f1fc42b 100644 --- a/src/main/kotlin/com/lambda/command/commands/TaskCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/TaskCommand.kt @@ -22,7 +22,7 @@ import com.lambda.brigadier.execute import com.lambda.brigadier.required import com.lambda.command.LambdaCommand import com.lambda.task.RootTask -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.extension.CommandBuilder object TaskCommand : LambdaCommand( diff --git a/src/main/kotlin/com/lambda/command/commands/TransferCommand.kt b/src/main/kotlin/com/lambda/command/commands/TransferCommand.kt index 08086d1ff..759a51315 100644 --- a/src/main/kotlin/com/lambda/command/commands/TransferCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/TransferCommand.kt @@ -27,7 +27,7 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required import com.lambda.command.LambdaCommand -import com.lambda.config.AutomationConfig +import com.lambda.config.automation.AutomationConfig import com.lambda.interaction.material.StackSelection.Companion.selectStack import com.lambda.interaction.material.container.ContainerHandler import com.lambda.interaction.material.container.ContainerHandler.findContainersWithMaterial @@ -35,7 +35,7 @@ import com.lambda.interaction.material.container.ContainerHandler.findContainers import com.lambda.task.RootTask import com.lambda.task.Task import com.lambda.threading.runSafeAutomated -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandSource.suggestMatching diff --git a/src/main/kotlin/com/lambda/config/Codec.kt b/src/main/kotlin/com/lambda/config/Codec.kt index 8fed5594a..7b0eb7d79 100644 --- a/src/main/kotlin/com/lambda/config/Codec.kt +++ b/src/main/kotlin/com/lambda/config/Codec.kt @@ -19,7 +19,12 @@ package com.lambda.config import com.google.gson.JsonDeserializer import com.google.gson.JsonSerializer +import com.sun.org.apache.bcel.internal.classfile.JavaClass +import java.lang.reflect.Type +import kotlin.jvm.java interface Stringifiable { fun stringify(value: T): String } -interface Codec : JsonSerializer, JsonDeserializer \ No newline at end of file +interface Codec : JsonSerializer, JsonDeserializer { + val type: Type +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/Configurable.kt b/src/main/kotlin/com/lambda/config/Config.kt similarity index 85% rename from src/main/kotlin/com/lambda/config/Configurable.kt rename to src/main/kotlin/com/lambda/config/Config.kt index 021ef3448..e56a5adb7 100644 --- a/src/main/kotlin/com/lambda/config/Configurable.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -21,7 +21,7 @@ import com.google.gson.JsonElement import com.google.gson.JsonObject import com.google.gson.reflect.TypeToken import com.lambda.Lambda.LOG -import com.lambda.config.Configuration.Companion.configurables +import com.lambda.config.ConfigLoader.configs import com.lambda.config.settings.CharSetting import com.lambda.config.settings.FunctionSetting import com.lambda.config.settings.StringSetting @@ -44,7 +44,7 @@ import com.lambda.config.settings.numeric.IntegerSetting import com.lambda.config.settings.numeric.LongSetting import com.lambda.event.Muteable import com.lambda.imgui.flag.ImGuiInputTextFlags -import com.lambda.util.Communication.logError +import com.lambda.util.CommunicationUtils.logError import com.lambda.util.KeyCode import com.lambda.util.Nameable import net.minecraft.block.Block @@ -55,32 +55,25 @@ import net.minecraft.util.math.Vec3d import java.awt.Color /** - * Represents a set of [SettingCore]s that are associated with the [name] of the [Configurable]. - * The settings are managed by this [Configurable] and are saved and loaded as part of the [Configuration]. + * Represents a set of [SettingCore]s that are associated with the [name] of the [Config]. + * The settings are managed by this [Config] and are saved and loaded as part of the [ConfigCategory]. * * This class also provides a series of helper methods ([setting]) for creating different types of settings. * - * @property settings A set of [SettingCore]s that this configurable manages. + * @property settings A set of [SettingCore]s that this config manages. */ -abstract class Configurable( - val configuration: Configuration, -) : Jsonable, Nameable { +abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { val settings = mutableListOf>() - val settingGroups = mutableListOf() init { - registerConfigurable() - } - - private fun registerConfigurable() { - if (configurables.any { it.name == name }) - throw IllegalStateException("Configurable with name $name already exists") - configuration.configurables.add(this) + if (configs.any { it.name == name }) + throw IllegalStateException("Configs with name $name already exists") + configCategory.configs.add(this) } fun , R : Any> Setting.register() = apply { if (settings.any { it.name == name }) - throw IllegalStateException("Setting with name $name already exists for configurable: ${this@Configurable.name}") + throw IllegalStateException("Setting with name $name already exists for config: ${this@Config.name}") settings.add(this) } @@ -107,21 +100,21 @@ abstract class Configurable( defaultValue: Boolean, description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, BooleanSetting(defaultValue), this, visibility).register() + ) = Setting(name, description, BooleanSetting(defaultValue), this, visibility) inline fun > setting( name: String, defaultValue: T, description: String = "", noinline visibility: () -> Boolean = { true }, - ) = Setting(name, description,EnumSetting(defaultValue), this, visibility).register() + ) = Setting(name, description,EnumSetting(defaultValue), this, visibility) fun setting( name: String, defaultValue: Char, description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, CharSetting(defaultValue), this, visibility).register() + ) = Setting(name, description, CharSetting(defaultValue), this, visibility) fun setting( name: String, @@ -130,7 +123,7 @@ abstract class Configurable( flags: Int = ImGuiInputTextFlags.None, description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, StringSetting(defaultValue, multiline, flags), this, visibility).register() + ) = Setting(name, description, StringSetting(defaultValue, multiline, flags), this, visibility) @JvmName("collectionSetting1") fun setting( @@ -139,7 +132,7 @@ abstract class Configurable( immutableCollection: Collection = Registries.BLOCK.toList(), description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, BlockCollectionSetting(immutableCollection, defaultValue.toMutableList()), this, visibility).register() + ) = Setting(name, description, BlockCollectionSetting(immutableCollection, defaultValue.toMutableList()), this, visibility) @JvmName("collectionSetting2") fun setting( @@ -148,7 +141,7 @@ abstract class Configurable( immutableCollection: Collection = Registries.ITEM.toList(), description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, ItemCollectionSetting(immutableCollection, defaultValue.toMutableList()), this, visibility).register() + ) = Setting(name, description, ItemCollectionSetting(immutableCollection, defaultValue.toMutableList()), this, visibility) @JvmName("collectionSetting3") inline fun setting( @@ -166,7 +159,7 @@ abstract class Configurable( else CollectionSetting(defaultValue.toMutableList(), immutableList, TypeToken.getParameterized(Collection::class.java, T::class.java).type, serialize), this, visibility - ).register() + ) // ToDo: Actually implement maps inline fun setting( @@ -183,7 +176,7 @@ abstract class Configurable( ), this, visibility - ).register() + ) fun setting( name: String, @@ -193,7 +186,7 @@ abstract class Configurable( description: String = "", unit: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, DoubleSetting(defaultValue, range, step, unit), this, visibility).register() + ) = Setting(name, description, DoubleSetting(defaultValue, range, step, unit), this, visibility) fun setting( name: String, @@ -203,7 +196,7 @@ abstract class Configurable( description: String = "", unit: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, FloatSetting(defaultValue, range, step, unit), this, visibility).register() + ) = Setting(name, description, FloatSetting(defaultValue, range, step, unit), this, visibility) fun setting( name: String, @@ -213,7 +206,7 @@ abstract class Configurable( description: String = "", unit: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, IntegerSetting(defaultValue, range, step, unit), this, visibility).register() + ) = Setting(name, description, IntegerSetting(defaultValue, range, step, unit), this, visibility) fun setting( name: String, @@ -223,7 +216,7 @@ abstract class Configurable( description: String = "", unit: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, LongSetting(defaultValue, range, step, unit), this, visibility).register() + ) = Setting(name, description, LongSetting(defaultValue, range, step, unit), this, visibility) fun setting( name: String, @@ -232,7 +225,7 @@ abstract class Configurable( alwaysListening: Boolean = false, screenCheck: Boolean = true, visibility: () -> Boolean = { true }, - ) = Setting(name, description, KeybindSetting(defaultValue, this as? Muteable, alwaysListening, screenCheck), this, visibility).register() + ) = Setting(name, description, KeybindSetting(defaultValue, this as? Muteable, alwaysListening, screenCheck), this, visibility) fun setting( name: String, @@ -241,47 +234,67 @@ abstract class Configurable( alwaysListening: Boolean = false, screenCheck: Boolean = true, visibility: () -> Boolean = { true }, - ) = Setting(name, description, KeybindSetting(defaultValue, this as? Muteable, alwaysListening, screenCheck), this, visibility).register() + ) = Setting(name, description, KeybindSetting(defaultValue, this as? Muteable, alwaysListening, screenCheck), this, visibility) fun setting( name: String, defaultValue: Color, description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, ColorSetting(defaultValue), this, visibility).register() + ) = Setting(name, description, ColorSetting(defaultValue), this, visibility) fun setting( name: String, defaultValue: Vec3d, description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, Vec3dSetting(defaultValue), this, visibility).register() + ) = Setting(name, description, Vec3dSetting(defaultValue), this, visibility) fun setting( name: String, defaultValue: BlockPos.Mutable, description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, BlockPosSetting(defaultValue), this, visibility).register() + ) = Setting(name, description, BlockPosSetting(defaultValue), this, visibility) fun setting( name: String, defaultValue: BlockPos, description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, BlockPosSetting(defaultValue), this, visibility).register() + ) = Setting(name, description, BlockPosSetting(defaultValue), this, visibility) fun setting( name: String, defaultValue: Block, description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, BlockSetting(defaultValue), this, visibility).register() + ) = Setting(name, description, BlockSetting(defaultValue), this, visibility) fun setting( name: String, defaultValue: () -> Unit, description: String = "", visibility: () -> Boolean = { true } - ) = Setting(name, description, FunctionSetting(defaultValue), this, visibility).register() + ) = Setting(name, description, FunctionSetting(defaultValue), this, visibility) + + @Target(AnnotationTarget.PROPERTY) + @Retention(AnnotationRetention.RUNTIME) + annotation class Tab(vararg val tab: String) + + @Target(AnnotationTarget.PROPERTY) + @Retention(AnnotationRetention.RUNTIME) + annotation class Group(vararg val group: String) + + @Suppress("unused") + object StandardTabs { + const val GENERAL_TAB = "General" + const val RENDER_TAB = "Render" + } + + @Suppress("unused") + object StandardGroups { + const val GENERAL_GROUP = "General" + const val RENDER_GROUP = "Render" + } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/Configuration.kt b/src/main/kotlin/com/lambda/config/ConfigCategory.kt similarity index 77% rename from src/main/kotlin/com/lambda/config/Configuration.kt rename to src/main/kotlin/com/lambda/config/ConfigCategory.kt index 8b70fca13..5b053cc7e 100644 --- a/src/main/kotlin/com/lambda/config/Configuration.kt +++ b/src/main/kotlin/com/lambda/config/ConfigCategory.kt @@ -24,15 +24,16 @@ import com.google.gson.JsonParser import com.google.gson.JsonSyntaxException import com.lambda.Lambda.LOG import com.lambda.Lambda.gson -import com.lambda.config.Configuration.Companion.configurables -import com.lambda.config.configurations.ModuleConfigs +import com.lambda.config.ConfigLoader.configByName +import com.lambda.config.ConfigLoader.configCategories +import com.lambda.config.categories.ModuleCategory import com.lambda.config.migration.ConfigMigrations import com.lambda.core.Loadable import com.lambda.event.events.ClientEvent import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.threading.runIO -import com.lambda.util.Communication.info -import com.lambda.util.Communication.logError +import com.lambda.util.CommunicationUtils.info +import com.lambda.util.CommunicationUtils.logError import com.lambda.util.FileUtils.createIfNotExists import com.lambda.util.FileUtils.ifExists import com.lambda.util.FileUtils.ifNotExists @@ -43,38 +44,31 @@ import kotlin.time.Duration.Companion.minutes /** - * Represents a compound of [Configurable] objects whose [SettingCore]s - * are saved into a single [Configuration] file ([Configuration.primary]). + * Represents a compound of [Config] objects whose [SettingCore]s + * are saved into a single [ConfigCategory] file ([ConfigCategory.primary]). * * This class also handles the concurrent loading and saving of persisted data on the `Dispatchers.IO` thread. * Each configuration will be loaded concurrently, - * while the underlying configurables are populated with the settings in sequence. + * while the underlying configs are populated with the settings in sequence. * - * See also [ModuleConfigs]. + * See also [ModuleCategory]. * * @property configName The name of the configuration. * @property primary The primary file where the configuration is saved. - * @property configurables A set of [Configurable] objects that this configuration manages. + * @property configs A set of [Config] objects that this configuration manages. */ -abstract class Configuration : Jsonable, Loadable { +abstract class ConfigCategory : Jsonable, Loadable { override val priority = 1 abstract val configName: String abstract val primary: File - val configurables = mutableSetOf() + val configs = mutableSetOf() private val backup: File get() = File("${primary.parent}/${primary.nameWithoutExtension}-backup.${primary.extension}") override fun load(): String { - listenUnsafe({ Int.MIN_VALUE }) { trySave() } - register() - return super.load() - } - - // Avoid context-leaking warning - private fun register() { - if (configurations.any { it.configName == configName }) - throw IllegalStateException("Configuration with name $configName already exists") + if (configCategories.any { it.configName == configName }) + throw IllegalStateException("Configuration with name $configName already exists") fixedRateTimer( daemon = true, @@ -83,7 +77,11 @@ abstract class Configuration : Jsonable, Loadable { period = 5.minutes.inWholeMilliseconds, ) { trySave() } - configurations.add(this) + configCategories.add(this) + + listenUnsafe({ Int.MIN_VALUE }) { trySave() } + + return super.load() } override fun toJson() = @@ -95,7 +93,7 @@ abstract class Configuration : Jsonable, Loadable { latestSchemaVersion ) } - configurables.forEach { + configs.forEach { add(it.name, it.toJson()) } } @@ -104,7 +102,7 @@ abstract class Configuration : Jsonable, Loadable { val schemaKey = ConfigMigrations.schemaVersionKey(configName) ?: ConfigMigrations.DEFAULT_SCHEMA_VERSION_KEY serialized.asJsonObject.entrySet().forEach { (name, value) -> if (name == schemaKey) return@forEach - configurableByName(name) + configByName(name) ?.loadFromJson(value) ?: LOG.warn("No matching setting found for saved setting $name with $value in ${configName.capitalize()} config") } @@ -177,21 +175,4 @@ abstract class Configuration : Jsonable, Loadable { fun tryLoad() = runIO { internalTryLoad() } fun trySave(logToChat: Boolean = false) = runIO { internalTrySave(logToChat) } - - companion object { - val configurations = mutableSetOf() - val configurables: Set - get() = configurations.flatMapTo(mutableSetOf()) { it.configurables } - val settings: List> - get() = configurables.flatMapTo(mutableListOf()) { it.settings } - - fun configurableByName(name: String) = - configurables.find { it.name == name } - - fun configurableByCommandName(name: String) = - configurables.find { it.commandName == name } - - fun settingByCommandName(configurable: Configurable, name: String) = - configurable.settings.find { it.commandName == name } - } } diff --git a/src/main/kotlin/com/lambda/config/ConfigEditor.kt b/src/main/kotlin/com/lambda/config/ConfigEditor.kt index 8c2cd6b64..be403cf4a 100644 --- a/src/main/kotlin/com/lambda/config/ConfigEditor.kt +++ b/src/main/kotlin/com/lambda/config/ConfigEditor.kt @@ -25,12 +25,12 @@ import kotlin.reflect.jvm.isAccessible annotation class SettingEditorDsl @SettingEditorDsl -fun T.applyEdits(edits: ConfigurableEditor.() -> Unit) { - ConfigurableEditor(this).apply(edits) +fun T.applyEdits(edits: ConfigEditor.() -> Unit) { + ConfigEditor(this).apply(edits) } @Suppress("unchecked_cast", "unused") -open class SettingGroupEditor(open val c: T) { +open class SettingGroupEditor(open val c: T) { val KProperty0<*>.delegate get() = try { apply { isAccessible = true }.getDelegate() @@ -125,7 +125,7 @@ open class SettingGroupEditor(open val c: T) { } @Suppress("unchecked_cast", "unused") -class ConfigurableEditor(override val c: T) : SettingGroupEditor(c) { +class ConfigEditor(override val c: T) : SettingGroupEditor(c) { @SettingEditorDsl fun hideGroup(settingGroup: ISettingGroup) = hide(settingGroup.settings) diff --git a/src/main/kotlin/com/lambda/config/configurations/ConfigLoader.kt b/src/main/kotlin/com/lambda/config/ConfigLoader.kt similarity index 53% rename from src/main/kotlin/com/lambda/config/configurations/ConfigLoader.kt rename to src/main/kotlin/com/lambda/config/ConfigLoader.kt index f7ab1a83a..e65642f25 100644 --- a/src/main/kotlin/com/lambda/config/configurations/ConfigLoader.kt +++ b/src/main/kotlin/com/lambda/config/ConfigLoader.kt @@ -15,16 +15,31 @@ * along with this program. If not, see . */ -package com.lambda.config.configurations +package com.lambda.config -import com.lambda.config.Configuration import com.lambda.core.Loadable +@Suppress("unused") object ConfigLoader: Loadable { + val configCategories = mutableSetOf() + val configs: Set + get() = configCategories.flatMapTo(mutableSetOf()) { it.configs } + val settings: List> + get() = configs.flatMapTo(mutableListOf()) { it.settings } + override fun load(): String { - Configuration.configurations.forEach { + configCategories.forEach { it.tryLoad() } - return "Loading ${Configuration.configurations.size} configurations" + return "Loading ${configCategories.size} config categories" } + + fun configByName(name: String) = + configs.find { it.name == name } + + fun configByCommandName(name: String) = + configs.find { it.commandName == name } + + fun settingByCommandName(config: Config, name: String) = + config.settings.find { it.commandName == name } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/Setting.kt b/src/main/kotlin/com/lambda/config/Setting.kt index 9272becfc..06f2cdee0 100644 --- a/src/main/kotlin/com/lambda/config/Setting.kt +++ b/src/main/kotlin/com/lambda/config/Setting.kt @@ -17,6 +17,7 @@ package com.lambda.config +import com.google.common.base.Defaults.defaultValue import com.google.gson.JsonElement import com.google.gson.JsonParser import com.lambda.Lambda.LOG @@ -33,7 +34,7 @@ import com.lambda.config.Setting.ValueListener import com.lambda.context.SafeContext import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.threading.runSafe -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.Describable import com.lambda.util.Nameable import com.lambda.util.NamedEnum @@ -92,72 +93,16 @@ import kotlin.reflect.KProperty * @property defaultValue The default value of the setting. * @property type The type reflection of the setting. */ -abstract class SettingCore( - var defaultValue: T, - val type: Type -) { - open var value = defaultValue - set(value) { - val oldValue = field - field = value - listeners.forEach { - if (it.requiresValueChange && oldValue == value) return@forEach - it.execute(oldValue, value) - } - } - val listeners = mutableListOf>() - - context(setting: Setting<*, T>) - abstract fun ImGuiBuilder.buildLayout() - - context(setting: Setting<*, T>) - open fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { - required(string("value as JSON")) { value -> - executeWithResult { - val valueString = value().value() - val parsed = try { - JsonParser.parseString("\"$valueString\"") - } catch (_: Exception) { - return@executeWithResult failure("$valueString is not a valid JSON string.") - } - ?: return@executeWithResult failure("No config found for $name.") - val previous = this@SettingCore.value - try { - loadFromJson(parsed) - } catch (_: Exception) { - return@executeWithResult failure("Failed to load $valueString as a ${type::class.simpleName} for $name in ${setting.configurable.name}.") - } - ConfigCommand.info(setting.setMessage(previous, this@SettingCore.value)) - return@executeWithResult success() - } - } - } - - context(setting: Setting<*, T>) - open fun toJson(): JsonElement = - gson.toJsonTree(value, type) - - context(setting: Setting<*, T>) - open fun loadFromJson(serialized: JsonElement) { - runCatching { - value = gson.fromJson(serialized, type) - }.onFailure { - LOG.warn("Failed to load setting ${setting.name} with value $serialized. Resetting to default value $defaultValue") - value = defaultValue - } - } -} - +@Suppress("unused") class Setting, R>( override val name: String, override val description: String, var core: T, - val configurable: Configurable, + val config: Config, var visibility: () -> Boolean, -) : Nameable, Describable { +) : Nameable, Describable, Jsonable { val originalCore = core var disabled = { false } - var groups: MutableList> = mutableListOf() var buttonMenu: NamedEnum? = null var value by this @@ -185,8 +130,14 @@ class Setting, R>( fun ImGuiBuilder.buildLayout() = with(core) { buildLayout() } fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) = with(core) { buildCommand(registry) } - fun toJson() = originalCore.toJson() - fun loadFromJson(serialized: JsonElement) = originalCore.loadFromJson(serialized) + override fun toJson() = originalCore.toJson() + override fun loadFromJson(serialized: JsonElement) { + runCatching { + originalCore.loadFromJson(serialized) + }.onFailure { + LOG.warn("Failed to load setting $name with value $serialized. Resetting to default value ${core.defaultValue}") + } + } class ValueListener(val requiresValueChange: Boolean, val execute: (from: T, to: T) -> Unit) @@ -214,18 +165,6 @@ class Setting, R>( disabled = predicate } - fun group(path: List, vararg continuation: NamedEnum) = apply { - groups.add(path + continuation) - } - - fun group(vararg path: NamedEnum) = apply { - groups.add(path.toList()) - } - - fun group(path: NamedEnum?) = apply { - path?.let { groups.add(listOf(it)) } - } - fun buttonMenu(menu: NamedEnum) = apply { buttonMenu = menu } @@ -243,7 +182,7 @@ class Setting, R>( fun setMessage(previousValue: R, newValue: R) = buildText { literal("Set ") changedMessage(previousValue, newValue) - clickEvent(ClickEvents.suggestCommand("${CommandRegistry.prefix}${ConfigCommand.name} reset ${configurable.commandName} $commandName")) { + clickEvent(ClickEvents.suggestCommand("${CommandRegistry.prefix}${ConfigCommand.name} reset ${config.commandName} $commandName")) { hoverEvent(HoverEvents.showText(buildText { literal("Click to reset to default value ") highlighted(core.defaultValue.toString()) @@ -267,7 +206,7 @@ class Setting, R>( } private fun TextBuilder.changedMessage(previousValue: R, newValue: R) { - highlighted(configurable.name) + highlighted(config.name) literal(" > ") highlighted(name) literal(" from ") @@ -275,7 +214,7 @@ class Setting, R>( literal(" to ") highlighted(newValue.toString()) literal(".") - clickEvent(ClickEvents.suggestCommand("${CommandRegistry.prefix}${ConfigCommand.name} set ${configurable.commandName} $commandName $previousValue")) { + clickEvent(ClickEvents.suggestCommand("${CommandRegistry.prefix}${ConfigCommand.name} set ${config.commandName} $commandName $previousValue")) { hoverEvent(HoverEvents.showText(buildText { literal("Click to undo to previous value ") highlighted(previousValue.toString()) @@ -286,7 +225,53 @@ class Setting, R>( } override fun toString() = "Setting $name: $value of type ${core.type.typeName}" +} + +abstract class SettingCore( + var defaultValue: T, + val type: Type +) : Jsonable { + open var value = defaultValue + set(value) { + val oldValue = field + field = value + listeners.forEach { + if (it.requiresValueChange && oldValue == value) return@forEach + it.execute(oldValue, value) + } + } + val listeners = mutableListOf>() - override fun equals(other: Any?) = other is Setting<*, *> && name == other.name - override fun hashCode() = name.hashCode() + context(setting: Setting<*, T>) + abstract fun ImGuiBuilder.buildLayout() + + context(setting: Setting<*, T>) + open fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { + required(string("value as JSON")) { value -> + executeWithResult { + val valueString = value().value() + val parsed = try { + JsonParser.parseString("\"$valueString\"") + } catch (_: Exception) { + return@executeWithResult failure("$valueString is not a valid JSON string.") + } + ?: return@executeWithResult failure("No config found for $name.") + val previous = this@SettingCore.value + try { + loadFromJson(parsed) + } catch (_: Exception) { + return@executeWithResult failure("Failed to load $valueString as a ${type::class.simpleName} for $name in ${setting.config.name}.") + } + ConfigCommand.info(setting.setMessage(previous, this@SettingCore.value)) + return@executeWithResult success() + } + } + } + + override fun toJson(): JsonElement = + gson.toJsonTree(value, type) + + override fun loadFromJson(serialized: JsonElement) { + value = gson.fromJson(serialized, type) + } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/SettingGroup.kt b/src/main/kotlin/com/lambda/config/SettingGroup.kt index c5bc7711e..86e0c8cfa 100644 --- a/src/main/kotlin/com/lambda/config/SettingGroup.kt +++ b/src/main/kotlin/com/lambda/config/SettingGroup.kt @@ -22,7 +22,7 @@ interface ISettingGroup { val visibility: () -> Boolean } -abstract class SettingGroup(c: Configurable) : ISettingGroup { +abstract class SettingGroup(c: Config) : ISettingGroup { override val settings = mutableListOf>() init { diff --git a/src/main/kotlin/com/lambda/config/AutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt similarity index 90% rename from src/main/kotlin/com/lambda/config/AutomationConfig.kt rename to src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt index 68b721e2d..c66314385 100644 --- a/src/main/kotlin/com/lambda/config/AutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt @@ -15,9 +15,11 @@ * along with this program. If not, see . */ -package com.lambda.config +package com.lambda.config.automation -import com.lambda.config.configurations.AutomationConfigs +import com.lambda.config.Config +import com.lambda.config.ConfigCategory +import com.lambda.config.categories.AutomationCategory import com.lambda.config.groups.BreakSettings import com.lambda.config.groups.BuildSettings import com.lambda.config.groups.EatSettings @@ -32,8 +34,8 @@ import com.lambda.util.NamedEnum open class AutomationConfig( override val name: String, - configuration: Configuration = AutomationConfigs -) : Configurable(configuration), Automated { + configCategory: ConfigCategory = AutomationCategory +) : Config(configCategory), Automated { enum class Group(override val displayName: String) : NamedEnum { Build("Build"), Break("Break"), diff --git a/src/main/kotlin/com/lambda/config/IMutableAutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt similarity index 88% rename from src/main/kotlin/com/lambda/config/IMutableAutomationConfig.kt rename to src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt index 42d35feff..23ab6c0f8 100644 --- a/src/main/kotlin/com/lambda/config/IMutableAutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt @@ -15,16 +15,18 @@ * along with this program. If not, see . */ -package com.lambda.config +package com.lambda.config.automation +import com.lambda.config.Setting +import com.lambda.config.SettingCore import com.lambda.config.groups.BuildConfig import com.lambda.config.groups.EatConfig import com.lambda.context.Automated -import com.lambda.interaction.managers.breaking.BreakConfig -import com.lambda.interaction.managers.hotbar.HotbarConfig -import com.lambda.interaction.managers.interacting.InteractConfig -import com.lambda.interaction.managers.inventory.InventoryConfig -import com.lambda.interaction.managers.rotating.RotationConfig +import com.lambda.config.groups.BreakConfig +import com.lambda.config.groups.HotbarConfig +import com.lambda.config.groups.InteractConfig +import com.lambda.config.groups.InventoryConfig +import com.lambda.config.groups.RotationConfig interface IMutableAutomationConfig : Automated { var defaultAutomationConfig: AutomationConfig diff --git a/src/main/kotlin/com/lambda/config/UserAutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/UserAutomationConfig.kt similarity index 92% rename from src/main/kotlin/com/lambda/config/UserAutomationConfig.kt rename to src/main/kotlin/com/lambda/config/automation/UserAutomationConfig.kt index c1dabd000..52554f5b0 100644 --- a/src/main/kotlin/com/lambda/config/UserAutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/UserAutomationConfig.kt @@ -15,15 +15,15 @@ * along with this program. If not, see . */ -package com.lambda.config +package com.lambda.config.automation -import com.lambda.config.configurations.UserAutomationConfigs +import com.lambda.config.categories.UserAutomationCategory import com.lambda.config.settings.collections.CollectionSetting.Companion.onDeselect import com.lambda.config.settings.collections.CollectionSetting.Companion.onSelect import com.lambda.module.Module import com.lambda.module.ModuleRegistry.moduleNameMap -class UserAutomationConfig(override val name: String) : AutomationConfig(name, UserAutomationConfigs) { +class UserAutomationConfig(override val name: String) : AutomationConfig(name, UserAutomationCategory) { val linkedModules = setting("Linked Modules", emptySet(), moduleNameMap.filter { it.value.defaultAutomationConfig != Companion.DEFAULT }.keys) { false } .onSelect { name -> moduleNameMap[name]?.let { diff --git a/src/main/kotlin/com/lambda/config/configurations/AutomationConfigs.kt b/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt similarity index 77% rename from src/main/kotlin/com/lambda/config/configurations/AutomationConfigs.kt rename to src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt index 2290deafc..f94590d44 100644 --- a/src/main/kotlin/com/lambda/config/configurations/AutomationConfigs.kt +++ b/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt @@ -15,13 +15,13 @@ * along with this program. If not, see . */ -package com.lambda.config.configurations +package com.lambda.config.categories -import com.lambda.config.Configuration -import com.lambda.util.FolderRegister +import com.lambda.config.ConfigCategory +import com.lambda.util.FolderRegistry import java.io.File -object AutomationConfigs : Configuration() { +object AutomationCategory : ConfigCategory() { override val configName = "automation" - override val primary: File = FolderRegister.config.resolve("${configName}.json").toFile() + override val primary: File = FolderRegistry.config.resolve("${configName}.json").toFile() } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/configurations/FontConfig.kt b/src/main/kotlin/com/lambda/config/categories/FontCategory.kt similarity index 77% rename from src/main/kotlin/com/lambda/config/configurations/FontConfig.kt rename to src/main/kotlin/com/lambda/config/categories/FontCategory.kt index 10ff2d6f1..6024bb0c0 100644 --- a/src/main/kotlin/com/lambda/config/configurations/FontConfig.kt +++ b/src/main/kotlin/com/lambda/config/categories/FontCategory.kt @@ -15,14 +15,13 @@ * along with this program. If not, see . */ -package com.lambda.config.configurations +package com.lambda.config.categories -import com.lambda.config.Configuration -import com.lambda.util.FolderRegister +import com.lambda.config.ConfigCategory +import com.lambda.util.FolderRegistry import java.io.File - -object FontConfig : Configuration() { +object FontCategory : ConfigCategory() { override val configName = "font" - override val primary: File = FolderRegister.config.resolve("${configName}.json").toFile() + override val primary: File = FolderRegistry.config.resolve("${configName}.json").toFile() } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/configurations/FriendConfig.kt b/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt similarity index 77% rename from src/main/kotlin/com/lambda/config/configurations/FriendConfig.kt rename to src/main/kotlin/com/lambda/config/categories/FriendCategory.kt index f87030db0..03a46f3dc 100644 --- a/src/main/kotlin/com/lambda/config/configurations/FriendConfig.kt +++ b/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt @@ -15,13 +15,13 @@ * along with this program. If not, see . */ -package com.lambda.config.configurations +package com.lambda.config.categories -import com.lambda.config.Configuration -import com.lambda.util.FolderRegister +import com.lambda.config.ConfigCategory +import com.lambda.util.FolderRegistry import java.io.File -object FriendConfig : Configuration() { +object FriendCategory : ConfigCategory() { override val configName get() = "friends" - override val primary: File = FolderRegister.config.resolve("$configName.json").toFile() + override val primary: File = FolderRegistry.config.resolve("$configName.json").toFile() } diff --git a/src/main/kotlin/com/lambda/config/configurations/GuiConfig.kt b/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt similarity index 81% rename from src/main/kotlin/com/lambda/config/configurations/GuiConfig.kt rename to src/main/kotlin/com/lambda/config/categories/GuiCategory.kt index afea31040..7f7348bec 100644 --- a/src/main/kotlin/com/lambda/config/configurations/GuiConfig.kt +++ b/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt @@ -15,13 +15,13 @@ * along with this program. If not, see . */ -package com.lambda.config.configurations +package com.lambda.config.categories -import com.lambda.config.Configuration -import com.lambda.util.FolderRegister +import com.lambda.config.ConfigCategory +import com.lambda.util.FolderRegistry import java.io.File -object GuiConfig : Configuration() { +object GuiCategory : ConfigCategory() { override val configName get() = "gui" - override val primary: File = FolderRegister.config.resolve("$configName.json").toFile() + override val primary: File = FolderRegistry.config.resolve("$configName.json").toFile() } diff --git a/src/main/kotlin/com/lambda/config/configurations/HudConfig.kt b/src/main/kotlin/com/lambda/config/categories/HudCategory.kt similarity index 77% rename from src/main/kotlin/com/lambda/config/configurations/HudConfig.kt rename to src/main/kotlin/com/lambda/config/categories/HudCategory.kt index 17d6ce58e..aecd1fac5 100644 --- a/src/main/kotlin/com/lambda/config/configurations/HudConfig.kt +++ b/src/main/kotlin/com/lambda/config/categories/HudCategory.kt @@ -15,13 +15,13 @@ * along with this program. If not, see . */ -package com.lambda.config.configurations +package com.lambda.config.categories -import com.lambda.config.Configuration -import com.lambda.util.FolderRegister +import com.lambda.config.ConfigCategory +import com.lambda.util.FolderRegistry import java.io.File -object HudConfig : Configuration() { +object HudCategory : ConfigCategory() { override val configName get() = "hud" - override val primary: File = FolderRegister.config.resolve("$configName.json").toFile() + override val primary: File = FolderRegistry.config.resolve("$configName.json").toFile() } diff --git a/src/main/kotlin/com/lambda/config/configurations/LambdaConfig.kt b/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt similarity index 77% rename from src/main/kotlin/com/lambda/config/configurations/LambdaConfig.kt rename to src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt index 1b1f50299..036ae3113 100644 --- a/src/main/kotlin/com/lambda/config/configurations/LambdaConfig.kt +++ b/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt @@ -15,13 +15,13 @@ * along with this program. If not, see . */ -package com.lambda.config.configurations +package com.lambda.config.categories -import com.lambda.config.Configuration -import com.lambda.util.FolderRegister +import com.lambda.config.ConfigCategory +import com.lambda.util.FolderRegistry import java.io.File -object LambdaConfig : Configuration() { +object LambdaCategory : ConfigCategory() { override val configName get() = "lambda" - override val primary: File = FolderRegister.config.resolve("$configName.json").toFile() + override val primary: File = FolderRegistry.config.resolve("$configName.json").toFile() } diff --git a/src/main/kotlin/com/lambda/config/configurations/ModuleConfigs.kt b/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt similarity index 69% rename from src/main/kotlin/com/lambda/config/configurations/ModuleConfigs.kt rename to src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt index 5f141f170..e4ba65b1b 100644 --- a/src/main/kotlin/com/lambda/config/configurations/ModuleConfigs.kt +++ b/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt @@ -15,24 +15,24 @@ * along with this program. If not, see . */ -package com.lambda.config.configurations +package com.lambda.config.categories -import com.lambda.config.Configuration -import com.lambda.config.configurations.ModuleConfigs.configName -import com.lambda.config.configurations.ModuleConfigs.primary -import com.lambda.util.FolderRegister +import com.lambda.config.ConfigCategory +import com.lambda.config.categories.ModuleCategory.configName +import com.lambda.config.categories.ModuleCategory.primary +import com.lambda.util.FolderRegistry import java.io.File /** - * The [ModuleConfigs] object represents the configuration file for the [Module]s. + * The [ModuleCategory] object represents the configuration file for the [Module]s. * * This object is used to save and load the settings of all [Module]s in the system. * * @property configName The name of the configuration. * @property primary The primary file where the configuration is saved. */ -object ModuleConfigs : Configuration() { +object ModuleCategory : ConfigCategory() { override val configName get() = "modules" - override val primary: File = FolderRegister.config.resolve("$configName.json").toFile() + override val primary: File = FolderRegistry.config.resolve("$configName.json").toFile() } diff --git a/src/main/kotlin/com/lambda/config/configurations/SecretsConfig.kt b/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt similarity index 77% rename from src/main/kotlin/com/lambda/config/configurations/SecretsConfig.kt rename to src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt index 2e695e8d7..f5c2189d7 100644 --- a/src/main/kotlin/com/lambda/config/configurations/SecretsConfig.kt +++ b/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt @@ -15,13 +15,13 @@ * along with this program. If not, see . */ -package com.lambda.config.configurations +package com.lambda.config.categories -import com.lambda.config.Configuration -import com.lambda.util.FolderRegister +import com.lambda.config.ConfigCategory +import com.lambda.util.FolderRegistry import java.io.File -object SecretsConfig : Configuration() { +object SecretsCategory : ConfigCategory() { override val configName get() = "secrets" - override val primary: File = FolderRegister.config.resolve("$configName.json").toFile() + override val primary: File = FolderRegistry.config.resolve("$configName.json").toFile() } diff --git a/src/main/kotlin/com/lambda/config/configurations/UserAutomationConfigs.kt b/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt similarity index 81% rename from src/main/kotlin/com/lambda/config/configurations/UserAutomationConfigs.kt rename to src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt index 14cfb3784..eb8eca17c 100644 --- a/src/main/kotlin/com/lambda/config/configurations/UserAutomationConfigs.kt +++ b/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt @@ -15,29 +15,29 @@ * along with this program. If not, see . */ -package com.lambda.config.configurations +package com.lambda.config.categories import com.google.gson.JsonParser -import com.lambda.config.Configuration +import com.lambda.config.ConfigCategory import com.lambda.config.UserAutomationConfig import com.lambda.module.ModuleRegistry.moduleNameMap import com.lambda.util.FileUtils.ifExists -import com.lambda.util.FolderRegister +import com.lambda.util.FolderRegistry import java.io.File -object UserAutomationConfigs : Configuration() { +object UserAutomationCategory : ConfigCategory() { override val configName = "custom-automation" - override val primary: File = FolderRegister.config.resolve("${configName}.json").toFile() + override val primary: File = FolderRegistry.config.resolve("${configName}.json").toFile() override fun internalTryLoad() { primary.ifExists { JsonParser.parseReader(it.reader()).asJsonObject.entrySet().forEach { (name, _) -> - if (configurables.any { config -> config.name == name }) return@forEach + if (configs.any { config -> config.name == name }) return@forEach UserAutomationConfig(name) } } super.internalTryLoad() - configurables.forEach { + configs.forEach { val config = it as? UserAutomationConfig ?: throw IllegalStateException("UserAutomationConfigs contains non-UserAutomationConfig") config.linkedModules.value.forEach { moduleName -> moduleNameMap[moduleName]?.automationConfig = config diff --git a/src/main/kotlin/com/lambda/config/serializer/BlockCodec.kt b/src/main/kotlin/com/lambda/config/codecs/BlockCodec.kt similarity index 95% rename from src/main/kotlin/com/lambda/config/serializer/BlockCodec.kt rename to src/main/kotlin/com/lambda/config/codecs/BlockCodec.kt index a990d93c0..d77877ec4 100644 --- a/src/main/kotlin/com/lambda/config/serializer/BlockCodec.kt +++ b/src/main/kotlin/com/lambda/config/codecs/BlockCodec.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.serializer +package com.lambda.config.codecs import com.google.gson.JsonDeserializationContext import com.google.gson.JsonElement @@ -28,6 +28,8 @@ import net.minecraft.registry.Registries import java.lang.reflect.Type object BlockCodec : Codec, Stringifiable { + override val type = Block::class.java + override fun serialize( src: Block, typeOfSrc: Type, diff --git a/src/main/kotlin/com/lambda/config/serializer/BlockPosCodec.kt b/src/main/kotlin/com/lambda/config/codecs/BlockPosCodec.kt similarity index 91% rename from src/main/kotlin/com/lambda/config/serializer/BlockPosCodec.kt rename to src/main/kotlin/com/lambda/config/codecs/BlockPosCodec.kt index 193d7b842..0faf37eea 100644 --- a/src/main/kotlin/com/lambda/config/serializer/BlockPosCodec.kt +++ b/src/main/kotlin/com/lambda/config/codecs/BlockPosCodec.kt @@ -15,20 +15,23 @@ * along with this program. If not, see . */ -package com.lambda.config.serializer +package com.lambda.config.codecs import com.google.gson.JsonDeserializationContext import com.google.gson.JsonElement import com.google.gson.JsonSerializationContext import com.lambda.config.Codec import com.lambda.config.Stringifiable -import com.lambda.util.Formatting.format +import com.lambda.util.FormattingUtils.format import com.mojang.serialization.JsonOps import net.minecraft.util.math.BlockPos import java.lang.reflect.Type import kotlin.jvm.optionals.getOrElse +@Suppress("unused") object BlockPosCodec : Codec, Stringifiable { + override val type = BlockPos::class.java + override fun serialize( src: BlockPos, typeOfSrc: Type, diff --git a/src/main/kotlin/com/lambda/config/serializer/ColorCodec.kt b/src/main/kotlin/com/lambda/config/codecs/ColorCodec.kt similarity index 91% rename from src/main/kotlin/com/lambda/config/serializer/ColorCodec.kt rename to src/main/kotlin/com/lambda/config/codecs/ColorCodec.kt index 2bf3afdf2..9e6419fca 100644 --- a/src/main/kotlin/com/lambda/config/serializer/ColorCodec.kt +++ b/src/main/kotlin/com/lambda/config/codecs/ColorCodec.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.serializer +package com.lambda.config.codecs import com.google.gson.JsonDeserializationContext import com.google.gson.JsonElement @@ -24,10 +24,14 @@ import com.google.gson.JsonPrimitive import com.google.gson.JsonSerializationContext import com.lambda.config.Codec import com.lambda.config.Stringifiable +import net.minecraft.world.attribute.EnvironmentAttributeModifier.override import java.awt.Color import java.lang.reflect.Type +@Suppress("unused") object ColorCodec : Codec, Stringifiable { + override val type = Color::class.java + override fun serialize( src: Color, typeOfSrc: Type, diff --git a/src/main/kotlin/com/lambda/config/serializer/GameProfileCodec.kt b/src/main/kotlin/com/lambda/config/codecs/GameProfileCodec.kt similarity index 95% rename from src/main/kotlin/com/lambda/config/serializer/GameProfileCodec.kt rename to src/main/kotlin/com/lambda/config/codecs/GameProfileCodec.kt index 24487397c..b8ebfcf00 100644 --- a/src/main/kotlin/com/lambda/config/serializer/GameProfileCodec.kt +++ b/src/main/kotlin/com/lambda/config/codecs/GameProfileCodec.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.serializer +package com.lambda.config.codecs import com.google.gson.JsonDeserializationContext import com.google.gson.JsonElement @@ -31,7 +31,10 @@ import java.util.* // But who cares, I'm doing it again. // What you gon' do bout it, huh? // That's what I thought. +@Suppress("unused") object GameProfileCodec : Codec, Stringifiable { + override val type = GameProfile::class.java + override fun serialize( src: GameProfile, typeOfSrc: Type?, diff --git a/src/main/kotlin/com/lambda/config/serializer/ItemCodec.kt b/src/main/kotlin/com/lambda/config/codecs/ItemCodec.kt similarity index 95% rename from src/main/kotlin/com/lambda/config/serializer/ItemCodec.kt rename to src/main/kotlin/com/lambda/config/codecs/ItemCodec.kt index 1e7324dac..b56a5f8d5 100644 --- a/src/main/kotlin/com/lambda/config/serializer/ItemCodec.kt +++ b/src/main/kotlin/com/lambda/config/codecs/ItemCodec.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.serializer +package com.lambda.config.codecs import com.google.gson.JsonDeserializationContext import com.google.gson.JsonElement @@ -29,6 +29,8 @@ import net.minecraft.util.Identifier import java.lang.reflect.Type object ItemCodec : Codec, Stringifiable { + override val type = Item::class.java + override fun serialize( item: Item, typeOfSrc: Type, diff --git a/src/main/kotlin/com/lambda/config/serializer/ItemStackCodec.kt b/src/main/kotlin/com/lambda/config/codecs/ItemStackCodec.kt similarity index 94% rename from src/main/kotlin/com/lambda/config/serializer/ItemStackCodec.kt rename to src/main/kotlin/com/lambda/config/codecs/ItemStackCodec.kt index 68a3e4119..b35d0e19e 100644 --- a/src/main/kotlin/com/lambda/config/serializer/ItemStackCodec.kt +++ b/src/main/kotlin/com/lambda/config/codecs/ItemStackCodec.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.serializer +package com.lambda.config.codecs import com.google.gson.JsonDeserializationContext import com.google.gson.JsonElement @@ -27,7 +27,10 @@ import net.minecraft.item.ItemStack import java.lang.reflect.Type import kotlin.jvm.optionals.getOrElse +@Suppress("unused") object ItemStackCodec : Codec, Stringifiable { + override val type = ItemStack::class.java + override fun serialize( stack: ItemStack, typeOfSrc: Type, diff --git a/src/main/kotlin/com/lambda/config/serializer/KeyCodeCodec.kt b/src/main/kotlin/com/lambda/config/codecs/KeyCodeCodec.kt similarity index 89% rename from src/main/kotlin/com/lambda/config/serializer/KeyCodeCodec.kt rename to src/main/kotlin/com/lambda/config/codecs/KeyCodeCodec.kt index d7729412d..f661d4e17 100644 --- a/src/main/kotlin/com/lambda/config/serializer/KeyCodeCodec.kt +++ b/src/main/kotlin/com/lambda/config/codecs/KeyCodeCodec.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.serializer +package com.lambda.config.codecs import com.google.gson.JsonDeserializationContext import com.google.gson.JsonElement @@ -25,9 +25,13 @@ import com.google.gson.JsonPrimitive import com.google.gson.JsonSerializationContext import com.lambda.config.Codec import com.lambda.util.KeyCode +import net.minecraft.world.attribute.EnvironmentAttributeModifier.override import java.lang.reflect.Type +@Suppress("unused") object KeyCodeCodec : Codec { + override val type = KeyCode::class.java + override fun serialize( src: KeyCode?, typeOfSrc: Type?, diff --git a/src/main/kotlin/com/lambda/config/serializer/OptionalCodec.kt b/src/main/kotlin/com/lambda/config/codecs/OptionalCodec.kt similarity index 93% rename from src/main/kotlin/com/lambda/config/serializer/OptionalCodec.kt rename to src/main/kotlin/com/lambda/config/codecs/OptionalCodec.kt index 798120aaf..0067d0b31 100644 --- a/src/main/kotlin/com/lambda/config/serializer/OptionalCodec.kt +++ b/src/main/kotlin/com/lambda/config/codecs/OptionalCodec.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.serializer +package com.lambda.config.codecs import com.google.gson.JsonDeserializationContext import com.google.gson.JsonElement @@ -25,7 +25,10 @@ import com.lambda.config.Codec import java.lang.reflect.Type import java.util.* +@Suppress("unused") object OptionalCodec : Codec> { + override val type = Optional::class.java + override fun serialize(src: Optional?, typeOfSrc: Type?, context: JsonSerializationContext?): JsonElement = src?.map { context?.serialize(it) }?.orElse(JsonNull.INSTANCE) ?: JsonNull.INSTANCE diff --git a/src/main/kotlin/com/lambda/config/serializer/TextCodec.kt b/src/main/kotlin/com/lambda/config/codecs/TextCodec.kt similarity index 94% rename from src/main/kotlin/com/lambda/config/serializer/TextCodec.kt rename to src/main/kotlin/com/lambda/config/codecs/TextCodec.kt index 5dc863ea3..ec20eaac2 100644 --- a/src/main/kotlin/com/lambda/config/serializer/TextCodec.kt +++ b/src/main/kotlin/com/lambda/config/codecs/TextCodec.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.serializer +package com.lambda.config.codecs import com.google.gson.JsonDeserializationContext import com.google.gson.JsonElement @@ -27,7 +27,10 @@ import net.minecraft.text.TextCodecs import java.lang.reflect.Type import kotlin.jvm.optionals.getOrElse +@Suppress("unused") object TextCodec : Codec { + override val type = Text::class.java + override fun serialize( src: Text, typeOfSrc: Type, diff --git a/src/main/kotlin/com/lambda/config/serializer/UUIDCodec.kt b/src/main/kotlin/com/lambda/config/codecs/UUIDCodec.kt similarity index 92% rename from src/main/kotlin/com/lambda/config/serializer/UUIDCodec.kt rename to src/main/kotlin/com/lambda/config/codecs/UUIDCodec.kt index 0b3169872..258b79a0c 100644 --- a/src/main/kotlin/com/lambda/config/serializer/UUIDCodec.kt +++ b/src/main/kotlin/com/lambda/config/codecs/UUIDCodec.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.serializer +package com.lambda.config.codecs import com.google.gson.JsonDeserializationContext import com.google.gson.JsonElement @@ -23,10 +23,14 @@ import com.google.gson.JsonParseException import com.google.gson.JsonSerializationContext import com.lambda.config.Codec import com.lambda.config.Stringifiable +import net.minecraft.world.attribute.EnvironmentAttributeModifier.override import java.lang.reflect.Type import java.util.* +@Suppress("unused") object UUIDCodec : Codec, Stringifiable { + override val type = UUID::class.java + override fun serialize( src: UUID, typeOfSrc: Type?, diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakConfig.kt b/src/main/kotlin/com/lambda/config/groups/BreakConfig.kt similarity index 96% rename from src/main/kotlin/com/lambda/interaction/managers/breaking/BreakConfig.kt rename to src/main/kotlin/com/lambda/config/groups/BreakConfig.kt index 7f93f567b..e06b03d61 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/BreakConfig.kt @@ -15,12 +15,9 @@ * along with this program. If not, see . */ -package com.lambda.interaction.managers.breaking +package com.lambda.config.groups import com.lambda.config.ISettingGroup -import com.lambda.config.groups.ActionConfig -import com.lambda.config.groups.BuildConfig -import com.lambda.config.groups.LineConfig import com.lambda.util.Describable import com.lambda.util.NamedEnum import net.minecraft.block.Block @@ -145,4 +142,4 @@ interface BreakConfig : ActionConfig, ISettingGroup { Blacklist("Blacklist", "Only break blocks not in the blacklist"), None("None", "Breaks all blocks") } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt b/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt index 9c09ab9c1..0e9e28989 100644 --- a/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt @@ -17,23 +17,23 @@ package com.lambda.config.groups -import com.lambda.config.Configurable +import com.lambda.config.Config import com.lambda.config.SettingGroup import com.lambda.config.applyEdits import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.interaction.managers.breaking.BreakConfig -import com.lambda.interaction.managers.breaking.BreakConfig.AnimationMode -import com.lambda.interaction.managers.breaking.BreakConfig.BreakConfirmationMode -import com.lambda.interaction.managers.breaking.BreakConfig.BreakMode -import com.lambda.interaction.managers.breaking.BreakConfig.SwingMode -import com.lambda.interaction.managers.breaking.BreakConfig.WhitelistMode +import com.lambda.config.groups.BreakConfig +import com.lambda.config.groups.BreakConfig.AnimationMode +import com.lambda.config.groups.BreakConfig.BreakConfirmationMode +import com.lambda.config.groups.BreakConfig.BreakMode +import com.lambda.config.groups.BreakConfig.SwingMode +import com.lambda.config.groups.BreakConfig.WhitelistMode import com.lambda.util.NamedEnum import net.minecraft.registry.Registries import java.awt.Color open class BreakSettings( - c: Configurable, + c: Config, vararg baseGroup: NamedEnum, prefix: String = "", override val visibility: () -> Boolean = { true }, diff --git a/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt b/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt index 3f3262f45..be3d25195 100644 --- a/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt @@ -17,17 +17,17 @@ package com.lambda.config.groups -import com.lambda.config.Configurable +import com.lambda.config.Config import com.lambda.config.SettingGroup import com.lambda.interaction.managers.rotating.visibilty.PointSelection import com.lambda.util.NamedEnum import kotlin.math.max class BuildSettings( - c: Configurable, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, + c: Config, + vararg baseGroup: NamedEnum, + prefix: String = "", + override val visibility: () -> Boolean = { true }, ) : SettingGroup(c), BuildConfig { enum class Group(override val displayName: String) : NamedEnum { General("General"), diff --git a/src/main/kotlin/com/lambda/config/groups/EatSettings.kt b/src/main/kotlin/com/lambda/config/groups/EatSettings.kt index 58fbe341a..b2de049f7 100644 --- a/src/main/kotlin/com/lambda/config/groups/EatSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/EatSettings.kt @@ -17,16 +17,16 @@ package com.lambda.config.groups -import com.lambda.config.Configurable +import com.lambda.config.Config import com.lambda.config.SettingGroup import com.lambda.util.NamedEnum import net.minecraft.item.Items class EatSettings( - c: Configurable, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, + c: Config, + vararg baseGroup: NamedEnum, + prefix: String = "", + override val visibility: () -> Boolean = { true }, ) : SettingGroup(c), EatConfig { val nutritiousFoodDefaults = listOf(Items.APPLE, Items.BAKED_POTATO, Items.BEEF, Items.BEETROOT, Items.BEETROOT_SOUP, Items.BREAD, Items.CARROT, Items.CHICKEN, Items.CHORUS_FRUIT, Items.COD, Items.COOKED_BEEF, Items.COOKED_CHICKEN, Items.COOKED_COD, Items.COOKED_MUTTON, Items.COOKED_PORKCHOP, Items.COOKED_RABBIT, Items.COOKED_SALMON, Items.COOKIE, Items.DRIED_KELP, Items.ENCHANTED_GOLDEN_APPLE, Items.GOLDEN_APPLE, Items.GOLDEN_CARROT, Items.HONEY_BOTTLE, Items.MELON_SLICE, Items.MUSHROOM_STEW, Items.MUTTON, Items.POISONOUS_POTATO, Items.PORKCHOP, Items.POTATO, Items.PUFFERFISH, Items.PUMPKIN_PIE, Items.RABBIT, Items.RABBIT_STEW, Items.ROTTEN_FLESH, Items.SALMON, Items.SPIDER_EYE, Items.SUSPICIOUS_STEW, Items.SWEET_BERRIES, Items.GLOW_BERRIES, Items.TROPICAL_FISH) val resistanceFoodDefaults = listOf(Items.ENCHANTED_GOLDEN_APPLE) diff --git a/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt b/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt index a62671fd9..6549593dd 100644 --- a/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt @@ -17,7 +17,7 @@ package com.lambda.config.groups -import com.lambda.config.Configurable +import com.lambda.config.Config import com.lambda.config.SettingGroup import com.lambda.context.SafeContext import com.lambda.friend.FriendHandler.isFriend @@ -34,7 +34,7 @@ import net.minecraft.entity.Entity import java.awt.Color class EntityColorSettings( - c: Configurable, + c: Config, vararg baseGroup: NamedEnum, prefix: String = "", override val visibility: () -> Boolean = { true }, diff --git a/src/main/kotlin/com/lambda/config/groups/EntitySelectionSettings.kt b/src/main/kotlin/com/lambda/config/groups/EntitySelectionSettings.kt index dbd293ff5..2efd3b913 100644 --- a/src/main/kotlin/com/lambda/config/groups/EntitySelectionSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/EntitySelectionSettings.kt @@ -18,7 +18,7 @@ package com.lambda.config.groups import com.lambda.Lambda.mc -import com.lambda.config.Configurable +import com.lambda.config.Config import com.lambda.config.SettingGroup import com.lambda.util.EntityUtils.blockEntityMap import com.lambda.util.EntityUtils.bossEntityMap @@ -35,7 +35,7 @@ import net.minecraft.entity.Entity import net.minecraft.entity.SpawnGroup class EntitySelectionSettings( - c: Configurable, + c: Config, vararg baseGroup: NamedEnum, prefix: String = "", override val visibility: () -> Boolean = { true }, diff --git a/src/main/kotlin/com/lambda/config/groups/FormatterSettings.kt b/src/main/kotlin/com/lambda/config/groups/FormatterSettings.kt index 0f847073e..902a239a9 100644 --- a/src/main/kotlin/com/lambda/config/groups/FormatterSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/FormatterSettings.kt @@ -17,15 +17,15 @@ package com.lambda.config.groups -import com.lambda.config.Configurable +import com.lambda.config.Config import com.lambda.config.SettingGroup import com.lambda.util.NamedEnum class FormatterSettings( - c: Configurable, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, + c: Config, + vararg baseGroup: NamedEnum, + prefix: String = "", + override val visibility: () -> Boolean = { true }, ) : FormatterConfig, SettingGroup(c) { val localeEnum by c.setting("${prefix}Locale", FormatterConfig.Locales.US, "The regional formatting used for numbers", visibility = visibility).group(*baseGroup).index() override val locale get() = localeEnum.locale diff --git a/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarConfig.kt b/src/main/kotlin/com/lambda/config/groups/HotbarConfig.kt similarity index 97% rename from src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarConfig.kt rename to src/main/kotlin/com/lambda/config/groups/HotbarConfig.kt index eac80f7ee..8d6c1974a 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/HotbarConfig.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.managers.hotbar +package com.lambda.config.groups import com.lambda.config.ISettingGroup import com.lambda.event.events.TickEvent diff --git a/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt b/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt index d424f79df..e9a10df8f 100644 --- a/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt @@ -17,18 +17,18 @@ package com.lambda.config.groups -import com.lambda.config.Configurable +import com.lambda.config.Config import com.lambda.config.SettingGroup import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.interaction.managers.hotbar.HotbarConfig +import com.lambda.config.groups.HotbarConfig import com.lambda.util.NamedEnum class HotbarSettings( - c: Configurable, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, + c: Config, + vararg baseGroup: NamedEnum, + prefix: String = "", + override val visibility: () -> Boolean = { true }, ) : SettingGroup(c), HotbarConfig { override val swapMode by c.setting("${prefix}Swap Mode", HotbarConfig.SwapMode.Temporary, visibility = visibility).group(*baseGroup).index() override val keepTicks by c.setting("${prefix}Keep Ticks", 1, 0..20, 1, "The number of ticks to keep the current hotbar selection active", " ticks") { visibility() && swapMode == HotbarConfig.SwapMode.Temporary }.group(*baseGroup).index() diff --git a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractConfig.kt b/src/main/kotlin/com/lambda/config/groups/InteractConfig.kt similarity index 81% rename from src/main/kotlin/com/lambda/interaction/managers/interacting/InteractConfig.kt rename to src/main/kotlin/com/lambda/config/groups/InteractConfig.kt index 077acf610..39cc3c13b 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/InteractConfig.kt @@ -15,15 +15,9 @@ * along with this program. If not, see . */ -package com.lambda.interaction.managers.interacting +package com.lambda.config.groups -import com.lambda.config.ISettingGroup -import com.lambda.config.groups.ActionConfig -import com.lambda.config.groups.BuildConfig -import com.lambda.util.Describable -import com.lambda.util.NamedEnum - -interface InteractConfig : ActionConfig, ISettingGroup { +interface InteractConfig : ActionConfig, com.lambda.config.ISettingGroup { val rotate: Boolean val airPlace: AirPlaceMode val axisRotateSetting: Boolean @@ -38,11 +32,10 @@ interface InteractConfig : ActionConfig, ISettingGroup { enum class AirPlaceMode( override val displayName: String, override val description: String - ) : NamedEnum, Describable { + ) : com.lambda.util.NamedEnum, com.lambda.util.Describable { None("None", "Do not attempt air placements; only place against valid supports."), Standard("Standard", "Try common air-place techniques for convenience; moderate compatibility."), - Grim("Grim", "Use grim specific air placing.") - ; + Grim("Grim", "Use grim specific air placing."); val isEnabled get() = this != None } @@ -50,9 +43,9 @@ interface InteractConfig : ActionConfig, ISettingGroup { enum class InteractConfirmationMode( override val displayName: String, override val description: String - ) : NamedEnum, Describable { + ) : com.lambda.util.NamedEnum, com.lambda.util.Describable { None("No confirmation", "Interact immediately without waiting for the server; possible desync."), PlaceThenAwait("Interact now, confirm later", "Interact immediately, then wait for server confirmation to verify."), AwaitThenPlace("Confirm first, then Interact", "Wait for server response before interacting; safest, adds a short delay.") } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt b/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt index 5759cdbfe..dfd809542 100644 --- a/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt @@ -17,20 +17,20 @@ package com.lambda.config.groups -import com.lambda.config.Configurable +import com.lambda.config.Config import com.lambda.config.SettingGroup import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.interaction.managers.interacting.InteractConfig -import com.lambda.interaction.managers.interacting.InteractConfig.AirPlaceMode -import com.lambda.interaction.managers.interacting.InteractConfig.InteractConfirmationMode +import com.lambda.config.groups.InteractConfig +import com.lambda.config.groups.InteractConfig.AirPlaceMode +import com.lambda.config.groups.InteractConfig.InteractConfirmationMode import com.lambda.util.NamedEnum class InteractSettings( - c: Configurable, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, + c: Config, + vararg baseGroup: NamedEnum, + prefix: String = "", + override val visibility: () -> Boolean = { true }, ) : SettingGroup(c), InteractConfig { override val rotate by c.setting("${prefix}Rotate For Interact", true, "Rotate towards block while placing", visibility = visibility).group(*baseGroup).index() override val airPlace by c.setting("${prefix}Air Place", AirPlaceMode.Grim, "Allows for placing blocks without adjacent faces", visibility = visibility).group(*baseGroup).index() diff --git a/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryConfig.kt b/src/main/kotlin/com/lambda/config/groups/InventoryConfig.kt similarity index 98% rename from src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryConfig.kt rename to src/main/kotlin/com/lambda/config/groups/InventoryConfig.kt index d62b02de1..c33290305 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/InventoryConfig.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.interaction.managers.inventory +package com.lambda.config.groups import com.lambda.config.ISettingGroup import com.lambda.context.SafeContext @@ -82,4 +82,4 @@ interface InventoryConfig : ISettingGroup { .thenBy { it.name } } } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt b/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt index 6b4fac6c9..2f928152e 100644 --- a/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt @@ -17,18 +17,18 @@ package com.lambda.config.groups -import com.lambda.config.Configurable +import com.lambda.config.Config import com.lambda.config.SettingGroup import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.interaction.managers.inventory.InventoryConfig +import com.lambda.config.groups.InventoryConfig import com.lambda.util.NamedEnum import com.lambda.util.item.ItemUtils class InventorySettings( - c: Configurable, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, + c: Config, + vararg baseGroup: NamedEnum, + prefix: String = "", + override val visibility: () -> Boolean = { true }, ) : SettingGroup(c), InventoryConfig { enum class Group(override val displayName: String) : NamedEnum { General("General"), diff --git a/src/main/kotlin/com/lambda/config/groups/OutlineSettings.kt b/src/main/kotlin/com/lambda/config/groups/OutlineSettings.kt index 8a21b7723..b4a0ada41 100644 --- a/src/main/kotlin/com/lambda/config/groups/OutlineSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/OutlineSettings.kt @@ -17,14 +17,14 @@ package com.lambda.config.groups -import com.lambda.config.Configurable +import com.lambda.config.Config import com.lambda.config.SettingGroup import com.lambda.graphics.outline.OutlineStyle import com.lambda.util.NamedEnum import java.awt.Color class OutlineSettings( - c: Configurable, + c: Config, vararg baseGroup: NamedEnum, prefix: String = "", override val visibility: () -> Boolean = { true }, diff --git a/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationConfig.kt b/src/main/kotlin/com/lambda/config/groups/RotationConfig.kt similarity index 54% rename from src/main/kotlin/com/lambda/interaction/managers/rotating/RotationConfig.kt rename to src/main/kotlin/com/lambda/config/groups/RotationConfig.kt index 17eea26d4..d661abb0d 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/RotationConfig.kt @@ -15,11 +15,21 @@ * along with this program. If not, see . */ -package com.lambda.interaction.managers.rotating +package com.lambda.config.groups import com.lambda.config.ISettingGroup import com.lambda.config.Setting import com.lambda.event.events.TickEvent +import com.lambda.interaction.managers.rotating.Rotation.Companion.dist +import com.lambda.interaction.managers.rotating.RotationManager +import com.lambda.interaction.managers.rotating.RotationMode +import com.lambda.util.Describable +import com.lambda.util.NamedEnum +import com.lambda.util.math.distSq +import com.lambda.util.math.times +import com.lambda.util.player.CheckedHit +import kotlin.collections.mapNotNull +import kotlin.collections.minByOrNull interface RotationConfig : ISettingGroup { /** @@ -54,4 +64,33 @@ interface RotationConfig : ISettingGroup { override val turnSpeed = 180.0 override val tickStageMask = RotationManager.openStages.toSet() } -} + + @Suppress("unused") + enum class PointSelection( + override val displayName: String, + override val description: String, + val select: (Collection) -> CheckedHit? + ) : NamedEnum, Describable { + ByRotation( + "By Rotation", + "Choose the point that needs the least rotation from your current view (minimal camera turn).", + select = { hits -> + hits.minByOrNull { RotationManager.activeRotation dist it.rotation } + } + ), + Optimum( + "Optimum", + "Choose the point closest to the average of all candidates (balanced and stable aim).", + select = { hits -> + val optimum = hits + .mapNotNull { it.hit.pos } + .reduceOrNull { acc, pos -> acc.add(pos) } + ?.times(1 / hits.size.toDouble()) + + optimum?.let { center -> + hits.minByOrNull { it.hit.pos?.distSq(center) ?: 0.0 } + } + } + ) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/groups/RotationSettings.kt b/src/main/kotlin/com/lambda/config/groups/RotationSettings.kt index ae44bc781..b78eea91e 100644 --- a/src/main/kotlin/com/lambda/config/groups/RotationSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/RotationSettings.kt @@ -17,11 +17,11 @@ package com.lambda.config.groups -import com.lambda.config.Configurable +import com.lambda.config.Config import com.lambda.config.SettingGroup import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.interaction.managers.rotating.RotationConfig +import com.lambda.config.groups.RotationConfig import com.lambda.interaction.managers.rotating.RotationMode import com.lambda.util.NamedEnum import kotlin.math.PI @@ -32,10 +32,10 @@ import kotlin.math.sqrt import kotlin.random.Random class RotationSettings( - c: Configurable, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, + c: Config, + vararg baseGroup: NamedEnum, + prefix: String = "", + override val visibility: () -> Boolean = { true }, ) : SettingGroup(c), RotationConfig { override var rotationMode by c.setting("${prefix}Mode", RotationMode.Sync, "How the player is being rotated on interaction", visibility = visibility).group(*baseGroup).index() diff --git a/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt b/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt index addfa317a..e80400b85 100644 --- a/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt @@ -17,13 +17,13 @@ package com.lambda.config.groups -import com.lambda.config.Configurable +import com.lambda.config.Config import com.lambda.config.SettingGroup import com.lambda.util.NamedEnum import java.awt.Color class ScreenLineSettings( - c: Configurable, + c: Config, vararg baseGroup: NamedEnum, prefix: String = "", override val visibility: () -> Boolean = { true }, diff --git a/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt b/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt index 22ad3f926..ee4855e18 100644 --- a/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt @@ -17,16 +17,16 @@ package com.lambda.config.groups -import com.lambda.config.Configurable +import com.lambda.config.Config import com.lambda.config.SettingGroup import com.lambda.util.NamedEnum import java.awt.Color class ScreenTextSettings( - c: Configurable, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, + c: Config, + vararg baseGroup: NamedEnum, + prefix: String = "", + override val visibility: () -> Boolean = { true }, ) : SettingGroup(c), TextConfig { enum class Group(override val displayName: String) : NamedEnum { General("General"), diff --git a/src/main/kotlin/com/lambda/config/groups/Targeting.kt b/src/main/kotlin/com/lambda/config/groups/TargetingSettings.kt similarity index 95% rename from src/main/kotlin/com/lambda/config/groups/Targeting.kt rename to src/main/kotlin/com/lambda/config/groups/TargetingSettings.kt index d505a657e..b4ef5b466 100644 --- a/src/main/kotlin/com/lambda/config/groups/Targeting.kt +++ b/src/main/kotlin/com/lambda/config/groups/TargetingSettings.kt @@ -17,7 +17,7 @@ package com.lambda.config.groups -import com.lambda.config.Configurable +import com.lambda.config.Config import com.lambda.config.SettingGroup import com.lambda.config.applyEdits import com.lambda.context.SafeContext @@ -45,13 +45,13 @@ import java.util.* * based on player settings and entity characteristics. It allows for specifying which types of entities * are targetable, the range of targeting, and various other conditions for targeting. * - * @param c The [Configurable] instance used to get and set configuration options for targeting. + * @param c The [Config] instance used to get and set configuration options for targeting. * @param visibility The predicate used to determine whether the targeting settings are visible and active. * @param defaultRange The default range within which entities can be targeted. * @param maxRange The maximum range within which entities can be targeted. */ -abstract class Targeting( - c: Configurable, +abstract class TargetingSettings( + c: Config, vararg baseGroup: NamedEnum, defaultRange: Double, maxRange: Double, @@ -59,7 +59,7 @@ abstract class Targeting( visibility: () -> Boolean = { true }, ) : SettingGroup(c), TargetingConfig { /** - * The range within which entities can be targeted. This value is configurable and constrained + * The range within which entities can be targeted. This value is config and constrained * between 1.0 and [maxRange]. */ override val targetingRange by c.setting("${prefix}Targeting Range", defaultRange, 1.0..maxRange, 0.05, visibility = visibility).group(*baseGroup).index() @@ -85,14 +85,14 @@ abstract class Targeting( * @property fov The field of view limit within which entities are considered for targeting. Configurable. * @property priority The priority used to determine which entity is targeted when multiple candidates are available. */ - class Combat( - c: Configurable, + class CombatSettings( + c: Config, vararg baseGroup: NamedEnum, defaultRange: Double = 5.0, maxRange: Double = 16.0, prefix: String = "", override val visibility: () -> Boolean = { true }, - ) : Targeting(c, *baseGroup, defaultRange = defaultRange, maxRange = maxRange, prefix = prefix, visibility = visibility) { + ) : TargetingSettings(c, *baseGroup, defaultRange = defaultRange, maxRange = maxRange, prefix = prefix, visibility = visibility) { /** * The field of view limit for targeting entities. Configurable between 5 and 180 degrees. */ diff --git a/src/main/kotlin/com/lambda/config/groups/WorldLineSettings.kt b/src/main/kotlin/com/lambda/config/groups/WorldLineSettings.kt index 8e247befc..b641a7443 100644 --- a/src/main/kotlin/com/lambda/config/groups/WorldLineSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/WorldLineSettings.kt @@ -17,16 +17,16 @@ package com.lambda.config.groups -import com.lambda.config.Configurable +import com.lambda.config.Config import com.lambda.config.SettingGroup import com.lambda.util.NamedEnum import java.awt.Color class WorldLineSettings( - c: Configurable, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, + c: Config, + vararg baseGroup: NamedEnum, + prefix: String = "", + override val visibility: () -> Boolean = { true }, ) : SettingGroup(c), LineConfig { enum class Group(override val displayName: String) : NamedEnum { General("General"), diff --git a/src/main/kotlin/com/lambda/config/groups/WorldTextSettings.kt b/src/main/kotlin/com/lambda/config/groups/WorldTextSettings.kt index 0fa62a65c..db81d179a 100644 --- a/src/main/kotlin/com/lambda/config/groups/WorldTextSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/WorldTextSettings.kt @@ -17,13 +17,13 @@ package com.lambda.config.groups -import com.lambda.config.Configurable +import com.lambda.config.Config import com.lambda.config.SettingGroup import com.lambda.util.NamedEnum import java.awt.Color class WorldTextSettings( - c: Configurable, + c: Config, vararg baseGroup: NamedEnum, prefix: String = "", override val visibility: () -> Boolean = { true }, diff --git a/src/main/kotlin/com/lambda/config/migration/Migrations.kt b/src/main/kotlin/com/lambda/config/migration/Migrations.kt index e169794c6..db3903eae 100644 --- a/src/main/kotlin/com/lambda/config/migration/Migrations.kt +++ b/src/main/kotlin/com/lambda/config/migration/Migrations.kt @@ -22,7 +22,7 @@ import com.google.gson.JsonElement import com.google.gson.JsonObject import com.lambda.Lambda.LOG import com.lambda.core.Loadable -import com.lambda.util.reflections.getInstances +import com.lambda.util.ReflectionUtils.getInstances import java.util.* import kotlin.math.max diff --git a/src/main/kotlin/com/lambda/config/migration/migrations/FriendConfigMigration.kt b/src/main/kotlin/com/lambda/config/migration/migrations/FriendConfigMigration.kt index 4acf41076..2f7f0a1be 100644 --- a/src/main/kotlin/com/lambda/config/migration/migrations/FriendConfigMigration.kt +++ b/src/main/kotlin/com/lambda/config/migration/migrations/FriendConfigMigration.kt @@ -25,14 +25,15 @@ import com.lambda.config.migration.objectOrCreate import com.lambda.config.migration.parseUuidOrNull import java.util.* +@Suppress("unused") object FriendConfigMigration : StepConfigMigration() { override val configName = "friends" override val latestVersion = 2 init { step(1, 2) { - val configurable = objectOrCreate("friends") - val rawFriends = configurable.arrayOrCreate("friends") + val config = objectOrCreate("friends") + val rawFriends = config.arrayOrCreate("friends") val migrated = JsonArray() val seen = mutableSetOf() var dropped = 0 @@ -45,7 +46,7 @@ object FriendConfigMigration : StepConfigMigration() { ?: run { dropped++ } } - configurable.add("friends", migrated) + config.add("friends", migrated) LOG.info("Migrated Friend config schema v1 -> v2: ${migrated.size()} entries converted, $dropped entries dropped") } } diff --git a/src/main/kotlin/com/lambda/config/settings/CharSetting.kt b/src/main/kotlin/com/lambda/config/settings/CharSetting.kt index 7c13a8043..c713570f8 100644 --- a/src/main/kotlin/com/lambda/config/settings/CharSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/CharSetting.kt @@ -31,7 +31,7 @@ import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandRegistryAccess /** - * @see [com.lambda.config.Configurable] + * @see [com.lambda.config.Config] */ class CharSetting(defaultValue: Char) : SettingCore( defaultValue, diff --git a/src/main/kotlin/com/lambda/config/settings/FunctionSetting.kt b/src/main/kotlin/com/lambda/config/settings/FunctionSetting.kt index 96eabb9cd..f46f69da2 100644 --- a/src/main/kotlin/com/lambda/config/settings/FunctionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/FunctionSetting.kt @@ -34,8 +34,6 @@ open class FunctionSetting(defaultValue: () -> T) : SettingCore<() -> T>( lambdaTooltip(setting.description) } - context(setting: Setting<*, () -> T>) override fun toJson(): JsonElement = JsonNull.INSTANCE - context(setting: Setting<*, () -> T>) override fun loadFromJson(serialized: JsonElement) { value = defaultValue } } diff --git a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt index 526b556c7..ebe8d58a6 100644 --- a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt @@ -31,7 +31,7 @@ import java.text.NumberFormat import java.util.* /** - * @see [com.lambda.config.Configurable] + * @see [com.lambda.config.Config] */ abstract class NumericSetting( defaultValue: T, diff --git a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt index 5c2a27ccb..ffe69d405 100644 --- a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt @@ -32,7 +32,7 @@ import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandRegistryAccess /** - * @see [com.lambda.config.Configurable] + * @see [com.lambda.config.Config] */ class StringSetting( defaultValue: String, diff --git a/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt index 62452f9f3..0a066533a 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt @@ -19,7 +19,7 @@ package com.lambda.config.settings.collections import com.google.gson.reflect.TypeToken import com.lambda.config.Setting -import com.lambda.config.serializer.BlockCodec +import com.lambda.config.codecs.BlockCodec import com.lambda.gui.dsl.ImGuiBuilder import net.minecraft.block.Block diff --git a/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt index f40ef8ff3..31bb13c7e 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt @@ -22,11 +22,11 @@ import com.google.gson.reflect.TypeToken import com.lambda.Lambda.gson import com.lambda.config.Setting import com.lambda.gui.dsl.ImGuiBuilder -import com.lambda.util.reflections.className +import com.lambda.util.ReflectionUtils.className /** * @see [com.lambda.config.settings.collections.CollectionSetting] - * @see [com.lambda.config.Configurable] + * @see [com.lambda.config.Config] */ class ClassCollectionSetting( private val immutableCollection: Collection, @@ -43,10 +43,8 @@ class ClassCollectionSetting( // When serializing the list to json we do not want to serialize the elements' classes, but their stringified representation. // If we do serialize the classes we'll run into missing type adapters errors by Gson. // This is intended behaviour. If you wish your collection settings to display something else then you must extend this class. - context(setting: Setting<*, MutableCollection>) override fun toJson(): JsonElement = gson.toJsonTree(value.map { it.className }) - context(setting: Setting<*, MutableCollection>) override fun loadFromJson(serialized: JsonElement) { val strList = gson.fromJson>(serialized, type) .mapNotNull { str -> immutableCollection.find { it.className == str } } diff --git a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt index 6eb4c140c..3f56cf60f 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt @@ -44,7 +44,7 @@ import java.lang.reflect.Type * If you wish to use a different codec or simply display values differently, you must create your own * collection setting. * - * @see [com.lambda.config.Configurable] + * @see [com.lambda.config.Config] */ open class CollectionSetting( defaultValue: MutableCollection, @@ -167,11 +167,9 @@ open class CollectionSetting( } } - context(setting: Setting<*, MutableCollection>) override fun toJson(): JsonElement = gson.toJsonTree(value, type) - context(setting: Setting<*, MutableCollection>) override fun loadFromJson(serialized: JsonElement) { val strList = if (serialize) gson.fromJson(serialized, type) diff --git a/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt index 8a045ed29..637277af4 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt @@ -19,7 +19,7 @@ package com.lambda.config.settings.collections import com.google.gson.reflect.TypeToken import com.lambda.config.Setting -import com.lambda.config.serializer.ItemCodec +import com.lambda.config.codecs.ItemCodec import com.lambda.gui.dsl.ImGuiBuilder import net.minecraft.item.Item diff --git a/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt index db0e45b51..81b3acfeb 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt @@ -23,7 +23,7 @@ import com.lambda.gui.dsl.ImGuiBuilder import java.lang.reflect.Type /** - * @see [com.lambda.config.Configurable] + * @see [com.lambda.config.Config] */ class MapSetting( defaultValue: MutableMap, diff --git a/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt b/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt index f316e0b2f..f732d037c 100644 --- a/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt @@ -29,7 +29,7 @@ import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandRegistryAccess /** - * @see [com.lambda.config.Configurable] + * @see [com.lambda.config.Config] */ class BooleanSetting(defaultValue: Boolean) : SettingCore( defaultValue, diff --git a/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt b/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt index 67ecd6225..2b55f965c 100644 --- a/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt @@ -36,7 +36,7 @@ import net.minecraft.command.CommandRegistryAccess import kotlin.properties.Delegates /** - * @see [com.lambda.config.Configurable] + * @see [com.lambda.config.Config] */ class EnumSetting>(defaultValue: T) : SettingCore( defaultValue, @@ -46,7 +46,6 @@ class EnumSetting>(defaultValue: T) : SettingCore( value = value.enumValues[to % value.enumValues.size] } - context(setting: Setting<*, T>) override fun loadFromJson(serialized: JsonElement) { super.loadFromJson(serialized) index = value.ordinal // super bug fix for imgui diff --git a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt index b9fb525f4..2853df57b 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt @@ -27,14 +27,14 @@ import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.util.BlockUtils.blockPos -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.extension.CommandBuilder import com.lambda.util.world.raycast.RayCastUtils.blockResult import net.minecraft.command.CommandRegistryAccess import net.minecraft.util.math.BlockPos /** - * @see [com.lambda.config.Configurable] + * @see [com.lambda.config.Config] */ class BlockPosSetting(defaultValue: BlockPos) : SettingCore( defaultValue, diff --git a/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt index 7dbe8bf33..048d448d1 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt @@ -30,7 +30,7 @@ import net.minecraft.block.Block import net.minecraft.command.CommandRegistryAccess /** - * @see [com.lambda.config.Configurable] + * @see [com.lambda.config.Config] */ class BlockSetting(defaultValue: Block) : SettingCore( defaultValue, diff --git a/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt index 88913b3f1..9c78e6cb3 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt @@ -31,7 +31,7 @@ import net.minecraft.command.CommandRegistryAccess import java.awt.Color /** - * @see [com.lambda.config.Configurable] + * @see [com.lambda.config.Config] */ class ColorSetting(defaultValue: Color) : SettingCore( defaultValue, diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt index d5efa138b..7aab3f3b6 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt @@ -31,7 +31,7 @@ import net.minecraft.command.CommandRegistryAccess import kotlin.math.roundToInt /** - * @see [com.lambda.config.Configurable] + * @see [com.lambda.config.Config] */ class DoubleSetting( defaultValue: Double, diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt index a82509a09..0a9bb300c 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt @@ -30,7 +30,7 @@ import net.minecraft.command.CommandRegistryAccess import kotlin.math.roundToInt /** - * @see [com.lambda.config.Configurable] + * @see [com.lambda.config.Config] */ class FloatSetting( defaultValue: Float, diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/IntegerSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/IntegerSetting.kt index 07a1849dc..99748da62 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/IntegerSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/IntegerSetting.kt @@ -28,7 +28,7 @@ import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandRegistryAccess /** - * @see [com.lambda.config.Configurable] + * @see [com.lambda.config.Config] */ class IntegerSetting( defaultValue: Int, diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt index c71a2a838..8c3511caa 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt @@ -28,7 +28,7 @@ import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandRegistryAccess /** - * @see [com.lambda.config.Configurable] + * @see [com.lambda.config.Config] */ class LongSetting( defaultValue: Long, diff --git a/src/main/kotlin/com/lambda/context/Automated.kt b/src/main/kotlin/com/lambda/context/Automated.kt index 46d4cb23d..939c54213 100644 --- a/src/main/kotlin/com/lambda/context/Automated.kt +++ b/src/main/kotlin/com/lambda/context/Automated.kt @@ -19,11 +19,11 @@ package com.lambda.context import com.lambda.config.groups.BuildConfig import com.lambda.config.groups.EatConfig -import com.lambda.interaction.managers.breaking.BreakConfig -import com.lambda.interaction.managers.hotbar.HotbarConfig -import com.lambda.interaction.managers.interacting.InteractConfig -import com.lambda.interaction.managers.inventory.InventoryConfig -import com.lambda.interaction.managers.rotating.RotationConfig +import com.lambda.config.groups.BreakConfig +import com.lambda.config.groups.HotbarConfig +import com.lambda.config.groups.InteractConfig +import com.lambda.config.groups.InventoryConfig +import com.lambda.config.groups.RotationConfig interface Automated { val buildConfig: BuildConfig diff --git a/src/main/kotlin/com/lambda/core/Loader.kt b/src/main/kotlin/com/lambda/core/Loader.kt index 564f6fa81..2820a42f2 100644 --- a/src/main/kotlin/com/lambda/core/Loader.kt +++ b/src/main/kotlin/com/lambda/core/Loader.kt @@ -19,8 +19,8 @@ package com.lambda.core import com.lambda.Lambda import com.lambda.Lambda.LOG -import com.lambda.util.Communication.ascii -import com.lambda.util.reflections.getInstances +import com.lambda.util.CommunicationUtils.ascii +import com.lambda.util.getInstances import kotlin.system.measureTimeMillis import kotlin.time.Duration.Companion.milliseconds diff --git a/src/main/kotlin/com/lambda/friend/FriendHandler.kt b/src/main/kotlin/com/lambda/friend/FriendHandler.kt index 224e4175e..43195e83c 100644 --- a/src/main/kotlin/com/lambda/friend/FriendHandler.kt +++ b/src/main/kotlin/com/lambda/friend/FriendHandler.kt @@ -18,8 +18,8 @@ package com.lambda.friend import com.lambda.Lambda.mc -import com.lambda.config.Configurable -import com.lambda.config.configurations.FriendConfig +import com.lambda.config.Config +import com.lambda.config.categories.FriendCategory import com.lambda.core.Loadable import com.lambda.network.mojang.getProfile import com.lambda.util.text.ClickEvents @@ -34,7 +34,7 @@ import net.minecraft.text.Text import java.awt.Color import java.util.* -object FriendHandler : Configurable(FriendConfig), Loadable { +object FriendHandler : Config(FriendCategory), Loadable { override val name = "friends" val friends by setting("friends", emptySet(), serialize = true) diff --git a/src/main/kotlin/com/lambda/graphics/text/FontHandler.kt b/src/main/kotlin/com/lambda/graphics/text/FontHandler.kt index bad50be5e..261dcb665 100644 --- a/src/main/kotlin/com/lambda/graphics/text/FontHandler.kt +++ b/src/main/kotlin/com/lambda/graphics/text/FontHandler.kt @@ -18,12 +18,12 @@ package com.lambda.graphics.text import com.lambda.Lambda.LOG -import com.lambda.config.Configurable -import com.lambda.config.configurations.FontConfig +import com.lambda.config.Config +import com.lambda.config.categories.FontCategory import com.lambda.core.Loadable import com.lambda.event.events.ClientEvent import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.util.FolderRegister +import com.lambda.util.FolderRegistry import java.util.concurrent.ConcurrentHashMap import kotlin.io.path.notExists @@ -33,7 +33,7 @@ import kotlin.io.path.notExists * Manages SDF font atlases with automatic caching by path and size. * Fonts are discovered at startup but only loaded when actually used. */ -object FontHandler : Loadable, Configurable(FontConfig) { +object FontHandler : Loadable, Config(FontCategory) { override val name = "Font" override val priority = -1 @@ -74,7 +74,7 @@ object FontHandler : Loadable, Configurable(FontConfig) { fun discoverFonts() { discoveredFonts.clear() - val fontsFolder = FolderRegister.fonts + val fontsFolder = FolderRegistry.fonts if (fontsFolder.notExists()) { fontsFolder.toFile().mkdirs() diff --git a/src/main/kotlin/com/lambda/gui/MenuBar.kt b/src/main/kotlin/com/lambda/gui/MenuBar.kt index c496a03e4..fba4f930a 100644 --- a/src/main/kotlin/com/lambda/gui/MenuBar.kt +++ b/src/main/kotlin/com/lambda/gui/MenuBar.kt @@ -21,11 +21,10 @@ import com.lambda.Lambda import com.lambda.Lambda.REPO_URL import com.lambda.Lambda.mc import com.lambda.command.CommandRegistry -import com.lambda.config.AutomationConfig -import com.lambda.config.Configuration -import com.lambda.config.Configuration.Companion.configurables -import com.lambda.config.UserAutomationConfig -import com.lambda.config.configurations.UserAutomationConfigs +import com.lambda.config.automation.AutomationConfig +import com.lambda.config.ConfigLoader +import com.lambda.config.automation.UserAutomationConfig +import com.lambda.config.categories.UserAutomationCategory import com.lambda.core.Loader import com.lambda.event.EventFlow import com.lambda.graphics.texture.TextureOwner.upload @@ -46,10 +45,10 @@ import com.lambda.module.ModuleRegistry.moduleNameMap import com.lambda.module.tag.ModuleTag import com.lambda.network.LambdaAPI import com.lambda.threading.runSafe -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.Diagnostics.gatherDiagnostics -import com.lambda.util.FolderRegister -import com.lambda.util.FolderRegister.minecraft +import com.lambda.util.FolderRegistry +import com.lambda.util.FolderRegistry.minecraft import com.mojang.blaze3d.platform.TextureUtil import net.fabricmc.loader.api.FabricLoader import net.minecraft.client.gui.screen.DebugOptionsScreen @@ -118,10 +117,10 @@ object MenuBar { private fun ImGuiBuilder.buildLambdaMenu() { menu("Save Config...") { menuItem("Save All Configs") { - Configuration.configurations.forEach { it.trySave(true) } - info("Saved ${Configuration.configurations.size} configuration files.") + ConfigLoader.configCategories.forEach { it.trySave(true) } + info("Saved ${ConfigLoader.configCategories.size} configuration files.") } - Configuration.configurations.forEach { config -> + ConfigLoader.configCategories.forEach { config -> menuItem("Save ${config.configName}") { config.trySave(true) info("Saved ${config.configName}") @@ -130,10 +129,10 @@ object MenuBar { } menu("Load Config...") { menuItem("Load All Configs") { - Configuration.configurations.forEach { it.tryLoad() } - info("Loaded ${Configuration.configurations.size} configuration files.") + ConfigLoader.configCategories.forEach { it.tryLoad() } + info("Loaded ${ConfigLoader.configCategories.size} configuration files.") } - Configuration.configurations.forEach { config -> + ConfigLoader.configCategories.forEach { config -> menuItem("Load ${config.configName}") { config.tryLoad() info("Loaded ${config.configName}") @@ -158,28 +157,28 @@ object MenuBar { separator() menu("Open Folder") { menuItem("Open Lambda Folder") { - Util.getOperatingSystem().open(FolderRegister.lambda) + Util.getOperatingSystem().open(FolderRegistry.lambda) } menuItem("Open Config Folder") { - Util.getOperatingSystem().open(FolderRegister.config) + Util.getOperatingSystem().open(FolderRegistry.config) } menuItem("Open Packet Logs Folder") { - Util.getOperatingSystem().open(FolderRegister.packetLogs) + Util.getOperatingSystem().open(FolderRegistry.packetLogs) } menuItem("Open Replay Folder") { - Util.getOperatingSystem().open(FolderRegister.replay) + Util.getOperatingSystem().open(FolderRegistry.replay) } menuItem("Open Cache Folder") { - Util.getOperatingSystem().open(FolderRegister.cache) + Util.getOperatingSystem().open(FolderRegistry.cache) } menuItem("Open Capes Folder") { - Util.getOperatingSystem().open(FolderRegister.capes) + Util.getOperatingSystem().open(FolderRegistry.capes) } menuItem("Open Structures Folder") { - Util.getOperatingSystem().open(FolderRegister.structure) + Util.getOperatingSystem().open(FolderRegistry.structure) } menuItem("Open Maps Folder") { - Util.getOperatingSystem().open(FolderRegister.maps) + Util.getOperatingSystem().open(FolderRegistry.maps) } } separator() @@ -290,7 +289,7 @@ object MenuBar { popupContextWindow("##new-config") { inputText("Name", ::newConfigName) button("Create") { - if (newConfigName.isEmpty() && configurables.none { it.name == newConfigName }) return@button + if (newConfigName.isEmpty() && configs.none { it.name == newConfigName }) return@button UserAutomationConfig(newConfigName) newConfigName = "" closeCurrentPopup() @@ -303,8 +302,8 @@ object MenuBar { } } - UserAutomationConfigs.configurables.forEach { config -> - if (config !is UserAutomationConfig) throw java.lang.IllegalStateException("All configurables within UserAutomationConfigs must be UserAutomationConfigs!") + UserAutomationCategory.configs.forEach { config -> + if (config !is UserAutomationConfig) throw java.lang.IllegalStateException("All configs within UserAutomationConfigs must be UserAutomationConfigs!") buildAutomationConfigSelectable(config) } buildAutomationConfigSelectable(AutomationConfig.Companion.DEFAULT) @@ -321,7 +320,7 @@ object MenuBar { module.automationConfig = module.defaultAutomationConfig } } - UserAutomationConfigs.configurables.remove(config) + UserAutomationCategory.configs.remove(config) } separator() } @@ -469,8 +468,8 @@ object MenuBar { text("Runtime: ${Loader.runtime}") text("Modules: ${ModuleRegistry.modules.size}") text("Commands: ${CommandRegistry.commands.size}") - val totalSettings = Configuration.configurations.sumOf { cfg -> - cfg.configurables.sumOf { it.settings.size } + val totalSettings = ConfigLoader.configCategories.sumOf { cfg -> + cfg.configs.sumOf { it.settings.size } } text("Settings: $totalSettings") text("Synchronous listeners: ${EventFlow.syncListeners.size}") diff --git a/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt b/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt index a5b023466..b8d078309 100644 --- a/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt +++ b/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt @@ -18,8 +18,8 @@ package com.lambda.gui.components import com.lambda.Lambda.mc -import com.lambda.config.Configurable -import com.lambda.config.configurations.GuiConfig +import com.lambda.config.Config +import com.lambda.config.categories.GuiCategory import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.core.Loadable import com.lambda.event.events.GuiEvent @@ -61,7 +61,7 @@ import net.minecraft.client.util.Icons import java.awt.Color @Suppress("unused") -object ClickGuiLayout : Loadable, Configurable(GuiConfig) { +object ClickGuiLayout : Loadable, Config(GuiCategory) { override val name = "GUI" var open = false var developerMode = false diff --git a/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt b/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt index aaf27ebc3..20c1d4fea 100644 --- a/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt +++ b/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt @@ -17,8 +17,8 @@ package com.lambda.gui.components -import com.lambda.config.Configurable -import com.lambda.config.configurations.HudConfig +import com.lambda.config.Config +import com.lambda.config.categories.HudCategory import com.lambda.core.Loadable import com.lambda.event.events.GuiEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -43,7 +43,7 @@ import com.lambda.util.NamedEnum import java.awt.Color import kotlin.math.PI -object HudGuiLayout : Loadable, Configurable(HudConfig) { +object HudGuiLayout : Loadable, Config(HudCategory) { override val name = "HUD" enum class Group(override val displayName: String) : NamedEnum { diff --git a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt index a33b93581..a3d7fbf1c 100644 --- a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt +++ b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt @@ -20,8 +20,8 @@ package com.lambda.gui.components import com.lambda.Lambda.mc import com.lambda.command.CommandRegistry import com.lambda.command.LambdaCommand -import com.lambda.config.Configurable -import com.lambda.config.Configuration +import com.lambda.config.Config +import com.lambda.config.ConfigLoader import com.lambda.config.Setting import com.lambda.event.events.ButtonEvent import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe @@ -102,8 +102,8 @@ object QuickSearch { } } - private class SettingResult(val setting: Setting<*, *>, val configurable: Configurable) : SearchResult { - override val breadcrumb: String by lazy { buildSettingBreadcrumb(configurable.name, setting) } + private class SettingResult(val setting: Setting<*, *>, val config: Config) : SearchResult { + override val breadcrumb: String by lazy { buildSettingBreadcrumb(config.name, setting) } override fun ImGuiBuilder.buildLayout() { with(setting) { @@ -261,13 +261,13 @@ object QuickSearch { } else null } - val settingResults = Configuration.configurations.flatMap { - it.configurables.flatMap { configurable -> - configurable.settings + val settingResults = ConfigLoader.configCategories.flatMap { + it.configs.flatMap { config -> + config.settings .filter { setting -> setting.visibility() } .mapNotNull { setting -> val score = calculateScore(lowerCaseQuery, setting.name.lowercase(), lenient) - if (score > 0) RankedSearchResult(SettingResult(setting, configurable), score) else null + if (score > 0) RankedSearchResult(SettingResult(setting, config), score) else null } } } @@ -297,12 +297,12 @@ object QuickSearch { } } - private fun buildSettingBreadcrumb(configurableName: String, setting: Setting<*, *>): String { + private fun buildSettingBreadcrumb(configName: String, setting: Setting<*, *>): String { val group = setting.groups .minByOrNull { it.size } ?.joinToString(" » ") { it.displayName } - ?: return configurableName - return "$configurableName » $group" + ?: return configName + return "$configName » $group" } private fun handleKeyPress(event: ButtonEvent.Keyboard.Press) { diff --git a/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt b/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt index a691888ac..22d38f9b4 100644 --- a/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt +++ b/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt @@ -17,12 +17,13 @@ package com.lambda.gui.components -import com.lambda.config.AutomationConfig -import com.lambda.config.Configurable -import com.lambda.config.IMutableAutomationConfig +import com.lambda.config.automation.AutomationConfig +import com.lambda.config.Config +import com.lambda.config.automation.IMutableAutomationConfig import com.lambda.config.Setting import com.lambda.config.UserAutomationConfig -import com.lambda.config.configurations.UserAutomationConfigs +import com.lambda.config.automation.UserAutomationConfig +import com.lambda.config.categories.UserAutomationCategory import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.ImGui import com.lambda.imgui.flag.ImGuiPopupFlags @@ -34,9 +35,9 @@ import com.lambda.util.NamedEnum object SettingsWidget { /** - * Builds the settings context popup content for the given configurable. + * Builds the settings context popup content for the given config. */ - fun ImGuiBuilder.buildConfigSettingsContext(config: Configurable) { + fun ImGuiBuilder.buildConfigSettingsContext(config: Config) { group { if (config is Module && config != AutoUpdater) { button("Module Settings") { @@ -68,7 +69,7 @@ object SettingsWidget { ImGui.setNextWindowSizeConstraints(0f, 0f, Float.MAX_VALUE, io.displaySize.y * 0.5f) popupContextItem("##automation-config-popup-${config.name}", ImGuiPopupFlags.None) { combo("##LinkedConfig", preview = "Linked Config: ${config.backingAutomationConfig.name}") { - val addItem: (Configurable) -> Unit = { item -> + val addItem: (Config) -> Unit = { item -> val selected = item === config.backingAutomationConfig selectable(item.name, selected) { @@ -80,7 +81,7 @@ object SettingsWidget { } } addItem(config.defaultAutomationConfig) - UserAutomationConfigs.configurables.forEach { addItem(it) } + UserAutomationCategory.configs.forEach { addItem(it) } } buildConfigSettingsContext(config.automationConfig) } @@ -106,7 +107,7 @@ object SettingsWidget { private fun ImGuiBuilder.renderGroup( settings: List>, parentPath: List, - config: Configurable + config: Config ) { settings.filter { it.groups.contains(parentPath) }.forEach { it.withDisabled { buildLayout() } diff --git a/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt b/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt index a6c7fe12e..46b8a3986 100644 --- a/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt @@ -21,9 +21,9 @@ import baritone.api.BaritoneAPI import baritone.api.IBaritone import baritone.api.Settings import baritone.api.pathing.goals.Goal -import com.lambda.config.AutomationConfig -import com.lambda.config.Configurable -import com.lambda.config.configurations.LambdaConfig +import com.lambda.config.automation.AutomationConfig +import com.lambda.config.Config +import com.lambda.config.categories.LambdaCategory import com.lambda.config.groups.RotationSettings import com.lambda.context.Automated import com.lambda.util.BlockUtils.blockPos @@ -31,7 +31,7 @@ import com.lambda.util.NamedEnum import net.fabricmc.loader.api.FabricLoader @Suppress("unused") -object BaritoneHandler : Configurable(LambdaConfig), Automated by AutomationConfig.Companion.DEFAULT { +object BaritoneHandler : Config(LambdaCategory), Automated by AutomationConfig.Companion.DEFAULT { override val name = "baritone" val isBaritoneLoaded = FabricLoader.getInstance().isModLoaded("baritone") diff --git a/src/main/kotlin/com/lambda/interaction/construction/StructureRegistry.kt b/src/main/kotlin/com/lambda/interaction/construction/StructureRegistry.kt index fb8cea819..77ce6dd8e 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/StructureRegistry.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/StructureRegistry.kt @@ -19,8 +19,8 @@ package com.lambda.interaction.construction import com.lambda.Lambda.LOG import com.lambda.core.Loadable -import com.lambda.util.FolderRegister -import com.lambda.util.FolderRegister.structure +import com.lambda.util.FolderRegistry +import com.lambda.util.FolderRegistry.structure import com.lambda.util.extension.readLitematica import com.lambda.util.extension.readSchematic import com.lambda.util.extension.readSponge @@ -164,7 +164,7 @@ object StructureRegistry : ConcurrentHashMap(), Loada * @param structure The [StructureTemplate] to save. */ private fun saveStructure(relativePath: String, structure: StructureTemplate) { - val path = FolderRegister.structure.resolve("$relativePath.nbt") + val path = FolderRegistry.structure.resolve("$relativePath.nbt") val compound = structure.writeNbt(NbtCompound()) Files.createDirectories(path.parent) diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt index dd165d7c0..7ce397a90 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt @@ -21,9 +21,9 @@ import com.lambda.interaction.construction.simulation.processing.PreProcessingDa import com.lambda.interaction.construction.simulation.result.BuildResult import com.lambda.interaction.construction.simulation.result.results.GenericResult import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo -import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.CheckedHit -import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.scanClosestPoints -import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.scanSurfaces +import com.lambda.util.player.RotationUtils.CheckedHit +import com.lambda.util.player.RotationUtils.scanClosestPoints +import com.lambda.util.player.RotationUtils.scanSurfaces import com.lambda.util.math.distSq import com.lambda.util.math.vec3d import com.lambda.util.world.raycast.RayCastUtils.blockResult diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt index 8d588b317..655a64765 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt @@ -24,7 +24,7 @@ import com.lambda.interaction.construction.simulation.SimDsl import com.lambda.interaction.construction.simulation.SimInfo import com.lambda.interaction.construction.simulation.result.results.GenericResult import com.lambda.interaction.construction.simulation.result.results.PreSimResult -import com.lambda.interaction.managers.breaking.BreakConfig.WhitelistMode +import com.lambda.config.groups.BreakConfig.WhitelistMode import com.lambda.util.player.gamemode import com.lambda.util.world.WorldUtils.isLoaded import net.minecraft.block.OperatorBlock diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt index cd5880aff..43a80cd08 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt @@ -31,8 +31,8 @@ import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotat import com.lambda.interaction.managers.rotating.Rotation import com.lambda.interaction.managers.rotating.Rotation.Companion.rotation import com.lambda.interaction.managers.rotating.RotationManager -import com.lambda.interaction.managers.rotating.visibilty.PlaceDirection -import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.CheckedHit +import com.lambda.util.PlaceDirection +import com.lambda.util.player.RotationUtils.CheckedHit import com.lambda.interaction.managers.rotating.visibilty.lookInDirection import com.lambda.interaction.material.ContainerSelection.Companion.selectContainer import com.lambda.interaction.material.StackSelection diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/ProcessorRegistry.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/ProcessorRegistry.kt index 7e6de74ad..0e4d52b9e 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/ProcessorRegistry.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/ProcessorRegistry.kt @@ -23,7 +23,7 @@ import com.lambda.core.Loadable import com.lambda.interaction.construction.simulation.SimDsl import com.lambda.interaction.construction.verify.TargetState import com.lambda.util.BlockUtils.matches -import com.lambda.util.reflections.getInstances +import com.lambda.util.getInstances import net.minecraft.block.BlockState import net.minecraft.item.ItemStack import net.minecraft.state.property.Properties diff --git a/src/main/kotlin/com/lambda/interaction/managers/ManagerUtils.kt b/src/main/kotlin/com/lambda/interaction/managers/ManagerUtils.kt index 491eb623c..7a26ca836 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/ManagerUtils.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/ManagerUtils.kt @@ -17,7 +17,7 @@ package com.lambda.interaction.managers -import com.lambda.util.reflections.getInstances +import com.lambda.util.getInstances import net.minecraft.util.math.BlockPos object ManagerUtils { diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakInfo.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakInfo.kt index 0d0873dee..acf6aaa6b 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakInfo.kt @@ -17,6 +17,7 @@ package com.lambda.interaction.managers.breaking +import com.lambda.config.groups.BreakConfig import com.lambda.context.SafeContext import com.lambda.interaction.construction.simulation.context.BreakContext import com.lambda.interaction.managers.ActionInfo diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt index c1e3d526a..0ef507446 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt @@ -17,6 +17,7 @@ package com.lambda.interaction.managers.breaking +import com.lambda.config.groups.BreakConfig import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext import com.lambda.event.events.ConnectionEvent @@ -36,8 +37,8 @@ import com.lambda.interaction.managers.ManagerUtils.isPosBlocked import com.lambda.interaction.managers.PacketLimitHandler import com.lambda.interaction.managers.PacketType import com.lambda.interaction.managers.PositionBlocking -import com.lambda.interaction.managers.breaking.BreakConfig.BreakConfirmationMode -import com.lambda.interaction.managers.breaking.BreakConfig.BreakMode +import com.lambda.config.groups.BreakConfig.BreakConfirmationMode +import com.lambda.config.groups.BreakConfig.BreakMode import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Primary import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Rebreak import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.RedundantSecondary diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt index abb45b1f9..6d0b83a6c 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt @@ -17,14 +17,14 @@ package com.lambda.interaction.managers.breaking -import com.lambda.config.AutomationConfig.Companion.DEFAULT +import com.lambda.config.automation.AutomationConfig.Companion.DEFAULT import com.lambda.context.SafeContext import com.lambda.event.events.EntityEvent import com.lambda.event.events.WorldEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.construction.simulation.processing.ProcessorRegistry import com.lambda.interaction.managers.PostActionHandler -import com.lambda.interaction.managers.breaking.BreakConfig.BreakConfirmationMode +import com.lambda.config.groups.BreakConfig.BreakConfirmationMode import com.lambda.interaction.managers.breaking.BreakManager.lastPosStarted import com.lambda.interaction.managers.breaking.BreakManager.matchesBlockItem import com.lambda.interaction.managers.breaking.RebreakHandler.rebreak @@ -36,7 +36,7 @@ import com.lambda.util.BlockUtils.fluidState import com.lambda.util.BlockUtils.isEmpty import com.lambda.util.BlockUtils.isNotBroken import com.lambda.util.BlockUtils.matches -import com.lambda.util.Communication.warn +import com.lambda.util.CommunicationUtils.warn import com.lambda.util.collections.LimitedDecayQueue import com.lambda.util.player.gamemode import net.minecraft.block.OperatorBlock diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakHandler.kt index e504e5603..42c098ddb 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakHandler.kt @@ -17,6 +17,7 @@ package com.lambda.interaction.managers.breaking +import com.lambda.config.groups.BreakConfig import com.lambda.context.SafeContext import com.lambda.event.events.ConnectionEvent import com.lambda.event.events.TickEvent diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/SwapInfo.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/SwapInfo.kt index 2e79dd828..fd2c11b38 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/SwapInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/SwapInfo.kt @@ -17,7 +17,8 @@ package com.lambda.interaction.managers.breaking -import com.lambda.config.AutomationConfig.Companion.DEFAULT +import com.lambda.config.automation.AutomationConfig.Companion.DEFAULT +import com.lambda.config.groups.BreakConfig import com.lambda.context.Automated import com.lambda.context.SafeContext import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Primary diff --git a/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt index 4bc8bcca9..4dbbf21bd 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt @@ -22,7 +22,7 @@ import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.Manager -import com.lambda.interaction.managers.hotbar.HotbarConfig.SwapMode +import com.lambda.config.groups.HotbarConfig.SwapMode import com.lambda.interaction.managers.hotbar.HotbarManager.activeRequest import com.lambda.interaction.managers.hotbar.HotbarManager.activeSlot import com.lambda.interaction.managers.hotbar.HotbarManager.checkResetSwap @@ -142,7 +142,7 @@ object HotbarManager : Manager( /** * Called after every [tickStage] closes. This method checks if the current [activeRequest] should be stopped. * This action is counted as another swap, so the conditions for a regular swap must be met. If the requests - * [HotbarConfig.tickStageMask] does not contain the current tick stage, no actions can be performed. + * [com.lambda.config.groups.HotbarConfig.tickStageMask] does not contain the current tick stage, no actions can be performed. * * @see net.minecraft.client.network.ClientPlayerInteractionManager.syncSelectedSlot */ diff --git a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractInfo.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractInfo.kt index febea9365..b05b6c0a8 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractInfo.kt @@ -17,6 +17,7 @@ package com.lambda.interaction.managers.interacting +import com.lambda.config.groups.InteractConfig import com.lambda.context.SafeContext import com.lambda.interaction.construction.simulation.context.BuildContext import com.lambda.interaction.construction.simulation.context.InteractContext diff --git a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt index 271c2c578..29f156dc9 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt @@ -17,6 +17,7 @@ package com.lambda.interaction.managers.interacting +import com.lambda.config.groups.InteractConfig import com.lambda.context.Automated import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext @@ -34,7 +35,7 @@ import com.lambda.interaction.managers.PacketType import com.lambda.interaction.managers.PositionBlocking import com.lambda.interaction.managers.breaking.BreakManager import com.lambda.interaction.managers.hotbar.HotbarRequest -import com.lambda.interaction.managers.interacting.InteractConfig.AirPlaceMode +import com.lambda.config.groups.InteractConfig.AirPlaceMode import com.lambda.interaction.managers.interacting.InteractManager.activeRequest import com.lambda.interaction.managers.interacting.InteractManager.maxInteractionsThisTick import com.lambda.interaction.managers.interacting.InteractManager.populateFrom @@ -49,6 +50,7 @@ import com.lambda.threading.runConcurrent import com.lambda.threading.runSafeAutomated import com.lambda.threading.runSafeGameScheduled import com.lambda.util.BlockUtils.blockState +import com.lambda.util.PacketUtils.sendPacket import com.lambda.util.item.ItemUtils.blockItem import com.lambda.util.player.MovementUtils.sneaking import com.lambda.util.player.gamemode @@ -217,9 +219,9 @@ object InteractManager : Manager( runConcurrent { delay(signWriteDelay) runSafeGameScheduled { - connection.sendPacket( + connection.sendPacket { UpdateSignC2SPacket(ctx.blockPos, true, "", "", "", "") - ) + } } } } diff --git a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt index 7472b431b..137ea9358 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt @@ -17,7 +17,8 @@ package com.lambda.interaction.managers.interacting -import com.lambda.config.AutomationConfig.Companion.DEFAULT +import com.lambda.config.automation.AutomationConfig.Companion.DEFAULT +import com.lambda.config.groups.InteractConfig import com.lambda.event.events.WorldEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.PostActionHandler @@ -25,7 +26,7 @@ import com.lambda.interaction.managers.interacting.InteractManager.placeSound import com.lambda.module.modules.client.Client.verboseDebug import com.lambda.threading.runSafe import com.lambda.util.BlockUtils.matches -import com.lambda.util.Communication.warn +import com.lambda.util.CommunicationUtils.warn import com.lambda.util.collections.LimitedDecayQueue object InteractedBlockHandler : PostActionHandler() { diff --git a/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryRequest.kt b/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryRequest.kt index e051d932e..fbbf9202d 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryRequest.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryRequest.kt @@ -20,6 +20,7 @@ package com.lambda.interaction.managers.inventory import com.lambda.context.Automated import com.lambda.context.SafeContext import com.lambda.interaction.managers.Request +import com.lambda.util.PacketUtils.sendPacket import com.lambda.util.player.SlotUtils.clickSlot import net.minecraft.item.ItemStack import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket @@ -81,13 +82,13 @@ class InventoryRequest private constructor( val offhandStack = player.getStackInHand(Hand.OFF_HAND) player.setStackInHand(Hand.OFF_HAND, player.getStackInHand(Hand.MAIN_HAND)) player.setStackInHand(Hand.MAIN_HAND, offhandStack) - connection.sendPacket( + connection.sendPacket { PlayerActionC2SPacket( PlayerActionC2SPacket.Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ORIGIN, Direction.DOWN ) - ) + } }.addToActions() } diff --git a/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PointSelection.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PointSelection.kt deleted file mode 100644 index 69df13106..000000000 --- a/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PointSelection.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.interaction.managers.rotating.visibilty - -import com.lambda.interaction.managers.rotating.Rotation.Companion.dist -import com.lambda.interaction.managers.rotating.RotationManager -import com.lambda.util.Describable -import com.lambda.util.NamedEnum -import com.lambda.util.math.distSq -import com.lambda.util.math.times - -enum class PointSelection( - override val displayName: String, - override val description: String, - val select: (Collection) -> VisibilityChecker.CheckedHit? -) : NamedEnum, Describable { - ByRotation( - "By Rotation", - "Choose the point that needs the least rotation from your current view (minimal camera turn).", - select = { hits -> - hits.minByOrNull { RotationManager.activeRotation dist it.rotation } - } - ), - Optimum( - "Optimum", - "Choose the point closest to the average of all candidates (balanced and stable aim).", - select = { hits -> - val optimum = hits - .mapNotNull { it.hit.pos } - .reduceOrNull { acc, pos -> acc.add(pos) } - ?.times(1 / hits.size.toDouble()) - - optimum?.let { center -> - hits.minByOrNull { it.hit.pos?.distSq(center) ?: 0.0 } - } - } - ) -} diff --git a/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/RotationTargets.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/RotationTargets.kt deleted file mode 100644 index ffa91a59c..000000000 --- a/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/RotationTargets.kt +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.interaction.managers.rotating.visibilty - -import com.lambda.context.AutomatedSafeContext -import com.lambda.context.SafeContext -import com.lambda.interaction.managers.rotating.Rotation -import com.lambda.interaction.managers.rotating.RotationManager -import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.ALL_SIDES -import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.findRotation -import com.lambda.util.extension.rotation -import net.minecraft.entity.Entity -import net.minecraft.util.hit.BlockHitResult -import net.minecraft.util.hit.EntityHitResult -import net.minecraft.util.hit.HitResult -import net.minecraft.util.math.BlockPos -import net.minecraft.util.math.Direction -import net.minecraft.util.math.Vec3d -import kotlin.math.atan2 -import kotlin.math.hypot - -@DslMarker -annotation class RotationDsl - -@RotationDsl -fun SafeContext.lookAt(pos: Vec3d): Rotation { - val direction = pos.subtract(player.eyePos).normalize() - val yaw = Math.toDegrees(atan2(direction.z, direction.x)) - 90.0 - val pitch = -Math.toDegrees(atan2(direction.y, hypot(direction.x, direction.z))) - return Rotation(yaw, pitch) -} - -@RotationDsl -fun SafeContext.lookInDirection(direction: PlaceDirection) = - if (!direction.isInArea(player.rotation)) direction.snapToArea(RotationManager.activeRotation) - else player.rotation - -@RotationDsl -fun AutomatedSafeContext.lookAtHit(hit: HitResult) = - when (hit) { - is BlockHitResult -> lookAtBlock(hit.blockPos, setOf(hit.side)) - is EntityHitResult -> lookAtEntity(hit.entity) - else -> null - } - -@RotationDsl -fun AutomatedSafeContext.lookAtEntity(entity: Entity, sides: Set = ALL_SIDES) = - entity.findRotation(buildConfig.entityReach, player.eyePos, sides) - -@RotationDsl -fun AutomatedSafeContext.lookAtBlock(pos: BlockPos, sides: Set = ALL_SIDES) = - pos.findRotation(buildConfig.blockReach, player.eyePos, sides) \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/material/container/ContainerHandler.kt b/src/main/kotlin/com/lambda/interaction/material/container/ContainerHandler.kt index bf14abcd2..f5700ced4 100644 --- a/src/main/kotlin/com/lambda/interaction/material/container/ContainerHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/material/container/ContainerHandler.kt @@ -30,7 +30,7 @@ import com.lambda.interaction.material.container.containers.ChestContainer import com.lambda.interaction.material.container.containers.EnderChestContainer import com.lambda.util.BlockUtils.blockEntity import com.lambda.util.extension.containerStacks -import com.lambda.util.reflections.getInstances +import com.lambda.util.getInstances import net.minecraft.block.entity.BlockEntity import net.minecraft.block.entity.ChestBlockEntity import net.minecraft.block.entity.EnderChestBlockEntity diff --git a/src/main/kotlin/com/lambda/module/Module.kt b/src/main/kotlin/com/lambda/module/Module.kt index ae47bf58f..9a4eec880 100644 --- a/src/main/kotlin/com/lambda/module/Module.kt +++ b/src/main/kotlin/com/lambda/module/Module.kt @@ -18,12 +18,12 @@ package com.lambda.module import com.lambda.command.LambdaCommand -import com.lambda.config.Configurable -import com.lambda.config.Configuration -import com.lambda.config.IMutableAutomationConfig -import com.lambda.config.MutableAutomationConfig +import com.lambda.config.Config +import com.lambda.config.ConfigCategory +import com.lambda.config.automation.IMutableAutomationConfig +import com.lambda.config.automation.MutableAutomationConfig import com.lambda.config.SettingCore -import com.lambda.config.configurations.ModuleConfigs +import com.lambda.config.categories.ModuleCategory import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.config.settings.complex.KeybindSetting.Companion.onRelease @@ -46,7 +46,7 @@ import com.lambda.util.Nameable /** * A [Module] is a feature or tool for the utility mod. - * It represents a [Configurable] component of the mod, + * It represents a [Config] component of the mod, * with its own set of behaviors and properties. * * Each [Module] has a [name], which is displayed in-game. @@ -61,7 +61,7 @@ import com.lambda.util.Nameable * If a module does not need to be activated by a key (like [ClickGui]), * the default [keybind] should not be set (using [KeyCode.Unbound]). * - * [Module]s are [Configurable]s with [settings] (see [SettingCore] for all setting types). + * [Module]s are [Config]s with [settings] (see [SettingCore] for all setting types). * Example: * ``` * private val foo by setting("Foo", true) @@ -69,7 +69,7 @@ import com.lambda.util.Nameable * ``` * * These settings are persisted in the `lambda/config/modules.json` config file. - * See [ModuleConfigs.primary] and [Configuration] for more details. + * See [ModuleCategory.primary] and [ConfigCategory] for more details. * * In the `init` block, you can add hooks like [onEnable], [onDisable], [onToggle] and add listeners. * @@ -123,7 +123,7 @@ abstract class Module( enabledByDefault: Boolean = false, defaultKeybind: Bind = Bind.EMPTY, autoDisable: Boolean = false -) : Nameable, Muteable, OwnerPriority, Configurable(ModuleConfigs), +) : Nameable, Muteable, OwnerPriority, Config(ModuleCategory), IMutableAutomationConfig by MutableAutomationConfig() { private val isEnabledSetting = setting("Enabled", enabledByDefault) { false } diff --git a/src/main/kotlin/com/lambda/module/ModuleRegistry.kt b/src/main/kotlin/com/lambda/module/ModuleRegistry.kt index 9c9f52dbe..2662346b2 100644 --- a/src/main/kotlin/com/lambda/module/ModuleRegistry.kt +++ b/src/main/kotlin/com/lambda/module/ModuleRegistry.kt @@ -18,7 +18,8 @@ package com.lambda.module import com.lambda.core.Loadable -import com.lambda.util.reflections.getInstances +import com.lambda.util.ReflectionUtils.getInstances +import com.lambda.util.getInstances object ModuleRegistry : Loadable { override val priority = 1 diff --git a/src/main/kotlin/com/lambda/module/hud/Coordinates.kt b/src/main/kotlin/com/lambda/module/hud/Coordinates.kt index 7162b5da0..9a924aa0f 100644 --- a/src/main/kotlin/com/lambda/module/hud/Coordinates.kt +++ b/src/main/kotlin/com/lambda/module/hud/Coordinates.kt @@ -23,7 +23,7 @@ import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe -import com.lambda.util.Formatting.format +import com.lambda.util.FormattingUtils.format import com.lambda.util.NamedEnum import com.lambda.util.extension.dimensionName import com.lambda.util.extension.isNether diff --git a/src/main/kotlin/com/lambda/module/hud/Rotation.kt b/src/main/kotlin/com/lambda/module/hud/Rotation.kt index 22f244658..fb39ebc05 100644 --- a/src/main/kotlin/com/lambda/module/hud/Rotation.kt +++ b/src/main/kotlin/com/lambda/module/hud/Rotation.kt @@ -23,7 +23,7 @@ import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe -import com.lambda.util.Formatting.format +import com.lambda.util.FormattingUtils.format @Suppress("unused") object Rotation : HudModule( diff --git a/src/main/kotlin/com/lambda/module/hud/TPS.kt b/src/main/kotlin/com/lambda/module/hud/TPS.kt index 2198a7a21..cd1b3022c 100644 --- a/src/main/kotlin/com/lambda/module/hud/TPS.kt +++ b/src/main/kotlin/com/lambda/module/hud/TPS.kt @@ -21,9 +21,9 @@ import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.ImVec2 import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag -import com.lambda.util.Formatting.format -import com.lambda.util.ServerTPS -import com.lambda.util.ServerTPS.recentData +import com.lambda.util.FormattingUtils.format +import com.lambda.util.ServerTPSUtils +import com.lambda.util.ServerTPSUtils.recentData @Suppress("unused") object TPS : HudModule( @@ -31,7 +31,7 @@ object TPS : HudModule( description = "Display the server's tick rate", tag = ModuleTag.HUD, ) { - private val format by setting("Tick format", ServerTPS.TickFormat.Tps) + private val format by setting("Tick format", ServerTPSUtils.TickFormat.Tps) private val showGraph by setting("Show TPS Graph", false) private val graphHeight by setting("Graph Height", 40f, 10f..200f, 1f) private val graphWidth by setting("Graph Width", 200f, 10f..500f, 1f) diff --git a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt index ce2a42fac..dd67184a4 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.chat -import com.lambda.config.Configurable +import com.lambda.config.Config import com.lambda.config.SettingGroup import com.lambda.config.applyEdits import com.lambda.config.groups.ReplaceConfig @@ -137,7 +137,7 @@ object AntiSpam : Module( class ReplaceSettings( name: String, - c: Configurable, + c: Config, baseGroup: NamedEnum, override val visibility: () -> Boolean = { true }, ) : ReplaceConfig, SettingGroup(c) { diff --git a/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt b/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt index 85cd25c5c..b55ade417 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt @@ -24,7 +24,7 @@ import com.lambda.event.events.ChatEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.Formatting.format +import com.lambda.util.FormattingUtils.format import com.lambda.util.text.buildText import com.lambda.util.text.literal import com.lambda.util.text.styled diff --git a/src/main/kotlin/com/lambda/module/modules/chat/FriendHighlight.kt b/src/main/kotlin/com/lambda/module/modules/chat/FriendHighlight.kt index 5c8057fdc..dfbe2d603 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/FriendHighlight.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/FriendHighlight.kt @@ -23,7 +23,7 @@ import com.lambda.friend.FriendHandler import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.sound.SoundHandler.playSound -import com.lambda.util.Communication.logError +import com.lambda.util.CommunicationUtils.logError import com.lambda.util.text.MessageType import com.lambda.util.text.buildText import com.lambda.util.text.literal diff --git a/src/main/kotlin/com/lambda/module/modules/client/AutoUpdater.kt b/src/main/kotlin/com/lambda/module/modules/client/AutoUpdater.kt index 371e5a79e..c39d803e1 100644 --- a/src/main/kotlin/com/lambda/module/modules/client/AutoUpdater.kt +++ b/src/main/kotlin/com/lambda/module/modules/client/AutoUpdater.kt @@ -28,9 +28,9 @@ import com.lambda.imgui.flag.ImGuiWindowFlags import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runIO -import com.lambda.util.Communication.debug -import com.lambda.util.Communication.logError -import com.lambda.util.Communication.warn +import com.lambda.util.CommunicationUtils.debug +import com.lambda.util.CommunicationUtils.logError +import com.lambda.util.CommunicationUtils.warn import net.fabricmc.loader.api.FabricLoader import net.minecraft.SharedConstants import java.net.URI diff --git a/src/main/kotlin/com/lambda/module/modules/client/Discord.kt b/src/main/kotlin/com/lambda/module/modules/client/Discord.kt index 7cfbf04ed..0ba10681a 100644 --- a/src/main/kotlin/com/lambda/module/modules/client/Discord.kt +++ b/src/main/kotlin/com/lambda/module/modules/client/Discord.kt @@ -28,7 +28,7 @@ import com.lambda.module.tag.ModuleTag import com.lambda.network.NetworkHandler.updateToken import com.lambda.network.api.v1.endpoints.linkDiscord import com.lambda.threading.runConcurrent -import com.lambda.util.Communication.warn +import com.lambda.util.CommunicationUtils.warn import com.lambda.util.Nameable import com.lambda.util.extension.dimensionName import com.lambda.util.extension.fullHealth diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt index 9fffcb642..26ad5da8a 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.combat -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoDisconnect.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoDisconnect.kt index 3337778f2..e20318171 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoDisconnect.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoDisconnect.kt @@ -25,9 +25,9 @@ import com.lambda.friend.FriendHandler import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.sound.SoundHandler.playSound -import com.lambda.util.Communication -import com.lambda.util.Communication.prefix -import com.lambda.util.Formatting.format +import com.lambda.util.CommunicationUtils +import com.lambda.util.CommunicationUtils.prefix +import com.lambda.util.FormattingUtils.format import com.lambda.util.combat.CombatUtils.hasDeadlyCrystal import com.lambda.util.combat.DamageUtils.isFallDeadly import com.lambda.util.extension.fullHealth @@ -161,13 +161,13 @@ object AutoDisconnect : Module( } private fun SafeContext.generateInfo(text: Text) = buildText { - text(prefix(Communication.LogLevel.Warn.logoColor)) + text(prefix(CommunicationUtils.LogLevel.Warn.logoColor)) text(text) literal("\n\n") literal("Disconnected at ") highlighted(player.pos.format()) literal(" on ") - highlighted(Communication.currentTime()) + highlighted(CommunicationUtils.currentTime()) literal(" with ") highlighted(player.fullHealth.format()) literal(" health.") diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt index e6ae22686..a8c1fbe32 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.combat -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent diff --git a/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt b/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt index 42a9e4ac3..365098320 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt @@ -24,6 +24,7 @@ import com.lambda.interaction.managers.rotating.Rotation import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo import com.lambda.module.Module import com.lambda.module.tag.ModuleTag +import com.lambda.util.PacketUtils.sendPacket import com.lambda.util.extension.rotation import com.lambda.util.math.component1 import com.lambda.util.math.component2 @@ -55,13 +56,13 @@ object Criticals : Module( posPacket(-0.000000001, rotation = player.eyePos.rotationTo(it.entity.boundingBox.center)) connection.sendPacket(PlayerInteractItemC2SPacket(Hand.OFF_HAND, 0, player.yaw, player.pitch)) // TODO: This is wrong, fix it - connection.sendPacket( + connection.sendPacket { PlayerActionC2SPacket( PlayerActionC2SPacket.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Direction.DOWN ) - ) + } } } } diff --git a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt index a628c701b..fff4d571b 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt @@ -17,9 +17,9 @@ package com.lambda.module.modules.combat -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits -import com.lambda.config.groups.Targeting +import com.lambda.config.groups.TargetingSettings import com.lambda.context.SafeContext import com.lambda.event.events.EntityEvent import com.lambda.event.events.TickEvent @@ -28,7 +28,7 @@ import com.lambda.interaction.managers.hotbar.HotbarRequest import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo import com.lambda.interaction.managers.rotating.RotationManager -import com.lambda.interaction.managers.rotating.visibilty.VisibilityChecker.getVisibleSurfaces +import com.lambda.util.player.RotationUtils.getVisibleSurfaces import com.lambda.interaction.material.StackSelection.Companion.selectStack import com.lambda.interaction.material.container.ContainerHandler.transfer import com.lambda.interaction.material.container.containers.HotbarContainer @@ -39,7 +39,7 @@ import com.lambda.threading.runSafe import com.lambda.threading.runSafeAutomated import com.lambda.threading.runSafeGameScheduled import com.lambda.util.BlockUtils.blockState -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.NamedEnum import com.lambda.util.PacketUtils.sendPacket import com.lambda.util.Timer @@ -111,7 +111,7 @@ object CrystalAura : Module( private val packetLifetime by setting("Packet Lifetime", 500L, 50L..1000L) { prediction.onPlace }.group(Group.Prediction) /* Targeting */ - private val targeting = Targeting.Combat(c = this, Group.Targeting, defaultRange = 10.0) + private val targetingSettings = TargetingSettings.CombatSettings(c = this, Group.Targeting, defaultRange = 10.0) private val blueprint = mutableMapOf() private var activeOpportunity: Opportunity? = null @@ -246,7 +246,7 @@ object CrystalAura : Module( private fun SafeContext.tick() { // Update the target - currentTarget = targeting.target() + currentTarget = targetingSettings.target() // Update the blueprint currentTarget?.let { diff --git a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt index 04feeb894..bc38a7d72 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt @@ -17,9 +17,9 @@ package com.lambda.module.modules.combat -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits -import com.lambda.config.groups.Targeting +import com.lambda.config.groups.TargetingSettings import com.lambda.context.SafeContext import com.lambda.event.events.InventoryEvent import com.lambda.event.events.TickEvent @@ -58,10 +58,10 @@ object KillAura : Module( private val hitDelay2 by setting("Hit Delay 2", 6.0, 0.0..20.0, 1.0) { attackMode == AttackMode.Delay }.group(Group.General) // Targeting - private val targeting = Targeting.Combat(c = this, Group.Targeting) + private val targetingSettings = TargetingSettings.CombatSettings(c = this, Group.Targeting) val target: Entity? - get() = targeting.target() + get() = targetingSettings.target() private var prevEntity = target private var validServerRot = false diff --git a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt index af1770b4d..7ea991cef 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.combat -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.context.SafeContext import com.lambda.friend.FriendHandler.isFriend diff --git a/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt b/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt index 5aae5107c..20b82ead4 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.combat -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint import com.lambda.interaction.construction.verify.TargetState diff --git a/src/main/kotlin/com/lambda/module/modules/debug/FallTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/FallTest.kt index e07485723..d397b76a5 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/FallTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/FallTest.kt @@ -21,7 +21,7 @@ import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.combat.DamageUtils.fallDamage import com.lambda.util.combat.DamageUtils.isFallDeadly diff --git a/src/main/kotlin/com/lambda/module/modules/debug/InventoryDebug.kt b/src/main/kotlin/com/lambda/module/modules/debug/InventoryDebug.kt index 12319276b..47ec92134 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/InventoryDebug.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/InventoryDebug.kt @@ -23,7 +23,7 @@ import com.lambda.event.events.PacketEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.DynamicReflectionSerializer.dynamicString import net.minecraft.network.packet.c2s.play.ClickSlotC2SPacket import net.minecraft.network.packet.c2s.play.CloseHandledScreenC2SPacket diff --git a/src/main/kotlin/com/lambda/module/modules/debug/PropertyPrinter.kt b/src/main/kotlin/com/lambda/module/modules/debug/PropertyPrinter.kt index c29a07ead..6b5a18da1 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/PropertyPrinter.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/PropertyPrinter.kt @@ -19,7 +19,7 @@ package com.lambda.module.modules.debug import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.FolderRegister +import com.lambda.util.FolderRegistry import com.lambda.util.extension.resolveFile import net.minecraft.block.Block import net.minecraft.block.Blocks @@ -32,7 +32,7 @@ object PropertyPrinter : Module( ) { init { onEnable { - val file = FolderRegister.lambda.resolve("property-print").resolveFile("property-print.txt") + val file = FolderRegistry.lambda.resolve("property-print").resolveFile("property-print.txt") file.parentFile.mkdirs() file.writeText("") StateInfo.propertyFields.forEach properties@{ property -> diff --git a/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt index 43cfdd9ba..052ed150b 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.debug -import com.lambda.config.AutomationConfig +import com.lambda.config.automation.AutomationConfig import com.lambda.config.groups.RotationSettings import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen diff --git a/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt b/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt index 3e194fc37..988bb586f 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt @@ -23,7 +23,7 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.hotbar.HotbarRequest import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.NamedEnum object SilentSwap : Module( diff --git a/src/main/kotlin/com/lambda/module/modules/debug/StateInfo.kt b/src/main/kotlin/com/lambda/module/modules/debug/StateInfo.kt index beb055cbc..6d67b5067 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/StateInfo.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/StateInfo.kt @@ -21,7 +21,7 @@ import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.BlockUtils.blockState -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.KeyCode import net.minecraft.block.BlockState import net.minecraft.state.property.Properties diff --git a/src/main/kotlin/com/lambda/module/modules/debug/TimerTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/TimerTest.kt index 63373bf32..25073151a 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/TimerTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/TimerTest.kt @@ -22,7 +22,7 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.event.listener.SafeListener.Companion.listenConcurrently import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info @Suppress("unused") object TimerTest : Module( diff --git a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt index 5426400fa..ae0f59255 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt @@ -19,7 +19,7 @@ package com.lambda.module.modules.movement import com.lambda.Lambda import com.lambda.Lambda.mc -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress @@ -32,7 +32,7 @@ import com.lambda.interaction.material.StackSelection.Companion.selectStack import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe -import com.lambda.util.Communication.warn +import com.lambda.util.CommunicationUtils.warn import com.lambda.util.KeyCode import com.lambda.util.Mouse import com.lambda.util.player.SlotUtils.hotbarAndInventoryStacks diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt index 99d67d7bd..c05622e46 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.movement -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -26,7 +26,7 @@ import com.lambda.module.Module import com.lambda.module.modules.movement.BetterFirework.startFirework import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.NamedEnum import com.lambda.util.SpeedUnit import com.lambda.util.Timer diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt index 6c2db1696..87bbf213b 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt @@ -18,7 +18,7 @@ package com.lambda.module.modules.movement import baritone.api.pathing.goals.GoalGetToBlock -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.context.SafeContext import com.lambda.event.events.ClientEvent diff --git a/src/main/kotlin/com/lambda/module/modules/movement/NoFall.kt b/src/main/kotlin/com/lambda/module/modules/movement/NoFall.kt index 73bf81959..5275eb08a 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/NoFall.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/NoFall.kt @@ -21,6 +21,7 @@ import com.lambda.event.events.MovementEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module import com.lambda.module.tag.ModuleTag +import com.lambda.util.PacketUtils.sendPacket import com.lambda.util.math.component1 import com.lambda.util.math.component2 import com.lambda.util.math.component3 @@ -55,13 +56,13 @@ object NoFall : Module( val (x, y, z) = player.pos connection.sendPacket(PlayerMoveC2SPacket.Full(x, y + 0.0000000001, z, 0.01f, 90f, false, true)) // TODO: Check this after update connection.sendPacket(PlayerInteractItemC2SPacket(Hand.OFF_HAND, 0, player.yaw, player.pitch)) // TODO: This is wrong, fix it - connection.sendPacket( + connection.sendPacket { PlayerActionC2SPacket( PlayerActionC2SPacket.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Direction.DOWN ) - ) + } player.motion = Vec3d.ZERO player.fallDistance = 0.0 diff --git a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt index d84c9e787..109c7b196 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt @@ -23,7 +23,7 @@ import com.lambda.event.events.MovementEvent import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest -import com.lambda.interaction.managers.rotating.RotationConfig +import com.lambda.config.groups.RotationConfig import com.lambda.interaction.managers.rotating.RotationMode import com.lambda.module.Module import com.lambda.module.tag.ModuleTag diff --git a/src/main/kotlin/com/lambda/module/modules/movement/TickShift.kt b/src/main/kotlin/com/lambda/module/modules/movement/TickShift.kt index 7b888e52a..98cf8c9fa 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/TickShift.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/TickShift.kt @@ -26,7 +26,7 @@ import com.lambda.module.Module import com.lambda.module.modules.combat.KillAura import com.lambda.module.tag.ModuleTag import com.lambda.threading.runConcurrent -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.PacketUtils.handlePacketSilently import com.lambda.util.PacketUtils.sendPacketSilently import kotlinx.coroutines.delay diff --git a/src/main/kotlin/com/lambda/module/modules/network/PacketLimiter.kt b/src/main/kotlin/com/lambda/module/modules/network/PacketLimiter.kt index 3ae6f21e2..4e927ae85 100644 --- a/src/main/kotlin/com/lambda/module/modules/network/PacketLimiter.kt +++ b/src/main/kotlin/com/lambda/module/modules/network/PacketLimiter.kt @@ -21,9 +21,9 @@ import com.lambda.event.events.PacketEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.collections.LimitedDecayQueue -import com.lambda.util.reflections.className +import com.lambda.util.className import net.minecraft.network.packet.c2s.common.CommonPongC2SPacket import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket.Full import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket.LookAndOnGround diff --git a/src/main/kotlin/com/lambda/module/modules/network/PacketLogger.kt b/src/main/kotlin/com/lambda/module/modules/network/PacketLogger.kt index 3adb35d9c..efcf05299 100644 --- a/src/main/kotlin/com/lambda/module/modules/network/PacketLogger.kt +++ b/src/main/kotlin/com/lambda/module/modules/network/PacketLogger.kt @@ -26,12 +26,12 @@ import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runIO -import com.lambda.util.Communication -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils +import com.lambda.util.CommunicationUtils.info import com.lambda.util.DynamicReflectionSerializer.dynamicString -import com.lambda.util.FolderRegister -import com.lambda.util.FolderRegister.relativeMCPath -import com.lambda.util.Formatting.getTime +import com.lambda.util.FolderRegistry +import com.lambda.util.FolderRegistry.relativeMCPath +import com.lambda.util.FormattingUtils.getTime import com.lambda.util.text.ClickEvents import com.lambda.util.text.buildText import com.lambda.util.text.clickEvent @@ -105,7 +105,7 @@ object PacketLogger : Module( val fileName = "packet-log-${getTime(fileFormatter)}.txt" // ToDo: Organize files with FolderRegister.worldBoundDirectory - file = FolderRegister.packetLogs.resolve(fileName).toFile().apply { + file = FolderRegistry.packetLogs.resolve(fileName).toFile().apply { if (!parentFile.exists()) { parentFile.mkdirs() } @@ -122,7 +122,7 @@ object PacketLogger : Module( this@PacketLogger.info(info) }.apply { StringBuilder().apply { - appendLine(Communication.ascii) + appendLine(CommunicationUtils.ascii) appendLine("${Lambda.SYMBOL} - Lambda ${Lambda.VERSION} - Packet Log") val playerName = mc.player?.name?.string ?: "Unknown" diff --git a/src/main/kotlin/com/lambda/module/modules/network/Rubberband.kt b/src/main/kotlin/com/lambda/module/modules/network/Rubberband.kt index 2d11549ed..45fb7f1b7 100644 --- a/src/main/kotlin/com/lambda/module/modules/network/Rubberband.kt +++ b/src/main/kotlin/com/lambda/module/modules/network/Rubberband.kt @@ -22,7 +22,7 @@ import com.lambda.event.events.PlayerPacketEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.Communication.warn +import com.lambda.util.CommunicationUtils.warn import com.lambda.util.collections.LimitedOrderedSet import com.lambda.util.math.dist import com.lambda.util.math.distSq diff --git a/src/main/kotlin/com/lambda/module/modules/network/ServerSpoof.kt b/src/main/kotlin/com/lambda/module/modules/network/ServerSpoof.kt index 0dcc2fcc5..39dbcfdd1 100644 --- a/src/main/kotlin/com/lambda/module/modules/network/ServerSpoof.kt +++ b/src/main/kotlin/com/lambda/module/modules/network/ServerSpoof.kt @@ -21,7 +21,7 @@ import com.lambda.event.events.PacketEvent import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.text.ClickEvents import com.lambda.util.text.buildText import com.lambda.util.text.clickEvent diff --git a/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt b/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt index 3ef6c4b50..8bb4c17a1 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.player -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.config.groups.EatConfig.Companion.reasonEating import com.lambda.event.events.TickEvent diff --git a/src/main/kotlin/com/lambda/module/modules/player/ClickFriend.kt b/src/main/kotlin/com/lambda/module/modules/player/ClickFriend.kt index 1344fc94b..b70df459d 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/ClickFriend.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/ClickFriend.kt @@ -26,7 +26,7 @@ import com.lambda.friend.FriendHandler.isFriend import com.lambda.friend.FriendHandler.unfriend import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.InputUtils.isSatisfied import com.lambda.util.world.raycast.RayCastUtils.entityResult import net.minecraft.client.network.OtherClientPlayerEntity diff --git a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt index 9e466a7ec..2938ade84 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.player -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.event.events.PlayerEvent import com.lambda.event.events.TickEvent diff --git a/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt b/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt index b1d961326..9bb2471c6 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt @@ -22,7 +22,7 @@ import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.gui.LambdaScreen import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest -import com.lambda.interaction.managers.rotating.RotationConfig +import com.lambda.config.groups.RotationConfig import com.lambda.interaction.managers.rotating.RotationMode import com.lambda.module.Module import com.lambda.module.tag.ModuleTag diff --git a/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt b/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt index 37c6263cd..206c4e51c 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.player -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.event.events.InventoryEvent import com.lambda.event.events.PlayerEvent diff --git a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt index 0ef98ddd3..d26fe6f32 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.player -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.context.SafeContext import com.lambda.event.events.PlayerEvent @@ -29,7 +29,7 @@ import com.lambda.interaction.construction.simulation.context.BreakContext import com.lambda.interaction.construction.simulation.context.BuildContext import com.lambda.interaction.construction.simulation.result.results.BreakResult import com.lambda.interaction.construction.verify.TargetState -import com.lambda.interaction.managers.breaking.BreakConfig +import com.lambda.config.groups.BreakConfig import com.lambda.interaction.managers.breaking.BreakRequest.Companion.breakRequest import com.lambda.module.Module import com.lambda.module.tag.ModuleTag diff --git a/src/main/kotlin/com/lambda/module/modules/player/Replay.kt b/src/main/kotlin/com/lambda/module/modules/player/Replay.kt index 0c03daa26..92631d1a1 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/Replay.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/Replay.kt @@ -36,19 +36,19 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.gui.components.ClickGuiLayout import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest import com.lambda.interaction.managers.rotating.Rotation -import com.lambda.interaction.managers.rotating.RotationConfig +import com.lambda.config.groups.RotationConfig import com.lambda.interaction.managers.rotating.RotationMode import com.lambda.module.Module import com.lambda.module.modules.player.Replay.InputAction.Companion.toAction import com.lambda.module.tag.ModuleTag import com.lambda.sound.SoundHandler.playSound -import com.lambda.util.Communication.info -import com.lambda.util.Communication.logError -import com.lambda.util.Communication.warn +import com.lambda.util.CommunicationUtils.info +import com.lambda.util.CommunicationUtils.logError +import com.lambda.util.CommunicationUtils.warn import com.lambda.util.FileUtils.locationBoundDirectory -import com.lambda.util.FolderRegister -import com.lambda.util.Formatting.format -import com.lambda.util.Formatting.getTime +import com.lambda.util.FolderRegistry +import com.lambda.util.FormattingUtils.format +import com.lambda.util.FormattingUtils.getTime import com.lambda.util.KeyCode import com.lambda.util.StringUtils.sanitizeForFilename import com.lambda.util.extension.rotation @@ -424,7 +424,7 @@ object Replay : Module( this@Replay.warn("Recording too short. Minimum length: 5 ticks.") return } - val file = FolderRegister.replay.toFile().locationBoundDirectory().resolve("$name.json") + val file = FolderRegistry.replay.toFile().locationBoundDirectory().resolve("$name.json") lambdaScope.launch(Dispatchers.IO) { file.writeText(gsonCompact.toJson(recording)) diff --git a/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt b/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt index 416040a5a..b44851bc6 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.player -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent diff --git a/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt b/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt index ce8c79eb2..0638f9933 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.player -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.event.events.ContainerEvent import com.lambda.event.events.TickEvent diff --git a/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt b/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt index 959dd43ce..41f6e0e4d 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt @@ -18,7 +18,7 @@ package com.lambda.module.modules.render import com.lambda.Lambda.mc -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.context.SafeContext import com.lambda.event.events.MovementEvent diff --git a/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt b/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt index 5125d4321..a9a0e053f 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt @@ -23,7 +23,7 @@ import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.EntityUtils.createNameMap import com.lambda.util.NamedEnum -import com.lambda.util.reflections.scanResult +import com.lambda.util.scanResult import net.minecraft.block.entity.BlockEntity import net.minecraft.client.particle.Particle import net.minecraft.entity.Entity diff --git a/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt b/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt index e3b9e0074..63e433d83 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt @@ -17,6 +17,7 @@ package com.lambda.module.modules.render +import com.lambda.config.Config.StandardTabs.GENERAL_TAB import com.lambda.config.applyEdits import com.lambda.config.groups.EntityColorSettings import com.lambda.config.groups.EntitySelectionSettings @@ -41,20 +42,13 @@ object Tracers : Module( description = "Draws lines to entities within the world", tag = ModuleTag.RENDER ) { - private enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Entities("Entities"), - Colors("Colors"), - LineStyle("Line Style") - } - private enum class LineGroup(override val displayName: String) : NamedEnum { Other("Other"), Friend("Friend") } - private val target by setting("Target", TracerMode.Feet).group(Group.General) - private val stem by setting("Stem", true).group(Group.General) + @Tab(GENERAL_TAB) private val target by setting("Target", TracerMode.Feet) + @Tab(GENERAL_TAB) private val stem by setting("Stem", true) private val entitySettings = EntitySelectionSettings(this, Group.Entities).apply { applyEdits { hide(::self, ::blockEntities) diff --git a/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt b/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt index 54710053f..84dfd3e48 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt @@ -18,7 +18,7 @@ package com.lambda.module.modules.world import com.lambda.Lambda.mc -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.config.settings.complex.Bind import com.lambda.context.SafeContext diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt index 04fb41f2a..4ca31e6c5 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt @@ -18,7 +18,7 @@ package com.lambda.module.modules.world import baritone.api.pathing.goals.GoalBlock -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.config.groups.WorldLineSettings import com.lambda.config.settings.complex.Bind @@ -47,6 +47,7 @@ import com.lambda.util.BlockUtils.blockState import com.lambda.util.BlockUtils.isEmpty import com.lambda.util.BlockUtils.isNotEmpty import com.lambda.util.NamedEnum +import com.lambda.util.PacketUtils.sendPacket import com.lambda.util.extension.blockColor import com.lambda.util.extension.tickDelta import com.lambda.util.math.lerp @@ -309,13 +310,13 @@ object AutoPortal : Module( } private fun SafeContext.swapPacket() = - connection.sendPacket( + connection.sendPacket { PlayerActionC2SPacket( PlayerActionC2SPacket.Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ORIGIN, Direction.DOWN ) - ) + } private fun SafeContext.withFlintAndSteel(block: SafeContext.() -> Unit) { if (player.mainHandStack.item == Items.FLINT_AND_STEEL) { diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoSign.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoSign.kt index 5adc4af1d..d2f1e502b 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoSign.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoSign.kt @@ -24,6 +24,7 @@ import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runConcurrent import com.lambda.threading.runSafeGameScheduled +import com.lambda.util.PacketUtils.sendPacket import kotlinx.coroutines.delay import net.minecraft.block.entity.HangingSignBlockEntity import net.minecraft.client.gui.screen.ingame.AbstractSignEditScreen @@ -95,13 +96,13 @@ object AutoSign : Module( runConcurrent { delay(signWriteDelay) runSafeGameScheduled { - connection.sendPacket( + connection.sendPacket { UpdateSignC2SPacket( pos, writeOnFront, messages[0], messages[1], messages[2], messages[3] ) - ) + } } } } else mc.setScreen(editor) diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt index 8bdb4ddf6..43c7061ba 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.world -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress @@ -39,8 +39,8 @@ import com.lambda.task.tasks.BuildTask.Companion.build import com.lambda.threading.runSafeAutomated import com.lambda.util.BlockUtils.blockState import com.lambda.util.BlockUtils.isEmpty -import com.lambda.util.Communication.info -import com.lambda.util.Communication.logError +import com.lambda.util.CommunicationUtils.info +import com.lambda.util.CommunicationUtils.logError import com.lambda.util.NamedEnum import com.lambda.util.world.closestEntity import net.minecraft.block.Blocks diff --git a/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt b/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt index df380304e..b427550dc 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.world -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.construction.blueprint.Blueprint.Companion.emptyStructure @@ -28,7 +28,7 @@ import com.lambda.module.tag.ModuleTag import com.lambda.task.RootTask.run import com.lambda.task.Task import com.lambda.task.tasks.BuildTask.Companion.build -import com.lambda.util.Communication.info +import com.lambda.util.CommunicationUtils.info import com.lambda.util.Describable import com.lambda.util.NamedEnum import com.lambda.util.extension.Structure diff --git a/src/main/kotlin/com/lambda/module/modules/world/MapDownloader.kt b/src/main/kotlin/com/lambda/module/modules/world/MapDownloader.kt index a351640eb..b4de4c5e7 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/MapDownloader.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/MapDownloader.kt @@ -22,7 +22,7 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.FileUtils.locationBoundDirectory -import com.lambda.util.FolderRegister +import com.lambda.util.FolderRegistry import com.lambda.util.StringUtils.hashString import com.lambda.util.player.SlotUtils.allStacks import com.lambda.util.world.entitySearch @@ -49,7 +49,7 @@ object MapDownloader : Module( val name = map.hash val image = map.toBufferedImage() - val file = FolderRegister.maps.toFile().locationBoundDirectory().resolve("$name.png") + val file = FolderRegistry.maps.toFile().locationBoundDirectory().resolve("$name.png") if (file.exists()) return@listen ImageIO.write(image, "png", file) diff --git a/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt b/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt index 416fa8672..591f56d4c 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.world -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.context.SafeContext import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint diff --git a/src/main/kotlin/com/lambda/module/modules/world/Printer.kt b/src/main/kotlin/com/lambda/module/modules/world/Printer.kt index 2c4c59dfc..b25337ac0 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Printer.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Printer.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.world -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.context.SafeContext import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint import com.lambda.interaction.construction.simulation.result.BuildResult @@ -30,7 +30,7 @@ import com.lambda.task.RootTask.run import com.lambda.task.Task import com.lambda.task.tasks.BuildTask.Companion.build import com.lambda.util.BlockUtils.blockPos -import com.lambda.util.Communication.logError +import com.lambda.util.CommunicationUtils.logError import com.lambda.util.Describable import com.lambda.util.NamedEnum import com.lambda.util.PlayerBuildLayerUtils.FlattenMode diff --git a/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt b/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt index f4bd238e5..e0707fd8f 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.world -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.config.settings.complex.Bind import com.lambda.context.SafeContext @@ -26,7 +26,7 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.construction.simulation.BuildSimulator.simulate import com.lambda.interaction.construction.simulation.context.BuildContext import com.lambda.interaction.construction.verify.TargetState -import com.lambda.interaction.managers.interacting.InteractConfig +import com.lambda.config.groups.InteractConfig import com.lambda.interaction.managers.interacting.InteractRequest.Companion.interactRequest import com.lambda.interaction.material.StackSelection.Companion.selectStack import com.lambda.interaction.material.container.containers.HotbarContainer diff --git a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt index e5483dfe2..8d32d6ccd 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt @@ -19,7 +19,7 @@ package com.lambda.module.modules.world import baritone.api.pathing.goals.GoalBlock import com.lambda.Lambda.mc -import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress @@ -35,7 +35,7 @@ import com.lambda.graphics.mc.renderer.TickedRenderer.Companion.tickedRenderer import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.construction.verify.TargetState import com.lambda.interaction.managers.hotbar.HotbarRequest -import com.lambda.interaction.managers.interacting.InteractConfig +import com.lambda.config.groups.InteractConfig import com.lambda.interaction.managers.inventory.InventoryRequest.Companion.inventoryRequest import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest import com.lambda.interaction.managers.rotating.Rotation @@ -51,9 +51,9 @@ import com.lambda.task.tasks.OpenContainerTask import com.lambda.threading.runSafeAutomated import com.lambda.util.BlockUtils.blockEntity import com.lambda.util.BlockUtils.blockState -import com.lambda.util.Communication.info -import com.lambda.util.Communication.logError -import com.lambda.util.Communication.warn +import com.lambda.util.CommunicationUtils.info +import com.lambda.util.CommunicationUtils.logError +import com.lambda.util.CommunicationUtils.warn import com.lambda.util.NamedEnum import com.lambda.util.TickTimer import com.lambda.util.extension.containerSlots diff --git a/src/main/kotlin/com/lambda/network/CapeHandler.kt b/src/main/kotlin/com/lambda/network/CapeHandler.kt index 9d38d557c..ea9a33f52 100644 --- a/src/main/kotlin/com/lambda/network/CapeHandler.kt +++ b/src/main/kotlin/com/lambda/network/CapeHandler.kt @@ -19,8 +19,8 @@ package com.lambda.network import com.lambda.Lambda.LOG import com.lambda.Lambda.mc -import com.lambda.config.Configurable -import com.lambda.config.configurations.SecretsConfig +import com.lambda.config.Config +import com.lambda.config.categories.SecretsCategory import com.lambda.core.Loadable import com.lambda.event.events.WorldEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -34,7 +34,7 @@ import com.lambda.util.FileUtils.downloadCompare import com.lambda.util.FileUtils.downloadIfNotPresent import com.lambda.util.FileUtils.ifNotExists import com.lambda.util.FileUtils.isOlderThan -import com.lambda.util.FolderRegister.capes +import com.lambda.util.FolderRegistry.capes import com.lambda.util.StringUtils.asIdentifier import com.lambda.util.extension.resolveFile import kotlinx.coroutines.runBlocking @@ -49,7 +49,7 @@ import kotlin.time.Duration.Companion.hours import kotlin.time.Duration.Companion.seconds @Suppress("unused") -object CapeHandler : Configurable(SecretsConfig), Loadable { +object CapeHandler : Config(SecretsCategory), Loadable { override val name: String = "capes" var currentCape by setting("cape", "") diff --git a/src/main/kotlin/com/lambda/network/LambdaAPI.kt b/src/main/kotlin/com/lambda/network/LambdaAPI.kt index 43cc6e470..2d02b4980 100644 --- a/src/main/kotlin/com/lambda/network/LambdaAPI.kt +++ b/src/main/kotlin/com/lambda/network/LambdaAPI.kt @@ -19,8 +19,8 @@ package com.lambda.network import com.lambda.Lambda.LOG import com.lambda.Lambda.mc -import com.lambda.config.Configurable -import com.lambda.config.configurations.LambdaConfig +import com.lambda.config.Config +import com.lambda.config.categories.LambdaCategory import com.lambda.event.events.ClientEvent import com.lambda.event.events.ConnectionEvent import com.lambda.event.events.ConnectionEvent.Connect.Login.EncryptionResponse @@ -42,7 +42,7 @@ import net.minecraft.text.Text import java.math.BigInteger import kotlin.jvm.optionals.getOrElse -object LambdaAPI : Configurable(LambdaConfig) { +object LambdaAPI : Config(LambdaCategory) { override val name = "api" val authServer by setting("Auth Server", "auth.lambda-client.org") diff --git a/src/main/kotlin/com/lambda/network/NetworkHandler.kt b/src/main/kotlin/com/lambda/network/NetworkHandler.kt index 6b8a80661..d42a4096f 100644 --- a/src/main/kotlin/com/lambda/network/NetworkHandler.kt +++ b/src/main/kotlin/com/lambda/network/NetworkHandler.kt @@ -18,8 +18,8 @@ package com.lambda.network import com.lambda.Lambda.mc -import com.lambda.config.Configurable -import com.lambda.config.configurations.SecretsConfig +import com.lambda.config.Config +import com.lambda.config.categories.SecretsCategory import com.lambda.core.Loadable import com.lambda.network.api.v1.models.Authentication import com.lambda.network.api.v1.models.Authentication.Data @@ -27,7 +27,7 @@ import com.lambda.util.StringUtils.base64UrlDecode import com.lambda.util.StringUtils.json import com.lambda.util.collections.updatableLazy -object NetworkHandler : Configurable(SecretsConfig), Loadable { +object NetworkHandler : Config(SecretsCategory), Loadable { override val name = "network" var accessToken by setting("access_token", "") { false }; private set diff --git a/src/main/kotlin/com/lambda/task/Task.kt b/src/main/kotlin/com/lambda/task/Task.kt index 53eb08812..764e13a91 100644 --- a/src/main/kotlin/com/lambda/task/Task.kt +++ b/src/main/kotlin/com/lambda/task/Task.kt @@ -26,7 +26,7 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.modules.client.Client import com.lambda.module.modules.client.Client.verboseDebug import com.lambda.threading.runSafe -import com.lambda.util.Communication.logError +import com.lambda.util.CommunicationUtils.logError import com.lambda.util.Nameable import com.lambda.util.StringUtils.capitalize import kotlin.time.Duration.Companion.milliseconds diff --git a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt index 3171b3cbc..d6accc558 100644 --- a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt +++ b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt @@ -59,7 +59,7 @@ import com.lambda.threading.runSafeAutomated import com.lambda.util.BlockUtils.blockState import com.lambda.util.EntityUtils.getClosestPointTo import com.lambda.util.EntityUtils.getPositionsWithinBox -import com.lambda.util.Formatting.format +import com.lambda.util.FormattingUtils.format import com.lambda.util.extension.Structure import com.lambda.util.extension.playerSlots import com.lambda.util.math.dist diff --git a/src/main/kotlin/com/lambda/util/Communication.kt b/src/main/kotlin/com/lambda/util/CommunicationUtils.kt similarity index 97% rename from src/main/kotlin/com/lambda/util/Communication.kt rename to src/main/kotlin/com/lambda/util/CommunicationUtils.kt index ab711fc34..bf981eebd 100644 --- a/src/main/kotlin/com/lambda/util/Communication.kt +++ b/src/main/kotlin/com/lambda/util/CommunicationUtils.kt @@ -21,7 +21,8 @@ import com.lambda.Lambda import com.lambda.Lambda.mc import com.lambda.command.CommandRegistry import com.lambda.command.LambdaCommand -import com.lambda.config.Configuration +import com.lambda.config.ConfigCategory +import com.lambda.config.ConfigLoader import com.lambda.core.Loader import com.lambda.event.EventFlow import com.lambda.gui.components.ClickGuiLayout @@ -46,7 +47,7 @@ import java.time.ZoneId import java.time.format.DateTimeFormatter import java.time.format.FormatStyle -object Communication { +object CommunicationUtils { val ascii = """ ⣰⡛⠶⣄⠀⠀⠀⠀⠀⠀ @@ -206,8 +207,8 @@ object Communication { literal("Commands: ${CommandRegistry.commands.size}\n") literal( "Settings: ${ - Configuration.configurations.sumOf { config -> - config.configurables.sumOf { it.settings.size } + ConfigLoader.configCategories.sumOf { config -> + config.configs.sumOf { it.settings.size } } }" ) diff --git a/src/main/kotlin/com/lambda/util/DebugInfoHud.kt b/src/main/kotlin/com/lambda/util/DebugInfoHud.kt deleted file mode 100644 index 83fd62349..000000000 --- a/src/main/kotlin/com/lambda/util/DebugInfoHud.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.util - -import com.lambda.Lambda -import com.lambda.Lambda.mc -import com.lambda.command.CommandRegistry -import com.lambda.event.EventFlow -import com.lambda.module.ModuleRegistry -import com.lambda.util.Formatting.format -import com.lambda.util.extension.tickDeltaF -import net.minecraft.util.Formatting -import net.minecraft.util.hit.BlockHitResult -import net.minecraft.util.hit.EntityHitResult - -object DebugInfoHud { - @JvmStatic - fun MutableList.addDebugInfo() { - add("") - add("" + Formatting.UNDERLINE + "Lambda ${Lambda.VERSION}+${mc.versionType}") - add("Modules: ${ModuleRegistry.modules.size} with ${ModuleRegistry.modules.sumOf { it.settings.size }} settings") - add("Commands: ${CommandRegistry.commands.size}") - add("Synchronous Listeners: ${EventFlow.syncListeners.size}") - add("Concurrent Listeners: ${EventFlow.concurrentListeners.size}") - - when (val hit = mc.crosshairTarget) { - is BlockHitResult -> { - add("Crosshair Target: Block") - add(" Vec3d: %.5f, %.5f, %.5f".format(hit.pos.x, hit.pos.y, hit.pos.z)) - add(" BlockPos: ${hit.blockPos.toShortString()}") - add(" Side: ${hit.side}") - } - - is EntityHitResult -> { - add("Crosshair Target: Entity") - add(" Vec3d: ${hit.pos}") - add(" Entity: ${hit.entity}") - } - - null -> add("Crosshair Target: None") - } - - add("Eye Pos: ${mc.cameraEntity?.getCameraPosVec(mc.tickDeltaF)?.format()}") - - return - } -} diff --git a/src/main/kotlin/com/lambda/util/DynamicReflectionSerializer.kt b/src/main/kotlin/com/lambda/util/DynamicReflectionSerializer.kt index 12bf6d209..80119e273 100644 --- a/src/main/kotlin/com/lambda/util/DynamicReflectionSerializer.kt +++ b/src/main/kotlin/com/lambda/util/DynamicReflectionSerializer.kt @@ -22,7 +22,7 @@ import com.lambda.Lambda.LOG import com.lambda.core.Loadable import com.lambda.network.LambdaAPI import com.lambda.util.FileUtils.downloadIfNotPresent -import com.lambda.util.FolderRegister.cache +import com.lambda.util.FolderRegistry.cache import com.lambda.util.extension.resolveFile import com.mojang.serialization.Codec import kotlinx.coroutines.runBlocking diff --git a/src/main/kotlin/com/lambda/util/EntityUtils.kt b/src/main/kotlin/com/lambda/util/EntityUtils.kt index 58e3b8f97..f0af2a7e9 100644 --- a/src/main/kotlin/com/lambda/util/EntityUtils.kt +++ b/src/main/kotlin/com/lambda/util/EntityUtils.kt @@ -19,7 +19,6 @@ package com.lambda.util import com.lambda.util.DynamicReflectionSerializer.remappedName import com.lambda.util.math.MathUtils.floorToInt -import com.lambda.util.reflections.scanResult import io.github.classgraph.ClassInfo import net.minecraft.block.entity.BlockEntity import net.minecraft.entity.Entity diff --git a/src/main/kotlin/com/lambda/util/FolderRegister.kt b/src/main/kotlin/com/lambda/util/FolderRegistry.kt similarity index 93% rename from src/main/kotlin/com/lambda/util/FolderRegister.kt rename to src/main/kotlin/com/lambda/util/FolderRegistry.kt index dd2f68e97..d02d89b6f 100644 --- a/src/main/kotlin/com/lambda/util/FolderRegister.kt +++ b/src/main/kotlin/com/lambda/util/FolderRegistry.kt @@ -25,9 +25,9 @@ import kotlin.io.path.createDirectories import kotlin.io.path.notExists /** - * The [FolderRegister] object is responsible for managing the directory structure of the application. + * Object responsible for managing the directory structure of the application. */ -object FolderRegister : Loadable { +object FolderRegistry : Loadable { val minecraft: Path = mc.runDirectory.toPath() val lambda: Path = minecraft.resolve("lambda") val config: Path = lambda.resolve("config") diff --git a/src/main/kotlin/com/lambda/util/Formatting.kt b/src/main/kotlin/com/lambda/util/FormattingUtils.kt similarity index 99% rename from src/main/kotlin/com/lambda/util/Formatting.kt rename to src/main/kotlin/com/lambda/util/FormattingUtils.kt index 4b0b56055..8d4e1ce09 100644 --- a/src/main/kotlin/com/lambda/util/Formatting.kt +++ b/src/main/kotlin/com/lambda/util/FormattingUtils.kt @@ -30,7 +30,7 @@ import java.time.ZonedDateTime import java.time.format.DateTimeFormatter import java.util.* -object Formatting { +object FormattingUtils { fun Short.format(formatter: FormatterConfig) = format(formatter.locale) fun Short.format(locale: Locale = Default.locale) = "%d".format(locale, this) diff --git a/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PlaceDirection.kt b/src/main/kotlin/com/lambda/util/PlaceDirection.kt similarity index 93% rename from src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PlaceDirection.kt rename to src/main/kotlin/com/lambda/util/PlaceDirection.kt index aa7b4ecdf..b6e3b0484 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/PlaceDirection.kt +++ b/src/main/kotlin/com/lambda/util/PlaceDirection.kt @@ -15,11 +15,9 @@ * along with this program. If not, see . */ -package com.lambda.interaction.managers.rotating.visibilty +package com.lambda.util import com.lambda.interaction.managers.rotating.Rotation -import net.minecraft.entity.Entity -import net.minecraft.util.math.Direction import net.minecraft.util.math.MathHelper import net.minecraft.util.math.Vec3i @@ -54,9 +52,9 @@ enum class PlaceDirection( companion object { /** * A modified version of the minecraft getEntityFacingOrder method. This version takes a - * [Rotation] instead of an [Entity] + * [Rotation] instead of an [net.minecraft.entity.Entity] * - * @see Direction.getEntityFacingOrder + * @see net.minecraft.util.math.Direction.getEntityFacingOrder */ fun fromRotation(rotation: Rotation): PlaceDirection { val pitchRad = rotation.pitchF * (Math.PI.toFloat() / 180f).toDouble() @@ -98,4 +96,4 @@ enum class PlaceDirection( } } } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/util/ReflectionUtils.kt b/src/main/kotlin/com/lambda/util/ReflectionUtils.kt new file mode 100644 index 000000000..f55449182 --- /dev/null +++ b/src/main/kotlin/com/lambda/util/ReflectionUtils.kt @@ -0,0 +1,103 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.util + +import com.lambda.util.extension.isObject +import com.lambda.util.extension.objectInstance +import io.github.classgraph.ClassGraph +import io.github.classgraph.ClassInfo +import io.github.classgraph.ClassInfoList +import io.github.classgraph.Resource +import io.github.classgraph.ResourceList +import io.github.classgraph.ScanResult +import java.lang.reflect.Modifier +import kotlin.reflect.KClass + +@Suppress("unused") +object ReflectionUtils { + val scanResult: ScanResult by lazy { ClassGraph().enableAllInfo().scan() } + + val Any.className: String get() = this::class.java.name + .substringAfter("${this::class.java.packageName}.") + .replace('$', '.') + + val KClass<*>.className: String get() = java.name + .substringAfter("${java.packageName}.") + .replace('$', '.') + + /** + * This function returns an instance of subtype [T]. + * + * When [T] is an interface, the function with returns a list of classes that implements [T]. + * When [T] is an abstract class (open classes too), the function will return a list of classes extending [T]. + * + * Only final classes with empty constructors will be created. + */ + inline fun getInstances(crossinline block: (ClassInfo) -> Boolean = { true }): List { + if (scanResult.isClosed) return emptyList() + + val clazz = T::class.java + + return when { + clazz.isInterface -> scanResult.getClassesImplementing(clazz) + Modifier.isAbstract(clazz.modifiers) -> scanResult.getSubclasses(clazz) + + else -> throw IllegalStateException("class ${clazz.name} is neither an interface or open class") + }.filter { block(it) } + .mapNotNull { createInstance(Class.forName(it.name)) } + } + + @JvmName("getInstancesImplementingWithParameters1") + inline fun getInstancesImplementingWithParameters() = + getInstancesImplementingWithParameters(A1::class) + + @JvmName("getInstancesImplementingWithParameters2") + inline fun getInstancesImplementingWithParameters() = + getInstancesImplementingWithParameters(A1::class, A2::class) + + @JvmName("getInstancesImplementingWithParameters3") + inline fun getInstancesImplementingWithParameters() = + getInstancesImplementingWithParameters(A1::class, A2::class, A3::class) + + inline fun getInstancesImplementingWithParameters(vararg arguments: KClass<*>): ClassInfoList = + scanResult.getClassesImplementing(T::class.java) + .filter { + it.typeSignature.superinterfaceSignatures + .any { int -> int.typeArguments + .any { arg -> arguments.any { it.qualifiedName == arg.typeSignature.toString() }} } + } + + inline fun getResources(pattern: String, crossinline block: (Resource) -> Boolean): ResourceList = + scanResult.getResourcesMatchingWildcard(pattern) + .filter { block(it) } + + inline fun createInstance(clazz: Class<*>): T? { + return when { + clazz.isInterface || clazz.isEnum || clazz.isAnnotation || clazz.isObject -> { + // Handle objects (singletons) or invalid types + clazz.objectInstance as? T + } + else -> { + // Look for a constructor with no parameters + clazz.constructors + .filterNot { Modifier.isAbstract(it.declaringClass.modifiers) } // Avoid abstract constructors + .firstOrNull { it.parameterCount == 0 }?.newInstance() as? T + } + } + } +} diff --git a/src/main/kotlin/com/lambda/util/ServerTPS.kt b/src/main/kotlin/com/lambda/util/ServerTPSUtils.kt similarity index 98% rename from src/main/kotlin/com/lambda/util/ServerTPS.kt rename to src/main/kotlin/com/lambda/util/ServerTPSUtils.kt index 855cbbf7c..86e95246f 100644 --- a/src/main/kotlin/com/lambda/util/ServerTPS.kt +++ b/src/main/kotlin/com/lambda/util/ServerTPSUtils.kt @@ -23,7 +23,7 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.util.collections.LimitedDecayQueue import net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket -object ServerTPS { +object ServerTPSUtils { // Server sends exactly one world time update every 20 server ticks (one per second). private val updateHistory = LimitedDecayQueue(61, 60000) private var lastUpdate = 0L diff --git a/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/VisibilityChecker.kt b/src/main/kotlin/com/lambda/util/player/RotationUtils.kt similarity index 89% rename from src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/VisibilityChecker.kt rename to src/main/kotlin/com/lambda/util/player/RotationUtils.kt index 9e25611b9..8d7bce80e 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/rotating/visibilty/VisibilityChecker.kt +++ b/src/main/kotlin/com/lambda/util/player/RotationUtils.kt @@ -15,10 +15,11 @@ * along with this program. If not, see . */ -package com.lambda.interaction.managers.rotating.visibilty +package com.lambda.util.player import com.lambda.context.Automated import com.lambda.context.AutomatedSafeContext +import com.lambda.context.SafeContext import com.lambda.interaction.construction.simulation.processing.PreProcessingData import com.lambda.interaction.construction.verify.ScanMode import com.lambda.interaction.construction.verify.SurfaceScan @@ -27,7 +28,9 @@ import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo import com.lambda.interaction.managers.rotating.RotationManager import com.lambda.module.modules.client.Client import com.lambda.util.BlockUtils.blockState +import com.lambda.util.PlaceDirection import com.lambda.util.extension.component6 +import com.lambda.util.extension.rotation import com.lambda.util.math.distSq import com.lambda.util.world.raycast.RayCastUtils.blockResult import com.lambda.util.world.raycast.RayCastUtils.entityResult @@ -39,7 +42,10 @@ import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Box import net.minecraft.util.math.Direction import net.minecraft.util.math.Vec3d -import java.util.* +import java.util.EnumSet +import kotlin.collections.minus +import kotlin.math.atan2 +import kotlin.math.hypot import kotlin.math.max import kotlin.math.min import kotlin.math.pow @@ -47,9 +53,33 @@ import kotlin.math.pow /** * Object for handling visibility checks, rotation calculations, and hit detection. */ -object VisibilityChecker { +object RotationUtils { val ALL_SIDES = Direction.entries.toSet() + fun SafeContext.lookAt(pos: Vec3d): Rotation { + val direction = pos.subtract(player.eyePos).normalize() + val yaw = Math.toDegrees(atan2(direction.z, direction.x)) - 90.0 + val pitch = -Math.toDegrees(atan2(direction.y, hypot(direction.x, direction.z))) + return Rotation(yaw, pitch) + } + + fun SafeContext.lookInDirection(direction: PlaceDirection) = + if (!direction.isInArea(player.rotation)) direction.snapToArea(RotationManager.activeRotation) + else player.rotation + + fun AutomatedSafeContext.lookAtHit(hit: HitResult) = + when (hit) { + is BlockHitResult -> lookAtBlock(hit.blockPos, setOf(hit.side)) + is EntityHitResult -> lookAtEntity(hit.entity) + else -> null + } + + fun AutomatedSafeContext.lookAtEntity(entity: Entity, sides: Set = ALL_SIDES) = + entity.findRotation(buildConfig.entityReach, player.eyePos, sides) + + fun AutomatedSafeContext.lookAtBlock(pos: BlockPos, sides: Set = ALL_SIDES) = + pos.findRotation(buildConfig.blockReach, player.eyePos, sides) + /** * Finds a rotation that intersects with one of the specified bounding boxes, allowing the player to look at entities or blocks. * To increase the stability, it will pause the rotation if eye position is within any of the bounding boxes @@ -330,9 +360,9 @@ object VisibilityChecker { ) = if (automated.buildConfig.checkSideVisibility || automated.buildConfig.strictRayCast) { intersect(box.getVisibleSurfaces(eye)) } else this - - class CheckedHit( - val hit: HitResult, - val rotation: Rotation - ) } + +class CheckedHit( + val hit: HitResult, + val rotation: Rotation +) \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/util/reflections/Reflections.kt b/src/main/kotlin/com/lambda/util/reflections/Reflections.kt deleted file mode 100644 index 700f68045..000000000 --- a/src/main/kotlin/com/lambda/util/reflections/Reflections.kt +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.util.reflections - -import com.lambda.util.extension.isObject -import com.lambda.util.extension.objectInstance -import io.github.classgraph.ClassGraph -import io.github.classgraph.ClassInfo -import io.github.classgraph.Resource -import io.github.classgraph.ResourceList -import io.github.classgraph.ScanResult -import java.lang.reflect.Modifier -import kotlin.reflect.KClass - -val scanResult: ScanResult by lazy { ClassGraph().enableAllInfo().scan() } - -val Any.className: String get() = this::class.java.name - .substringAfter("${this::class.java.packageName}.") - .replace('$', '.') - -val KClass<*>.className: String get() = java.name - .substringAfter("${java.packageName}.") - .replace('$', '.') - -/** - * This function returns a instance of subtype [T]. - * - * When [T] is an interface, the function with returns a list of classes that implements [T]. - * When [T] is an abstract class (open classes too), the function will return a list of classes extending [T]. - * - * Only final classes with empty constructors will be created. - */ -inline fun getInstances(crossinline block: (ClassInfo) -> Boolean = { true }): List { - if (scanResult.isClosed) return emptyList() - - val clazz = T::class.java - - return when { - clazz.isInterface -> scanResult.getClassesImplementing(clazz) - Modifier.isAbstract(clazz.modifiers) -> scanResult.getSubclasses(clazz) - - else -> throw IllegalStateException("class ${clazz.name} is neither an interface or open class") - }.filter { block(it) } - .mapNotNull { createInstance(Class.forName(it.name)) } -} - -@JvmName("getInstancesImplementingWithParameters1") -inline fun getInstancesImplementingWithParameters() = getInstancesImplementingWithParameters(A1::class) - -@JvmName("getInstancesImplementingWithParameters2") -inline fun getInstancesImplementingWithParameters() = getInstancesImplementingWithParameters(A1::class, A2::class) - -@JvmName("getInstancesImplementingWithParameters3") -inline fun getInstancesImplementingWithParameters() = getInstancesImplementingWithParameters(A1::class, A2::class, A3::class) - -inline fun getInstancesImplementingWithParameters(vararg arguments: KClass<*>) = - scanResult.getClassesImplementing(T::class.java) - .filter { - it.typeSignature.superinterfaceSignatures - .any { int -> int.typeArguments - .any { arg -> arguments.any { it.qualifiedName == arg.typeSignature.toString() }} } - } - -inline fun getResources(pattern: String, crossinline block: (Resource) -> Boolean): ResourceList = - scanResult.getResourcesMatchingWildcard(pattern) - .filter { block(it) } - -inline fun createInstance(clazz: Class<*>): T? { - return when { - clazz.isInterface || clazz.isEnum || clazz.isAnnotation || clazz.isObject -> { - // Handle objects (singletons) or invalid types - clazz.objectInstance as? T - } - else -> { - // Look for a constructor with no parameters - clazz.constructors - .filterNot { Modifier.isAbstract(it.declaringClass.modifiers) } // Avoid abstract constructors - .firstOrNull { it.parameterCount == 0 }?.newInstance() as? T - } - } -} diff --git a/src/test/kotlin/PlaceDirectionTest.kt b/src/test/kotlin/PlaceDirectionTest.kt index 713fd5d75..02b5fb6e3 100644 --- a/src/test/kotlin/PlaceDirectionTest.kt +++ b/src/test/kotlin/PlaceDirectionTest.kt @@ -16,7 +16,7 @@ */ import com.lambda.interaction.managers.rotating.Rotation -import com.lambda.interaction.managers.rotating.visibilty.PlaceDirection +import com.lambda.util.PlaceDirection import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse From f04e30926cd978fd42aaecc3ccede25ca43e204d Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Sat, 2 May 2026 01:35:34 +0100 Subject: [PATCH 06/40] checkpoint 2; also doesnt compile in the slightest --- .../com/lambda/mixin/CrashReportMixin.java | 2 +- .../lambda/command/commands/ConfigCommand.kt | 8 +- .../lambda/command/commands/PrefixCommand.kt | 2 +- src/main/kotlin/com/lambda/config/Config.kt | 107 +++++++++++---- .../com/lambda/config/ConfigCategory.kt | 96 ++++++++----- .../kotlin/com/lambda/config/ConfigEditor.kt | 79 +++++------ .../kotlin/com/lambda/config/ConfigLoader.kt | 9 +- .../{SettingGroup.kt => SettingBlock.kt} | 18 +-- .../config/automation/AutomationConfig.kt | 45 +++---- .../automation/IMutableAutomationConfig.kt | 8 +- .../com/lambda/config/groups/ActionConfig.kt | 3 +- .../com/lambda/config/groups/BreakConfig.kt | 4 +- .../com/lambda/config/groups/BreakSettings.kt | 127 ++++++++---------- .../com/lambda/config/groups/BuildConfig.kt | 39 +++++- .../com/lambda/config/groups/BuildSettings.kt | 69 +++++----- .../com/lambda/config/groups/EatConfig.kt | 5 +- .../com/lambda/config/groups/EatSettings.kt | 35 +++-- .../config/groups/EntityColorSettings.kt | 39 +++--- .../config/groups/EntityColorsConfig.kt | 3 +- .../config/groups/EntitySelectionConfig.kt | 4 +- .../config/groups/EntitySelectionSettings.kt | 47 +++---- .../lambda/config/groups/FormatterConfig.kt | 5 +- .../lambda/config/groups/FormatterSettings.kt | 25 ++-- .../com/lambda/config/groups/HotbarConfig.kt | 4 +- .../lambda/config/groups/HotbarSettings.kt | 22 ++- .../lambda/config/groups/InteractConfig.kt | 10 +- .../lambda/config/groups/InteractSettings.kt | 32 ++--- .../lambda/config/groups/InventoryConfig.kt | 4 +- .../lambda/config/groups/InventorySettings.kt | 37 +++-- .../com/lambda/config/groups/LineConfig.kt | 3 +- .../lambda/config/groups/OutlineSettings.kt | 19 +-- .../com/lambda/config/groups/ReplaceConfig.kt | 4 +- .../lambda/config/groups/RotationConfig.kt | 46 +------ .../lambda/config/groups/RotationSettings.kt | 23 ++-- .../config/groups/ScreenLineSettings.kt | 34 +++-- .../config/groups/ScreenTextSettings.kt | 46 +++---- .../lambda/config/groups/TargetingConfig.kt | 4 +- .../lambda/config/groups/TargetingSettings.kt | 32 ++--- .../com/lambda/config/groups/TextConfig.kt | 3 +- .../lambda/config/groups/WorldLineSettings.kt | 41 +++--- .../lambda/config/groups/WorldTextSettings.kt | 46 +++---- .../migrations/AutomationConfigMigration.kt | 1 + .../lambda/config/settings/NumericSetting.kt | 8 +- .../lambda/config/settings/StringSetting.kt | 6 +- .../collections/ClassCollectionSetting.kt | 2 +- .../settings/collections/CollectionSetting.kt | 4 +- src/main/kotlin/com/lambda/core/Loader.kt | 2 +- src/main/kotlin/com/lambda/gui/MenuBar.kt | 10 +- .../com/lambda/gui/components/QuickSearch.kt | 2 +- .../lambda/gui/components/SettingsWidget.kt | 5 +- src/main/kotlin/com/lambda/module/Module.kt | 2 +- .../com/lambda/module/ModuleRegistry.kt | 3 +- .../com/lambda/module/hud/Coordinates.kt | 7 + .../lambda/module/modules/chat/AntiSpam.kt | 4 +- .../com/lambda/util/CommunicationUtils.kt | 3 +- .../kotlin/com/lambda/util/Diagnostics.kt | 2 +- .../kotlin/com/lambda/util/ReflectionUtils.kt | 9 +- 57 files changed, 606 insertions(+), 653 deletions(-) rename src/main/kotlin/com/lambda/config/{SettingGroup.kt => SettingBlock.kt} (64%) diff --git a/src/main/java/com/lambda/mixin/CrashReportMixin.java b/src/main/java/com/lambda/mixin/CrashReportMixin.java index 79cb84581..29633b767 100644 --- a/src/main/java/com/lambda/mixin/CrashReportMixin.java +++ b/src/main/java/com/lambda/mixin/CrashReportMixin.java @@ -65,7 +65,7 @@ String injectString(ReportType type, List extraInfo, Operation o .forEach(module -> { list.add(String.format("\t%s", module.getName())); - module.getSettings() + module.getSettingContainers() .stream() .filter(Setting::isModified) .forEach(setting -> list.add(String.format("\t\t%s -> %s", setting.getName(), setting.getValue()))); diff --git a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt index 610b7b2c0..5f5725d7b 100644 --- a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt @@ -41,7 +41,7 @@ object ConfigCommand : LambdaCommand( required(literal("save")) { executeWithResult { ConfigLoader.configCategories.forEach { config -> - config.trySave(true) + config.trySaveToFile(true) } this@ConfigCommand.info("Saved ${ConfigLoader.configCategories.size} configuration files.") return@executeWithResult success() @@ -50,7 +50,7 @@ object ConfigCommand : LambdaCommand( required(literal("load")) { executeWithResult { ConfigLoader.configCategories.forEach { config -> - config.tryLoad() + config.tryLoadFromFile() } this@ConfigCommand.info("Loaded ${ConfigLoader.configCategories.size} configuration files.") return@executeWithResult success() @@ -65,7 +65,7 @@ object ConfigCommand : LambdaCommand( suggests { ctx, builder -> val conf = config(ctx).value() ConfigLoader.configByName(conf)?.let { config -> - suggestMatching(config.settings.map { it.commandName }, builder) + suggestMatching(config.settingContainers.map { it.commandName }, builder) } ?: builder.buildFuture() } executeWithResult { @@ -84,7 +84,7 @@ object ConfigCommand : LambdaCommand( required(literal("set")) { ConfigLoader.configs.forEach { config -> required(literal(config.commandName)) { - config.settings.forEach { setting -> + config.settingContainers.forEach { setting -> required(literal(setting.commandName)) { with(setting) { buildCommand(registry) diff --git a/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt b/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt index 6b98509fd..cc6365e35 100644 --- a/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt @@ -54,7 +54,7 @@ object PrefixCommand : LambdaCommand( val prefixChar = prefix.first() val config = ConfigLoader.configByName("command") ?: return@executeWithResult failure("No command config found.") @Suppress("UNCHECKED_CAST") - val setting = config.settings.find { it.name == "prefix" } as? Setting, Char> + val setting = config.settingContainers.find { it.name == "prefix" } as? Setting, Char> ?: return@executeWithResult failure("Prefix setting is not a Char or can not be found.") setting.trySetValue(prefixChar) return@executeWithResult success() diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index e56a5adb7..8c86dbaa7 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -60,10 +60,12 @@ import java.awt.Color * * This class also provides a series of helper methods ([setting]) for creating different types of settings. * - * @property settings A set of [SettingCore]s that this config manages. + * @property settingContainers A set of [SettingCore]s that this config manages. */ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { - val settings = mutableListOf>() + val settingContainers = mutableListOf() + val settingTabs = mutableListOf() + val settingGroups = mutableListOf() init { if (configs.any { it.name == name }) @@ -71,28 +73,63 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { configCategory.configs.add(this) } - fun , R : Any> Setting.register() = apply { - if (settings.any { it.name == name }) - throw IllegalStateException("Setting with name $name already exists for config: ${this@Config.name}") - settings.add(this) - } - - override fun toJson() = + final override fun toJson() = JsonObject().apply { - settings.forEach { setting -> - try { - add(setting.name, setting.toJson()) - } catch (e: Exception) { - logError("Failed to serialize $setting in ${this::class.simpleName}", e) + fun JsonObject.addSettings(settings: Collection) { + settings.forEach { container -> + when (container) { + is SettingContainer.Single -> + try { + add(container.setting.name, container.setting.toJson()) + } catch(e: Throwable) { + logError("Failed to serialize '${container.setting}' in ${this::class.simpleName}", e) + } + is SettingContainer.Multiple -> { + val grouped = JsonObject() + grouped.addSettings(container.settings) + try { + add(container.name, grouped) + } catch(e: Throwable) { + logError("Failed to serialize ${container.type}: ${container.name} in ${this::class.simpleName}", e) + } + } + } } } + addSettings(settingContainers) } - override fun loadFromJson(serialized: JsonElement) { - serialized.asJsonObject.entrySet().forEach { (name, value) -> - settings.find { it.name == name }?.loadFromJson(value) - ?: LOG.warn("No saved setting found for $name with $value in ${this::class.simpleName}") + final override fun loadFromJson(serialized: JsonElement) { + val rootObj = serialized.asJsonObject + + fun loadFromObject(obj: JsonObject, containers: Collection) { + containers.forEach { container -> + when (container) { + is SettingContainer.Single -> { + val jsonValue = obj[container.setting.name] + if (jsonValue != null) { + try { + container.setting.loadFromJson(jsonValue) + } catch (e: Throwable) { + logError("Failed to deserialize setting '${container.setting.name}'", e) + } + } else { + LOG.warn("No saved value for setting '${container.setting.name}' in ${this::class.simpleName}") + } + } + is SettingContainer.Multiple -> { + val nestedObj = obj[container.name]?.asJsonObject + if (nestedObj != null) { + loadFromObject(nestedObj, container.settings) + } else { + LOG.debug("No data for group/tab '${container.name}' in ${this::class.simpleName}") + } + } + } + } } + + loadFromObject(rootObj, settingContainers) } fun setting( @@ -278,6 +315,9 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true } ) = Setting(name, description, FunctionSetting(defaultValue), this, visibility) + fun settingBlock(settingBlock: T, block: (T.() -> Unit)? = null) = + settingBlock.apply { block?.invoke(this) } + @Target(AnnotationTarget.PROPERTY) @Retention(AnnotationRetention.RUNTIME) annotation class Tab(vararg val tab: String) @@ -286,15 +326,28 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { @Retention(AnnotationRetention.RUNTIME) annotation class Group(vararg val group: String) - @Suppress("unused") - object StandardTabs { - const val GENERAL_TAB = "General" - const val RENDER_TAB = "Render" - } + sealed interface SettingContainer { + class Single(val setting: Setting<*, *>) : SettingContainer - @Suppress("unused") - object StandardGroups { - const val GENERAL_GROUP = "General" - const val RENDER_GROUP = "Render" + sealed class Multiple( + val name: String, + val settings: Collection + ) : SettingContainer { + abstract val type: String + } + + class Tab( + name: String, + settings: Collection + ) : Multiple(name, settings) { + override val type = "tab" + } + + class Group( + name: String, + settings: Collection + ) : Multiple(name, settings) { + override val type = "group" + } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/ConfigCategory.kt b/src/main/kotlin/com/lambda/config/ConfigCategory.kt index 5b053cc7e..d4f188a3c 100644 --- a/src/main/kotlin/com/lambda/config/ConfigCategory.kt +++ b/src/main/kotlin/com/lambda/config/ConfigCategory.kt @@ -40,6 +40,10 @@ import com.lambda.util.FileUtils.ifNotExists import com.lambda.util.StringUtils.capitalize import java.io.File import kotlin.concurrent.fixedRateTimer +import kotlin.reflect.KClass +import kotlin.reflect.KClassifier +import kotlin.reflect.full.declaredMemberProperties +import kotlin.reflect.jvm.isAccessible import kotlin.time.Duration.Companion.minutes @@ -58,33 +62,54 @@ import kotlin.time.Duration.Companion.minutes * @property configs A set of [Config] objects that this configuration manages. */ abstract class ConfigCategory : Jsonable, Loadable { - override val priority = 1 abstract val configName: String abstract val primary: File + override val priority = 1 val configs = mutableSetOf() private val backup: File get() = File("${primary.parent}/${primary.nameWithoutExtension}-backup.${primary.extension}") - override fun load(): String { + final override fun load(): String { if (configCategories.any { it.configName == configName }) throw IllegalStateException("Configuration with name $configName already exists") + configs.forEach { config -> + val settings = config::class.declaredMemberProperties.mapNotNull { prop -> + val returnType = prop.returnType + val classifier = returnType.classifier ?: return@mapNotNull null + + when { + classifier.isOf>() || classifier.isOf() -> { + prop.isAccessible = true + prop to prop.getter.call(config) // returns the Setting instance + } + else -> null + } + } + } + fixedRateTimer( daemon = true, name = "Scheduler-config-${configName}", initialDelay = 5.minutes.inWholeMilliseconds, period = 5.minutes.inWholeMilliseconds, - ) { trySave() } + ) { trySaveToFile() } configCategories.add(this) - listenUnsafe({ Int.MIN_VALUE }) { trySave() } + listenUnsafe({ Int.MIN_VALUE }) { trySaveToFile() } return super.load() } - override fun toJson() = + private inline fun KClassifier.isOf() = + this == T::class || (this is KClass<*> && T::class.java.isAssignableFrom(java)) + + fun tryLoadFromFile() = runIO { internalTryLoad() } + fun trySaveToFile(logToChat: Boolean = false) = runIO { internalTrySave(logToChat) } + + final override fun toJson() = JsonObject().apply { val latestSchemaVersion = ConfigMigrations.latestVersion(configName) if (latestSchemaVersion > 1) { @@ -98,7 +123,7 @@ abstract class ConfigCategory : Jsonable, Loadable { } } - override fun loadFromJson(serialized: JsonElement) { + final override fun loadFromJson(serialized: JsonElement) { val schemaKey = ConfigMigrations.schemaVersionKey(configName) ?: ConfigMigrations.DEFAULT_SCHEMA_VERSION_KEY serialized.asJsonObject.entrySet().forEach { (name, value) -> if (name == schemaKey) return@forEach @@ -108,16 +133,32 @@ abstract class ConfigCategory : Jsonable, Loadable { } } - private fun save() = runCatching { - primary.createIfNotExists() - .let { - it.writeText(gson.toJson(toJson())) - it.copyTo(backup, true) + protected open fun internalTryLoad() { + loadFromFile(primary) + .onSuccess { + val message = "${configName.capitalize()} config loaded." + LOG.info(message) + info(message) + } + .onFailure { primaryError -> + LOG.error(primaryError) + + runCatching { loadFromFile(backup) } + .onSuccess { + val message = "${configName.capitalize()} config loaded from backup" + LOG.info(message) + info(message) + } + .onFailure { error -> + val message = "Failed to load ${configName.capitalize()} config from backup, unrecoverable error" + LOG.error(message, error) + logError(message) + } } } protected open fun internalTrySave(logToChat: Boolean) { - save() + saveToFile() .onSuccess { val message = "Saved ${configName.capitalize()} config." LOG.info(message) @@ -134,7 +175,7 @@ abstract class ConfigCategory : Jsonable, Loadable { * Loads the config from the [file] * Encapsulates [JsonIOException] and [JsonSyntaxException] in a runCatching block */ - private fun load(file: File) = runCatching { + private fun loadFromFile(file: File) = runCatching { file.ifNotExists { LOG.warn("No configuration file found for ${configName.capitalize()}. Creating new file when saving.") } .ifExists { val parsed = JsonParser.parseReader(it.reader()).asJsonObject @@ -149,30 +190,11 @@ abstract class ConfigCategory : Jsonable, Loadable { } } - protected open fun internalTryLoad() { - load(primary) - .onSuccess { - val message = "${configName.capitalize()} config loaded." - LOG.info(message) - info(message) - } - .onFailure { primaryError -> - LOG.error(primaryError) - - runCatching { load(backup) } - .onSuccess { - val message = "${configName.capitalize()} config loaded from backup" - LOG.info(message) - info(message) - } - .onFailure { error -> - val message = "Failed to load ${configName.capitalize()} config from backup, unrecoverable error" - LOG.error(message, error) - logError(message) - } + private fun saveToFile() = runCatching { + primary.createIfNotExists() + .let { + it.writeText(gson.toJson(toJson())) + it.copyTo(backup, true) } } - - fun tryLoad() = runIO { internalTryLoad() } - fun trySave(logToChat: Boolean = false) = runIO { internalTrySave(logToChat) } } diff --git a/src/main/kotlin/com/lambda/config/ConfigEditor.kt b/src/main/kotlin/com/lambda/config/ConfigEditor.kt index be403cf4a..c4dc4590e 100644 --- a/src/main/kotlin/com/lambda/config/ConfigEditor.kt +++ b/src/main/kotlin/com/lambda/config/ConfigEditor.kt @@ -15,9 +15,10 @@ * along with this program. If not, see . */ +@file:Suppress("unchecked_cast", "unused") + package com.lambda.config -import com.lambda.util.NamedEnum import kotlin.reflect.KProperty0 import kotlin.reflect.jvm.isAccessible @@ -29,32 +30,31 @@ fun T.applyEdits(edits: ConfigEditor.() -> Unit) { ConfigEditor(this).apply(edits) } -@Suppress("unchecked_cast", "unused") -open class SettingGroupEditor(open val c: T) { - val KProperty0<*>.delegate +class ConfigEditor(val c: T) { + private val KProperty0<*>.delegate get() = try { apply { isAccessible = true }.getDelegate() } catch (e: Exception) { throw IllegalStateException("Could not access delegate for property $name", e) } - fun KProperty0.setting() = + private fun KProperty0.setting() = this.delegate as? Setting, T> ?: throw IllegalStateException("Setting delegate did not match current value's type") - fun KProperty0.settingCore() = setting().core + private fun KProperty0.settingCore() = setting().core @SettingEditorDsl - inline fun KProperty0.edit(edits: TypedEditBuilder.(SettingCore) -> Unit) { + fun KProperty0.edit(edits: TypedEditBuilder.(SettingCore) -> Unit) { val delegate = setting() - TypedEditBuilder(this@SettingGroupEditor, listOf(delegate)).edits(delegate.core) + TypedEditBuilder(this@ConfigEditor, listOf(delegate)).edits(delegate.core) } @SettingEditorDsl - inline fun KProperty0.editWith( + fun KProperty0.editWith( other: KProperty0, edits: TypedEditBuilder.(SettingCore) -> Unit - ) = TypedEditBuilder(this@SettingGroupEditor, listOf(setting())).edits(other.settingCore()) + ) = TypedEditBuilder(this@ConfigEditor, listOf(setting())).edits(other.settingCore()) @SettingEditorDsl fun edit( @@ -63,20 +63,20 @@ open class SettingGroupEditor(open val c: T) { ) = BasicEditBuilder(this, settings.map { (it as KProperty0).setting() }).apply(edits) @SettingEditorDsl - inline fun editWith( + fun editWith( vararg settings: KProperty0<*>, other: KProperty0, edits: BasicEditBuilder.(SettingCore) -> Unit ) = BasicEditBuilder(this, settings.map { (it as KProperty0).setting() }).edits(other.settingCore()) @SettingEditorDsl - inline fun editTyped( + fun editTyped( vararg settings: KProperty0, edits: TypedEditBuilder.() -> Unit ) = TypedEditBuilder(this, settings.map { it.setting() }).apply(edits) @SettingEditorDsl - inline fun editTypedWith( + fun editTypedWith( vararg settings: KProperty0, other: KProperty0, edits: TypedEditBuilder.(SettingCore) -> Unit @@ -84,24 +84,33 @@ open class SettingGroupEditor(open val c: T) { @SettingEditorDsl fun hide(settings: Collection>) { - c.settings.removeAll(settings) + c.settingContainers.removeAll(settings) } @SettingEditorDsl - fun hide(vararg settings: KProperty0<*>) = - hide(settings.map { (it as KProperty0).setting() }) + fun hide(vararg settings: KProperty0) = + hide(settings.map { it.setting() }) - open class BasicEditBuilder(val c: SettingGroupEditor<*>, open val settings: Collection>) { - @SettingEditorDsl - fun hide() = c.hide(settings) + @SettingEditorDsl + fun hideGroup(settingGroup: SettingBlock) = hide(settingGroup.settings) - @SettingEditorDsl - fun groups(vararg groups: NamedEnum) = - settings.forEach { it.groups = mutableListOf(groups.toList()) } + @SettingEditorDsl + fun hideGroupExcept(settingGroup: SettingBlock, vararg except: KProperty0) { + val exceptSettings = except.map { it.setting() }.toSet() + hide(settingGroup.settings.filter { it !in exceptSettings }) + } + + @SettingEditorDsl + fun hideGroups(vararg settingGroups: SettingBlock) = + settingGroups.forEach { hide(it.settings) } + + @SettingEditorDsl + fun hideAllGroupsExcept(vararg except: SettingBlock) = + hideGroups(*(c.settingGroups - except.toSet()).toTypedArray()) + open class BasicEditBuilder(val c: ConfigEditor<*>, open val settings: Collection>) { @SettingEditorDsl - fun groups(groups: MutableList>) = - settings.forEach { it.groups = groups } + fun hide() = c.hide(settings) @SettingEditorDsl fun visibility(visibility: (() -> Boolean) -> () -> Boolean) { @@ -112,7 +121,7 @@ open class SettingGroupEditor(open val c: T) { } class TypedEditBuilder( - c: SettingGroupEditor<*>, + c: ConfigEditor<*>, override val settings: Collection, T>> ) : BasicEditBuilder(c, settings) { @SettingEditorDsl @@ -122,24 +131,4 @@ open class SettingGroupEditor(open val c: T) { it.core.value = value } } -} - -@Suppress("unchecked_cast", "unused") -class ConfigEditor(override val c: T) : SettingGroupEditor(c) { - @SettingEditorDsl - fun hideGroup(settingGroup: ISettingGroup) = hide(settingGroup.settings) - - @SettingEditorDsl - fun hideGroupExcept(settingGroup: ISettingGroup, vararg except: KProperty0<*>) { - val exceptSettings = except.map { (it as KProperty0).setting() }.toSet() - hide(settingGroup.settings.filter { it !in exceptSettings }) - } - - @SettingEditorDsl - fun hideGroups(vararg settingGroups: ISettingGroup) = - settingGroups.forEach { hide(it.settings) } - - @SettingEditorDsl - fun hideAllGroupsExcept(vararg except: ISettingGroup) = - hideGroups(*(c.settingGroups - except.toSet()).toTypedArray()) } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/ConfigLoader.kt b/src/main/kotlin/com/lambda/config/ConfigLoader.kt index e65642f25..da5e68ca6 100644 --- a/src/main/kotlin/com/lambda/config/ConfigLoader.kt +++ b/src/main/kotlin/com/lambda/config/ConfigLoader.kt @@ -19,17 +19,16 @@ package com.lambda.config import com.lambda.core.Loadable -@Suppress("unused") object ConfigLoader: Loadable { val configCategories = mutableSetOf() val configs: Set get() = configCategories.flatMapTo(mutableSetOf()) { it.configs } val settings: List> - get() = configs.flatMapTo(mutableListOf()) { it.settings } + get() = configs.flatMapTo(mutableListOf()) { it.settingContainers } override fun load(): String { configCategories.forEach { - it.tryLoad() + it.tryLoadFromFile() } return "Loading ${configCategories.size} config categories" } @@ -40,6 +39,6 @@ object ConfigLoader: Loadable { fun configByCommandName(name: String) = configs.find { it.commandName == name } - fun settingByCommandName(config: Config, name: String) = - config.settings.find { it.commandName == name } + fun settingByCommandName(config: Config, tab: String?, group: String?, name: String) = + config.settingContainers.find { it.commandName == name } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/SettingGroup.kt b/src/main/kotlin/com/lambda/config/SettingBlock.kt similarity index 64% rename from src/main/kotlin/com/lambda/config/SettingGroup.kt rename to src/main/kotlin/com/lambda/config/SettingBlock.kt index 86e0c8cfa..1766e23ba 100644 --- a/src/main/kotlin/com/lambda/config/SettingGroup.kt +++ b/src/main/kotlin/com/lambda/config/SettingBlock.kt @@ -17,20 +17,6 @@ package com.lambda.config -interface ISettingGroup { - val settings: MutableList> - val visibility: () -> Boolean -} - -abstract class SettingGroup(c: Config) : ISettingGroup { - override val settings = mutableListOf>() - - init { - c.settingGroups.add(this) - } - - fun , R : Any> Setting.index(): Setting { - settings.add(this) - return this - } +interface SettingBlock { + val c: Config } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt index c66314385..98d5c85fe 100644 --- a/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt @@ -29,49 +29,40 @@ import com.lambda.config.groups.InventorySettings import com.lambda.config.groups.RotationSettings import com.lambda.context.Automated import com.lambda.module.Module -import com.lambda.util.NamedEnum open class AutomationConfig( override val name: String, configCategory: ConfigCategory = AutomationCategory ) : Config(configCategory), Automated { - enum class Group(override val displayName: String) : NamedEnum { - Build("Build"), - Break("Break"), - Interact("Interact"), - Rotation("Rotation"), - Inventory("Inventory"), - Hotbar("Hotbar"), - Eat("Eat"), - Render("Render"), - Debug("Debug") - } - - override val buildConfig = BuildSettings(this, Group.Build) - override val breakConfig = BreakSettings(this, Group.Break) - override val interactConfig = InteractSettings(this, Group.Interact) - override val rotationConfig = RotationSettings(this, Group.Rotation) - override val inventoryConfig = InventorySettings(this, Group.Inventory) - override val hotbarConfig = HotbarSettings(this, Group.Hotbar) - override val eatConfig = EatSettings(this, Group.Eat) + @Tab(BUILD_TAB) override val buildConfig = BuildSettings(this) + @Tab(BREAK_TAB) override val breakConfig = BreakSettings(this) + @Tab(INTERACT_TAB) override val interactConfig = InteractSettings(this) + @Tab(ROTATION_TAB) override val rotationConfig = RotationSettings(this) + @Tab(INVENTORY_TAB) override val inventoryConfig = InventorySettings(this) + @Tab(HOTBAR_TAB) override val hotbarConfig = HotbarSettings(this) + @Tab(EAT_TAB) override val eatConfig = EatSettings(this) companion object { + private const val BUILD_TAB = "Build" + private const val BREAK_TAB = "Break" + private const val INTERACT_TAB = "Interact" + private const val ROTATION_TAB = "Rotation" + private const val INVENTORY_TAB = "Inventory" + private const val HOTBAR_TAB = "Hotbar" + private const val EAT_TAB = "Eat" + context(module: Module) fun IMutableAutomationConfig.setDefaultAutomationConfig( name: String = module.name, edits: (AutomationConfig.() -> Unit)? = null - ) { - this.defaultAutomationConfig = AutomationConfig("$name Automation Config").apply { edits?.invoke(this) } - } + ) { this.defaultAutomationConfig = AutomationConfig("$name Automation Config").apply { edits?.invoke(this) } } fun IMutableAutomationConfig.setDefaultAutomationConfig( name: String, edits: (AutomationConfig.() -> Unit)? = null - ) { - defaultAutomationConfig = AutomationConfig("$name Automation Config").apply { edits?.invoke(this) } - } + ) { defaultAutomationConfig = AutomationConfig("$name Automation Config").apply { edits?.invoke(this) } } - object DEFAULT : AutomationConfig("Default") + val DEFAULT = AutomationConfig("Default") } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt index 23ab6c0f8..3e8371151 100644 --- a/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt @@ -43,7 +43,7 @@ interface IMutableAutomationConfig : Automated { } class MutableAutomationConfig : IMutableAutomationConfig { - override var defaultAutomationConfig: AutomationConfig = AutomationConfig.Companion.DEFAULT + override var defaultAutomationConfig: AutomationConfig = AutomationConfig.DEFAULT set(value) { field = value automationConfig = value @@ -53,11 +53,11 @@ class MutableAutomationConfig : IMutableAutomationConfig { set(value) { if (value === defaultAutomationConfig) { if (backingAutomationConfig !== defaultAutomationConfig) { - field.settings.forEach(Setting<*, *>::restoreOriginalCore) + field.settingContainers.forEach(Setting<*, *>::restoreOriginalCore) } field = value - } else field.settings.forEach { setting -> - value.settings.forEach { newSetting -> + } else field.settingContainers.forEach { setting -> + value.settingContainers.forEach { newSetting -> if (setting.name == newSetting.name) { if (setting.core.type != newSetting.core.type) throw IllegalStateException("Settings with the same name do not have the same type.") diff --git a/src/main/kotlin/com/lambda/config/groups/ActionConfig.kt b/src/main/kotlin/com/lambda/config/groups/ActionConfig.kt index 561a72ca1..d30de5b5b 100644 --- a/src/main/kotlin/com/lambda/config/groups/ActionConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/ActionConfig.kt @@ -17,11 +17,12 @@ package com.lambda.config.groups +import com.lambda.config.SettingBlock import com.lambda.event.events.TickEvent import com.lambda.util.Describable import com.lambda.util.NamedEnum -interface ActionConfig { +interface ActionConfig : SettingBlock { val sorter: SortMode val tickStageMask: Collection diff --git a/src/main/kotlin/com/lambda/config/groups/BreakConfig.kt b/src/main/kotlin/com/lambda/config/groups/BreakConfig.kt index e06b03d61..b62543d71 100644 --- a/src/main/kotlin/com/lambda/config/groups/BreakConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/BreakConfig.kt @@ -17,13 +17,13 @@ package com.lambda.config.groups -import com.lambda.config.ISettingGroup import com.lambda.util.Describable import com.lambda.util.NamedEnum import net.minecraft.block.Block import java.awt.Color -interface BreakConfig : ActionConfig, ISettingGroup { +@Suppress("unused") +interface BreakConfig : ActionConfig { val breakMode: BreakMode val rebreak: Boolean diff --git a/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt b/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt index 0e9e28989..0095d1a84 100644 --- a/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt @@ -18,104 +18,83 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.config.SettingGroup +import com.lambda.config.Config.Group import com.lambda.config.applyEdits import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.config.groups.BreakConfig import com.lambda.config.groups.BreakConfig.AnimationMode import com.lambda.config.groups.BreakConfig.BreakConfirmationMode import com.lambda.config.groups.BreakConfig.BreakMode import com.lambda.config.groups.BreakConfig.SwingMode import com.lambda.config.groups.BreakConfig.WhitelistMode -import com.lambda.util.NamedEnum import net.minecraft.registry.Registries import java.awt.Color -open class BreakSettings( - c: Config, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, -) : SettingGroup(c), BreakConfig { - enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Cosmetic("Cosmetic") +class BreakSettings(override val c: Config) : BreakConfig { + companion object { + const val GENERAL_GROUP = "General" + const val COSMETIC_GROUP = "Cosmetic" } // General - override val breakMode by c.setting("${prefix}Break Mode", BreakMode.Packet, visibility = visibility).group(*baseGroup, Group.General).index() - override val sorter by c.setting("${prefix}Break Sorter", ActionConfig.SortMode.Tool, "The order in which breaks are performed", visibility = visibility).group(*baseGroup, Group.General).index() - override val rebreak by c.setting("${prefix}Rebreak", true, "Re-breaks blocks after they've been broken once", visibility = visibility).group(*baseGroup, Group.General).index() - + @Group(GENERAL_GROUP) override val breakMode by c.setting("Break Mode", BreakMode.Packet) + @Group(GENERAL_GROUP) override val sorter by c.setting("Break Sorter", ActionConfig.SortMode.Tool, "The order in which breaks are performed") + @Group(GENERAL_GROUP) override val rebreak by c.setting("Rebreak", true, "Re-breaks blocks after they've been broken once") // Double break - override val doubleBreak by c.setting("${prefix}Double Break", true, "Allows breaking two blocks at once", visibility = visibility).group(*baseGroup, Group.General).index() - override val unsafeCancels by c.setting("${prefix}Unsafe Cancels", true, "Allows cancelling block breaking even if the server might continue breaking sever side, potentially causing unexpected state changes") { visibility() && doubleBreak }.group(*baseGroup, Group.General).index() - + @Group(GENERAL_GROUP) override val doubleBreak by c.setting("Double Break", true, "Allows breaking two blocks at once") + @Group(GENERAL_GROUP) override val unsafeCancels by c.setting("Unsafe Cancels", true, "Allows cancelling block breaking even if the server might continue breaking sever side, potentially causing unexpected state changes") { doubleBreak } // Fixes / Delays - override val breakThreshold by c.setting("${prefix}Break Threshold", 0.70f, 0.1f..1.0f, 0.01f, "The break amount at which the block is considered broken", visibility = visibility).group(*baseGroup, Group.General).index() - override val fudgeFactor by c.setting("${prefix}Fudge Factor", 1, 0..5, 1, "The number of ticks to add to the break time, usually to account for server lag", visibility = visibility).group(*baseGroup, Group.General).index() - override val serverSwapTicks by c.setting("${prefix}Server Swap", 0, 0..5, 1, "The number of ticks to give the server time to recognize the player attributes on the swapped item", " tick(s)", visibility = visibility).group(*baseGroup, Group.General).index() - - // override val desyncFix by c.setting("Desync Fix", false, "Predicts if the players breaking will be slowed next tick as block break packets are processed using the players next position") { vis() && page == Page.General } - override val breakDelay by c.setting("${prefix}Break Delay", 0, 0..6, 1, "The delay between breaking blocks", " tick(s)", visibility = visibility).group(*baseGroup, Group.General).index() - + @Group(GENERAL_GROUP) override val breakThreshold by c.setting("Break Threshold", 0.70f, 0.1f..1.0f, 0.01f, "The break amount at which the block is considered broken") + @Group(GENERAL_GROUP) override val fudgeFactor by c.setting("Fudge Factor", 1, 0..5, 1, "The number of ticks to add to the break time, usually to account for server lag") + @Group(GENERAL_GROUP) override val serverSwapTicks by c.setting("Server Swap", 0, 0..5, 1, "The number of ticks to give the server time to recognize the player attributes on the swapped item", " tick(s)") +// @Group(GENERAL_GROUP) override val desyncFix by c.setting("Desync Fix", false, "Predicts if the players breaking will be slowed next tick as block break packets are processed using the players next position") { page == Page.General } + @Group(GENERAL_GROUP) override val breakDelay by c.setting("Break Delay", 0, 0..6, 1, "The delay between breaking blocks", " tick(s)") // Timing - override val tickStageMask by c.setting("${prefix}Break Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), "The sub-tick timing at which break actions can be performed", displayClassName = true, visibility = visibility).group(*baseGroup, Group.General).index() - - // Swap - override val swapMode by c.setting("${prefix}Break Swap Mode", BreakConfig.SwapMode.End, "Decides when to swap to the best suited tool when breaking a block", visibility = visibility).group(*baseGroup, Group.General).index() - - // Swing - override val swing by c.setting("${prefix}Swing Mode", SwingMode.Constant, "The times at which to swing the players hand", visibility = visibility).group(*baseGroup, Group.General).index() - override val swingType by c.setting("${prefix}Break Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { visibility() && swing != SwingMode.None }.group(*baseGroup, Group.General).index() - + @Group(GENERAL_GROUP) override val tickStageMask by c.setting("Break Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), "The sub-tick timing at which break actions can be performed", displayClassName = true) + @Group(GENERAL_GROUP) override val swapMode by c.setting("Break Swap Mode", BreakConfig.SwapMode.End, "Decides when to swap to the best suited tool when breaking a block") + @Group(GENERAL_GROUP) override val swing by c.setting("Swing Mode", SwingMode.Constant, "The times at which to swing the players hand") + @Group(GENERAL_GROUP) override val swingType by c.setting("Break Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { swing != SwingMode.None } // Rotate - override val rotate by c.setting("${prefix}Rotate For Break", false, "Rotate towards block while breaking", visibility = visibility).group(*baseGroup, Group.General).index() - + @Group(GENERAL_GROUP) override val rotate by c.setting("Rotate For Break", false, "Rotate towards block while breaking") // Pending / Post - override val breakConfirmation by c.setting("${prefix}Break Confirmation", BreakConfirmationMode.BreakThenAwait, "The style of confirmation used when breaking", visibility = visibility).group(*baseGroup, Group.General).index() - override val breaksPerTick by c.setting("${prefix}Breaks Per Tick", 30, 1..30, 1, "Maximum instant block breaks per tick", visibility = visibility).group(*baseGroup, Group.General).index() - - // Block - override val whitelistMode by c.setting("${prefix}Whitelist Mode", WhitelistMode.None, "The type of block selection used", visibility = visibility).group(*baseGroup, Group.General).index() - override val whitelist by c.setting("${prefix}Whitelist", mutableSetOf(), Registries.BLOCK.toMutableSet(), "Only these selected blocks are allowed to be broken") { visibility() && whitelistMode == WhitelistMode.Whitelist }.group(*baseGroup, Group.General).index() - override val blacklist by c.setting("${prefix}Blacklist", mutableSetOf(), Registries.BLOCK.toMutableSet(), "These selected blocks are not allowed to be broken") { visibility() && whitelistMode == WhitelistMode.Blacklist }.group(*baseGroup, Group.General).index() - override val avoidFluids by c.setting("${prefix}Avoid Fluids", true, "Avoids breaking blocks that would cause fluids to spill", visibility = visibility).group(*baseGroup, Group.General).index() - override val avoidSupporting by c.setting("${prefix}Avoid Supporting", true, "Avoids breaking the block supporting the player", visibility = visibility).group(*baseGroup, Group.General).index() - override val fillFluids by c.setting("Fill Fluids", true, "Fills fluids in order to break blocks that would initially spill them") { visibility() && avoidFluids }.group(*baseGroup, Group.General).index() + @Group(GENERAL_GROUP) override val breakConfirmation by c.setting("Break Confirmation", BreakConfirmationMode.BreakThenAwait, "The style of confirmation used when breaking") + @Group(GENERAL_GROUP) override val breaksPerTick by c.setting("Breaks Per Tick", 30, 1..30, 1, "Maximum instant block breaks per tick") + @Group(GENERAL_GROUP) override val whitelistMode by c.setting("Whitelist Mode", WhitelistMode.None, "The type of block selection used") + @Group(GENERAL_GROUP) override val whitelist by c.setting("Whitelist", mutableSetOf(), Registries.BLOCK.toSet(), "Only these selected blocks are allowed to be broken") { whitelistMode == WhitelistMode.Whitelist } + @Group(GENERAL_GROUP) override val blacklist by c.setting("Blacklist", mutableSetOf(), Registries.BLOCK.toSet(), "These selected blocks are not allowed to be broken") { whitelistMode == WhitelistMode.Blacklist } + @Group(GENERAL_GROUP) override val avoidFluids by c.setting("Avoid Fluids", true, "Avoids breaking blocks that would cause fluids to spill") + @Group(GENERAL_GROUP) override val avoidSupporting by c.setting("Avoid Supporting", true, "Avoids breaking the block supporting the player") + @Group(GENERAL_GROUP) override val fillFluids by c.setting("Fill Fluids", true, "Fills fluids in order to break blocks that would initially spill them") { avoidFluids } // Tool - override val efficientOnly by c.setting("${prefix}Efficient Tools Only", true, "Only use tools suitable for the given block (will get the item drop)") { visibility() && swapMode.isEnabled() }.group(*baseGroup, Group.General).index() - override val suitableToolsOnly by c.setting("${prefix}Suitable Tools Only", true, "Only use tools suitable for the given block (will get the item drop)") { visibility() && swapMode.isEnabled() }.group(*baseGroup, Group.General).index() - override val forceSilkTouch by c.setting("${prefix}Force Silk Touch", false, "Force silk touch when breaking blocks") { visibility() && swapMode.isEnabled() }.group(*baseGroup, Group.General).index() - override val forceFortunePickaxe by c.setting("${prefix}Force Fortune Pickaxe", false, "Force fortune pickaxe when breaking blocks") { visibility() && swapMode.isEnabled() }.group(*baseGroup, Group.General).index() - override val minFortuneLevel by c.setting("${prefix}Min Fortune Level", 1, 1..3, 1, "The minimum fortune level to use") { visibility() && swapMode.isEnabled() && forceFortunePickaxe }.group(*baseGroup, Group.General).index() + @Group(GENERAL_GROUP) override val efficientOnly by c.setting("Efficient Tools Only", true, "Only use tools suitable for the given block (will get the item drop)") { swapMode.isEnabled() } + @Group(GENERAL_GROUP) override val suitableToolsOnly by c.setting("Suitable Tools Only", true, "Only use tools suitable for the given block (will get the item drop)") { swapMode.isEnabled() } + @Group(GENERAL_GROUP) override val forceSilkTouch by c.setting("Force Silk Touch", false, "Force silk touch when breaking blocks") { swapMode.isEnabled() } + @Group(GENERAL_GROUP) override val forceFortunePickaxe by c.setting("Force Fortune Pickaxe", false, "Force fortune pickaxe when breaking blocks") { swapMode.isEnabled() } + @Group(GENERAL_GROUP) override val minFortuneLevel by c.setting("Min Fortune Level", 1, 1..3, 1, "The minimum fortune level to use") { swapMode.isEnabled() && forceFortunePickaxe } // Cosmetics - override val sounds by c.setting("${prefix}Break Sounds", true, "Plays the breaking sounds", visibility = visibility).group(*baseGroup, Group.Cosmetic).index() - override val particles by c.setting("${prefix}Particles", true, "Renders the breaking particles", visibility = visibility).group(*baseGroup, Group.Cosmetic).index() - override val breakingTexture by c.setting("${prefix}Breaking Overlay", true, "Overlays the breaking texture at its different stages", visibility = visibility).group(*baseGroup, Group.Cosmetic).index() - + @Group(COSMETIC_GROUP) override val sounds by c.setting("Break Sounds", true, "Plays the breaking sounds") + @Group(COSMETIC_GROUP) override val particles by c.setting("Particles", true, "Renders the breaking particles") + @Group(COSMETIC_GROUP) override val breakingTexture by c.setting("Breaking Overlay", true, "Overlays the breaking texture at its different stages") // Modes - override val renders by c.setting("${prefix}Renders", true, "Enables the render settings for breaking progress", visibility = visibility).group(*baseGroup, Group.Cosmetic).index() - override val animation by c.setting("${prefix}Animation", AnimationMode.Out, "The style of animation used for the box") { visibility() && renders }.group(*baseGroup, Group.Cosmetic).index() - + @Group(COSMETIC_GROUP) override val renders by c.setting("Renders", true, "Enables the render settings for breaking progress") + @Group(COSMETIC_GROUP) override val animation by c.setting("Animation", AnimationMode.Out, "The style of animation used for the box") { renders } // Fill - override val fill by c.setting("${prefix}Fill", true, "Renders the sides of the box to display break progress") { visibility() && renders }.group(*baseGroup, Group.Cosmetic).index() - override val dynamicFillColor by c.setting("${prefix}Dynamic Colour", true, "Enables fill color interpolation from start to finish for fill when breaking a block") { visibility() && renders && fill }.group(*baseGroup, Group.Cosmetic).index() - override val staticFillColor by c.setting("${prefix}Fill Color", Color(255, 0, 0, 60).brighter(), "The color of the fill") { visibility() && renders && !dynamicFillColor && fill }.group(*baseGroup, Group.Cosmetic).index() - override val startFillColor by c.setting("${prefix}Start Fill Color", Color(255, 0, 0, 60).brighter(), "The color of the fill at the start of breaking") { visibility() && renders && dynamicFillColor && fill }.group(*baseGroup, Group.Cosmetic).index() - override val endFillColor by c.setting("${prefix}End Fill Color", Color(0, 255, 0, 60).brighter(), "The color of the fill at the end of breaking") { visibility() && renders && dynamicFillColor && fill }.group(*baseGroup, Group.Cosmetic).index() - + @Group(COSMETIC_GROUP) override val fill by c.setting("Fill", true, "Renders the sides of the box to display break progress") { renders } + @Group(COSMETIC_GROUP) override val dynamicFillColor by c.setting("Dynamic Colour", true, "Enables fill color interpolation from start to finish for fill when breaking a block") { renders && fill } + @Group(COSMETIC_GROUP) override val staticFillColor by c.setting("Fill Color", Color(255, 0, 0, 60), "The color of the fill") { renders && !dynamicFillColor && fill } + @Group(COSMETIC_GROUP) override val startFillColor by c.setting("Start Fill Color", Color(255, 0, 0, 60), "The color of the fill at the start of breaking") { renders && dynamicFillColor && fill } + @Group(COSMETIC_GROUP) override val endFillColor by c.setting("End Fill Color", Color(0, 255, 0, 60), "The color of the fill at the end of breaking") { renders && dynamicFillColor && fill } // Outline - override val outline by c.setting("${prefix}Outline", true, "Renders the lines of the box to display break progress") { visibility() && renders }.group(*baseGroup, Group.Cosmetic).index() - override val outlineConfig = WorldLineSettings(c, *baseGroup, Group.Cosmetic, prefix = "${prefix}Outline ") { visibility() && outline }.apply { - c.applyEdits { - hide(::startColor, ::endColor) + @Group(COSMETIC_GROUP) override val outline by c.setting("Outline", true, "Renders the lines of the box to display break progress") { renders } + @Group(COSMETIC_GROUP) override val outlineConfig = + c.settingBlock(WorldLineSettings(c)) { + c.applyEdits { + hide(::startColor, ::endColor) + } } - } - override val dynamicOutlineColor by c.setting("${prefix}Dynamic Outline Color", true, "Enables color interpolation from start to finish for the outline when breaking a block") { visibility() && renders && outline }.group(*baseGroup, Group.Cosmetic).index() - override val staticOutlineColor by c.setting("${prefix}Outline Color", Color.RED.brighter(), "The Color of the outline at the start of breaking") { visibility() && renders && !dynamicOutlineColor && outline }.group(*baseGroup, Group.Cosmetic).index() - override val startOutlineColor by c.setting("${prefix}Start Outline Color", Color.RED.brighter(), "The color of the outline at the start of breaking") { visibility() && renders && dynamicOutlineColor && outline }.group(*baseGroup, Group.Cosmetic).index() - override val endOutlineColor by c.setting("${prefix}End Outline Color", Color.GREEN.brighter(), "The color of the outline at the end of breaking") { visibility() && renders && dynamicOutlineColor && outline }.group(*baseGroup, Group.Cosmetic).index() + @Group(COSMETIC_GROUP) override val dynamicOutlineColor by c.setting("Dynamic Outline Color", true, "Enables color interpolation from start to finish for the outline when breaking a block") { renders && outline } + @Group(COSMETIC_GROUP) override val staticOutlineColor by c.setting("Outline Color", Color.RED, "The Color of the outline at the start of breaking") { renders && !dynamicOutlineColor && outline } + @Group(COSMETIC_GROUP) override val startOutlineColor by c.setting("Start Outline Color", Color.RED, "The color of the outline at the start of breaking") { renders && dynamicOutlineColor && outline } + @Group(COSMETIC_GROUP) override val endOutlineColor by c.setting("End Outline Color", Color.GREEN, "The color of the outline at the end of breaking") { renders && dynamicOutlineColor && outline } } diff --git a/src/main/kotlin/com/lambda/config/groups/BuildConfig.kt b/src/main/kotlin/com/lambda/config/groups/BuildConfig.kt index 8752d08c9..20f339fa7 100644 --- a/src/main/kotlin/com/lambda/config/groups/BuildConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/BuildConfig.kt @@ -17,12 +17,16 @@ package com.lambda.config.groups -import com.lambda.config.ISettingGroup -import com.lambda.interaction.managers.rotating.visibilty.PointSelection +import com.lambda.config.SettingBlock +import com.lambda.interaction.managers.rotating.Rotation.Companion.dist +import com.lambda.interaction.managers.rotating.RotationManager import com.lambda.util.Describable import com.lambda.util.NamedEnum +import com.lambda.util.math.distSq +import com.lambda.util.math.times +import com.lambda.util.player.CheckedHit -interface BuildConfig : ISettingGroup { +interface BuildConfig : SettingBlock { val breakBlocks: Boolean val placeBlocks: Boolean val interactBlocks: Boolean @@ -57,4 +61,33 @@ interface BuildConfig : ISettingGroup { Server("Server", "Only notify the server to swing; local animation may not play unless the server echoes it."), Client("Client", "Only play the local swing animation; does not notify the server (purely visual).") } + + @Suppress("unused") + enum class PointSelection( + override val displayName: String, + override val description: String, + val select: (Collection) -> CheckedHit? + ) : NamedEnum, Describable { + ByRotation( + "By Rotation", + "Choose the point that needs the least rotation from your current view (minimal camera turn).", + select = { hits -> + hits.minByOrNull { RotationManager.activeRotation dist it.rotation } + } + ), + Optimum( + "Optimum", + "Choose the point closest to the average of all candidates (balanced and stable aim).", + select = { hits -> + val optimum = hits + .mapNotNull { it.hit.pos } + .reduceOrNull { acc, pos -> acc.add(pos) } + ?.times(1 / hits.size.toDouble()) + + optimum?.let { center -> + hits.minByOrNull { it.hit.pos?.distSq(center) ?: 0.0 } + } + } + ) + } } diff --git a/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt b/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt index be3d25195..24b83bb24 100644 --- a/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt @@ -18,47 +18,42 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.config.SettingGroup -import com.lambda.interaction.managers.rotating.visibilty.PointSelection -import com.lambda.util.NamedEnum +import com.lambda.config.Config.Group +import com.lambda.config.SettingBlock +import com.lambda.config.groups.BuildConfig.PointSelection import kotlin.math.max -class BuildSettings( - c: Config, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, -) : SettingGroup(c), BuildConfig { - enum class Group(override val displayName: String) : NamedEnum { - General("General"), - PacketLimits("Packet Limits"), - Reach("Reach"), - Scan("Scan") +class BuildSettings(override val c: Config) : BuildConfig { + companion object { + private const val GROUP_GENERAL = "General" + private const val GROUP_PACKET_LIMITS = "Packet Limits" + private const val GROUP_REACH = "Reach" + private const val GROUP_SCAN = "Scan" } - override val breakBlocks by c.setting("${prefix}Break", true, "Break blocks", visibility = visibility).group(*baseGroup, Group.General).index() - override val placeBlocks by c.setting("${prefix}Place", true, "Place blocks", visibility = visibility).group(*baseGroup, Group.General).index() - override val interactBlocks by c.setting("${prefix}Interact", true, "Interact blocks", visibility = visibility).group(*baseGroup, Group.General).index() - - override val pathing by c.setting("${prefix}Pathing", false, "Path to blocks", visibility = visibility).group(*baseGroup, Group.General).index() - override val stayInRange by c.setting("${prefix}Stay In Range", false, "Stay in range of blocks", visibility = visibility).group(*baseGroup, Group.General).index() - override val collectDrops by c.setting("${prefix}Collect All Drops", false, "Collect all drops when breaking blocks", visibility = visibility).group(*baseGroup, Group.General).index() - override val spleefEntities by c.setting("${prefix}Spleef Entities", false, "Breaks blocks beneath entities blocking placements to get them out of the way", visibility = visibility).group(*baseGroup, Group.General).index() - override val maxPendingActions by c.setting("${prefix}Max Pending Actions", 15, 1..30, 1, "The maximum count of pending interactions to allow before pausing future interactions", visibility = visibility).group(*baseGroup, Group.General).index() - override val actionTimeout by c.setting("${prefix}Action Timeout", 10, 1..30, 1, "Timeout for block breaks in ticks", unit = " ticks", visibility = visibility).group(*baseGroup, Group.General).index() - override val maxBuildDependencies by c.setting("${prefix}Max Sim Dependencies", 3, 0..10, 1, "Maximum dependency build results", visibility = visibility).group(*baseGroup, Group.General).index() - - override val limitTimeframe by c.setting("${prefix}Limit Timeframe", 310, 50..1500, 1, "The timeframe in which the limit is bound to", "ms", visibility = visibility).group(*baseGroup, Group.PacketLimits).index() - override val actionLimit by c.setting("${prefix}Action Limit", 59, 1..100, 1, "The maximum allowed action packets to be sent to the server per given timeframe", visibility = visibility).group(*baseGroup, Group.PacketLimits).index() - override val interactionLimit by c.setting("${prefix}Interaction Limit", 9, 1..20, 1, "The maximum allowed interaction packets to be sent to the server per given timeframe", visibility = visibility).group(*baseGroup, Group.PacketLimits).index() - override val inventoryLimit by c.setting("${prefix}Inventory Limit", 5, 1..100, 1, "The maximum allowed inventory packets to be sent to the server per given timeframe", visibility = visibility).group(*baseGroup, Group.PacketLimits).index() - - override var blockReach by c.setting("${prefix}Interact Reach", 4.5, 1.0..7.0, 0.01, "Maximum block interaction distance", visibility = visibility).group(*baseGroup, Group.Reach).index() - override var entityReach by c.setting("${prefix}Attack Reach", 3.0, 1.0..7.0, 0.01, "Maximum entity interaction distance", visibility = visibility).group(*baseGroup, Group.Reach).index() + @Group(GROUP_GENERAL) override val breakBlocks by c.setting("Break", true, "Break blocks") + @Group(GROUP_GENERAL) override val placeBlocks by c.setting("Place", true, "Place blocks") + @Group(GROUP_GENERAL) override val interactBlocks by c.setting("Interact", true, "Interact blocks") + + @Group(GROUP_GENERAL) override val pathing by c.setting("Pathing", false, "Path to blocks") + @Group(GROUP_GENERAL) override val stayInRange by c.setting("Stay In Range", false, "Stay in range of blocks") + @Group(GROUP_GENERAL) override val collectDrops by c.setting("Collect All Drops", false, "Collect all drops when breaking blocks") + @Group(GROUP_GENERAL) override val spleefEntities by c.setting("Spleef Entities", false, "Breaks blocks beneath entities blocking placements to get them out of the way") + @Group(GROUP_GENERAL) override val maxPendingActions by c.setting("Max Pending Actions", 15, 1..30, 1, "The maximum count of pending interactions to allow before pausing future interactions") + @Group(GROUP_GENERAL) override val actionTimeout by c.setting("Action Timeout", 10, 1..30, 1, "Timeout for block breaks in ticks", unit = " ticks") + @Group(GROUP_GENERAL) override val maxBuildDependencies by c.setting("Max Sim Dependencies", 3, 0..10, 1, "Maximum dependency build results") + + @Group(GROUP_PACKET_LIMITS) override val limitTimeframe by c.setting("Limit Timeframe", 310, 50..1500, 1, "The timeframe in which the limit is bound to", "ms") + @Group(GROUP_PACKET_LIMITS) override val actionLimit by c.setting("Action Limit", 59, 1..100, 1, "The maximum allowed action packets to be sent to the server per given timeframe") + @Group(GROUP_PACKET_LIMITS) override val interactionLimit by c.setting("Interaction Limit", 9, 1..20, 1, "The maximum allowed interaction packets to be sent to the server per given timeframe") + @Group(GROUP_PACKET_LIMITS) override val inventoryLimit by c.setting("Inventory Limit", 5, 1..100, 1, "The maximum allowed inventory packets to be sent to the server per given timeframe") + + @Group(GROUP_REACH) override var blockReach by c.setting("Interact Reach", 4.5, 1.0..7.0, 0.01, "Maximum block interaction distance") + @Group(GROUP_REACH) override var entityReach by c.setting("Attack Reach", 3.0, 1.0..7.0, 0.01, "Maximum entity interaction distance") override val scanReach: Double get() = max(entityReach, blockReach) - override val checkSideVisibility by c.setting("${prefix}Visibility Check", false, "Whether to check if an AABB side is visible", visibility = visibility).group(*baseGroup, Group.Scan).index() - override val strictRayCast by c.setting("${prefix}Strict Raycast", false, "Whether to include the environment to the ray cast context", visibility = visibility).group(*baseGroup, Group.Scan).index() - override val resolution by c.setting("${prefix}Resolution", 5, 1..20, 1, "The amount of grid divisions per surface of the hit box", "") { visibility() && strictRayCast }.group(*baseGroup, Group.Scan).index() - override val pointSelection by c.setting("${prefix}Point Selection", PointSelection.Optimum, "The strategy to select the best hit point", visibility = visibility).group(*baseGroup, Group.Scan).index() + @Group(GROUP_SCAN) override val checkSideVisibility by c.setting("Visibility Check", false, "Whether to check if an AABB side is visible") + @Group(GROUP_SCAN) override val strictRayCast by c.setting("Strict Raycast", false, "Whether to include the environment to the ray cast context") + @Group(GROUP_SCAN) override val resolution by c.setting("Resolution", 5, 1..20, 1, "The amount of grid divisions per surface of the hit box", "") { strictRayCast } + @Group(GROUP_SCAN) override val pointSelection by c.setting("Point Selection", PointSelection.Optimum, "The strategy to select the best hit point") } diff --git a/src/main/kotlin/com/lambda/config/groups/EatConfig.kt b/src/main/kotlin/com/lambda/config/groups/EatConfig.kt index 31e4ba5b0..d2f24a8af 100644 --- a/src/main/kotlin/com/lambda/config/groups/EatConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/EatConfig.kt @@ -17,7 +17,7 @@ package com.lambda.config.groups -import com.lambda.config.ISettingGroup +import com.lambda.config.SettingBlock import com.lambda.context.Automated import com.lambda.context.AutomatedSafeContext import com.lambda.interaction.material.StackSelection.Companion.selectStack @@ -29,7 +29,7 @@ import net.minecraft.entity.effect.StatusEffects import net.minecraft.item.Item import net.minecraft.item.ItemStack -interface EatConfig : ISettingGroup { +interface EatConfig : SettingBlock { val eatOnHunger: Boolean val minFoodLevel: Int val nutritiousFood: Collection @@ -54,6 +54,7 @@ interface EatConfig : ISettingGroup { EatUntilFull("Eat Until Full", "Eats food until the hunger bar is completely full. May waste some food."), } + @Suppress("unused") enum class SelectionPriority( val comparator: Comparator, override val displayName: String, diff --git a/src/main/kotlin/com/lambda/config/groups/EatSettings.kt b/src/main/kotlin/com/lambda/config/groups/EatSettings.kt index b2de049f7..c4b388b9e 100644 --- a/src/main/kotlin/com/lambda/config/groups/EatSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/EatSettings.kt @@ -18,31 +18,26 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.config.SettingGroup +import com.lambda.config.SettingBlock import com.lambda.util.NamedEnum import net.minecraft.item.Items -class EatSettings( - c: Config, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, -) : SettingGroup(c), EatConfig { +class EatSettings(override val c: Config) : SettingBlock, EatConfig { val nutritiousFoodDefaults = listOf(Items.APPLE, Items.BAKED_POTATO, Items.BEEF, Items.BEETROOT, Items.BEETROOT_SOUP, Items.BREAD, Items.CARROT, Items.CHICKEN, Items.CHORUS_FRUIT, Items.COD, Items.COOKED_BEEF, Items.COOKED_CHICKEN, Items.COOKED_COD, Items.COOKED_MUTTON, Items.COOKED_PORKCHOP, Items.COOKED_RABBIT, Items.COOKED_SALMON, Items.COOKIE, Items.DRIED_KELP, Items.ENCHANTED_GOLDEN_APPLE, Items.GOLDEN_APPLE, Items.GOLDEN_CARROT, Items.HONEY_BOTTLE, Items.MELON_SLICE, Items.MUSHROOM_STEW, Items.MUTTON, Items.POISONOUS_POTATO, Items.PORKCHOP, Items.POTATO, Items.PUFFERFISH, Items.PUMPKIN_PIE, Items.RABBIT, Items.RABBIT_STEW, Items.ROTTEN_FLESH, Items.SALMON, Items.SPIDER_EYE, Items.SUSPICIOUS_STEW, Items.SWEET_BERRIES, Items.GLOW_BERRIES, Items.TROPICAL_FISH) val resistanceFoodDefaults = listOf(Items.ENCHANTED_GOLDEN_APPLE) val regenerationFoodDefaults = listOf(Items.ENCHANTED_GOLDEN_APPLE, Items.GOLDEN_APPLE) val negativeFoodDefaults = listOf(Items.CHICKEN, Items.POISONOUS_POTATO, Items.PUFFERFISH, Items.ROTTEN_FLESH, Items.SPIDER_EYE) - override val eatOnHunger by c.setting("${prefix}Eat On Hunger", true, "Whether to eat when hungry", visibility = visibility).group(*baseGroup).index() - override val minFoodLevel by c.setting("${prefix}Minimum Food Level", 6, 0..20, 1, "The minimum food level to eat food", " food level") { visibility() && eatOnHunger }.group(*baseGroup).index() - override val saturated by c.setting("${prefix}Saturated", EatConfig.Saturation.EatSmart, "When to stop eating") { visibility() && eatOnHunger }.group(*baseGroup).index() - override val nutritiousFood by c.setting("${prefix}Nutritious Food", nutritiousFoodDefaults, nutritiousFoodDefaults, "Items that are be considered nutritious") { visibility() && eatOnHunger }.group(*baseGroup).index() - override val selectionPriority by c.setting("${prefix}Selection Priority", EatConfig.SelectionPriority.MostNutritious, "The priority for selecting food items") { visibility() && eatOnHunger }.group(*baseGroup).index() - override val eatOnFire by c.setting("${prefix}Eat On Fire", true, "Whether to eat when on fire", visibility = visibility).group(*baseGroup).index() - override val resistanceFood by c.setting("${prefix}Resistance Food", resistanceFoodDefaults, resistanceFoodDefaults, "Items that give Fire Resistance") { visibility() && eatOnFire }.group(*baseGroup).index() - override val eatOnDamage by c.setting("${prefix}Eat On Damage", true, "Whether to eat when damaged", visibility = visibility).group(*baseGroup).index() - override val minDamage by c.setting("${prefix}Minimum Damage", 10, 0..20, 1, "The minimum damage threshold to trigger eating") { visibility() && eatOnDamage }.group(*baseGroup).index() - override val regenerationFood by c.setting("${prefix}Regeneration Food", regenerationFoodDefaults, regenerationFoodDefaults, "Items that give Regeneration") { visibility() && eatOnDamage }.group(*baseGroup).index() - override val ignoreBadFood by c.setting("${prefix}Ignore Bad Food", true, "Whether to eat when the food is bad", visibility = visibility).group(*baseGroup).index() - override val badFood by c.setting("${prefix}Bad Food", negativeFoodDefaults, negativeFoodDefaults, "Items that are considered bad food") { visibility() && ignoreBadFood }.group(*baseGroup).index() -} \ No newline at end of file + override val eatOnHunger by c.setting("Eat On Hunger", true, "Whether to eat when hungry") + override val minFoodLevel by c.setting("Minimum Food Level", 6, 0..20, 1, "The minimum food level to eat food", " food level") { eatOnHunger } + override val saturated by c.setting("Saturated", EatConfig.Saturation.EatSmart, "When to stop eating") { eatOnHunger } + override val nutritiousFood by c.setting("Nutritious Food", nutritiousFoodDefaults, nutritiousFoodDefaults, "Items that are be considered nutritious") { eatOnHunger } + override val selectionPriority by c.setting("Selection Priority", EatConfig.SelectionPriority.MostNutritious, "The priority for selecting food items") { eatOnHunger } + override val eatOnFire by c.setting("Eat On Fire", true, "Whether to eat when on fire") + override val resistanceFood by c.setting("Resistance Food", resistanceFoodDefaults, resistanceFoodDefaults, "Items that give Fire Resistance") { eatOnFire } + override val eatOnDamage by c.setting("Eat On Damage", true, "Whether to eat when damaged") + override val minDamage by c.setting("Minimum Damage", 10, 0..20, 1, "The minimum damage threshold to trigger eating") { eatOnDamage } + override val regenerationFood by c.setting("Regeneration Food", regenerationFoodDefaults, regenerationFoodDefaults, "Items that give Regeneration") { eatOnDamage } + override val ignoreBadFood by c.setting("Ignore Bad Food", true, "Whether to eat when the food is bad") + override val badFood by c.setting("Bad Food", negativeFoodDefaults, negativeFoodDefaults, "Items that are considered bad food") { ignoreBadFood } +} diff --git a/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt b/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt index 6549593dd..c62c87997 100644 --- a/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt @@ -18,7 +18,7 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.config.SettingGroup +import com.lambda.config.SettingBlock import com.lambda.context.SafeContext import com.lambda.friend.FriendHandler.isFriend import com.lambda.util.EntityUtils @@ -33,27 +33,22 @@ import net.minecraft.client.network.OtherClientPlayerEntity import net.minecraft.entity.Entity import java.awt.Color -class EntityColorSettings( - c: Config, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, -) : EntityColorsConfig, SettingGroup(c) { - override val useNaturalColors by c.setting("${prefix}Use Natural Colors", false, "Uses an average color from the entities texture").group(*baseGroup).index() - override val playerColor by c.setting("${prefix}Player Color", Color(255, 50, 50)) { !useNaturalColors }.group(*baseGroup).index() - override val playerDistanceGradient by c.setting("${prefix}Player Distance Gradient", true).group(*baseGroup).index() - override val playerDistanceColorFar by c.setting("${prefix}Player Far Color", Color.GREEN) { playerDistanceGradient }.group(*baseGroup).index() - override val playerDistanceColorClose by c.setting("${prefix}Player Close Color", Color.RED) { playerDistanceGradient }.group(*baseGroup).index() - override val separateFriendColor by c.setting("${prefix}Separate Friend Color", true) { useNaturalColors }.group(*baseGroup).index() - override val friendColor by c.setting("${prefix}Friend Color", Color(0, 255, 255)) { !useNaturalColors || separateFriendColor }.group(*baseGroup).index() - override val mobColor by c.setting("${prefix}Mob Color", Color(255, 70, 50)) { !useNaturalColors }.group(*baseGroup).index() - override val passiveColor by c.setting("${prefix}Passive Color", Color(0, 255, 0)) { !useNaturalColors }.group(*baseGroup).index() - override val vehicleColor by c.setting("${prefix}Vehicle Color", Color(200, 150, 100)) { !useNaturalColors }.group(*baseGroup).index() - override val projectileColor by c.setting("${prefix}Projectile Color", Color(200, 200, 200)) { !useNaturalColors }.group(*baseGroup).index() - override val bossColor by c.setting("${prefix}Boss Color", Color(255, 100, 0)) { !useNaturalColors }.group(*baseGroup).index() - override val decorationColor by c.setting("${prefix}Decoration Color", Color(100, 100, 255)) { !useNaturalColors }.group(*baseGroup).index() - override val blockColor by c.setting("${prefix}Block Color", Color(200, 200, 200)) { !useNaturalColors }.group(*baseGroup).index() - override val miscColor by c.setting("${prefix}Misc Color", Color(255, 0, 255)) { !useNaturalColors }.group(*baseGroup).index() +class EntityColorSettings(override val c: Config) : SettingBlock, EntityColorsConfig { + override val useNaturalColors by c.setting("Use Natural Colors", false, "Uses an average color from the entities texture") + override val playerColor by c.setting("Player Color", Color(255, 50, 50)) { !useNaturalColors } + override val playerDistanceGradient by c.setting("Player Distance Gradient", true) + override val playerDistanceColorFar by c.setting("Player Far Color", Color.GREEN) { playerDistanceGradient } + override val playerDistanceColorClose by c.setting("Player Close Color", Color.RED) { playerDistanceGradient } + override val separateFriendColor by c.setting("Separate Friend Color", true) { useNaturalColors } + override val friendColor by c.setting("Friend Color", Color(0, 255, 255)) { !useNaturalColors || separateFriendColor } + override val mobColor by c.setting("Mob Color", Color(255, 70, 50)) { !useNaturalColors } + override val passiveColor by c.setting("Passive Color", Color(0, 255, 0)) { !useNaturalColors } + override val vehicleColor by c.setting("Vehicle Color", Color(200, 150, 100)) { !useNaturalColors } + override val projectileColor by c.setting("Projectile Color", Color(200, 200, 200)) { !useNaturalColors } + override val bossColor by c.setting("Boss Color", Color(255, 100, 0)) { !useNaturalColors } + override val decorationColor by c.setting("Decoration Color", Color(100, 100, 255)) { !useNaturalColors } + override val blockColor by c.setting("Block Color", Color(200, 200, 200)) { !useNaturalColors } + override val miscColor by c.setting("Misc Color", Color(255, 0, 255)) { !useNaturalColors } context(safeContext: SafeContext) fun getColor(entity: Entity): Color { diff --git a/src/main/kotlin/com/lambda/config/groups/EntityColorsConfig.kt b/src/main/kotlin/com/lambda/config/groups/EntityColorsConfig.kt index 02f2a9117..e118fe311 100644 --- a/src/main/kotlin/com/lambda/config/groups/EntityColorsConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/EntityColorsConfig.kt @@ -17,9 +17,10 @@ package com.lambda.config.groups +import com.lambda.config.SettingBlock import java.awt.Color -interface EntityColorsConfig { +interface EntityColorsConfig : SettingBlock { val useNaturalColors: Boolean val playerColor: Color val playerDistanceGradient: Boolean diff --git a/src/main/kotlin/com/lambda/config/groups/EntitySelectionConfig.kt b/src/main/kotlin/com/lambda/config/groups/EntitySelectionConfig.kt index 44b3d6182..bd13bc653 100644 --- a/src/main/kotlin/com/lambda/config/groups/EntitySelectionConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/EntitySelectionConfig.kt @@ -17,7 +17,9 @@ package com.lambda.config.groups -interface EntitySelectionConfig { +import com.lambda.config.SettingBlock + +interface EntitySelectionConfig : SettingBlock { val self: Boolean val enablePlayerEntities: Boolean val playerEntities: Collection diff --git a/src/main/kotlin/com/lambda/config/groups/EntitySelectionSettings.kt b/src/main/kotlin/com/lambda/config/groups/EntitySelectionSettings.kt index 2efd3b913..804498a6f 100644 --- a/src/main/kotlin/com/lambda/config/groups/EntitySelectionSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/EntitySelectionSettings.kt @@ -19,7 +19,7 @@ package com.lambda.config.groups import com.lambda.Lambda.mc import com.lambda.config.Config -import com.lambda.config.SettingGroup +import com.lambda.config.SettingBlock import com.lambda.util.EntityUtils.blockEntityMap import com.lambda.util.EntityUtils.bossEntityMap import com.lambda.util.EntityUtils.decorationEntityMap @@ -34,31 +34,26 @@ import net.minecraft.block.entity.BlockEntity import net.minecraft.entity.Entity import net.minecraft.entity.SpawnGroup -class EntitySelectionSettings( - c: Config, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, -) : EntitySelectionConfig, SettingGroup(c) { - override val self by c.setting("${prefix}Self", false, "Render own player in third person").group(*baseGroup).index() - override val enablePlayerEntities by c.setting("${prefix}Enable Player Entities", true).group(*baseGroup).index() - override val playerEntities by c.setting("${prefix}Player Entities", playerEntityMap.values.toSet(), playerEntityMap.values.toSet(), "Player entities to omit from rendering") { enablePlayerEntities }.group(*baseGroup).index() - override val enableMobEntities by c.setting("${prefix}Enable Mob Entities", true).group(*baseGroup).index() - override val mobEntities by c.setting("${prefix}Mob Entities", mobEntityMap.values.toSet(), mobEntityMap.values.toSet(), "Mob entities to omit from rendering") { enableMobEntities }.group(*baseGroup).index() - override val enablePassiveEntities by c.setting("${prefix}Enable Passive Entities", true).group(*baseGroup).index() - override val passiveEntities by c.setting("${prefix}Passive Entities", emptySet(), passiveEntityMap.values.toSet(), "Passive entities to omit from rendering") { enablePassiveEntities }.group(*baseGroup).index() - override val enableVehicleEntities by c.setting("${prefix}Enable Vehicle Entities", true).group(*baseGroup).index() - override val vehicleEntities by c.setting("${prefix}Vehicle Entities", emptySet(), vehicleEntityMap.values.toSet(), "Vehicle entities to omit from rendering") { enableVehicleEntities }.group(*baseGroup).index() - override val enableProjectileEntities by c.setting("${prefix}Enable Projectile Entities", true).group(*baseGroup).index() - override val projectileEntities by c.setting("${prefix}Projectile Entities", emptySet(), projectileEntityMap.values.toSet(), "Projectile entities to omit from rendering") { enableProjectileEntities }.group(*baseGroup).index() - override val enableBossEntities by c.setting("${prefix}Enable Boss Entities", true).group(*baseGroup).index() - override val bossEntities by c.setting("${prefix}Boss Entities", bossEntityMap.values.toSet(), bossEntityMap.values.toSet(), "Boss entities to omit from rendering") { enableBossEntities }.group(*baseGroup).index() - override val enableDecorationEntities by c.setting("${prefix}Enable Decoration Entities", true).group(*baseGroup).index() - override val decorationEntities by c.setting("${prefix}Decoration Entities", emptySet(), decorationEntityMap.values.toSet(), "Decoration entities to omit from rendering") { enableDecorationEntities }.group(*baseGroup).index() - override val enableBlockEntities by c.setting("${prefix}Enable Block Entities", true).group(*baseGroup).index() - override val blockEntities by c.setting("${prefix}Block Entities", emptySet(), blockEntityMap.values.toSet(), "Block entities to omit from rendering") { enableBlockEntities }.group(*baseGroup).index() - override val enableMiscEntities by c.setting("${prefix}Enable Misc Entities", true).group(*baseGroup).index() - override val miscEntities by c.setting("${prefix}Misc Entities", emptySet(), miscEntityMap.values.toSet(), "Miscellaneous entities to omit from rendering") { enableMiscEntities }.group(*baseGroup).index() +class EntitySelectionSettings(override val c: Config) : SettingBlock, EntitySelectionConfig { + override val self by c.setting("Self", false, "Render own player in third person") + override val enablePlayerEntities by c.setting("Enable Player Entities", true) + override val playerEntities by c.setting("Player Entities", playerEntityMap.values.toSet(), playerEntityMap.values.toSet(), "Player entities to omit from rendering") { enablePlayerEntities } + override val enableMobEntities by c.setting("Enable Mob Entities", true) + override val mobEntities by c.setting("Mob Entities", mobEntityMap.values.toSet(), mobEntityMap.values.toSet(), "Mob entities to omit from rendering") { enableMobEntities } + override val enablePassiveEntities by c.setting("Enable Passive Entities", true) + override val passiveEntities by c.setting("Passive Entities", emptySet(), passiveEntityMap.values.toSet(), "Passive entities to omit from rendering") { enablePassiveEntities } + override val enableVehicleEntities by c.setting("Enable Vehicle Entities", true) + override val vehicleEntities by c.setting("Vehicle Entities", emptySet(), vehicleEntityMap.values.toSet(), "Vehicle entities to omit from rendering") { enableVehicleEntities } + override val enableProjectileEntities by c.setting("Enable Projectile Entities", true) + override val projectileEntities by c.setting("Projectile Entities", emptySet(), projectileEntityMap.values.toSet(), "Projectile entities to omit from rendering") { enableProjectileEntities } + override val enableBossEntities by c.setting("Enable Boss Entities", true) + override val bossEntities by c.setting("Boss Entities", bossEntityMap.values.toSet(), bossEntityMap.values.toSet(), "Boss entities to omit from rendering") { enableBossEntities } + override val enableDecorationEntities by c.setting("Enable Decoration Entities", true) + override val decorationEntities by c.setting("Decoration Entities", emptySet(), decorationEntityMap.values.toSet(), "Decoration entities to omit from rendering") { enableDecorationEntities } + override val enableBlockEntities by c.setting("Enable Block Entities", true) + override val blockEntities by c.setting("Block Entities", emptySet(), blockEntityMap.values.toSet(), "Block entities to omit from rendering") { enableBlockEntities } + override val enableMiscEntities by c.setting("Enable Misc Entities", true) + override val miscEntities by c.setting("Misc Entities", emptySet(), miscEntityMap.values.toSet(), "Miscellaneous entities to omit from rendering") { enableMiscEntities } fun isSelected(entity: Entity): Boolean { val name = entity::class.simpleName diff --git a/src/main/kotlin/com/lambda/config/groups/FormatterConfig.kt b/src/main/kotlin/com/lambda/config/groups/FormatterConfig.kt index 28b093309..a82266907 100644 --- a/src/main/kotlin/com/lambda/config/groups/FormatterConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/FormatterConfig.kt @@ -17,13 +17,14 @@ package com.lambda.config.groups -import com.lambda.config.ISettingGroup +import com.lambda.config.SettingBlock import com.lambda.util.Describable import com.lambda.util.NamedEnum import java.time.format.DateTimeFormatter import java.util.* -interface FormatterConfig : ISettingGroup { +@Suppress("unused") +interface FormatterConfig : SettingBlock { val locale: Locale val separator: String val prefix: String diff --git a/src/main/kotlin/com/lambda/config/groups/FormatterSettings.kt b/src/main/kotlin/com/lambda/config/groups/FormatterSettings.kt index 902a239a9..d374f05b4 100644 --- a/src/main/kotlin/com/lambda/config/groups/FormatterSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/FormatterSettings.kt @@ -18,29 +18,24 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.config.SettingGroup +import com.lambda.config.SettingBlock import com.lambda.util.NamedEnum -class FormatterSettings( - c: Config, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, -) : FormatterConfig, SettingGroup(c) { - val localeEnum by c.setting("${prefix}Locale", FormatterConfig.Locales.US, "The regional formatting used for numbers", visibility = visibility).group(*baseGroup).index() +class FormatterSettings(override val c: Config) : SettingBlock, FormatterConfig { + val localeEnum by c.setting("Locale", FormatterConfig.Locales.US, "The regional formatting used for numbers") override val locale get() = localeEnum.locale - val sep by c.setting("${prefix}Separator", FormatterConfig.TupleSeparator.Comma, "Separator for string serialization of tuple data structures", visibility = visibility).group(*baseGroup).index() - val customSep by c.setting("${prefix}Custom Separator", "") { visibility() && sep == FormatterConfig.TupleSeparator.Custom }.group(*baseGroup).index() + val sep by c.setting("Separator", FormatterConfig.TupleSeparator.Comma, "Separator for string serialization of tuple data structures") + val customSep by c.setting("Custom Separator", "") { sep == FormatterConfig.TupleSeparator.Custom } override val separator get() = if (sep == FormatterConfig.TupleSeparator.Custom) customSep else sep.separator - val group by c.setting("${prefix}Tuple Prefix", FormatterConfig.TupleGrouping.Parentheses, visibility = visibility).group(*baseGroup).index() - override val prefix get() = group.prefix - override val postfix get() = group.postfix + val tupleGroup by c.setting("Tuple Prefix", FormatterConfig.TupleGrouping.Parentheses) + override val prefix get() = tupleGroup.prefix + override val postfix get() = tupleGroup.postfix - val floatingPrecision by c.setting("${prefix}Floating Precision", 3, 0..6, 1, "Precision for floating point numbers", visibility = visibility).group(*baseGroup).index() + val floatingPrecision by c.setting("Floating Precision", 3, 0..6, 1, "Precision for floating point numbers") override val precision get() = floatingPrecision - val timeFormat by c.setting("${prefix}Time Format", FormatterConfig.Time.IsoDateTime, visibility = visibility).group(*baseGroup).index() + val timeFormat by c.setting("Time Format", FormatterConfig.Time.IsoDateTime) override val format get() = timeFormat.format } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/groups/HotbarConfig.kt b/src/main/kotlin/com/lambda/config/groups/HotbarConfig.kt index 8d6c1974a..a45c00851 100644 --- a/src/main/kotlin/com/lambda/config/groups/HotbarConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/HotbarConfig.kt @@ -17,7 +17,7 @@ package com.lambda.config.groups -import com.lambda.config.ISettingGroup +import com.lambda.config.SettingBlock import com.lambda.event.events.TickEvent /** @@ -25,7 +25,7 @@ import com.lambda.event.events.TickEvent * * @param priority The priority of this configuration. */ -interface HotbarConfig : ISettingGroup { +interface HotbarConfig : SettingBlock { val swapMode: SwapMode /** * The number of ticks to keep the current hotbar selection active. diff --git a/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt b/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt index e9a10df8f..9f5185d88 100644 --- a/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt @@ -18,22 +18,16 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.config.SettingGroup +import com.lambda.config.SettingBlock import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.config.groups.HotbarConfig import com.lambda.util.NamedEnum -class HotbarSettings( - c: Config, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, -) : SettingGroup(c), HotbarConfig { - override val swapMode by c.setting("${prefix}Swap Mode", HotbarConfig.SwapMode.Temporary, visibility = visibility).group(*baseGroup).index() - override val keepTicks by c.setting("${prefix}Keep Ticks", 1, 0..20, 1, "The number of ticks to keep the current hotbar selection active", " ticks") { visibility() && swapMode == HotbarConfig.SwapMode.Temporary }.group(*baseGroup).index() - override val swapDelay by c.setting("${prefix}Swap Delay", 0, 0..3, 1, "The number of ticks delay before allowing another hotbar selection swap", " ticks", visibility = visibility).group(*baseGroup).index() - override val swapsPerTick by c.setting("${prefix}Swaps Per Tick", 3, 1..10, 1, "The number of hotbar selection swaps that can take place each tick") { visibility() && swapDelay <= 0 }.group(*baseGroup).index() - override val swapPause by c.setting("${prefix}Swap Pause", 0, 0..20, 1, "The delay in ticks to pause actions after switching to the slot", " ticks", visibility = visibility).group(*baseGroup).index() - override val tickStageMask by c.setting("${prefix}Hotbar Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), "The sub-tick timing at which hotbar actions are performed", displayClassName = true, visibility = visibility).group(*baseGroup).index() +class HotbarSettings(override val c: Config) : SettingBlock, HotbarConfig { + override val swapMode by c.setting("Swap Mode", HotbarConfig.SwapMode.Temporary) + override val keepTicks by c.setting("Keep Ticks", 1, 0..20, 1, "The number of ticks to keep the current hotbar selection active", " ticks") { swapMode == HotbarConfig.SwapMode.Temporary } + override val swapDelay by c.setting("Swap Delay", 0, 0..3, 1, "The number of ticks delay before allowing another hotbar selection swap", " ticks") + override val swapsPerTick by c.setting("Swaps Per Tick", 3, 1..10, 1, "The number of hotbar selection swaps that can take place each tick") { swapDelay <= 0 } + override val swapPause by c.setting("Swap Pause", 0, 0..20, 1, "The delay in ticks to pause actions after switching to the slot", " ticks") + override val tickStageMask by c.setting("Hotbar Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), "The sub-tick timing at which hotbar actions are performed", displayClassName = true) } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/groups/InteractConfig.kt b/src/main/kotlin/com/lambda/config/groups/InteractConfig.kt index 39cc3c13b..1f6359b6b 100644 --- a/src/main/kotlin/com/lambda/config/groups/InteractConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/InteractConfig.kt @@ -17,7 +17,10 @@ package com.lambda.config.groups -interface InteractConfig : ActionConfig, com.lambda.config.ISettingGroup { +import com.lambda.util.Describable +import com.lambda.util.NamedEnum + +interface InteractConfig : ActionConfig { val rotate: Boolean val airPlace: AirPlaceMode val axisRotateSetting: Boolean @@ -29,10 +32,11 @@ interface InteractConfig : ActionConfig, com.lambda.config.ISettingGroup { val swingType: BuildConfig.SwingType val sounds: Boolean + @Suppress("unused") enum class AirPlaceMode( override val displayName: String, override val description: String - ) : com.lambda.util.NamedEnum, com.lambda.util.Describable { + ) : NamedEnum, Describable { None("None", "Do not attempt air placements; only place against valid supports."), Standard("Standard", "Try common air-place techniques for convenience; moderate compatibility."), Grim("Grim", "Use grim specific air placing."); @@ -43,7 +47,7 @@ interface InteractConfig : ActionConfig, com.lambda.config.ISettingGroup { enum class InteractConfirmationMode( override val displayName: String, override val description: String - ) : com.lambda.util.NamedEnum, com.lambda.util.Describable { + ) : NamedEnum, Describable { None("No confirmation", "Interact immediately without waiting for the server; possible desync."), PlaceThenAwait("Interact now, confirm later", "Interact immediately, then wait for server confirmation to verify."), AwaitThenPlace("Confirm first, then Interact", "Wait for server response before interacting; safest, adds a short delay.") diff --git a/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt b/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt index dfd809542..fadff3149 100644 --- a/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt @@ -18,29 +18,21 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.config.SettingGroup import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.config.groups.InteractConfig import com.lambda.config.groups.InteractConfig.AirPlaceMode import com.lambda.config.groups.InteractConfig.InteractConfirmationMode -import com.lambda.util.NamedEnum -class InteractSettings( - c: Config, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, -) : SettingGroup(c), InteractConfig { - override val rotate by c.setting("${prefix}Rotate For Interact", true, "Rotate towards block while placing", visibility = visibility).group(*baseGroup).index() - override val airPlace by c.setting("${prefix}Air Place", AirPlaceMode.Grim, "Allows for placing blocks without adjacent faces", visibility = visibility).group(*baseGroup).index() - override val axisRotateSetting by c.setting("${prefix}Axis Rotate", true, "Overrides the Rotate For Place setting and rotates the player on each axis to air place rotational blocks") { visibility() && airPlace.isEnabled }.group(*baseGroup).index() - override val sorter by c.setting("${prefix}Interaction Sorter", ActionConfig.SortMode.Tool, "The order in which placements are performed", visibility = visibility).group(*baseGroup).index() - override val tickStageMask by c.setting("${prefix}Interaction Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), "The sub-tick timing at which place actions are performed", displayClassName = true, visibility = visibility).group(*baseGroup).index() - override val interactConfirmationMode by c.setting("${prefix}Interact Confirmation", InteractConfirmationMode.PlaceThenAwait, "Wait for block placement confirmation", visibility = visibility).group(*baseGroup).index() - override val interactDelay by c.setting("${prefix}Interact Delay", 0, 0..3, 1, "Tick delay between interacting with another block", visibility = visibility).group(*baseGroup).index() - override val interactionsPerTick by c.setting("${prefix}Interactions Per Tick", 9, 1..30, 1, "Maximum instant block places per tick", visibility = visibility).group(*baseGroup).index() - override val swing by c.setting("${prefix}Swing On Interact", true, "Swings the players hand when placing", visibility = visibility).group(*baseGroup).index() - override val swingType by c.setting("${prefix}Interact Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { visibility() && swing }.group(*baseGroup).index() - override val sounds by c.setting("${prefix}Place Sounds", true, "Plays the placing sounds", visibility = visibility).group(*baseGroup).index() +class InteractSettings(override val c: Config) : InteractConfig { + override val rotate by c.setting("Rotate For Interact", true, "Rotate towards block while placing") + override val airPlace by c.setting("Air Place", AirPlaceMode.Grim, "Allows for placing blocks without adjacent faces") + override val axisRotateSetting by c.setting("Axis Rotate", true, "Overrides the Rotate For Place setting and rotates the player on each axis to air place rotational blocks") { airPlace.isEnabled } + override val sorter by c.setting("Interaction Sorter", ActionConfig.SortMode.Tool, "The order in which placements are performed") + override val tickStageMask by c.setting("Interaction Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), "The sub-tick timing at which place actions are performed", displayClassName = true) + override val interactConfirmationMode by c.setting("Interact Confirmation", InteractConfirmationMode.PlaceThenAwait, "Wait for block placement confirmation") + override val interactDelay by c.setting("Interact Delay", 0, 0..3, 1, "Tick delay between interacting with another block") + override val interactionsPerTick by c.setting("Interactions Per Tick", 9, 1..30, 1, "Maximum instant block places per tick") + override val swing by c.setting("Swing On Interact", true, "Swings the players hand when placing") + override val swingType by c.setting("Interact Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { swing } + override val sounds by c.setting("Place Sounds", true, "Plays the placing sounds") } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/groups/InventoryConfig.kt b/src/main/kotlin/com/lambda/config/groups/InventoryConfig.kt index c33290305..e49c2e2d9 100644 --- a/src/main/kotlin/com/lambda/config/groups/InventoryConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/InventoryConfig.kt @@ -17,7 +17,7 @@ package com.lambda.config.groups -import com.lambda.config.ISettingGroup +import com.lambda.config.SettingBlock import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.interaction.material.ContainerSelection @@ -27,7 +27,7 @@ import com.lambda.util.Describable import com.lambda.util.NamedEnum import net.minecraft.item.Item -interface InventoryConfig : ISettingGroup { +interface InventoryConfig : SettingBlock { val tickStageMask: Collection val disposables: Collection val swapWithDisposables: Boolean diff --git a/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt b/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt index 2f928152e..7806ee7ea 100644 --- a/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt @@ -18,32 +18,27 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.config.SettingGroup +import com.lambda.config.Config.Group +import com.lambda.config.SettingBlock import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.config.groups.InventoryConfig import com.lambda.util.NamedEnum import com.lambda.util.item.ItemUtils -class InventorySettings( - c: Config, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, -) : SettingGroup(c), InventoryConfig { - enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Container("Container"), - Access("Access") +class InventorySettings(override val c: Config) : SettingBlock, InventoryConfig { + companion object { + private const val GROUP_GENERAL = "General" + private const val GROUP_CONTAINER = "Container" + private const val GROUP_ACCESS = "Access" } - override val tickStageMask by c.setting("${prefix}Inventory Stage Mask", ALL_STAGES.toSet(), description = "The sub-tick timing at which inventory actions are performed", displayClassName = true, visibility = visibility).group(*baseGroup, Group.General).index() - override val disposables by c.setting("${prefix}Disposables", ItemUtils.defaultDisposables, description = "Items that will be ignored when checking for a free slot", visibility = visibility).group(*baseGroup, Group.Container).index() - override val swapWithDisposables by c.setting("${prefix}Swap With Disposables", true, "Swap items with disposable ones", visibility = visibility).group(*baseGroup, Group.Container).index() - override val providerPriority by c.setting("${prefix}Provider Priority", InventoryConfig.Priority.WithMinItems, "What container to prefer when retrieving the item from", visibility = visibility).group(*baseGroup, Group.Container).index() - override val storePriority by c.setting("${prefix}Store Priority", InventoryConfig.Priority.WithMinItems, "What container to prefer when storing the item to", visibility = visibility).group(*baseGroup, Group.Container).index() + @Group(GROUP_GENERAL) override val tickStageMask by c.setting("Inventory Stage Mask", ALL_STAGES.toSet(), description = "The sub-tick timing at which inventory actions are performed", displayClassName = true) + @Group(GROUP_CONTAINER) override val disposables by c.setting("Disposables", ItemUtils.defaultDisposables, description = "Items that will be ignored when checking for a free slot") + @Group(GROUP_CONTAINER) override val swapWithDisposables by c.setting("Swap With Disposables", true, "Swap items with disposable ones") + @Group(GROUP_CONTAINER) override val providerPriority by c.setting("Provider Priority", InventoryConfig.Priority.WithMinItems, "What container to prefer when retrieving the item from") + @Group(GROUP_CONTAINER) override val storePriority by c.setting("Store Priority", InventoryConfig.Priority.WithMinItems, "What container to prefer when storing the item to") - override val accessShulkerBoxes by c.setting("${prefix}Access Shulker Boxes", false, "Allow access to the player's shulker boxes", visibility = visibility).group(*baseGroup, Group.Access).index() - override val accessChests by c.setting("${prefix}Access Chests", false, "Allow access to the player's normal chests", visibility = visibility).group(*baseGroup, Group.Access).index() - override val accessEnderChest by c.setting("${prefix}Access Ender Chest", false, "Allow access to the player's ender chest", visibility = visibility).group(*baseGroup, Group.Access).index() - override val accessStashes by c.setting("${prefix}Access Stashes", false, "Allow access to the player's stashes", visibility = visibility).group(*baseGroup, Group.Access).index() + @Group(GROUP_ACCESS) override val accessShulkerBoxes by c.setting("Access Shulker Boxes", false, "Allow access to the player's shulker boxes") + @Group(GROUP_ACCESS) override val accessChests by c.setting("Access Chests", false, "Allow access to the player's normal chests") + @Group(GROUP_ACCESS) override val accessEnderChest by c.setting("Access Ender Chest", false, "Allow access to the player's ender chest") + @Group(GROUP_ACCESS) override val accessStashes by c.setting("Access Stashes", false, "Allow access to the player's stashes") } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/groups/LineConfig.kt b/src/main/kotlin/com/lambda/config/groups/LineConfig.kt index 30f87205a..6f2331446 100644 --- a/src/main/kotlin/com/lambda/config/groups/LineConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/LineConfig.kt @@ -17,10 +17,11 @@ package com.lambda.config.groups +import com.lambda.config.SettingBlock import com.lambda.graphics.mc.LineDashStyle import java.awt.Color -interface LineConfig { +interface LineConfig : SettingBlock { val startColor: Color val endColor: Color val width: Float diff --git a/src/main/kotlin/com/lambda/config/groups/OutlineSettings.kt b/src/main/kotlin/com/lambda/config/groups/OutlineSettings.kt index b4a0ada41..03ec96e19 100644 --- a/src/main/kotlin/com/lambda/config/groups/OutlineSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/OutlineSettings.kt @@ -18,29 +18,24 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.config.SettingGroup +import com.lambda.config.SettingBlock import com.lambda.graphics.outline.OutlineStyle import com.lambda.util.NamedEnum import java.awt.Color -class OutlineSettings( - c: Config, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, -) : SettingGroup(c) { - val thicknessSetting by c.setting("${prefix}Line Width", 25, 1..100, 1, "The width of the outline", visibility = visibility).group(*baseGroup).index() +class OutlineSettings(override val c: Config) : SettingBlock { + val thicknessSetting by c.setting("Line Width", 25, 1..100, 1, "The width of the outline") val thickness get() = thicknessSetting * 0.00005f - val glowIntensitySetting by c.setting("${prefix}Glow Intensity", 50, 0..100, 1, "Intensity of the outline glow", visibility = visibility).group(*baseGroup).index() + val glowIntensitySetting by c.setting("Glow Intensity", 50, 0..100, 1, "Intensity of the outline glow") val glowIntensity get() = glowIntensitySetting * 0.01f - val glowRadiusSetting by c.setting("${prefix}Glow Radius", 20, 0..100, 1, "Radius of the outline glow", visibility = visibility).group(*baseGroup).index() + val glowRadiusSetting by c.setting("Glow Radius", 20, 0..100, 1, "Radius of the outline glow") val glowRadius get() = glowRadiusSetting * 0.00005f - val fill by c.setting("${prefix}Fill", true, "Fill the entity silhouette", visibility = visibility).group(*baseGroup).index() + val fill by c.setting("Fill", true, "Fill the entity silhouette") - val fillOpacitySetting by c.setting("${prefix}Fill Opacity", 10, 0..100, 1, "Opacity of the fill") { visibility() && fill }.group(*baseGroup).index() + val fillOpacitySetting by c.setting("Fill Opacity", 10, 0..100, 1, "Opacity of the fill") { fill } val fillOpacity get() = fillOpacitySetting * 0.01f fun toStyle(color: Color) = OutlineStyle( diff --git a/src/main/kotlin/com/lambda/config/groups/ReplaceConfig.kt b/src/main/kotlin/com/lambda/config/groups/ReplaceConfig.kt index e1aa35969..d35f4851f 100644 --- a/src/main/kotlin/com/lambda/config/groups/ReplaceConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/ReplaceConfig.kt @@ -17,9 +17,10 @@ package com.lambda.config.groups +import com.lambda.config.SettingBlock import com.lambda.util.Describable -interface ReplaceConfig { +interface ReplaceConfig : SettingBlock { val action: ActionStrategy val replace: ReplaceStrategy @@ -32,6 +33,7 @@ interface ReplaceConfig { None("Don't do anything."), } + @Suppress("unused") enum class ReplaceStrategy(val block: (String) -> String) { CensorAll({ it.replaceRange(0.. if (i % 2 == 0) acc + char else "$acc*" } }), diff --git a/src/main/kotlin/com/lambda/config/groups/RotationConfig.kt b/src/main/kotlin/com/lambda/config/groups/RotationConfig.kt index d661abb0d..a37b1da17 100644 --- a/src/main/kotlin/com/lambda/config/groups/RotationConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/RotationConfig.kt @@ -17,21 +17,13 @@ package com.lambda.config.groups -import com.lambda.config.ISettingGroup -import com.lambda.config.Setting +import com.lambda.config.Config +import com.lambda.config.SettingBlock import com.lambda.event.events.TickEvent -import com.lambda.interaction.managers.rotating.Rotation.Companion.dist import com.lambda.interaction.managers.rotating.RotationManager import com.lambda.interaction.managers.rotating.RotationMode -import com.lambda.util.Describable -import com.lambda.util.NamedEnum -import com.lambda.util.math.distSq -import com.lambda.util.math.times -import com.lambda.util.player.CheckedHit -import kotlin.collections.mapNotNull -import kotlin.collections.minByOrNull -interface RotationConfig : ISettingGroup { +interface RotationConfig : SettingBlock { /** * - [RotationMode.Silent] Spoofing server-side rotation. * - [RotationMode.Sync] Spoofing server-side rotation and adjusting client-side movement based on reported rotation (for Grim). @@ -56,41 +48,11 @@ interface RotationConfig : ISettingGroup { val tickStageMask: Set - open class Instant(mode: RotationMode, override val visibility: () -> Boolean = { true }) : RotationConfig { - override val settings = mutableListOf>() + open class Instant(override val c: Config, mode: RotationMode) : RotationConfig { override val rotationMode = mode override val keepTicks = 1 override val decayTicks = 1 override val turnSpeed = 180.0 override val tickStageMask = RotationManager.openStages.toSet() } - - @Suppress("unused") - enum class PointSelection( - override val displayName: String, - override val description: String, - val select: (Collection) -> CheckedHit? - ) : NamedEnum, Describable { - ByRotation( - "By Rotation", - "Choose the point that needs the least rotation from your current view (minimal camera turn).", - select = { hits -> - hits.minByOrNull { RotationManager.activeRotation dist it.rotation } - } - ), - Optimum( - "Optimum", - "Choose the point closest to the average of all candidates (balanced and stable aim).", - select = { hits -> - val optimum = hits - .mapNotNull { it.hit.pos } - .reduceOrNull { acc, pos -> acc.add(pos) } - ?.times(1 / hits.size.toDouble()) - - optimum?.let { center -> - hits.minByOrNull { it.hit.pos?.distSq(center) ?: 0.0 } - } - } - ) - } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/groups/RotationSettings.kt b/src/main/kotlin/com/lambda/config/groups/RotationSettings.kt index b78eea91e..93343813d 100644 --- a/src/main/kotlin/com/lambda/config/groups/RotationSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/RotationSettings.kt @@ -18,12 +18,10 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.config.SettingGroup +import com.lambda.config.SettingBlock import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.config.groups.RotationConfig import com.lambda.interaction.managers.rotating.RotationMode -import com.lambda.util.NamedEnum import kotlin.math.PI import kotlin.math.abs import kotlin.math.cos @@ -31,36 +29,31 @@ import kotlin.math.ln import kotlin.math.sqrt import kotlin.random.Random -class RotationSettings( - c: Config, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, -) : SettingGroup(c), RotationConfig { - override var rotationMode by c.setting("${prefix}Mode", RotationMode.Sync, "How the player is being rotated on interaction", visibility = visibility).group(*baseGroup).index() +class RotationSettings(override val c: Config) : SettingBlock, RotationConfig { + override var rotationMode by c.setting("Mode", RotationMode.Sync, "How the player is being rotated on interaction") /** How many ticks to keep the rotation before resetting */ - override val keepTicks by c.setting("${prefix}Keep Rotation", 1, 1..10, 1, "Ticks to keep rotation", " ticks", visibility = visibility).group(*baseGroup).index() + override val keepTicks by c.setting("Keep Rotation", 1, 1..10, 1, "Ticks to keep rotation", " ticks") /** How many ticks to wait before resetting the rotation */ - override val decayTicks by c.setting("${prefix}Reset Rotation", 1, 1..10, 1, "Ticks before rotation is reset", " ticks", visibility = visibility).group(*baseGroup).index() + override val decayTicks by c.setting("Reset Rotation", 1, 1..10, 1, "Ticks before rotation is reset", " ticks") override val tickStageMask = ALL_STAGES.subList(0, ALL_STAGES.indexOf(TickEvent.Player.Post)).toSet() /** Whether the rotation is instant */ - var instant by c.setting("${prefix}Instant Rotation", true, "Instantly rotate", visibility = visibility).group(*baseGroup).index() + var instant by c.setting("Instant Rotation", true, "Instantly rotate") /** * The mean (average/base) value used to calculate rotation speed. * This value represents the center of the distribution. */ - var mean by c.setting("${prefix}Mean", 40.0, 1.0..120.0, 0.1, "Average rotation speed", unit = "°") { visibility() && !instant }.group(*baseGroup).index() + var mean by c.setting("Mean", 40.0, 1.0..120.0, 0.1, "Average rotation speed", unit = "°") { !instant } /** * The standard deviation for the Gaussian distribution used to calculate rotation speed. * This value represents the spread of rotation speed. */ - var spread by c.setting("${prefix}Spread", 10.0, 0.0..60.0, 0.1, "Spread of rotation speeds", unit = "°") { visibility() && !instant }.group(*baseGroup).index() + var spread by c.setting("Spread", 10.0, 0.0..60.0, 0.1, "Spread of rotation speeds", unit = "°") { !instant } /** * We must always provide turn speed to the interpolator because the player's yaw might exceed the -180 to 180 range. diff --git a/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt b/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt index e80400b85..a0774263c 100644 --- a/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt @@ -18,35 +18,31 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.config.SettingGroup +import com.lambda.config.Config.Group +import com.lambda.config.SettingBlock import com.lambda.util.NamedEnum import java.awt.Color -class ScreenLineSettings( - c: Config, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, -) : SettingGroup(c), LineConfig { - enum class Group(override val displayName: String) : NamedEnum { - Color("Color"), - Dash("Dash") +class ScreenLineSettings(override val c: Config) : SettingBlock, LineConfig { + companion object { + private const val GROUP_COLOR = "Color" + private const val GROUP_DASH = "Dash" } - val widthSetting by c.setting("${prefix}Width", 20, 1..100, 1, "The width of the line", visibility = visibility).group(*baseGroup).index() + val widthSetting by c.setting("Width", 20, 1..100, 1, "The width of the line") override val width get() = widthSetting * 0.00005f - override val startColor by c.setting("${prefix}Start Color", Color.WHITE, "The color at the start of the line", visibility = visibility).group(*baseGroup, Group.Color).index() - override val endColor by c.setting("${prefix}End Color", Color.WHITE, "The color at the end of the line", visibility = visibility).group(*baseGroup, Group.Color).index() + @Group(GROUP_COLOR) override val startColor by c.setting("Start Color", Color.WHITE, "The color at the start of the line") + @Group(GROUP_COLOR) override val endColor by c.setting("End Color", Color.WHITE, "The color at the end of the line") - override val dashEnabled by c.setting("${prefix}Dashed", false, "Enable dashed line pattern", visibility = visibility).group(*baseGroup, Group.Dash).index() - val dashLengthSetting by c.setting("${prefix}Dash Length", 30, 1..50, 1, "Length of each dash") { visibility() && dashEnabled }.group(*baseGroup, Group.Dash).index() + @Group(GROUP_DASH) override val dashEnabled by c.setting("Dashed", false, "Enable dashed line pattern") + @Group(GROUP_DASH) val dashLengthSetting by c.setting("Dash Length", 30, 1..50, 1, "Length of each dash") { dashEnabled } override val dashLength get() = dashLengthSetting * 0.001f - val gapLengthSetting by c.setting("${prefix}Gap Length", 15, 1..50, 1, "Length of gaps between dashes") { visibility() && dashEnabled }.group(*baseGroup, Group.Dash).index() + @Group(GROUP_DASH) val gapLengthSetting by c.setting("Gap Length", 15, 1..50, 1, "Length of gaps between dashes") { dashEnabled } override val gapLength get() = gapLengthSetting * 0.001f - override val animated by c.setting("${prefix}Animated", true, "Animate the dash pattern") { visibility() && dashEnabled }.group(*baseGroup, Group.Dash).index() - val dashOffsetSetting by c.setting("${prefix}Dash Offset", 0, 0..100, 1, "Offset of the dash pattern") { visibility() && dashEnabled && !animated }.group(*baseGroup, Group.Dash).index() + @Group(GROUP_DASH) override val animated by c.setting("Animated", true, "Animate the dash pattern") { dashEnabled } + @Group(GROUP_DASH) val dashOffsetSetting by c.setting("Dash Offset", 0, 0..100, 1, "Offset of the dash pattern") { dashEnabled && !animated } override val dashOffset get() = dashOffsetSetting * 0.01f - val animationSpeedSetting by c.setting("${prefix}Animation Speed", 30, -100..100, 1, "Speed of dash animation (negative = reverse)") { visibility() && dashEnabled && animated }.group(*baseGroup, Group.Dash).index() + @Group(GROUP_DASH) val animationSpeedSetting by c.setting("Animation Speed", 30, -100..100, 1, "Speed of dash animation (negative = reverse)") { dashEnabled && animated } override val animationSpeed get() = animationSpeedSetting * 0.1f } diff --git a/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt b/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt index ee4855e18..4a93d398b 100644 --- a/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt @@ -18,38 +18,34 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.config.SettingGroup +import com.lambda.config.Config.Group +import com.lambda.config.SettingBlock import com.lambda.util.NamedEnum import java.awt.Color -class ScreenTextSettings( - c: Config, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, -) : SettingGroup(c), TextConfig { - enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Outline("Outline"), - Glow("Glow"), - Shadow("Shadow") +class ScreenTextSettings(override val c: Config) : SettingBlock, TextConfig { + companion object { + private const val GROUP_GENERAL = "General" + private const val GROUP_OUTLINE = "Outline" + private const val GROUP_GLOW = "Glow" + private const val GROUP_SHADOW = "Shadow" } - override val textColor by c.setting("${prefix}Text Color", Color.WHITE, "The main text color", visibility = visibility).group(*baseGroup, Group.General).index() - val sizeSetting by c.setting("${prefix}Text Size", 18, 1..50, 1, visibility = visibility).group(*baseGroup, Group.General).index() + @Group(GROUP_GENERAL) override val textColor by c.setting("Text Color", Color.WHITE, "The main text color") + @Group(GROUP_GENERAL) val sizeSetting by c.setting("Text Size", 18, 1..50, 1) override val size get() = sizeSetting * 0.001f - override val outlineEnabled by c.setting("${prefix}Outline", false, "Enable text outline", visibility = visibility).group(*baseGroup, Group.Outline).index() - override val outlineColor by c.setting("${prefix}Outline Color", Color.BLACK, "Color of the outline") { visibility() && outlineEnabled }.group(*baseGroup, Group.Outline).index() - override val outlineWidth by c.setting("${prefix}Outline Width", 0.1f, 0f..0.4f, 0.005f, "Width of the outline") { visibility() && outlineEnabled }.group(*baseGroup, Group.Outline).index() + @Group(GROUP_OUTLINE) override val outlineEnabled by c.setting("Outline", false, "Enable text outline") + @Group(GROUP_OUTLINE) override val outlineColor by c.setting("Outline Color", Color.BLACK, "Color of the outline") { outlineEnabled } + @Group(GROUP_OUTLINE) override val outlineWidth by c.setting("Outline Width", 0.1f, 0f..0.4f, 0.005f, "Width of the outline") { outlineEnabled } - override val glowEnabled by c.setting("${prefix}Glow", false, "Enable text glow effect", visibility = visibility).group(*baseGroup, Group.Glow).index() - override val glowColor by c.setting("${prefix}Glow Color", Color.WHITE, "Color of the glow") { visibility() && glowEnabled }.group(*baseGroup, Group.Glow).index() - override val glowRadius by c.setting("${prefix}Glow Radius", 0.2f, 0f..0.5f, 0.01f, "Radius of the glow effect") { visibility() && glowEnabled }.group(*baseGroup, Group.Glow).index() + @Group(GROUP_GLOW) override val glowEnabled by c.setting("Glow", false, "Enable text glow effect") + @Group(GROUP_GLOW) override val glowColor by c.setting("Glow Color", Color.WHITE, "Color of the glow") { glowEnabled } + @Group(GROUP_GLOW) override val glowRadius by c.setting("Glow Radius", 0.2f, 0f..0.5f, 0.01f, "Radius of the glow effect") { glowEnabled } - override val shadowEnabled by c.setting("${prefix}Shadow", true, "Enable text shadow", visibility = visibility).group(*baseGroup, Group.Shadow).index() - override val shadowColor by c.setting("${prefix}Shadow Color", Color(0, 0, 0, 180), "Color of the shadow") { visibility() && shadowEnabled }.group(*baseGroup, Group.Shadow).index() - override val shadowOffset by c.setting("${prefix}Shadow Offset", 0.05f, 0f..0.5f, 0.005f, "Distance of shadow from text") { visibility() && shadowEnabled }.group(*baseGroup, Group.Shadow).index() - override val shadowAngle by c.setting("${prefix}Shadow Angle", 135f, 0f..360f, 1f, "Angle of the shadow") { visibility() && shadowEnabled }.group(*baseGroup, Group.Shadow).index() - override val shadowSoftness by c.setting("${prefix}Shadow Softness", 0f, 0f..0.5f, 0.01f, "Softness of shadow edges") { visibility() && shadowEnabled }.group(*baseGroup, Group.Shadow).index() + @Group(GROUP_SHADOW) override val shadowEnabled by c.setting("Shadow", true, "Enable text shadow") + @Group(GROUP_SHADOW) override val shadowColor by c.setting("Shadow Color", Color(0, 0, 0, 180), "Color of the shadow") { shadowEnabled } + @Group(GROUP_SHADOW) override val shadowOffset by c.setting("Shadow Offset", 0.05f, 0f..0.5f, 0.005f, "Distance of shadow from text") { shadowEnabled } + @Group(GROUP_SHADOW) override val shadowAngle by c.setting("Shadow Angle", 135f, 0f..360f, 1f, "Angle of the shadow") { shadowEnabled } + @Group(GROUP_SHADOW) override val shadowSoftness by c.setting("Shadow Softness", 0f, 0f..0.5f, 0.01f, "Softness of shadow edges") { shadowEnabled } } diff --git a/src/main/kotlin/com/lambda/config/groups/TargetingConfig.kt b/src/main/kotlin/com/lambda/config/groups/TargetingConfig.kt index 929f86401..469b9e64e 100644 --- a/src/main/kotlin/com/lambda/config/groups/TargetingConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/TargetingConfig.kt @@ -17,7 +17,9 @@ package com.lambda.config.groups -interface TargetingConfig { +import com.lambda.config.SettingBlock + +interface TargetingConfig : SettingBlock { val targetingRange: Double val targets: EntitySelectionConfig } diff --git a/src/main/kotlin/com/lambda/config/groups/TargetingSettings.kt b/src/main/kotlin/com/lambda/config/groups/TargetingSettings.kt index b4ef5b466..11d2206a0 100644 --- a/src/main/kotlin/com/lambda/config/groups/TargetingSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/TargetingSettings.kt @@ -18,7 +18,7 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.config.SettingGroup +import com.lambda.config.SettingBlock import com.lambda.config.applyEdits import com.lambda.context.SafeContext import com.lambda.friend.FriendHandler.isFriend @@ -46,25 +46,22 @@ import java.util.* * are targetable, the range of targeting, and various other conditions for targeting. * * @param c The [Config] instance used to get and set configuration options for targeting. - * @param visibility The predicate used to determine whether the targeting settings are visible and active. * @param defaultRange The default range within which entities can be targeted. * @param maxRange The maximum range within which entities can be targeted. */ abstract class TargetingSettings( - c: Config, - vararg baseGroup: NamedEnum, + override val c: Config, defaultRange: Double, maxRange: Double, - prefix: String = "", - visibility: () -> Boolean = { true }, -) : SettingGroup(c), TargetingConfig { +) : SettingBlock, TargetingConfig { + /** * The range within which entities can be targeted. This value is config and constrained * between 1.0 and [maxRange]. */ - override val targetingRange by c.setting("${prefix}Targeting Range", defaultRange, 1.0..maxRange, 0.05, visibility = visibility).group(*baseGroup).index() - override val targets = EntitySelectionSettings(c = c, baseGroup = baseGroup).apply { - c.applyEdits { + override val targetingRange by c.setting("Targeting Range", defaultRange, 1.0..maxRange, 0.05) + override val targets = EntitySelectionSettings(c).apply { + applyEdits { hide(::self, ::blockEntities) } } @@ -87,31 +84,28 @@ abstract class TargetingSettings( */ class CombatSettings( c: Config, - vararg baseGroup: NamedEnum, defaultRange: Double = 5.0, maxRange: Double = 16.0, - prefix: String = "", - override val visibility: () -> Boolean = { true }, - ) : TargetingSettings(c, *baseGroup, defaultRange = defaultRange, maxRange = maxRange, prefix = prefix, visibility = visibility) { + ) : TargetingSettings(c, defaultRange, maxRange) { /** * The field of view limit for targeting entities. Configurable between 5 and 180 degrees. */ - val fov by c.setting("${prefix}FOV Limit", 180, 5..180, 1) { visibility() && priority == Priority.Fov }.group(*baseGroup).index() + val fov by c.setting("FOV Limit", 180, 5..180, 1) { priority == Priority.Fov } /** * The priority used to determine which entity is targeted. Configurable with default set to [Priority.Distance]. */ - val priority by c.setting("${prefix}Priority", Priority.Distance, visibility = visibility).group(*baseGroup).index() + val priority by c.setting("Priority", Priority.Distance) /** * Whether to target named entities that are not players. */ - val targetNamed by c.setting("${prefix}Target Named Entities", false, visibility = visibility).group(*baseGroup).index() + val targetNamed by c.setting("Target Named Entities", false) /** * Whether to target tamed entities. */ - val targetTamed by c.setting("${prefix}Target Tamed Entities", false, visibility = visibility).group(*baseGroup).index() - val owned by c.setting("${prefix}Owned", false) { visibility() && targetTamed }.group(*baseGroup).index() + val targetTamed by c.setting("Target Tamed Entities", false) + val owned by c.setting("Owned", false) { targetTamed } /** * Validates whether a given entity is targetable for combat based on the field of view limit and other settings. diff --git a/src/main/kotlin/com/lambda/config/groups/TextConfig.kt b/src/main/kotlin/com/lambda/config/groups/TextConfig.kt index 7d33c2c39..6877ffec5 100644 --- a/src/main/kotlin/com/lambda/config/groups/TextConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/TextConfig.kt @@ -17,10 +17,11 @@ package com.lambda.config.groups +import com.lambda.config.SettingBlock import com.lambda.graphics.mc.RenderBuilder import java.awt.Color -interface TextConfig { +interface TextConfig : SettingBlock { val size: Float val textColor: Color diff --git a/src/main/kotlin/com/lambda/config/groups/WorldLineSettings.kt b/src/main/kotlin/com/lambda/config/groups/WorldLineSettings.kt index b641a7443..af7f2099d 100644 --- a/src/main/kotlin/com/lambda/config/groups/WorldLineSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/WorldLineSettings.kt @@ -18,41 +18,36 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.config.SettingGroup -import com.lambda.util.NamedEnum +import com.lambda.config.Config.Group +import com.lambda.config.SettingBlock import java.awt.Color -class WorldLineSettings( - c: Config, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, -) : SettingGroup(c), LineConfig { - enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Color("Color"), - Dash("Dash") +class WorldLineSettings(override val c: Config) : SettingBlock, LineConfig { + companion object { + private const val GROUP_GENERAL = "General" + private const val GROUP_COLOR = "Color" + private const val GROUP_DASH = "Dash" } - val distanceScaling by c.setting("${prefix}Distance Scaling", true, "Line width stays constant on screen regardless of distance", visibility = visibility).group(*baseGroup, Group.General).index() - val worldWidthSetting by c.setting("${prefix}Width", 5, 1..50, 1) { visibility() && !distanceScaling }.group(*baseGroup, Group.General).index() - val screenWidthSetting by c.setting("${prefix}Screen Width", 20, 1..100, 1, "Line width in screen-space (stays constant size)") { visibility() && distanceScaling }.group(*baseGroup, Group.General).index() + @Group(GROUP_GENERAL) val distanceScaling by c.setting("Distance Scaling", true, "Line width stays constant on screen regardless of distance") + @Group(GROUP_GENERAL) val worldWidthSetting by c.setting("Width", 5, 1..50, 1) { !distanceScaling } + @Group(GROUP_GENERAL) val screenWidthSetting by c.setting("Screen Width", 20, 1..100, 1, "Line width in screen-space (stays constant size)") { distanceScaling } override val width: Float get() = if (distanceScaling) -screenWidthSetting * 0.00005f else worldWidthSetting * 0.001f - override val startColor by c.setting("${prefix}Start Color", Color.WHITE, "The color at the start of the line", visibility = visibility).group(*baseGroup, Group.Color).index() - override val endColor by c.setting("${prefix}End Color", Color.WHITE, "The color at the end of the line", visibility = visibility).group(*baseGroup, Group.Color).index() + @Group(GROUP_COLOR) override val startColor by c.setting("Start Color", Color.WHITE, "The color at the start of the line") + @Group(GROUP_COLOR) override val endColor by c.setting("End Color", Color.WHITE, "The color at the end of the line") - override val dashEnabled by c.setting("${prefix}Dashed", false, "Enable dashed line pattern", visibility = visibility).group(*baseGroup, Group.Dash).index() - val dashLengthSetting by c.setting("${prefix}Dash Length", 50, 1..200, 1, "Length of each dash") { visibility() && dashEnabled }.group(*baseGroup, Group.Dash).index() + @Group(GROUP_DASH) override val dashEnabled by c.setting("Dashed", false, "Enable dashed line pattern") + @Group(GROUP_DASH) val dashLengthSetting by c.setting("Dash Length", 50, 1..200, 1, "Length of each dash") { dashEnabled } override val dashLength get() = dashLengthSetting * 0.01f - val gapLengthSetting by c.setting("${prefix}Gap Length", 25, 1..200, 1, "Length of gaps between dashes") { visibility() && dashEnabled }.group(*baseGroup, Group.Dash).index() + @Group(GROUP_DASH) val gapLengthSetting by c.setting("Gap Length", 25, 1..200, 1, "Length of gaps between dashes") { dashEnabled } override val gapLength get() = gapLengthSetting * 0.01f - override val animated by c.setting("${prefix}Animated", true, "Animate the dash pattern") { visibility() && dashEnabled }.group(*baseGroup, Group.Dash).index() - val dashOffsetSetting by c.setting("${prefix}Dash Offset", 0, 0..100, 1, "Offset of the dash pattern") { visibility() && dashEnabled && !animated }.group(*baseGroup, Group.Dash).index() + @Group(GROUP_DASH) override val animated by c.setting("Animated", true, "Animate the dash pattern") { dashEnabled } + @Group(GROUP_DASH) val dashOffsetSetting by c.setting("Dash Offset", 0, 0..100, 1, "Offset of the dash pattern") { dashEnabled && !animated } override val dashOffset get() = dashOffsetSetting * 0.01f - val animationSpeedSetting by c.setting("${prefix}Animation Speed", 30, -100..100, 1, "Speed of dash animation (negative = reverse)") { visibility() && dashEnabled && animated }.group(*baseGroup, Group.Dash).index() + @Group(GROUP_DASH) val animationSpeedSetting by c.setting("Animation Speed", 30, -100..100, 1, "Speed of dash animation (negative = reverse)") { dashEnabled && animated } override val animationSpeed get() = animationSpeedSetting * 0.1f } diff --git a/src/main/kotlin/com/lambda/config/groups/WorldTextSettings.kt b/src/main/kotlin/com/lambda/config/groups/WorldTextSettings.kt index db81d179a..9af1cf7f9 100644 --- a/src/main/kotlin/com/lambda/config/groups/WorldTextSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/WorldTextSettings.kt @@ -18,38 +18,34 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.config.SettingGroup +import com.lambda.config.Config.Group +import com.lambda.config.SettingBlock import com.lambda.util.NamedEnum import java.awt.Color -class WorldTextSettings( - c: Config, - vararg baseGroup: NamedEnum, - prefix: String = "", - override val visibility: () -> Boolean = { true }, -) : SettingGroup(c), TextConfig { - enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Outline("Outline"), - Glow("Glow"), - Shadow("Shadow") +class WorldTextSettings(override val c: Config) : SettingBlock, TextConfig { + companion object { + private const val GROUP_GENERAL = "General" + private const val GROUP_OUTLINE = "Outline" + private const val GROUP_GLOW = "Glow" + private const val GROUP_SHADOW = "Shadow" } - override val textColor by c.setting("${prefix}Text Color", Color.WHITE, "The main text color", visibility = visibility).group(*baseGroup, Group.General).index() - val sizeSetting by c.setting("${prefix}Text Size", 5, 1..50, 1, visibility = visibility).group(*baseGroup, Group.General).index() + @Group(GROUP_GENERAL) override val textColor by c.setting("Text Color", Color.WHITE, "The main text color") + @Group(GROUP_GENERAL) val sizeSetting by c.setting("Text Size", 5, 1..50, 1) override val size get() = sizeSetting * 0.1f - override val outlineEnabled by c.setting("${prefix}Outline", false, "Enable text outline", visibility = visibility).group(*baseGroup, Group.Outline).index() - override val outlineColor by c.setting("${prefix}Outline Color", Color.BLACK, "Color of the outline") { visibility() && outlineEnabled }.group(*baseGroup, Group.Outline).index() - override val outlineWidth by c.setting("${prefix}Outline Width", 0.1f, 0f..0.4f, 0.005f, "Width of the outline") { visibility() && outlineEnabled }.group(*baseGroup, Group.Outline).index() + @Group(GROUP_OUTLINE) override val outlineEnabled by c.setting("Outline", false, "Enable text outline") + @Group(GROUP_OUTLINE) override val outlineColor by c.setting("Outline Color", Color.BLACK, "Color of the outline") { outlineEnabled } + @Group(GROUP_OUTLINE) override val outlineWidth by c.setting("Outline Width", 0.1f, 0f..0.4f, 0.005f, "Width of the outline") { outlineEnabled } - override val glowEnabled by c.setting("${prefix}Glow", false, "Enable text glow effect", visibility = visibility).group(*baseGroup, Group.Glow).index() - override val glowColor by c.setting("${prefix}Glow Color", Color.WHITE, "Color of the glow") { visibility() && glowEnabled }.group(*baseGroup, Group.Glow).index() - override val glowRadius by c.setting("${prefix}Glow Radius", 0.2f, 0f..0.5f, 0.01f, "Radius of the glow effect") { visibility() && glowEnabled }.group(*baseGroup, Group.Glow).index() + @Group(GROUP_GLOW) override val glowEnabled by c.setting("Glow", false, "Enable text glow effect") + @Group(GROUP_GLOW) override val glowColor by c.setting("Glow Color", Color.WHITE, "Color of the glow") { glowEnabled } + @Group(GROUP_GLOW) override val glowRadius by c.setting("Glow Radius", 0.2f, 0f..0.5f, 0.01f, "Radius of the glow effect") { glowEnabled } - override val shadowEnabled by c.setting("${prefix}Shadow", true, "Enable text shadow", visibility = visibility).group(*baseGroup, Group.Shadow).index() - override val shadowColor by c.setting("${prefix}Shadow Color", Color(0, 0, 0, 180), "Color of the shadow") { visibility() && shadowEnabled }.group(*baseGroup, Group.Shadow).index() - override val shadowOffset by c.setting("${prefix}Shadow Offset", 0.05f, 0f..0.5f, 0.005f, "Distance of shadow from text") { visibility() && shadowEnabled }.group(*baseGroup, Group.Shadow).index() - override val shadowAngle by c.setting("${prefix}Shadow Angle", 135f, 0f..360f, 1f, "Angle of the shadow") { visibility() && shadowEnabled }.group(*baseGroup, Group.Shadow).index() - override val shadowSoftness by c.setting("${prefix}Shadow Softness", 0f, 0f..0.5f, 0.01f, "Softness of shadow edges") { visibility() && shadowEnabled }.group(*baseGroup, Group.Shadow).index() + @Group(GROUP_SHADOW) override val shadowEnabled by c.setting("Shadow", true, "Enable text shadow") + @Group(GROUP_SHADOW) override val shadowColor by c.setting("Shadow Color", Color(0, 0, 0, 180), "Color of the shadow") { shadowEnabled } + @Group(GROUP_SHADOW) override val shadowOffset by c.setting("Shadow Offset", 0.05f, 0f..0.5f, 0.005f, "Distance of shadow from text") { shadowEnabled } + @Group(GROUP_SHADOW) override val shadowAngle by c.setting("Shadow Angle", 135f, 0f..360f, 1f, "Angle of the shadow") { shadowEnabled } + @Group(GROUP_SHADOW) override val shadowSoftness by c.setting("Shadow Softness", 0f, 0f..0.5f, 0.01f, "Softness of shadow edges") { shadowEnabled } } diff --git a/src/main/kotlin/com/lambda/config/migration/migrations/AutomationConfigMigration.kt b/src/main/kotlin/com/lambda/config/migration/migrations/AutomationConfigMigration.kt index cef85a53b..da8d459f4 100644 --- a/src/main/kotlin/com/lambda/config/migration/migrations/AutomationConfigMigration.kt +++ b/src/main/kotlin/com/lambda/config/migration/migrations/AutomationConfigMigration.kt @@ -20,6 +20,7 @@ package com.lambda.config.migration.migrations import com.lambda.Lambda.LOG import com.lambda.config.migration.StepConfigMigration +@Suppress("unused") object AutomationConfigMigration : StepConfigMigration() { override val configName = "automation" override val latestVersion = 2 diff --git a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt index ebe8d58a6..f21b8ee7c 100644 --- a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt @@ -21,7 +21,7 @@ import com.google.gson.reflect.TypeToken import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.config.SettingEditorDsl -import com.lambda.config.SettingGroupEditor +import com.lambda.config.ConfigEditor import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.ImGui import com.lambda.imgui.ImGui.calcTextSize @@ -98,19 +98,19 @@ abstract class NumericSetting( companion object { @SettingEditorDsl @Suppress("unchecked_cast") - fun SettingGroupEditor.TypedEditBuilder.range(range: ClosedRange) where T : Number, T : Comparable { + fun ConfigEditor.TypedEditBuilder.range(range: ClosedRange) where T : Number, T : Comparable { (settings as Collection>).forEach { it.range = range } } @SettingEditorDsl @Suppress("unchecked_cast") - fun SettingGroupEditor.TypedEditBuilder.step(step: T) where T : Number, T : Comparable { + fun ConfigEditor.TypedEditBuilder.step(step: T) where T : Number, T : Comparable { (settings as Collection>).forEach { it.step = step } } @SettingEditorDsl @Suppress("unchecked_cast") - fun SettingGroupEditor.TypedEditBuilder.unit(unit: String) where T : Number, T : Comparable { + fun ConfigEditor.TypedEditBuilder.unit(unit: String) where T : Number, T : Comparable { (settings as Collection>).forEach { it.unit = unit} } } diff --git a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt index ffe69d405..2129eb1cc 100644 --- a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt @@ -25,7 +25,7 @@ import com.lambda.brigadier.required import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.config.SettingEditorDsl -import com.lambda.config.SettingGroupEditor +import com.lambda.config.ConfigEditor import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.flag.ImGuiInputTextFlags import com.lambda.util.extension.CommandBuilder @@ -64,12 +64,12 @@ class StringSetting( @Suppress("unused", "unchecked_cast") companion object { @SettingEditorDsl - fun SettingGroupEditor.TypedEditBuilder.multiline(multiline: Boolean) { + fun ConfigEditor.TypedEditBuilder.multiline(multiline: Boolean) { (settings as Collection).forEach { it.multiline = multiline } } @SettingEditorDsl - fun SettingGroupEditor.TypedEditBuilder.flags(flags: Int) { + fun ConfigEditor.TypedEditBuilder.flags(flags: Int) { (settings as Collection).forEach { it.flags = flags } } } diff --git a/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt index 31bb13c7e..51c819b96 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt @@ -25,7 +25,7 @@ import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.util.ReflectionUtils.className /** - * @see [com.lambda.config.settings.collections.CollectionSetting] + * @see [CollectionSetting] * @see [com.lambda.config.Config] */ class ClassCollectionSetting( diff --git a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt index 3f56cf60f..81cce32af 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt @@ -23,7 +23,7 @@ import com.lambda.Lambda.gson import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.config.SettingEditorDsl -import com.lambda.config.SettingGroupEditor +import com.lambda.config.ConfigEditor import com.lambda.context.SafeContext import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.ImGui @@ -192,7 +192,7 @@ open class CollectionSetting( @SettingEditorDsl @Suppress("unchecked_cast") - fun SettingGroupEditor.TypedEditBuilder>.immutableCollection(collection: Collection) { + fun ConfigEditor.TypedEditBuilder>.immutableCollection(collection: Collection) { (settings as Collection>).forEach { it.immutableCollection = collection } } } diff --git a/src/main/kotlin/com/lambda/core/Loader.kt b/src/main/kotlin/com/lambda/core/Loader.kt index 2820a42f2..88e0a416f 100644 --- a/src/main/kotlin/com/lambda/core/Loader.kt +++ b/src/main/kotlin/com/lambda/core/Loader.kt @@ -20,7 +20,7 @@ package com.lambda.core import com.lambda.Lambda import com.lambda.Lambda.LOG import com.lambda.util.CommunicationUtils.ascii -import com.lambda.util.getInstances +import com.lambda.util.ReflectionUtils.getInstances import kotlin.system.measureTimeMillis import kotlin.time.Duration.Companion.milliseconds diff --git a/src/main/kotlin/com/lambda/gui/MenuBar.kt b/src/main/kotlin/com/lambda/gui/MenuBar.kt index fba4f930a..89dc73b9b 100644 --- a/src/main/kotlin/com/lambda/gui/MenuBar.kt +++ b/src/main/kotlin/com/lambda/gui/MenuBar.kt @@ -117,24 +117,24 @@ object MenuBar { private fun ImGuiBuilder.buildLambdaMenu() { menu("Save Config...") { menuItem("Save All Configs") { - ConfigLoader.configCategories.forEach { it.trySave(true) } + ConfigLoader.configCategories.forEach { it.trySaveToFile(true) } info("Saved ${ConfigLoader.configCategories.size} configuration files.") } ConfigLoader.configCategories.forEach { config -> menuItem("Save ${config.configName}") { - config.trySave(true) + config.trySaveToFile(true) info("Saved ${config.configName}") } } } menu("Load Config...") { menuItem("Load All Configs") { - ConfigLoader.configCategories.forEach { it.tryLoad() } + ConfigLoader.configCategories.forEach { it.tryLoadFromFile() } info("Loaded ${ConfigLoader.configCategories.size} configuration files.") } ConfigLoader.configCategories.forEach { config -> menuItem("Load ${config.configName}") { - config.tryLoad() + config.tryLoadFromFile() info("Loaded ${config.configName}") } } @@ -469,7 +469,7 @@ object MenuBar { text("Modules: ${ModuleRegistry.modules.size}") text("Commands: ${CommandRegistry.commands.size}") val totalSettings = ConfigLoader.configCategories.sumOf { cfg -> - cfg.configs.sumOf { it.settings.size } + cfg.configs.sumOf { it.settingContainers.size } } text("Settings: $totalSettings") text("Synchronous listeners: ${EventFlow.syncListeners.size}") diff --git a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt index a3d7fbf1c..6a6e8c1df 100644 --- a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt +++ b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt @@ -263,7 +263,7 @@ object QuickSearch { val settingResults = ConfigLoader.configCategories.flatMap { it.configs.flatMap { config -> - config.settings + config.settingContainers .filter { setting -> setting.visibility() } .mapNotNull { setting -> val score = calculateScore(lowerCaseQuery, setting.name.lowercase(), lenient) diff --git a/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt b/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt index 22d38f9b4..51b39a1cf 100644 --- a/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt +++ b/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt @@ -21,7 +21,6 @@ import com.lambda.config.automation.AutomationConfig import com.lambda.config.Config import com.lambda.config.automation.IMutableAutomationConfig import com.lambda.config.Setting -import com.lambda.config.UserAutomationConfig import com.lambda.config.automation.UserAutomationConfig import com.lambda.config.categories.UserAutomationCategory import com.lambda.gui.dsl.ImGuiBuilder @@ -53,7 +52,7 @@ object SettingsWidget { with(config.backgroundColor) { buildLayout() } } smallButton("Reset") { - config.settings.forEach { it.reset(silent = true) } + config.settingContainers.forEach { it.reset(silent = true) } } } } @@ -88,7 +87,7 @@ object SettingsWidget { } } - val visibleSettings = config.settings.filter { it.visibility() } + val visibleSettings = config.settingContainers.filter { it.visibility() } if (visibleSettings.isEmpty()) return else separator() val (grouped, ungrouped) = visibleSettings.partition { it.groups.isNotEmpty() } diff --git a/src/main/kotlin/com/lambda/module/Module.kt b/src/main/kotlin/com/lambda/module/Module.kt index 9a4eec880..add1cfb97 100644 --- a/src/main/kotlin/com/lambda/module/Module.kt +++ b/src/main/kotlin/com/lambda/module/Module.kt @@ -61,7 +61,7 @@ import com.lambda.util.Nameable * If a module does not need to be activated by a key (like [ClickGui]), * the default [keybind] should not be set (using [KeyCode.Unbound]). * - * [Module]s are [Config]s with [settings] (see [SettingCore] for all setting types). + * [Module]s are [Config]s with [settingContainers] (see [SettingCore] for all setting types). * Example: * ``` * private val foo by setting("Foo", true) diff --git a/src/main/kotlin/com/lambda/module/ModuleRegistry.kt b/src/main/kotlin/com/lambda/module/ModuleRegistry.kt index 2662346b2..256557ba7 100644 --- a/src/main/kotlin/com/lambda/module/ModuleRegistry.kt +++ b/src/main/kotlin/com/lambda/module/ModuleRegistry.kt @@ -19,7 +19,6 @@ package com.lambda.module import com.lambda.core.Loadable import com.lambda.util.ReflectionUtils.getInstances -import com.lambda.util.getInstances object ModuleRegistry : Loadable { override val priority = 1 @@ -30,5 +29,5 @@ object ModuleRegistry : Loadable { val moduleNameMap = modules.associateBy { it.name } override fun load() = - "Loaded ${modules.size} modules with ${modules.sumOf { it.settings.size }} settings" + "Loaded ${modules.size} modules with ${modules.sumOf { it.settingContainers.size }} settings" } diff --git a/src/main/kotlin/com/lambda/module/hud/Coordinates.kt b/src/main/kotlin/com/lambda/module/hud/Coordinates.kt index 9a924aa0f..e654f7487 100644 --- a/src/main/kotlin/com/lambda/module/hud/Coordinates.kt +++ b/src/main/kotlin/com/lambda/module/hud/Coordinates.kt @@ -46,6 +46,13 @@ object Coordinates : HudModule( private val showBiome by setting("Show Biome Name", true) private val showCurrentDimensionOnly by setting("Show Current Dimension Only", true) + private const val CURRENT_DIMENSION_TAB = "Current Dimension" + @Tab(CURRENT_DIMENSION_TAB) private val formatter = settingBlock(FormatterSettings(this)) { + applyEdits { + ::timeFormat.edit { hide() } + } + } + private val formatter = FormatterSettings(c = this, baseGroup = arrayOf(Group.CurrentDimension)).apply { applyEdits { ::timeFormat.edit { hide() } diff --git a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt index dd67184a4..4efd98896 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt @@ -18,7 +18,7 @@ package com.lambda.module.modules.chat import com.lambda.config.Config -import com.lambda.config.SettingGroup +import com.lambda.config.SettingBlock import com.lambda.config.applyEdits import com.lambda.config.groups.ReplaceConfig import com.lambda.event.events.ChatEvent @@ -140,7 +140,7 @@ object AntiSpam : Module( c: Config, baseGroup: NamedEnum, override val visibility: () -> Boolean = { true }, - ) : ReplaceConfig, SettingGroup(c) { + ) : ReplaceConfig, SettingBlock(c) { override val action by setting("$name Action Strategy", ReplaceConfig.ActionStrategy.Replace, visibility = visibility).group(baseGroup) override val replace by setting("$name Replace Strategy", ReplaceConfig.ReplaceStrategy.CensorAll) { visibility() && action == ReplaceConfig.ActionStrategy.Replace }.group(baseGroup) } diff --git a/src/main/kotlin/com/lambda/util/CommunicationUtils.kt b/src/main/kotlin/com/lambda/util/CommunicationUtils.kt index bf981eebd..7db846cf6 100644 --- a/src/main/kotlin/com/lambda/util/CommunicationUtils.kt +++ b/src/main/kotlin/com/lambda/util/CommunicationUtils.kt @@ -21,7 +21,6 @@ import com.lambda.Lambda import com.lambda.Lambda.mc import com.lambda.command.CommandRegistry import com.lambda.command.LambdaCommand -import com.lambda.config.ConfigCategory import com.lambda.config.ConfigLoader import com.lambda.core.Loader import com.lambda.event.EventFlow @@ -208,7 +207,7 @@ object CommunicationUtils { literal( "Settings: ${ ConfigLoader.configCategories.sumOf { config -> - config.configs.sumOf { it.settings.size } + config.configs.sumOf { it.settingContainers.size } } }" ) diff --git a/src/main/kotlin/com/lambda/util/Diagnostics.kt b/src/main/kotlin/com/lambda/util/Diagnostics.kt index d8eadc37f..84ba93dac 100644 --- a/src/main/kotlin/com/lambda/util/Diagnostics.kt +++ b/src/main/kotlin/com/lambda/util/Diagnostics.kt @@ -25,7 +25,7 @@ object Diagnostics { modules.filter { it.isEnabled } .forEach { module -> append("\t${module.name}") - module.settings + module.settingContainers .filter { it.isModified } .forEach { setting -> append("\t\t${setting.name} -> ${setting.value}") diff --git a/src/main/kotlin/com/lambda/util/ReflectionUtils.kt b/src/main/kotlin/com/lambda/util/ReflectionUtils.kt index f55449182..0d38c6f09 100644 --- a/src/main/kotlin/com/lambda/util/ReflectionUtils.kt +++ b/src/main/kotlin/com/lambda/util/ReflectionUtils.kt @@ -56,7 +56,6 @@ object ReflectionUtils { return when { clazz.isInterface -> scanResult.getClassesImplementing(clazz) Modifier.isAbstract(clazz.modifiers) -> scanResult.getSubclasses(clazz) - else -> throw IllegalStateException("class ${clazz.name} is neither an interface or open class") }.filter { block(it) } .mapNotNull { createInstance(Class.forName(it.name)) } @@ -86,12 +85,11 @@ object ReflectionUtils { scanResult.getResourcesMatchingWildcard(pattern) .filter { block(it) } - inline fun createInstance(clazz: Class<*>): T? { - return when { - clazz.isInterface || clazz.isEnum || clazz.isAnnotation || clazz.isObject -> { + inline fun createInstance(clazz: Class<*>) = + when { + clazz.isInterface || clazz.isEnum || clazz.isAnnotation || clazz.isObject -> // Handle objects (singletons) or invalid types clazz.objectInstance as? T - } else -> { // Look for a constructor with no parameters clazz.constructors @@ -99,5 +97,4 @@ object ReflectionUtils { .firstOrNull { it.parameterCount == 0 }?.newInstance() as? T } } - } } From 48e3c6db1a8caf04af749e14731e6d860cc4805f Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Sun, 3 May 2026 02:19:48 +0100 Subject: [PATCH 07/40] handle setting init and registration with tab and group paths handled by reflections from the parent init --- src/main/kotlin/com/lambda/config/Config.kt | 100 +++++++++++++++--- .../com/lambda/config/ConfigCategory.kt | 42 ++------ src/main/kotlin/com/lambda/config/Setting.kt | 4 + .../config/categories/AutomationCategory.kt | 7 +- .../lambda/config/categories/FontCategory.kt | 7 +- .../config/categories/FriendCategory.kt | 7 +- .../lambda/config/categories/GuiCategory.kt | 7 +- .../lambda/config/categories/HudCategory.kt | 7 +- .../config/categories/LambdaCategory.kt | 7 +- .../config/categories/ModuleCategory.kt | 10 +- .../config/categories/SecretsCategory.kt | 7 +- .../categories/UserAutomationCategory.kt | 11 +- .../com/lambda/config/groups/BuildSettings.kt | 1 - .../lambda/config/groups/InventorySettings.kt | 1 - .../config/groups/ScreenLineSettings.kt | 1 - .../config/groups/ScreenTextSettings.kt | 1 - .../lambda/config/groups/WorldTextSettings.kt | 1 - 17 files changed, 113 insertions(+), 108 deletions(-) diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index 8c86dbaa7..ffd854f6b 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -53,6 +53,11 @@ import net.minecraft.registry.Registries import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Vec3d import java.awt.Color +import kotlin.jvm.java +import kotlin.reflect.KClass +import kotlin.reflect.KProperty +import kotlin.reflect.full.declaredMemberProperties +import kotlin.reflect.jvm.javaField /** * Represents a set of [SettingCore]s that are associated with the [name] of the [Config]. @@ -64,15 +69,81 @@ import java.awt.Color */ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { val settingContainers = mutableListOf() - val settingTabs = mutableListOf() - val settingGroups = mutableListOf() + private val registrationQueue = ArrayDeque>() init { - if (configs.any { it.name == name }) - throw IllegalStateException("Configs with name $name already exists") + if (configs.any { it.name == name }) throw IllegalStateException("Configs with name $name already exists") + enqueueProperties(this::class, emptyList()) configCategory.configs.add(this) } + /** + * Recursively reflects over [klass]'s declared properties to build the [registrationQueue]. + * For each property: + * - If its backing field is a [Setting], enqueue its annotation path. + * - If its backing field is a [SettingBlock], recurse into that class with the current path as outer context. + * - If it has no backing field (computed property), skip it. + */ + private fun enqueueProperties(klass: KClass<*>, outerPath: List) { + klass.declaredMemberProperties.forEach { property -> + val path = outerPath + buildPathFromAnnotations(property) + val fieldType = property.javaField?.type + when { + fieldType == null -> {} + SettingBlock::class.java.isAssignableFrom(fieldType) -> + enqueueProperties(fieldType.kotlin, path) + Setting::class.java.isAssignableFrom(fieldType) -> + registrationQueue.addLast(path) + } + } + } + + /** + * Reads [Tab] and [Group] annotations from a property and builds a nesting path. + * Annotation order in source determines nesting order. + */ + private fun buildPathFromAnnotations(property: KProperty<*>): List { + val path = mutableListOf() + property.annotations.forEach { annotation -> + when (annotation) { + is Tab -> annotation.tabs.forEach { path.add(ContainerSpec(ContainerType.Tab, it)) } + is Group -> annotation.groups.forEach { path.add(ContainerSpec(ContainerType.Group, it)) } + } + } + return path + } + + /** + * Registers a [Setting] into the [settingContainers] tree. + * Dequeues the next path from [registrationQueue] and navigates/creates + * the container hierarchy, coalescing containers with the same name and type. + */ + fun register(setting: Setting<*, *>) { + val path = registrationQueue.removeFirst() + var currentList = settingContainers + + path.forEach { spec -> + val existing = currentList.firstOrNull { + it is SettingContainer.Multiple && + it.name == spec.name && + ((spec.type == ContainerType.Tab && it is SettingContainer.Tab) || + (spec.type == ContainerType.Group && it is SettingContainer.Group)) + } as? SettingContainer.Multiple + + if (existing != null) currentList = existing.settings + else { + val newContainer = when (spec.type) { + ContainerType.Tab -> SettingContainer.Tab(spec.name, mutableListOf()) + ContainerType.Group -> SettingContainer.Group(spec.name, mutableListOf()) + } + currentList.add(newContainer) + currentList = newContainer.settings + } + } + + currentList.add(SettingContainer.Single(setting)) + } + final override fun toJson() = JsonObject().apply { fun JsonObject.addSettings(settings: Collection) { @@ -90,7 +161,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { try { add(container.name, grouped) } catch(e: Throwable) { - logError("Failed to serialize ${container.type}: ${container.name} in ${this::class.simpleName}", e) + logError("Failed to serialize ${container.typeStr}: ${container.name} in ${this::class.simpleName}", e) } } } @@ -318,36 +389,39 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { fun settingBlock(settingBlock: T, block: (T.() -> Unit)? = null) = settingBlock.apply { block?.invoke(this) } + private enum class ContainerType { Tab, Group } + private data class ContainerSpec(val type: ContainerType, val name: String) + @Target(AnnotationTarget.PROPERTY) @Retention(AnnotationRetention.RUNTIME) - annotation class Tab(vararg val tab: String) + annotation class Tab(vararg val tabs: String) @Target(AnnotationTarget.PROPERTY) @Retention(AnnotationRetention.RUNTIME) - annotation class Group(vararg val group: String) + annotation class Group(vararg val groups: String) sealed interface SettingContainer { class Single(val setting: Setting<*, *>) : SettingContainer sealed class Multiple( val name: String, - val settings: Collection + val settings: MutableList ) : SettingContainer { - abstract val type: String + abstract val typeStr: String } class Tab( name: String, - settings: Collection + settings: MutableList ) : Multiple(name, settings) { - override val type = "tab" + override val typeStr = "tab" } class Group( name: String, - settings: Collection + settings: MutableList ) : Multiple(name, settings) { - override val type = "group" + override val typeStr = "group" } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/ConfigCategory.kt b/src/main/kotlin/com/lambda/config/ConfigCategory.kt index d4f188a3c..a5a66f68e 100644 --- a/src/main/kotlin/com/lambda/config/ConfigCategory.kt +++ b/src/main/kotlin/com/lambda/config/ConfigCategory.kt @@ -26,30 +26,28 @@ import com.lambda.Lambda.LOG import com.lambda.Lambda.gson import com.lambda.config.ConfigLoader.configByName import com.lambda.config.ConfigLoader.configCategories +import com.lambda.config.categories.AutomationCategory import com.lambda.config.categories.ModuleCategory import com.lambda.config.migration.ConfigMigrations import com.lambda.core.Loadable import com.lambda.event.events.ClientEvent import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe +import com.lambda.interaction.BaritoneHandler.primary import com.lambda.threading.runIO import com.lambda.util.CommunicationUtils.info import com.lambda.util.CommunicationUtils.logError import com.lambda.util.FileUtils.createIfNotExists import com.lambda.util.FileUtils.ifExists import com.lambda.util.FileUtils.ifNotExists +import com.lambda.util.FolderRegistry import com.lambda.util.StringUtils.capitalize import java.io.File import kotlin.concurrent.fixedRateTimer -import kotlin.reflect.KClass -import kotlin.reflect.KClassifier -import kotlin.reflect.full.declaredMemberProperties -import kotlin.reflect.jvm.isAccessible import kotlin.time.Duration.Companion.minutes - /** * Represents a compound of [Config] objects whose [SettingCore]s - * are saved into a single [ConfigCategory] file ([ConfigCategory.primary]). + * are saved into a single [ConfigCategory] file ([ConfigCategory.primaryFile]). * * This class also handles the concurrent loading and saving of persisted data on the `Dispatchers.IO` thread. * Each configuration will be loaded concurrently, @@ -61,34 +59,19 @@ import kotlin.time.Duration.Companion.minutes * @property primary The primary file where the configuration is saved. * @property configs A set of [Config] objects that this configuration manages. */ -abstract class ConfigCategory : Jsonable, Loadable { - abstract val configName: String - abstract val primary: File +abstract class ConfigCategory( + val configName: String +) : Jsonable, Loadable { + val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() + private val backup = File("${primaryFile.parent}/${primaryFile.nameWithoutExtension}-backup.${primaryFile.extension}") override val priority = 1 val configs = mutableSetOf() - private val backup: File - get() = File("${primary.parent}/${primary.nameWithoutExtension}-backup.${primary.extension}") final override fun load(): String { if (configCategories.any { it.configName == configName }) throw IllegalStateException("Configuration with name $configName already exists") - configs.forEach { config -> - val settings = config::class.declaredMemberProperties.mapNotNull { prop -> - val returnType = prop.returnType - val classifier = returnType.classifier ?: return@mapNotNull null - - when { - classifier.isOf>() || classifier.isOf() -> { - prop.isAccessible = true - prop to prop.getter.call(config) // returns the Setting instance - } - else -> null - } - } - } - fixedRateTimer( daemon = true, name = "Scheduler-config-${configName}", @@ -103,9 +86,6 @@ abstract class ConfigCategory : Jsonable, Loadable { return super.load() } - private inline fun KClassifier.isOf() = - this == T::class || (this is KClass<*> && T::class.java.isAssignableFrom(java)) - fun tryLoadFromFile() = runIO { internalTryLoad() } fun trySaveToFile(logToChat: Boolean = false) = runIO { internalTrySave(logToChat) } @@ -134,7 +114,7 @@ abstract class ConfigCategory : Jsonable, Loadable { } protected open fun internalTryLoad() { - loadFromFile(primary) + loadFromFile(primaryFile) .onSuccess { val message = "${configName.capitalize()} config loaded." LOG.info(message) @@ -191,7 +171,7 @@ abstract class ConfigCategory : Jsonable, Loadable { } private fun saveToFile() = runCatching { - primary.createIfNotExists() + primaryFile.createIfNotExists() .let { it.writeText(gson.toJson(toJson())) it.copyTo(backup, true) diff --git a/src/main/kotlin/com/lambda/config/Setting.kt b/src/main/kotlin/com/lambda/config/Setting.kt index 06f2cdee0..70c152c4b 100644 --- a/src/main/kotlin/com/lambda/config/Setting.kt +++ b/src/main/kotlin/com/lambda/config/Setting.kt @@ -109,6 +109,10 @@ class Setting, R>( val isModified get() = value != core.defaultValue + init { + config.register(this) + } + operator fun getValue(thisRef: Any?, property: KProperty<*>) = core.value operator fun setValue(thisRef: Any?, property: KProperty<*>, value: R) { core.value = value diff --git a/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt b/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt index f94590d44..bc334e2bf 100644 --- a/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt @@ -18,10 +18,5 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory -import com.lambda.util.FolderRegistry -import java.io.File -object AutomationCategory : ConfigCategory() { - override val configName = "automation" - override val primary: File = FolderRegistry.config.resolve("${configName}.json").toFile() -} \ No newline at end of file +object AutomationCategory : ConfigCategory("automation") \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/FontCategory.kt b/src/main/kotlin/com/lambda/config/categories/FontCategory.kt index 6024bb0c0..b94643318 100644 --- a/src/main/kotlin/com/lambda/config/categories/FontCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/FontCategory.kt @@ -18,10 +18,5 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory -import com.lambda.util.FolderRegistry -import java.io.File -object FontCategory : ConfigCategory() { - override val configName = "font" - override val primary: File = FolderRegistry.config.resolve("${configName}.json").toFile() -} \ No newline at end of file +object FontCategory : ConfigCategory("font") \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt b/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt index 03a46f3dc..77de146f7 100644 --- a/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt @@ -18,10 +18,5 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory -import com.lambda.util.FolderRegistry -import java.io.File -object FriendCategory : ConfigCategory() { - override val configName get() = "friends" - override val primary: File = FolderRegistry.config.resolve("$configName.json").toFile() -} +object FriendCategory : ConfigCategory("friends") diff --git a/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt b/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt index 7f7348bec..a690752a2 100644 --- a/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt @@ -18,10 +18,5 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory -import com.lambda.util.FolderRegistry -import java.io.File -object GuiCategory : ConfigCategory() { - override val configName get() = "gui" - override val primary: File = FolderRegistry.config.resolve("$configName.json").toFile() -} +object GuiCategory : ConfigCategory("gui") diff --git a/src/main/kotlin/com/lambda/config/categories/HudCategory.kt b/src/main/kotlin/com/lambda/config/categories/HudCategory.kt index aecd1fac5..92f8bd4bd 100644 --- a/src/main/kotlin/com/lambda/config/categories/HudCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/HudCategory.kt @@ -18,10 +18,5 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory -import com.lambda.util.FolderRegistry -import java.io.File -object HudCategory : ConfigCategory() { - override val configName get() = "hud" - override val primary: File = FolderRegistry.config.resolve("$configName.json").toFile() -} +object HudCategory : ConfigCategory("hud") \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt b/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt index 036ae3113..797c80898 100644 --- a/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt @@ -18,10 +18,5 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory -import com.lambda.util.FolderRegistry -import java.io.File -object LambdaCategory : ConfigCategory() { - override val configName get() = "lambda" - override val primary: File = FolderRegistry.config.resolve("$configName.json").toFile() -} +object LambdaCategory : ConfigCategory("lambda") \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt b/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt index e4ba65b1b..1d33f2165 100644 --- a/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt @@ -18,11 +18,6 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory -import com.lambda.config.categories.ModuleCategory.configName -import com.lambda.config.categories.ModuleCategory.primary -import com.lambda.util.FolderRegistry -import java.io.File - /** * The [ModuleCategory] object represents the configuration file for the [Module]s. @@ -32,7 +27,4 @@ import java.io.File * @property configName The name of the configuration. * @property primary The primary file where the configuration is saved. */ -object ModuleCategory : ConfigCategory() { - override val configName get() = "modules" - override val primary: File = FolderRegistry.config.resolve("$configName.json").toFile() -} +object ModuleCategory : ConfigCategory("modules") \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt b/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt index f5c2189d7..20c833bae 100644 --- a/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt @@ -18,10 +18,5 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory -import com.lambda.util.FolderRegistry -import java.io.File -object SecretsCategory : ConfigCategory() { - override val configName get() = "secrets" - override val primary: File = FolderRegistry.config.resolve("$configName.json").toFile() -} +object SecretsCategory : ConfigCategory("secrets") \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt b/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt index eb8eca17c..532cf0a41 100644 --- a/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt @@ -19,18 +19,13 @@ package com.lambda.config.categories import com.google.gson.JsonParser import com.lambda.config.ConfigCategory -import com.lambda.config.UserAutomationConfig +import com.lambda.config.automation.UserAutomationConfig import com.lambda.module.ModuleRegistry.moduleNameMap import com.lambda.util.FileUtils.ifExists -import com.lambda.util.FolderRegistry -import java.io.File - -object UserAutomationCategory : ConfigCategory() { - override val configName = "custom-automation" - override val primary: File = FolderRegistry.config.resolve("${configName}.json").toFile() +object UserAutomationCategory : ConfigCategory("custom-automation") { override fun internalTryLoad() { - primary.ifExists { + primaryFile.ifExists { JsonParser.parseReader(it.reader()).asJsonObject.entrySet().forEach { (name, _) -> if (configs.any { config -> config.name == name }) return@forEach UserAutomationConfig(name) diff --git a/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt b/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt index 24b83bb24..cc96d3f0a 100644 --- a/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt @@ -19,7 +19,6 @@ package com.lambda.config.groups import com.lambda.config.Config import com.lambda.config.Config.Group -import com.lambda.config.SettingBlock import com.lambda.config.groups.BuildConfig.PointSelection import kotlin.math.max diff --git a/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt b/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt index 7806ee7ea..b5116c605 100644 --- a/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt @@ -21,7 +21,6 @@ import com.lambda.config.Config import com.lambda.config.Config.Group import com.lambda.config.SettingBlock import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.util.NamedEnum import com.lambda.util.item.ItemUtils class InventorySettings(override val c: Config) : SettingBlock, InventoryConfig { diff --git a/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt b/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt index a0774263c..79ff06424 100644 --- a/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt @@ -20,7 +20,6 @@ package com.lambda.config.groups import com.lambda.config.Config import com.lambda.config.Config.Group import com.lambda.config.SettingBlock -import com.lambda.util.NamedEnum import java.awt.Color class ScreenLineSettings(override val c: Config) : SettingBlock, LineConfig { diff --git a/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt b/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt index 4a93d398b..92f26b106 100644 --- a/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt @@ -20,7 +20,6 @@ package com.lambda.config.groups import com.lambda.config.Config import com.lambda.config.Config.Group import com.lambda.config.SettingBlock -import com.lambda.util.NamedEnum import java.awt.Color class ScreenTextSettings(override val c: Config) : SettingBlock, TextConfig { diff --git a/src/main/kotlin/com/lambda/config/groups/WorldTextSettings.kt b/src/main/kotlin/com/lambda/config/groups/WorldTextSettings.kt index 9af1cf7f9..ab99e4be5 100644 --- a/src/main/kotlin/com/lambda/config/groups/WorldTextSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/WorldTextSettings.kt @@ -20,7 +20,6 @@ package com.lambda.config.groups import com.lambda.config.Config import com.lambda.config.Config.Group import com.lambda.config.SettingBlock -import com.lambda.util.NamedEnum import java.awt.Color class WorldTextSettings(override val c: Config) : SettingBlock, TextConfig { From 6c5e74dc8e4e94dec2ad97a8757052919753b6ce Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Mon, 4 May 2026 17:38:10 +0100 Subject: [PATCH 08/40] fix syntax errors in modules and first pass of changes for new system --- src/main/kotlin/com/lambda/config/Codec.kt | 2 - src/main/kotlin/com/lambda/config/Config.kt | 153 +++++++++++++----- .../kotlin/com/lambda/config/ConfigEditor.kt | 77 +++++++-- .../kotlin/com/lambda/config/ConfigLoader.kt | 19 ++- .../kotlin/com/lambda/config/SettingBlock.kt | 22 --- .../config/automation/AutomationConfig.kt | 1 + .../automation/IMutableAutomationConfig.kt | 4 +- .../com/lambda/config/codecs/ColorCodec.kt | 1 - .../com/lambda/config/codecs/KeyCodeCodec.kt | 1 - .../com/lambda/config/codecs/UUIDCodec.kt | 1 - .../com/lambda/config/groups/BreakSettings.kt | 4 +- .../com/lambda/config/groups/EatSettings.kt | 1 - .../config/groups/EntityColorSettings.kt | 1 - .../config/groups/EntitySelectionSettings.kt | 1 - .../lambda/config/groups/FormatterConfig.kt | 2 +- .../lambda/config/groups/FormatterSettings.kt | 1 - .../lambda/config/groups/HotbarSettings.kt | 3 +- .../lambda/config/groups/InteractSettings.kt | 4 +- .../lambda/config/groups/OutlineSettings.kt | 1 - .../config/groups/ScreenLineSettings.kt | 1 + .../config/groups/ScreenTextSettings.kt | 7 +- .../lambda/config/groups/TargetingSettings.kt | 1 - .../lambda/config/groups/WorldLineSettings.kt | 29 ++-- .../lambda/config/settings/NumericSetting.kt | 2 +- .../lambda/config/settings/StringSetting.kt | 2 +- .../settings/collections/CollectionSetting.kt | 2 +- .../graphics/mc/renderer/ChunkedRenderer.kt | 6 +- src/main/kotlin/com/lambda/gui/MenuBar.kt | 2 +- .../lambda/gui/components/SettingsWidget.kt | 138 ++++++++++------ .../processing/ProcessorRegistry.kt | 2 +- .../com/lambda/module/hud/Coordinates.kt | 1 + .../lambda/module/modules/chat/AntiSpam.kt | 55 +++---- .../module/modules/chat/ChatTimestamp.kt | 12 +- .../lambda/module/modules/chat/CustomChat.kt | 1 - .../lambda/module/modules/chat/FancyChat.kt | 4 +- .../module/modules/chat/FriendHighlight.kt | 15 +- .../module/modules/client/AutoUpdater.kt | 1 + .../lambda/module/modules/client/Client.kt | 32 ++-- .../module/modules/client/StyleEditor.kt | 60 ------- .../lambda/module/modules/combat/AutoArmor.kt | 4 +- .../lambda/module/modules/combat/AutoTotem.kt | 30 ++-- .../lambda/module/modules/combat/Criticals.kt | 4 +- .../module/modules/combat/CrystalAura.kt | 86 +++++----- .../lambda/module/modules/combat/KillAura.kt | 32 ++-- .../module/modules/combat/PlayerTrap.kt | 4 +- .../lambda/module/modules/combat/Surround.kt | 4 +- .../module/modules/debug/RotationTest.kt | 5 +- .../modules/debug/SettingsTestModule.kt | 38 ++--- .../lambda/module/modules/debug/SilentSwap.kt | 6 +- .../lambda/module/modules/debug/StateInfo.kt | 1 + .../module/modules/movement/AutoSpiral.kt | 2 +- .../module/modules/movement/BetterFirework.kt | 3 +- .../modules/movement/ElytraAltitudeControl.kt | 55 +++---- .../module/modules/movement/ElytraFly.kt | 2 +- .../lambda/module/modules/movement/Speed.kt | 27 ++-- .../module/modules/movement/TargetStrafe.kt | 5 +- .../module/modules/network/PacketLimiter.kt | 2 +- .../lambda/module/modules/player/AntiAim.kt | 58 +++---- .../lambda/module/modules/player/AutoEat.kt | 4 +- .../lambda/module/modules/player/FastBreak.kt | 4 +- .../lambda/module/modules/player/Interact.kt | 7 +- .../module/modules/player/InventoryMove.kt | 4 +- .../module/modules/player/InventoryTweaks.kt | 4 +- .../module/modules/player/PacketMine.kt | 44 +++-- .../lambda/module/modules/player/Replay.kt | 6 +- .../module/modules/player/RotationLock.kt | 34 ++-- .../module/modules/player/StackReplenish.kt | 4 +- .../lambda/module/modules/player/ToolSaver.kt | 4 +- .../module/modules/render/BlockOutline.kt | 34 ++-- .../module/modules/render/CameraTweaks.kt | 7 +- .../module/modules/render/ContainerPreview.kt | 32 ++-- .../com/lambda/module/modules/render/ESP.kt | 57 +++---- .../lambda/module/modules/render/Freecam.kt | 6 +- .../module/modules/render/LightLevels.kt | 25 ++- .../lambda/module/modules/render/Nametags.kt | 105 ++++++------ .../lambda/module/modules/render/NoRender.kt | 89 +++++----- .../lambda/module/modules/render/RadiusESP.kt | 42 +++-- .../lambda/module/modules/render/Search.kt | 76 +++++---- .../lambda/module/modules/render/Tracers.kt | 35 ++-- .../lambda/module/modules/render/ViewModel.kt | 138 ++++++++-------- .../lambda/module/modules/render/Weather.kt | 17 +- .../module/modules/render/WorldColors.kt | 31 +--- .../lambda/module/modules/world/AirPlace.kt | 22 ++- .../lambda/module/modules/world/AutoPortal.kt | 58 +++---- .../module/modules/world/AutoVillagerCycle.kt | 30 ++-- .../module/modules/world/HighwayTools.kt | 2 +- .../com/lambda/module/modules/world/Nuker.kt | 2 +- .../lambda/module/modules/world/Scaffold.kt | 6 +- .../lambda/module/modules/world/StashMover.kt | 98 +++++------ .../kotlin/com/lambda/task/tasks/BuildTask.kt | 2 +- .../kotlin/com/lambda/util/EntityUtils.kt | 2 +- .../kotlin/com/lambda/util/FormattingUtils.kt | 3 - .../com/lambda/util/player/RotationUtils.kt | 3 +- .../kotlin/com/lambda/util/text/TextDsl.kt | 4 +- 94 files changed, 1030 insertions(+), 1051 deletions(-) delete mode 100644 src/main/kotlin/com/lambda/config/SettingBlock.kt delete mode 100644 src/main/kotlin/com/lambda/module/modules/client/StyleEditor.kt diff --git a/src/main/kotlin/com/lambda/config/Codec.kt b/src/main/kotlin/com/lambda/config/Codec.kt index 7b0eb7d79..5f0971aaf 100644 --- a/src/main/kotlin/com/lambda/config/Codec.kt +++ b/src/main/kotlin/com/lambda/config/Codec.kt @@ -19,9 +19,7 @@ package com.lambda.config import com.google.gson.JsonDeserializer import com.google.gson.JsonSerializer -import com.sun.org.apache.bcel.internal.classfile.JavaClass import java.lang.reflect.Type -import kotlin.jvm.java interface Stringifiable { fun stringify(value: T): String } diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index ffd854f6b..fe5aee31d 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -20,7 +20,6 @@ package com.lambda.config import com.google.gson.JsonElement import com.google.gson.JsonObject import com.google.gson.reflect.TypeToken -import com.lambda.Lambda.LOG import com.lambda.config.ConfigLoader.configs import com.lambda.config.settings.CharSetting import com.lambda.config.settings.FunctionSetting @@ -56,9 +55,14 @@ import java.awt.Color import kotlin.jvm.java import kotlin.reflect.KClass import kotlin.reflect.KProperty +import kotlin.reflect.KProperty1 import kotlin.reflect.full.declaredMemberProperties +import kotlin.reflect.jvm.isAccessible import kotlin.reflect.jvm.javaField +@DslMarker +private annotation class SettingDsl + /** * Represents a set of [SettingCore]s that are associated with the [name] of the [Config]. * The settings are managed by this [Config] and are saved and loaded as part of the [ConfigCategory]. @@ -85,17 +89,15 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { * - If it has no backing field (computed property), skip it. */ private fun enqueueProperties(klass: KClass<*>, outerPath: List) { - klass.declaredMemberProperties.forEach { property -> - val path = outerPath + buildPathFromAnnotations(property) - val fieldType = property.javaField?.type - when { - fieldType == null -> {} - SettingBlock::class.java.isAssignableFrom(fieldType) -> - enqueueProperties(fieldType.kotlin, path) - Setting::class.java.isAssignableFrom(fieldType) -> - registrationQueue.addLast(path) + forEachSettingProperty( + klass, + onSetting = { setting -> + registrationQueue.addLast(outerPath + buildPathFromAnnotations(setting)) + }, + onSettingBlock = { settingBlock, blockClass -> + enqueueProperties(blockClass, outerPath + buildPathFromAnnotations(settingBlock)) } - } + ) } /** @@ -119,16 +121,23 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { * the container hierarchy, coalescing containers with the same name and type. */ fun register(setting: Setting<*, *>) { - val path = registrationQueue.removeFirst() + val path = try { + registrationQueue.removeFirst() + } catch(_: NoSuchElementException) { + logError("Setting registered from an unknown location; layer path was not queued before setting initialization") + return + } var currentList = settingContainers path.forEach { spec -> - val existing = currentList.firstOrNull { - it is SettingContainer.Multiple && - it.name == spec.name && - ((spec.type == ContainerType.Tab && it is SettingContainer.Tab) || - (spec.type == ContainerType.Group && it is SettingContainer.Group)) - } as? SettingContainer.Multiple + val existing = currentList + .asSequence() + .filterIsInstance() + .filter { it.name == spec.name } + .firstOrNull { + (spec.type == ContainerType.Tab && it is SettingContainer.Tab) || + (spec.type == ContainerType.Group && it is SettingContainer.Group) + } if (existing != null) currentList = existing.settings else { @@ -184,17 +193,13 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { } catch (e: Throwable) { logError("Failed to deserialize setting '${container.setting.name}'", e) } - } else { - LOG.warn("No saved value for setting '${container.setting.name}' in ${this::class.simpleName}") - } + } else logError("No saved value for setting '${container.setting.name}' in ${this::class.simpleName}") } is SettingContainer.Multiple -> { val nestedObj = obj[container.name]?.asJsonObject if (nestedObj != null) { loadFromObject(nestedObj, container.settings) - } else { - LOG.debug("No data for group/tab '${container.name}' in ${this::class.simpleName}") - } + } else logError("No data for group/tab '${container.name}' in ${this::class.simpleName}") } } } @@ -203,6 +208,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { loadFromObject(rootObj, settingContainers) } + @SettingDsl fun setting( name: String, defaultValue: Boolean, @@ -210,6 +216,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true }, ) = Setting(name, description, BooleanSetting(defaultValue), this, visibility) + @SettingDsl inline fun > setting( name: String, defaultValue: T, @@ -217,6 +224,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { noinline visibility: () -> Boolean = { true }, ) = Setting(name, description,EnumSetting(defaultValue), this, visibility) + @SettingDsl fun setting( name: String, defaultValue: Char, @@ -224,6 +232,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true }, ) = Setting(name, description, CharSetting(defaultValue), this, visibility) + @SettingDsl fun setting( name: String, defaultValue: String, @@ -233,6 +242,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true }, ) = Setting(name, description, StringSetting(defaultValue, multiline, flags), this, visibility) + @SettingDsl @JvmName("collectionSetting1") fun setting( name: String, @@ -242,6 +252,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true }, ) = Setting(name, description, BlockCollectionSetting(immutableCollection, defaultValue.toMutableList()), this, visibility) + @SettingDsl @JvmName("collectionSetting2") fun setting( name: String, @@ -251,6 +262,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true }, ) = Setting(name, description, ItemCollectionSetting(immutableCollection, defaultValue.toMutableList()), this, visibility) + @SettingDsl @JvmName("collectionSetting3") inline fun setting( name: String, @@ -269,6 +281,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility ) + @SettingDsl // ToDo: Actually implement maps inline fun setting( name: String, @@ -286,6 +299,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility ) + @SettingDsl fun setting( name: String, defaultValue: Double, @@ -296,6 +310,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true }, ) = Setting(name, description, DoubleSetting(defaultValue, range, step, unit), this, visibility) + @SettingDsl fun setting( name: String, defaultValue: Float, @@ -306,6 +321,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true }, ) = Setting(name, description, FloatSetting(defaultValue, range, step, unit), this, visibility) + @SettingDsl fun setting( name: String, defaultValue: Int, @@ -316,6 +332,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true }, ) = Setting(name, description, IntegerSetting(defaultValue, range, step, unit), this, visibility) + @SettingDsl fun setting( name: String, defaultValue: Long, @@ -326,6 +343,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true }, ) = Setting(name, description, LongSetting(defaultValue, range, step, unit), this, visibility) + @SettingDsl fun setting( name: String, defaultValue: Bind, @@ -335,6 +353,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true }, ) = Setting(name, description, KeybindSetting(defaultValue, this as? Muteable, alwaysListening, screenCheck), this, visibility) + @SettingDsl fun setting( name: String, defaultValue: KeyCode, @@ -344,6 +363,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true }, ) = Setting(name, description, KeybindSetting(defaultValue, this as? Muteable, alwaysListening, screenCheck), this, visibility) + @SettingDsl fun setting( name: String, defaultValue: Color, @@ -351,6 +371,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true }, ) = Setting(name, description, ColorSetting(defaultValue), this, visibility) + @SettingDsl fun setting( name: String, defaultValue: Vec3d, @@ -358,6 +379,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true }, ) = Setting(name, description, Vec3dSetting(defaultValue), this, visibility) + @SettingDsl fun setting( name: String, defaultValue: BlockPos.Mutable, @@ -365,6 +387,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true }, ) = Setting(name, description, BlockPosSetting(defaultValue), this, visibility) + @SettingDsl fun setting( name: String, defaultValue: BlockPos, @@ -372,6 +395,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true }, ) = Setting(name, description, BlockPosSetting(defaultValue), this, visibility) + @SettingDsl fun setting( name: String, defaultValue: Block, @@ -379,6 +403,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true }, ) = Setting(name, description, BlockSetting(defaultValue), this, visibility) + @SettingDsl fun setting( name: String, defaultValue: () -> Unit, @@ -386,27 +411,37 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { visibility: () -> Boolean = { true } ) = Setting(name, description, FunctionSetting(defaultValue), this, visibility) - fun settingBlock(settingBlock: T, block: (T.() -> Unit)? = null) = - settingBlock.apply { block?.invoke(this) } + @SettingDsl + fun settingBlock(settingBlock: T, visibility: (() -> Boolean)? = null, block: (T.() -> Unit)? = null) = + settingBlock + .apply { block?.invoke(this) } + .also { if (visibility != null) forEachSetting(settingBlock) { it.visibility = { it.visibility() && visibility() } } } + + /** + * Collects all [SettingBlock] instances declared as fields on this [Config]. + */ + fun collectSettingBlocks(): List { + val result = mutableListOf() + forEachSettingProperty(this::class, + onSettingBlock = { property, _ -> + val field = property.javaField ?: return@forEachSettingProperty + field.isAccessible = true + (field.get(this) as? SettingBlock)?.let { result.add(it) } + } + ) + return result + } private enum class ContainerType { Tab, Group } private data class ContainerSpec(val type: ContainerType, val name: String) - @Target(AnnotationTarget.PROPERTY) - @Retention(AnnotationRetention.RUNTIME) - annotation class Tab(vararg val tabs: String) - - @Target(AnnotationTarget.PROPERTY) - @Retention(AnnotationRetention.RUNTIME) - annotation class Group(vararg val groups: String) - sealed interface SettingContainer { class Single(val setting: Setting<*, *>) : SettingContainer sealed class Multiple( - val name: String, + override val name: String, val settings: MutableList - ) : SettingContainer { + ) : SettingContainer, Nameable { abstract val typeStr: String } @@ -424,4 +459,50 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { override val typeStr = "group" } } + + companion object { + @Suppress("unchecked_cast") + fun forEachSetting(instance: Any, block: (Setting<*, *>) -> Unit) { + instance::class.declaredMemberProperties.forEach { property -> + property.isAccessible = true + val fieldType = property.javaField?.type ?: return@forEach + when { + Setting::class.java.isAssignableFrom(fieldType) -> + block((property as KProperty1).get(instance) as Setting<*, *>) + SettingBlock::class.java.isAssignableFrom(fieldType) -> + forEachSetting((property as KProperty1).get(instance) as SettingBlock, block) + } + } + } + + /** + * Iterates over declared properties of [klass], invoking [onSetting] for fields + * assignable to [Setting] and [onSettingBlock] for fields assignable to [SettingBlock]. + */ + fun forEachSettingProperty( + klass: KClass<*>, + onSetting: (property: KProperty<*>) -> Unit = {}, + onSettingBlock: (property: KProperty<*>, blockClass: KClass<*>) -> Unit = { _, _ -> } + ) { + klass.declaredMemberProperties.forEach { property -> + val fieldType = property.javaField?.type ?: return@forEach + when { + Setting::class.java.isAssignableFrom(fieldType) -> onSetting(property) + SettingBlock::class.java.isAssignableFrom(fieldType) -> onSettingBlock(property, fieldType.kotlin) + } + } + } + } +} + +@Target(AnnotationTarget.PROPERTY) +@Retention(AnnotationRetention.RUNTIME) +annotation class Tab(vararg val tabs: String) + +@Target(AnnotationTarget.PROPERTY) +@Retention(AnnotationRetention.RUNTIME) +annotation class Group(vararg val groups: String) + +interface SettingBlock { + val c: Config } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/ConfigEditor.kt b/src/main/kotlin/com/lambda/config/ConfigEditor.kt index c4dc4590e..361d63247 100644 --- a/src/main/kotlin/com/lambda/config/ConfigEditor.kt +++ b/src/main/kotlin/com/lambda/config/ConfigEditor.kt @@ -19,8 +19,10 @@ package com.lambda.config +import com.lambda.config.Config.SettingContainer import kotlin.reflect.KProperty0 import kotlin.reflect.jvm.isAccessible +import kotlin.reflect.jvm.javaField @DslMarker annotation class SettingEditorDsl @@ -82,9 +84,13 @@ class ConfigEditor(val c: T) { edits: TypedEditBuilder.(SettingCore) -> Unit ) = TypedEditBuilder(this, settings.map { it.setting() }).edits(other.settingCore()) + /** + * Recursively removes matching [Setting]s from the [Config.settingContainers] tree. + * After removal, any [SettingContainer.Multiple] (group/tab) left empty is also pruned. + */ @SettingEditorDsl fun hide(settings: Collection>) { - c.settingContainers.removeAll(settings) + removeFromContainers(c.settingContainers, settings.toSet()) } @SettingEditorDsl @@ -92,21 +98,27 @@ class ConfigEditor(val c: T) { hide(settings.map { it.setting() }) @SettingEditorDsl - fun hideGroup(settingGroup: SettingBlock) = hide(settingGroup.settings) + fun hideBlock(settingGroup: SettingBlock) = hide(settingGroup.collectSettings()) @SettingEditorDsl - fun hideGroupExcept(settingGroup: SettingBlock, vararg except: KProperty0) { - val exceptSettings = except.map { it.setting() }.toSet() - hide(settingGroup.settings.filter { it !in exceptSettings }) + fun hideBlockExcept(settingGroup: SettingBlock, vararg except: KProperty0) { + val exceptSettings = except.map { it.setting() } + hide(settingGroup.collectSettings().filter { it !in exceptSettings }) } @SettingEditorDsl - fun hideGroups(vararg settingGroups: SettingBlock) = - settingGroups.forEach { hide(it.settings) } + fun hideBlocks(vararg settingGroups: SettingBlock) = + settingGroups.forEach { hide(it.collectSettings()) } @SettingEditorDsl - fun hideAllGroupsExcept(vararg except: SettingBlock) = - hideGroups(*(c.settingGroups - except.toSet()).toTypedArray()) + fun hideAllBlocksExcept(vararg except: SettingBlock) { + val toHide = c.collectSettingBlocks().filter { it !in except } + toHide.forEach { hide(it.collectSettings()) } + } + + @SettingEditorDsl + fun SettingBlock.forEachSetting(block: (Setting<*, *>) -> Unit) = + Config.forEachSetting(this, block) open class BasicEditBuilder(val c: ConfigEditor<*>, open val settings: Collection>) { @SettingEditorDsl @@ -131,4 +143,51 @@ class ConfigEditor(val c: T) { it.core.value = value } } + + /** + * Recursively removes [SettingContainer.Single] entries whose [Setting] is in [toRemove], + * and prunes any [SettingContainer.Multiple] (group/tab) left empty after removal. + */ + private fun removeFromContainers( + containers: MutableList, + toRemove: Set> + ) { + val iterator = containers.iterator() + while (iterator.hasNext()) { + when (val container = iterator.next()) { + is SettingContainer.Single -> { + if (container.setting in toRemove) iterator.remove() + } + is SettingContainer.Multiple -> { + removeFromContainers(container.settings, toRemove) + if (container.settings.isEmpty()) iterator.remove() + } + } + } + } + + /** + * Collects all [Setting] instances from a [SettingBlock] via reflection, + * recursing into nested [SettingBlock] fields. + */ + private fun SettingBlock.collectSettings(): List> { + val result = mutableListOf>() + collectSettingsRecursive(this, result) + return result + } + + private fun collectSettingsRecursive(instance: Any, result: MutableList>) { + Config.forEachSettingProperty(instance::class, + onSetting = { property -> + val field = property.javaField ?: return@forEachSettingProperty + field.isAccessible = true + (field.get(instance) as? Setting<*, *>)?.let { result.add(it) } + }, + onSettingBlock = { property, _ -> + val field = property.javaField ?: return@forEachSettingProperty + field.isAccessible = true + field.get(instance)?.let { collectSettingsRecursive(it, result) } + } + ) + } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/ConfigLoader.kt b/src/main/kotlin/com/lambda/config/ConfigLoader.kt index da5e68ca6..70851fdb2 100644 --- a/src/main/kotlin/com/lambda/config/ConfigLoader.kt +++ b/src/main/kotlin/com/lambda/config/ConfigLoader.kt @@ -23,8 +23,6 @@ object ConfigLoader: Loadable { val configCategories = mutableSetOf() val configs: Set get() = configCategories.flatMapTo(mutableSetOf()) { it.configs } - val settings: List> - get() = configs.flatMapTo(mutableListOf()) { it.settingContainers } override fun load(): String { configCategories.forEach { @@ -39,6 +37,19 @@ object ConfigLoader: Loadable { fun configByCommandName(name: String) = configs.find { it.commandName == name } - fun settingByCommandName(config: Config, tab: String?, group: String?, name: String) = - config.settingContainers.find { it.commandName == name } + fun settingByCommandName(name: String, config: Config, vararg layers: String): Setting<*, *>? { + var settingContainers = config.settingContainers.asSequence() + layers.forEach { layer -> + settingContainers = settingContainers + .filterIsInstance() + .find { container -> + container.commandName == layer + }?.settings + ?.asSequence() ?: return null + } + return settingContainers + .filterIsInstance() + .find { it.setting.commandName == name } + ?.setting + } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/SettingBlock.kt b/src/main/kotlin/com/lambda/config/SettingBlock.kt deleted file mode 100644 index 1766e23ba..000000000 --- a/src/main/kotlin/com/lambda/config/SettingBlock.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config - -interface SettingBlock { - val c: Config -} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt index 98d5c85fe..389b5fcd8 100644 --- a/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt @@ -19,6 +19,7 @@ package com.lambda.config.automation import com.lambda.config.Config import com.lambda.config.ConfigCategory +import com.lambda.config.Tab import com.lambda.config.categories.AutomationCategory import com.lambda.config.groups.BreakSettings import com.lambda.config.groups.BuildSettings diff --git a/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt index 3e8371151..2f878fa7d 100644 --- a/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt @@ -19,14 +19,14 @@ package com.lambda.config.automation import com.lambda.config.Setting import com.lambda.config.SettingCore +import com.lambda.config.groups.BreakConfig import com.lambda.config.groups.BuildConfig import com.lambda.config.groups.EatConfig -import com.lambda.context.Automated -import com.lambda.config.groups.BreakConfig import com.lambda.config.groups.HotbarConfig import com.lambda.config.groups.InteractConfig import com.lambda.config.groups.InventoryConfig import com.lambda.config.groups.RotationConfig +import com.lambda.context.Automated interface IMutableAutomationConfig : Automated { var defaultAutomationConfig: AutomationConfig diff --git a/src/main/kotlin/com/lambda/config/codecs/ColorCodec.kt b/src/main/kotlin/com/lambda/config/codecs/ColorCodec.kt index 9e6419fca..dbe57b1ae 100644 --- a/src/main/kotlin/com/lambda/config/codecs/ColorCodec.kt +++ b/src/main/kotlin/com/lambda/config/codecs/ColorCodec.kt @@ -24,7 +24,6 @@ import com.google.gson.JsonPrimitive import com.google.gson.JsonSerializationContext import com.lambda.config.Codec import com.lambda.config.Stringifiable -import net.minecraft.world.attribute.EnvironmentAttributeModifier.override import java.awt.Color import java.lang.reflect.Type diff --git a/src/main/kotlin/com/lambda/config/codecs/KeyCodeCodec.kt b/src/main/kotlin/com/lambda/config/codecs/KeyCodeCodec.kt index f661d4e17..4c8292cc2 100644 --- a/src/main/kotlin/com/lambda/config/codecs/KeyCodeCodec.kt +++ b/src/main/kotlin/com/lambda/config/codecs/KeyCodeCodec.kt @@ -25,7 +25,6 @@ import com.google.gson.JsonPrimitive import com.google.gson.JsonSerializationContext import com.lambda.config.Codec import com.lambda.util.KeyCode -import net.minecraft.world.attribute.EnvironmentAttributeModifier.override import java.lang.reflect.Type @Suppress("unused") diff --git a/src/main/kotlin/com/lambda/config/codecs/UUIDCodec.kt b/src/main/kotlin/com/lambda/config/codecs/UUIDCodec.kt index 258b79a0c..f7e0f4abd 100644 --- a/src/main/kotlin/com/lambda/config/codecs/UUIDCodec.kt +++ b/src/main/kotlin/com/lambda/config/codecs/UUIDCodec.kt @@ -23,7 +23,6 @@ import com.google.gson.JsonParseException import com.google.gson.JsonSerializationContext import com.lambda.config.Codec import com.lambda.config.Stringifiable -import net.minecraft.world.attribute.EnvironmentAttributeModifier.override import java.lang.reflect.Type import java.util.* diff --git a/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt b/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt index 0095d1a84..fabf2fedd 100644 --- a/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt @@ -20,13 +20,13 @@ package com.lambda.config.groups import com.lambda.config.Config import com.lambda.config.Config.Group import com.lambda.config.applyEdits -import com.lambda.event.events.TickEvent -import com.lambda.event.events.TickEvent.Companion.ALL_STAGES import com.lambda.config.groups.BreakConfig.AnimationMode import com.lambda.config.groups.BreakConfig.BreakConfirmationMode import com.lambda.config.groups.BreakConfig.BreakMode import com.lambda.config.groups.BreakConfig.SwingMode import com.lambda.config.groups.BreakConfig.WhitelistMode +import com.lambda.event.events.TickEvent +import com.lambda.event.events.TickEvent.Companion.ALL_STAGES import net.minecraft.registry.Registries import java.awt.Color diff --git a/src/main/kotlin/com/lambda/config/groups/EatSettings.kt b/src/main/kotlin/com/lambda/config/groups/EatSettings.kt index c4b388b9e..dca1f6cbd 100644 --- a/src/main/kotlin/com/lambda/config/groups/EatSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/EatSettings.kt @@ -19,7 +19,6 @@ package com.lambda.config.groups import com.lambda.config.Config import com.lambda.config.SettingBlock -import com.lambda.util.NamedEnum import net.minecraft.item.Items class EatSettings(override val c: Config) : SettingBlock, EatConfig { diff --git a/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt b/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt index c62c87997..71be13992 100644 --- a/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt @@ -23,7 +23,6 @@ import com.lambda.context.SafeContext import com.lambda.friend.FriendHandler.isFriend import com.lambda.util.EntityUtils import com.lambda.util.EntityUtils.entityGroup -import com.lambda.util.NamedEnum import com.lambda.util.extension.blockColor import com.lambda.util.extension.entityColor import com.lambda.util.math.dist diff --git a/src/main/kotlin/com/lambda/config/groups/EntitySelectionSettings.kt b/src/main/kotlin/com/lambda/config/groups/EntitySelectionSettings.kt index 804498a6f..f00fc762a 100644 --- a/src/main/kotlin/com/lambda/config/groups/EntitySelectionSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/EntitySelectionSettings.kt @@ -29,7 +29,6 @@ import com.lambda.util.EntityUtils.passiveEntityMap import com.lambda.util.EntityUtils.playerEntityMap import com.lambda.util.EntityUtils.projectileEntityMap import com.lambda.util.EntityUtils.vehicleEntityMap -import com.lambda.util.NamedEnum import net.minecraft.block.entity.BlockEntity import net.minecraft.entity.Entity import net.minecraft.entity.SpawnGroup diff --git a/src/main/kotlin/com/lambda/config/groups/FormatterConfig.kt b/src/main/kotlin/com/lambda/config/groups/FormatterConfig.kt index a82266907..0e5615cf1 100644 --- a/src/main/kotlin/com/lambda/config/groups/FormatterConfig.kt +++ b/src/main/kotlin/com/lambda/config/groups/FormatterConfig.kt @@ -24,7 +24,7 @@ import java.time.format.DateTimeFormatter import java.util.* @Suppress("unused") -interface FormatterConfig : SettingBlock { +interface FormatterConfig { val locale: Locale val separator: String val prefix: String diff --git a/src/main/kotlin/com/lambda/config/groups/FormatterSettings.kt b/src/main/kotlin/com/lambda/config/groups/FormatterSettings.kt index d374f05b4..f6b336a84 100644 --- a/src/main/kotlin/com/lambda/config/groups/FormatterSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/FormatterSettings.kt @@ -19,7 +19,6 @@ package com.lambda.config.groups import com.lambda.config.Config import com.lambda.config.SettingBlock -import com.lambda.util.NamedEnum class FormatterSettings(override val c: Config) : SettingBlock, FormatterConfig { val localeEnum by c.setting("Locale", FormatterConfig.Locales.US, "The regional formatting used for numbers") diff --git a/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt b/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt index 9f5185d88..01d61790d 100644 --- a/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt @@ -21,9 +21,8 @@ import com.lambda.config.Config import com.lambda.config.SettingBlock import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.util.NamedEnum -class HotbarSettings(override val c: Config) : SettingBlock, HotbarConfig { +class HotbarSettings(override val c: Config) : HotbarConfig { override val swapMode by c.setting("Swap Mode", HotbarConfig.SwapMode.Temporary) override val keepTicks by c.setting("Keep Ticks", 1, 0..20, 1, "The number of ticks to keep the current hotbar selection active", " ticks") { swapMode == HotbarConfig.SwapMode.Temporary } override val swapDelay by c.setting("Swap Delay", 0, 0..3, 1, "The number of ticks delay before allowing another hotbar selection swap", " ticks") diff --git a/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt b/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt index fadff3149..c2ae98907 100644 --- a/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt @@ -18,10 +18,10 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.event.events.TickEvent -import com.lambda.event.events.TickEvent.Companion.ALL_STAGES import com.lambda.config.groups.InteractConfig.AirPlaceMode import com.lambda.config.groups.InteractConfig.InteractConfirmationMode +import com.lambda.event.events.TickEvent +import com.lambda.event.events.TickEvent.Companion.ALL_STAGES class InteractSettings(override val c: Config) : InteractConfig { override val rotate by c.setting("Rotate For Interact", true, "Rotate towards block while placing") diff --git a/src/main/kotlin/com/lambda/config/groups/OutlineSettings.kt b/src/main/kotlin/com/lambda/config/groups/OutlineSettings.kt index 03ec96e19..c8e97752e 100644 --- a/src/main/kotlin/com/lambda/config/groups/OutlineSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/OutlineSettings.kt @@ -20,7 +20,6 @@ package com.lambda.config.groups import com.lambda.config.Config import com.lambda.config.SettingBlock import com.lambda.graphics.outline.OutlineStyle -import com.lambda.util.NamedEnum import java.awt.Color class OutlineSettings(override val c: Config) : SettingBlock { diff --git a/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt b/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt index 79ff06424..6697de6fd 100644 --- a/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt @@ -19,6 +19,7 @@ package com.lambda.config.groups import com.lambda.config.Config import com.lambda.config.Config.Group +import com.lambda.config.Group import com.lambda.config.SettingBlock import java.awt.Color diff --git a/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt b/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt index 92f26b106..402520d40 100644 --- a/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt @@ -18,20 +18,19 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.config.Config.Group +import com.lambda.config.Group import com.lambda.config.SettingBlock import java.awt.Color class ScreenTextSettings(override val c: Config) : SettingBlock, TextConfig { companion object { - private const val GROUP_GENERAL = "General" private const val GROUP_OUTLINE = "Outline" private const val GROUP_GLOW = "Glow" private const val GROUP_SHADOW = "Shadow" } - @Group(GROUP_GENERAL) override val textColor by c.setting("Text Color", Color.WHITE, "The main text color") - @Group(GROUP_GENERAL) val sizeSetting by c.setting("Text Size", 18, 1..50, 1) + override val textColor by c.setting("Text Color", Color.WHITE, "The main text color") + val sizeSetting by c.setting("Text Size", 18, 1..50, 1) override val size get() = sizeSetting * 0.001f @Group(GROUP_OUTLINE) override val outlineEnabled by c.setting("Outline", false, "Enable text outline") diff --git a/src/main/kotlin/com/lambda/config/groups/TargetingSettings.kt b/src/main/kotlin/com/lambda/config/groups/TargetingSettings.kt index 11d2206a0..dd2fd8477 100644 --- a/src/main/kotlin/com/lambda/config/groups/TargetingSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/TargetingSettings.kt @@ -26,7 +26,6 @@ import com.lambda.interaction.managers.rotating.Rotation.Companion.dist import com.lambda.interaction.managers.rotating.Rotation.Companion.rotation import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo import com.lambda.threading.runSafe -import com.lambda.util.NamedEnum import com.lambda.util.extension.fullHealth import com.lambda.util.math.distSq import com.lambda.util.world.fastEntitySearch diff --git a/src/main/kotlin/com/lambda/config/groups/WorldLineSettings.kt b/src/main/kotlin/com/lambda/config/groups/WorldLineSettings.kt index af7f2099d..7c486ad46 100644 --- a/src/main/kotlin/com/lambda/config/groups/WorldLineSettings.kt +++ b/src/main/kotlin/com/lambda/config/groups/WorldLineSettings.kt @@ -18,36 +18,35 @@ package com.lambda.config.groups import com.lambda.config.Config -import com.lambda.config.Config.Group +import com.lambda.config.Group import com.lambda.config.SettingBlock import java.awt.Color class WorldLineSettings(override val c: Config) : SettingBlock, LineConfig { companion object { - private const val GROUP_GENERAL = "General" - private const val GROUP_COLOR = "Color" - private const val GROUP_DASH = "Dash" + private const val COLOR_GROUP = "Color" + private const val DASH_GROUP = "Dash" } - @Group(GROUP_GENERAL) val distanceScaling by c.setting("Distance Scaling", true, "Line width stays constant on screen regardless of distance") - @Group(GROUP_GENERAL) val worldWidthSetting by c.setting("Width", 5, 1..50, 1) { !distanceScaling } - @Group(GROUP_GENERAL) val screenWidthSetting by c.setting("Screen Width", 20, 1..100, 1, "Line width in screen-space (stays constant size)") { distanceScaling } + val distanceScaling by c.setting("Distance Scaling", true, "Line width stays constant on screen regardless of distance") + val worldWidthSetting by c.setting("Width", 5, 1..50, 1) { !distanceScaling } + val screenWidthSetting by c.setting("Screen Width", 20, 1..100, 1, "Line width in screen-space (stays constant size)") { distanceScaling } override val width: Float get() = if (distanceScaling) -screenWidthSetting * 0.00005f else worldWidthSetting * 0.001f - @Group(GROUP_COLOR) override val startColor by c.setting("Start Color", Color.WHITE, "The color at the start of the line") - @Group(GROUP_COLOR) override val endColor by c.setting("End Color", Color.WHITE, "The color at the end of the line") + @Group(COLOR_GROUP) override val startColor by c.setting("Start Color", Color.WHITE, "The color at the start of the line") + @Group(COLOR_GROUP) override val endColor by c.setting("End Color", Color.WHITE, "The color at the end of the line") - @Group(GROUP_DASH) override val dashEnabled by c.setting("Dashed", false, "Enable dashed line pattern") - @Group(GROUP_DASH) val dashLengthSetting by c.setting("Dash Length", 50, 1..200, 1, "Length of each dash") { dashEnabled } + @Group(DASH_GROUP) override val dashEnabled by c.setting("Dashed", false, "Enable dashed line pattern") + @Group(DASH_GROUP) val dashLengthSetting by c.setting("Dash Length", 50, 1..200, 1, "Length of each dash") { dashEnabled } override val dashLength get() = dashLengthSetting * 0.01f - @Group(GROUP_DASH) val gapLengthSetting by c.setting("Gap Length", 25, 1..200, 1, "Length of gaps between dashes") { dashEnabled } + @Group(DASH_GROUP) val gapLengthSetting by c.setting("Gap Length", 25, 1..200, 1, "Length of gaps between dashes") { dashEnabled } override val gapLength get() = gapLengthSetting * 0.01f - @Group(GROUP_DASH) override val animated by c.setting("Animated", true, "Animate the dash pattern") { dashEnabled } - @Group(GROUP_DASH) val dashOffsetSetting by c.setting("Dash Offset", 0, 0..100, 1, "Offset of the dash pattern") { dashEnabled && !animated } + @Group(DASH_GROUP) override val animated by c.setting("Animated", true, "Animate the dash pattern") { dashEnabled } + @Group(DASH_GROUP) val dashOffsetSetting by c.setting("Dash Offset", 0, 0..100, 1, "Offset of the dash pattern") { dashEnabled && !animated } override val dashOffset get() = dashOffsetSetting * 0.01f - @Group(GROUP_DASH) val animationSpeedSetting by c.setting("Animation Speed", 30, -100..100, 1, "Speed of dash animation (negative = reverse)") { dashEnabled && animated } + @Group(DASH_GROUP) val animationSpeedSetting by c.setting("Animation Speed", 30, -100..100, 1, "Speed of dash animation (negative = reverse)") { dashEnabled && animated } override val animationSpeed get() = animationSpeedSetting * 0.1f } diff --git a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt index f21b8ee7c..24215b06e 100644 --- a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt @@ -18,10 +18,10 @@ package com.lambda.config.settings import com.google.gson.reflect.TypeToken +import com.lambda.config.ConfigEditor import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.config.SettingEditorDsl -import com.lambda.config.ConfigEditor import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.ImGui import com.lambda.imgui.ImGui.calcTextSize diff --git a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt index 2129eb1cc..079c5084b 100644 --- a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt @@ -22,10 +22,10 @@ import com.lambda.brigadier.argument.greedyString import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required +import com.lambda.config.ConfigEditor import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.config.SettingEditorDsl -import com.lambda.config.ConfigEditor import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.flag.ImGuiInputTextFlags import com.lambda.util.extension.CommandBuilder diff --git a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt index 81cce32af..1e0963b75 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt @@ -20,10 +20,10 @@ package com.lambda.config.settings.collections import com.google.gson.JsonElement import com.google.gson.reflect.TypeToken import com.lambda.Lambda.gson +import com.lambda.config.ConfigEditor import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.config.SettingEditorDsl -import com.lambda.config.ConfigEditor import com.lambda.context.SafeContext import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.ImGui diff --git a/src/main/kotlin/com/lambda/graphics/mc/renderer/ChunkedRenderer.kt b/src/main/kotlin/com/lambda/graphics/mc/renderer/ChunkedRenderer.kt index ac720a9ef..91d52c3d9 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/renderer/ChunkedRenderer.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/renderer/ChunkedRenderer.kt @@ -29,7 +29,7 @@ import com.lambda.graphics.RenderMain import com.lambda.graphics.mc.RegionRenderer import com.lambda.graphics.mc.RenderBuilder import com.lambda.module.Module -import com.lambda.module.modules.client.StyleEditor +import com.lambda.module.modules.client.Client import com.lambda.util.world.FastVector import com.lambda.util.world.fastVectorOf import com.mojang.blaze3d.buffers.GpuBufferSlice @@ -81,13 +81,13 @@ class ChunkedRenderer( owner.listenConcurrently { if (pauseUpdates()) return@listenConcurrently val queueSize = rebuildQueue.size - val polls = minOf(StyleEditor.rebuildsPerTick, queueSize) + val polls = minOf(Client.chunkRebuildsPerTick, queueSize) val depth = depthTest() repeat(polls) { rebuildQueue.poll()?.rebuild(depth) } } owner.listen { - val polls = minOf(StyleEditor.uploadsPerTick, uploadQueue.size) + val polls = minOf(Client.chunkUploadsPerTick, uploadQueue.size) repeat(polls) { uploadQueue.poll()?.invoke() } } diff --git a/src/main/kotlin/com/lambda/gui/MenuBar.kt b/src/main/kotlin/com/lambda/gui/MenuBar.kt index 89dc73b9b..9fc138477 100644 --- a/src/main/kotlin/com/lambda/gui/MenuBar.kt +++ b/src/main/kotlin/com/lambda/gui/MenuBar.kt @@ -21,8 +21,8 @@ import com.lambda.Lambda import com.lambda.Lambda.REPO_URL import com.lambda.Lambda.mc import com.lambda.command.CommandRegistry -import com.lambda.config.automation.AutomationConfig import com.lambda.config.ConfigLoader +import com.lambda.config.automation.AutomationConfig import com.lambda.config.automation.UserAutomationConfig import com.lambda.config.categories.UserAutomationCategory import com.lambda.core.Loader diff --git a/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt b/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt index 51b39a1cf..11362ba0b 100644 --- a/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt +++ b/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt @@ -17,10 +17,10 @@ package com.lambda.gui.components -import com.lambda.config.automation.AutomationConfig import com.lambda.config.Config -import com.lambda.config.automation.IMutableAutomationConfig import com.lambda.config.Setting +import com.lambda.config.automation.AutomationConfig +import com.lambda.config.automation.IMutableAutomationConfig import com.lambda.config.automation.UserAutomationConfig import com.lambda.config.categories.UserAutomationCategory import com.lambda.gui.dsl.ImGuiBuilder @@ -30,7 +30,6 @@ import com.lambda.imgui.flag.ImGuiTabBarFlags import com.lambda.module.HudModule import com.lambda.module.Module import com.lambda.module.modules.client.AutoUpdater -import com.lambda.util.NamedEnum object SettingsWidget { /** @@ -52,12 +51,12 @@ object SettingsWidget { with(config.backgroundColor) { buildLayout() } } smallButton("Reset") { - config.settingContainers.forEach { it.reset(silent = true) } + resetContainers(config.settingContainers) } } } lambdaTooltip("Resets all settings for this module to their default values") - if (config is IMutableAutomationConfig && config.automationConfig !== AutomationConfig.Companion.DEFAULT) { + if (config is IMutableAutomationConfig && config.automationConfig !== AutomationConfig.DEFAULT) { button("Automation Config") { ImGui.openPopup("##automation-config-popup-${config.name}") } @@ -87,55 +86,96 @@ object SettingsWidget { } } - val visibleSettings = config.settingContainers.filter { it.visibility() } - if (visibleSettings.isEmpty()) return - else separator() - val (grouped, ungrouped) = visibleSettings.partition { it.groups.isNotEmpty() } - ungrouped.forEach { - it.withDisabled { buildLayout() } - } - renderGroup(grouped, emptyList(), config) + if (!hasVisibleSettings(config.settingContainers)) return + separator() + renderContainers(config.settingContainers, config.name) } - private fun Setting<*, *>.withDisabled(block: Setting<*, *>.() -> Unit) { - if (disabled()) ImGui.beginDisabled() - block() - if (disabled()) ImGui.endDisabled() + /** + * Recursively renders [Config.SettingContainer]s in order. + * - [Config.SettingContainer.Single]: renders the setting with visibility/disabled checks. + * - [Config.SettingContainer.Tab]: renders as ImGui tab bar with tab items. + * - [Config.SettingContainer.Group]: renders as a collapsible tree node with indent. + */ + private fun ImGuiBuilder.renderContainers(containers: List, idPrefix: String) { + val runs = mutableListOf() + containers.forEach { container -> + if (container is Config.SettingContainer.Tab) { + val last = runs.lastOrNull() + if (last is MutableList<*>) { + @Suppress("UNCHECKED_CAST") + (last as MutableList).add(container) + } else { + runs.add(mutableListOf(container)) + } + } else { + runs.add(container) + } + } + + runs.forEach { run -> + when (run) { + is Config.SettingContainer.Single -> renderSetting(run.setting) + is Config.SettingContainer.Group -> { + if (hasVisibleSettings(run.settings)) { + treeNode("${run.name}##$idPrefix-group-${run.name}") { + renderContainers(run.settings, "$idPrefix-${run.name}") + } + } + } + is List<*> -> { + @Suppress("UNCHECKED_CAST") + renderTabBar(run as List, idPrefix) + } + } + } } - private fun ImGuiBuilder.renderGroup( - settings: List>, - parentPath: List, - config: Config - ) { - settings.filter { it.groups.contains(parentPath) }.forEach { - it.withDisabled { buildLayout() } - } + /** + * Renders a group of [Config.SettingContainer.Tab]s as a single ImGui tab bar. + */ + private fun ImGuiBuilder.renderTabBar(tabs: List, idPrefix: String) { + val visibleTabs = tabs.filter { hasVisibleSettings(it.settings) } + if (visibleTabs.isEmpty()) return + tabBar("##$idPrefix-tabs", ImGuiTabBarFlags.FittingPolicyResizeDown) { + visibleTabs.forEach { tab -> + tabItem(tab.name) { + renderContainers(tab.settings, "$idPrefix-${tab.name}") + } + } + } + } - val subGroupSettings = settings.filter { s -> - s.groups.any { it.size > parentPath.size && it.subList(0, parentPath.size) == parentPath } - } - val subTabs = subGroupSettings - .flatMap { s -> - s.groups.mapNotNull { path -> - if (path.size > parentPath.size && path.subList(0, parentPath.size) == parentPath) - path[parentPath.size] else null - } - }.distinct() + /** + * Renders a single [Setting] with visibility and disabled state checks. + */ + private fun ImGuiBuilder.renderSetting(setting: Setting<*, *>) { + if (!setting.visibility()) return + if (setting.disabled()) ImGui.beginDisabled() + with(setting) { buildLayout() } + if (setting.disabled()) ImGui.endDisabled() + } - if (subTabs.isNotEmpty()) { - val id = "##${config.name}-tabs-${parentPath.joinToString("-") { it.displayName }}" - tabBar(id, ImGuiTabBarFlags.FittingPolicyResizeDown) { - subTabs.forEach { tab -> - tabItem(tab.displayName) { - val newParentPath = parentPath + tab - val settingsForSubGroup = subGroupSettings.filter { s -> - s.groups.any { it.size >= newParentPath.size && it.subList(0, newParentPath.size) == newParentPath } - } - renderGroup(settingsForSubGroup, newParentPath, config) - } - } - } - } + /** + * Checks if any [Config.SettingContainer] in the tree has a visible setting. + */ + private fun hasVisibleSettings(containers: List): Boolean = + containers.any { container -> + when (container) { + is Config.SettingContainer.Single -> container.setting.visibility() + is Config.SettingContainer.Multiple -> hasVisibleSettings(container.settings) + } + } + + /** + * Recursively resets all settings in the container tree. + */ + private fun resetContainers(containers: List) { + containers.forEach { container -> + when (container) { + is Config.SettingContainer.Single -> container.setting.reset(silent = true) + is Config.SettingContainer.Multiple -> resetContainers(container.settings) + } + } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/ProcessorRegistry.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/ProcessorRegistry.kt index 0e4d52b9e..3ec075142 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/ProcessorRegistry.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/processing/ProcessorRegistry.kt @@ -23,7 +23,7 @@ import com.lambda.core.Loadable import com.lambda.interaction.construction.simulation.SimDsl import com.lambda.interaction.construction.verify.TargetState import com.lambda.util.BlockUtils.matches -import com.lambda.util.getInstances +import com.lambda.util.ReflectionUtils.getInstances import net.minecraft.block.BlockState import net.minecraft.item.ItemStack import net.minecraft.state.property.Properties diff --git a/src/main/kotlin/com/lambda/module/hud/Coordinates.kt b/src/main/kotlin/com/lambda/module/hud/Coordinates.kt index e654f7487..0458b00aa 100644 --- a/src/main/kotlin/com/lambda/module/hud/Coordinates.kt +++ b/src/main/kotlin/com/lambda/module/hud/Coordinates.kt @@ -21,6 +21,7 @@ import com.lambda.config.applyEdits import com.lambda.config.groups.FormatterSettings import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.module.HudModule +import com.lambda.module.hud.Coordinates.formatter import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe import com.lambda.util.FormattingUtils.format diff --git a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt index 4efd98896..91d72943a 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt @@ -18,9 +18,8 @@ package com.lambda.module.modules.chat import com.lambda.config.Config -import com.lambda.config.SettingBlock -import com.lambda.config.applyEdits import com.lambda.config.groups.ReplaceConfig +import com.lambda.config.groups.ReplaceConfig.ActionStrategy import com.lambda.event.events.ChatEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.friend.FriendHandler @@ -34,11 +33,11 @@ import com.lambda.util.ChatUtils.sexual import com.lambda.util.ChatUtils.slurs import com.lambda.util.ChatUtils.swears import com.lambda.util.ChatUtils.toAscii -import com.lambda.util.NamedEnum import com.lambda.util.text.DirectMessage import com.lambda.util.text.MessageParser import com.lambda.util.text.MessageType import net.minecraft.text.Text +import com.lambda.config.Group @Suppress("unused") object AntiSpam : Module( @@ -56,28 +55,13 @@ object AntiSpam : Module( private val ignoreSystem by setting("Ignore System", false) private val ignoreDms by setting("Ignore DMs", false) - private val detectSlurs = ReplaceSettings("Slurs", this, Group.Slurs) - private val detectSwears = ReplaceSettings("Swears", this, Group.Swears) - private val detectSexual = ReplaceSettings("Sexual", this, Group.Sexual) - private val detectDiscord = ReplaceSettings("Discord", this, Group.Discord) - .apply { applyEdits { ::action.edit { defaultValue(ReplaceConfig.ActionStrategy.Hide) } } } - private val detectAddresses = ReplaceSettings("Addresses", this, Group.Addresses) - .apply { applyEdits { ::action.edit { defaultValue(ReplaceConfig.ActionStrategy.Hide) } } } - private val detectHexBypass = ReplaceSettings("Hex", this, Group.Hex) - .apply { applyEdits { ::action.edit { defaultValue(ReplaceConfig.ActionStrategy.Hide) } } } - private val detectColors = ReplaceSettings("Colors", this, Group.Colors) - .apply { applyEdits { ::action.edit { defaultValue(ReplaceConfig.ActionStrategy.None) } } } - - enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Slurs("Slurs"), - Swears("Swears"), - Sexual("Sexual"), - Discord("Discord Invites"), - Addresses("IPs and Addresses"), - Hex("Hex Bypass"), - Colors("Color Prefixes") - } + @Group("Slurs") private val detectSlurs = settingBlock(ReplaceSettings("Slurs", this)) + @Group("Swears") private val detectSwears = settingBlock(ReplaceSettings("Swears", this)) + @Group("Sexual") private val detectSexual = settingBlock(ReplaceSettings("Sexual", this)) + @Group("Discord") private val detectDiscord = settingBlock(ReplaceSettings("Discord", this, ActionStrategy.Hide)) + @Group("Addresses") private val detectAddresses = settingBlock(ReplaceSettings("Addresses", this, ActionStrategy.Hide)) + @Group("Hex") private val detectHexBypass = settingBlock(ReplaceSettings("Hex", this, ActionStrategy.Hide)) + @Group("Colors") private val detectColors = settingBlock(ReplaceSettings("Colors", this, ActionStrategy.None)) init { setModulePriority(100) @@ -111,12 +95,12 @@ object AntiSpam : Module( ) return when (replace.action) { - ReplaceConfig.ActionStrategy.Hide -> matches.firstOrNull()?.let { event.cancel(); cancelled = true } // If there's one detection, nuke the whole damn thang - ReplaceConfig.ActionStrategy.Delete -> matches + ActionStrategy.Hide -> matches.firstOrNull()?.let { event.cancel(); cancelled = true } // If there's one detection, nuke the whole damn thang + ActionStrategy.Delete -> matches .forEach { raw = raw.replaceRange(it.range, ""); hasMatches = true } - ReplaceConfig.ActionStrategy.Replace -> matches + ActionStrategy.Replace -> matches .forEach { raw = raw.replaceRange(it.range, replace.replace.block(it.value)); hasMatches = true } - ReplaceConfig.ActionStrategy.None -> {} + ActionStrategy.None -> {} } } @@ -136,12 +120,11 @@ object AntiSpam : Module( } class ReplaceSettings( - name: String, - c: Config, - baseGroup: NamedEnum, - override val visibility: () -> Boolean = { true }, - ) : ReplaceConfig, SettingBlock(c) { - override val action by setting("$name Action Strategy", ReplaceConfig.ActionStrategy.Replace, visibility = visibility).group(baseGroup) - override val replace by setting("$name Replace Strategy", ReplaceConfig.ReplaceStrategy.CensorAll) { visibility() && action == ReplaceConfig.ActionStrategy.Replace }.group(baseGroup) + val name: String, + override val c: Config, + val actionStrategy: ActionStrategy = ActionStrategy.Replace + ) : ReplaceConfig { + override val action by setting("$name Action Strategy", ActionStrategy.Replace) + override val replace by setting("$name Replace Strategy", ReplaceConfig.ReplaceStrategy.CensorAll) { action == ActionStrategy.Replace } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt b/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt index b55ade417..641d48e0e 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt @@ -42,12 +42,16 @@ object ChatTimestamp : Module( description = "Displays the time a message was sent next to it", tag = ModuleTag.CHAT, ) { - var color: Formatting by setting("Color", Formatting.GRAY) + private var color: Formatting by setting("Color", Formatting.GRAY) .onValueChange { from, to -> if (to.colorIndex !in 0..15) color = from } + private val javaColor: Color get() = Color(color.colorValue!! and 16777215) - val javaColor: Color get() = Color(color.colorValue!! and 16777215) - - val formatter = FormatterSettings(c = this,).apply { applyEdits { hide(::localeEnum, ::sep, ::customSep, ::group, ::floatingPrecision); editTyped(::timeFormat) { defaultValue(FormatterConfig.Time.IsoLocalTime) } } } + val formatter = settingBlock(FormatterSettings(this)) { + applyEdits { + hide(::localeEnum, ::sep, ::customSep, ::floatingPrecision) + editTyped(::timeFormat) { defaultValue(FormatterConfig.Time.IsoLocalTime) } + } + } private val currentTime get() = ZonedDateTime.of(LocalDateTime.now(), ZoneId.systemDefault()) diff --git a/src/main/kotlin/com/lambda/module/modules/chat/CustomChat.kt b/src/main/kotlin/com/lambda/module/modules/chat/CustomChat.kt index 8869f4b7d..b55e6931d 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/CustomChat.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/CustomChat.kt @@ -34,7 +34,6 @@ object CustomChat : Module( ) { private val decoration by setting("Decoration", Decoration.Separator) private val text by setting("Text", Text.Lambda) - private val customText by setting("Custom Text", "") { text == Text.Custom } init { diff --git a/src/main/kotlin/com/lambda/module/modules/chat/FancyChat.kt b/src/main/kotlin/com/lambda/module/modules/chat/FancyChat.kt index 41f4728d3..080657967 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/FancyChat.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/FancyChat.kt @@ -34,9 +34,9 @@ object FancyChat : Module( description = "Makes messages you send - fancy", tag = ModuleTag.CHAT, ) { - private val uwu by setting("uwu", true) + private val uwu by setting("uwu", false) private val leet by setting("1337", false) - private val green by setting(">", false) + private val green by setting(">", true) private val blue by setting("`", false) init { diff --git a/src/main/kotlin/com/lambda/module/modules/chat/FriendHighlight.kt b/src/main/kotlin/com/lambda/module/modules/chat/FriendHighlight.kt index dfbe2d603..2065c74eb 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/FriendHighlight.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/FriendHighlight.kt @@ -38,17 +38,16 @@ object FriendHighlight : Module( description = "Highlights your friends names in chat", tag = ModuleTag.CHAT, ) { - var color: Formatting by setting("Color", Formatting.GREEN) + private var color: Formatting by setting("Color", Formatting.GREEN) .onValueChange { from, to -> if (to.colorIndex !in 0..15) color = from } + private val javaColor: Color get() = Color(color.colorValue!! and 16777215) - val javaColor: Color get() = Color(color.colorValue!! and 16777215) + private val bold by setting("Bold", true) + private val italic by setting("Italic", false) + private val underlined by setting("Underlined", false) + private val strikethrough by setting("Strikethrough", false) - val bold by setting("Bold", true) - val italic by setting("Italic", false) - val underlined by setting("Underlined", false) - val strikethrough by setting("Strikethrough", false) - - val ping by setting("Ping On Message", true) + private val ping by setting("Ping On Message", true) init { onEnable { diff --git a/src/main/kotlin/com/lambda/module/modules/client/AutoUpdater.kt b/src/main/kotlin/com/lambda/module/modules/client/AutoUpdater.kt index c39d803e1..839c2425a 100644 --- a/src/main/kotlin/com/lambda/module/modules/client/AutoUpdater.kt +++ b/src/main/kotlin/com/lambda/module/modules/client/AutoUpdater.kt @@ -45,6 +45,7 @@ object AutoUpdater : Module( private val debug by setting("Debug", false, "Enable debug logging") private val loaderBranch by setting("Loader Branch", Branch.Stable, "Select loader update branch") private val clientBranch by setting("Client Branch", Branch.Snapshot, "Select client update branch") + //ToDo: Saving arbitrary data to configs without weird setting display workarounds private var loaderPromptHandled by setting("Loader Prompt Handled", false) { false } @JvmStatic var showFirstLaunchModal = false diff --git a/src/main/kotlin/com/lambda/module/modules/client/Client.kt b/src/main/kotlin/com/lambda/module/modules/client/Client.kt index 9c99d71b0..10c135b25 100644 --- a/src/main/kotlin/com/lambda/module/modules/client/Client.kt +++ b/src/main/kotlin/com/lambda/module/modules/client/Client.kt @@ -17,11 +17,13 @@ package com.lambda.module.modules.client +import com.lambda.config.Group +import com.lambda.config.Tab import com.lambda.graphics.mc.renderer.TickedRenderer.Companion.tickedRenderer import com.lambda.interaction.construction.simulation.result.Drawable import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.NamedEnum +import java.awt.Color object Client : Module( name = "Client", @@ -29,19 +31,23 @@ object Client : Module( tag = ModuleTag.CLIENT, enabledByDefault = true ) { - private enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Debug("Debug") - } + private const val GENERAL_TAB = "General" + private const val DEBUG_TAB = "Debug" + + private const val RENDERING_GROUP = "Rendering" + + @Tab(GENERAL_TAB) val clientSounds by setting("Client Sounds", true, "Plays sounds when certain actions are performed with lambda. Toggling modules, for example") + @Tab(GENERAL_TAB) val buildTaskRenders by setting("Build Task Renders", false, "Displays renders from some build sim results generated from the build task") + @Tab(GENERAL_TAB) val avoidInventoryDesync by setting("Avoid Inventory Desync", true, "Cancels incoming inventory update packets if they match previous actions") + @Tab(GENERAL_TAB) val desyncTimeout by setting("Desync Timeout", 30, 1..30, 1, unit = " ticks", description = "Time to store previous inventory actions before dropping the cache") { avoidInventoryDesync } + @Tab(GENERAL_TAB) val scanShrinkFactor by setting("Scan Shrink Factor", 0.001, 0.0..1.0, 0.001, "How much to shrink block scans from the edges to avoid flagging anticheats") + @Tab(GENERAL_TAB) @Group(RENDERING_GROUP) val chunkUploadsPerTick by setting("Chunk Uploads", 16, 1..256, 1, unit = " chunks/tick") + @Tab(GENERAL_TAB) @Group(RENDERING_GROUP) val chunkRebuildsPerTick by setting("Chunk Rebuilds", 64, 1..256, 1, unit = " chunks/tick") + @Tab(GENERAL_TAB) val highlightColor by setting("Text Highlight Color", Color(214, 55, 87), "Base text highlight color") - val clientSounds by setting("Client Sounds", true, "Plays sounds when certain actions are performed with lambda. Toggling modules, for example").group(Group.General) - val buildTaskRenders by setting("Build Task Renders", false, "Displays renders from some build sim results generated from the build task").group(Group.General) - val avoidInventoryDesync by setting("Avoid Inventory Desync", true, "Cancels incoming inventory update packets if they match previous actions").group(Group.General) - val desyncTimeout by setting("Desync Timeout", 30, 1..30, 1, unit = " ticks", description = "Time to store previous inventory actions before dropping the cache") { avoidInventoryDesync }.group(Group.General) - val scanShrinkFactor by setting("Scan Shrink Factor", 0.001, 0.0..1.0, 0.001).group(Group.General) - val showAllEntries by setting("Show All Entries", false, "Show all entries in the task tree").group(Group.Debug) - val ignoreItemDropWarnings by setting("Ignore Drop Warnings", false, "Hides the item drop warnings from the break manager").group(Group.Debug) - val verboseDebug by setting("Verbose Debug", false, "Prints more, and more detailed, debug logs").group(Group.Debug) + @Tab(DEBUG_TAB) val showAllEntries by setting("Show All Entries", false, "Show all entries in the task tree") + @Tab(DEBUG_TAB) val ignoreItemDropWarnings by setting("Ignore Drop Warnings", false, "Hides the item drop warnings from the break manager") + @Tab(DEBUG_TAB) val verboseDebug by setting("Verbose Debug", false, "Prints more, and more detailed, debug logs") @Volatile var drawables = listOf() diff --git a/src/main/kotlin/com/lambda/module/modules/client/StyleEditor.kt b/src/main/kotlin/com/lambda/module/modules/client/StyleEditor.kt deleted file mode 100644 index b4d60b800..000000000 --- a/src/main/kotlin/com/lambda/module/modules/client/StyleEditor.kt +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.module.modules.client - -import com.lambda.module.Module -import com.lambda.module.tag.ModuleTag -import com.lambda.util.NamedEnum -import java.awt.Color - -object StyleEditor : Module( - name = "StyleEditor", - description = "Modify the style of the GUI", - tag = ModuleTag.CLIENT, -) { - val alpha by setting("Alpha", 1.0, 0.2..1.0, 0.005, "Global alpha applies to everything in Dear ImGui") - val disabledAlpha by setting("Disabled Alpha", 0.6, 0.0..1.0, 0.005, "Additional alpha multiplier applied by BeginDisabled(). Multiply over current value of Alpha") - //val windowPaddingH by setting("Horizontal Window Padding", 8, 0) - val itemSpacing by setting("Item Spacing", 21.0, 0.0..30.0, 1.0, "Horizontal spacing when e.g. entering a tree node") // Generally == (FontSize + FramePadding.x*2) - val scrollbarSize by setting("Scrollbar Size", 14.0, 1.0..20.0, 1.0) - - // General - val useMemoryMapping by setting("Use Memory Mapping", true).group(Group.General) - - // Font - val shadow by setting("Shadow", true).group(Group.Font) - val shadowBrightness by setting("Shadow Brightness", 0.35, 0.0..0.5, 0.01) { shadow }.group(Group.Font) - val shadowShift by setting("Shadow Shift", 1.0, 0.0..2.0, 0.05) { shadow }.group(Group.Font) - val gap by setting("Gap", 1.5, -10.0..10.0, 0.5).group(Group.Font) - val baselineOffset by setting("Vertical Offset", 0.0, -10.0..10.0, 0.5).group(Group.Font) - val highlightColor by setting("Text Highlight Color", Color(214, 55, 87)).group(Group.Font) - val sdfMin by setting("SDF Min", 0.4, 0.0..1.0, 0.01).group(Group.Font) - val sdfMax by setting("SDF Max", 1.0, 0.0..1.0, 0.01).group(Group.Font) - - // ESP - val uploadsPerTick by setting("Uploads", 16, 1..256, 1, unit = " chunks/tick").group(Group.ESP) - val rebuildsPerTick by setting("Rebuilds", 64, 1..256, 1, unit = " chunks/tick").group(Group.ESP) - val updateFrequency by setting("Update Frequency", 2, 1..10, 1, "Frequency of block updates", unit = " ticks").group(Group.ESP) - val outlineWidth by setting("Outline Width", 1.0, 0.1..5.0, 0.1, "Width of block outlines", unit = "px").group(Group.ESP) - - private enum class Group(override val displayName: String): NamedEnum { - General("General"), - Font("Font"), - ESP("ESP"), - } -} diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt index 26ad5da8a..9018c60a6 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.combat -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.context.SafeContext @@ -97,7 +97,7 @@ object AutoArmor : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllGroupsExcept(inventoryConfig) + hideAllBlocksExcept(inventoryConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt index a8c1fbe32..f19e6c50b 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.combat -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -27,7 +27,6 @@ import com.lambda.interaction.managers.inventory.InventoryRequest.Companion.inve import com.lambda.interaction.material.StackSelection.Companion.select import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.NamedEnum import com.lambda.util.combat.CombatUtils.hasDeadlyCrystal import com.lambda.util.combat.DamageUtils.isFallDeadly import com.lambda.util.extension.fullHealth @@ -43,22 +42,22 @@ object AutoTotem : Module( description = "Swaps the your off-hand item to a totem", tag = ModuleTag.COMBAT, ) { - private val always by setting("Always", true, "Always attempt to keep a totem in offhand").group(Group.General) - private val ignoreWhenHolding by setting("Ignore When Holding", false, "Ignore swapping to offhand when already holding a totem").group(Group.General) - private val minimumHealth by setting("Min Health", 10, 6..36, 1, "Set the minimum health threshold to swap", unit = " half-hearts") { !always }.group(Group.General) - private val falls by setting("Falls", true, "Swap if the player will die of fall damage") { !always }.group(Group.General) - private val fallDistance by setting("Falls Time", 10, 0..30, 1, "Number of blocks fallen before swapping", unit = " blocks") { !always && falls }.group(Group.General) - private val crystals by setting("Crystals", true, "Swap if an End Crystal explosion would be lethal") { !always }.group(Group.General) - private val creeper by setting("Creepers", true, "Swap when an ignited Creeper is nearby") { !always }.group(Group.General) - private val players by setting("Players", false, "Swap if a nearby player is detected within the set distance") { !always }.group(Group.General) - private val minPlayerDistance by setting("Player Distance", 64, 32..128, 4, "Set the distance to detect players to swap") { !always && players }.group(Group.General) - private val friends by setting("Friends", false, "Exclude friends from triggering player-based swaps") { !always && players }.group(Group.General) + private val always by setting("Always", true, "Always attempt to keep a totem in offhand") + private val ignoreWhenHolding by setting("Ignore When Holding", false, "Ignore swapping to offhand when already holding a totem") + private val minimumHealth by setting("Min Health", 10, 6..36, 1, "Set the minimum health threshold to swap", unit = " half-hearts") { !always } + private val falls by setting("Falls", true, "Swap if the player will die of fall damage") { !always } + private val fallDistance by setting("Falls Time", 10, 0..30, 1, "Number of blocks fallen before swapping", unit = " blocks") { !always && falls } + private val crystals by setting("Crystals", true, "Swap if an End Crystal explosion would be lethal") { !always } + private val creeper by setting("Creepers", true, "Swap when an ignited Creeper is nearby") { !always } + private val players by setting("Players", false, "Swap if a nearby player is detected within the set distance") { !always } + private val minPlayerDistance by setting("Player Distance", 64, 32..128, 4, "Set the distance to detect players to swap") { !always && players } + private val friends by setting("Friends", false, "Exclude friends from triggering player-based swaps") { !always && players } init { setModulePriority(100) setDefaultAutomationConfig { applyEdits { - hideAllGroupsExcept(inventoryConfig) + hideAllBlocksExcept(inventoryConfig) } } @@ -97,9 +96,4 @@ object AutoTotem : Module( EndCrystal({ crystals && hasDeadlyCrystal() }), FallDamage({ falls && isFallDeadly() && player.fallDistance > fallDistance }) } - - enum class Group(override val displayName: String): NamedEnum { - General("General"), - Inventory("Inventory"), - } } diff --git a/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt b/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt index 365098320..a4c848b0d 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt @@ -42,12 +42,12 @@ object Criticals : Module( description = "Forces your hits to be critical", tag = ModuleTag.COMBAT, ) { - private val mode by setting("Mode", Mode.Grim) - enum class Mode { Grim } + private val mode by setting("Mode", Mode.Grim) + init { listen { when (mode) { diff --git a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt index fff4d571b..4b2711f4c 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt @@ -17,8 +17,9 @@ package com.lambda.module.modules.combat -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.Tab import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.groups.TargetingSettings import com.lambda.context.SafeContext import com.lambda.event.events.EntityEvent @@ -28,7 +29,6 @@ import com.lambda.interaction.managers.hotbar.HotbarRequest import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo import com.lambda.interaction.managers.rotating.RotationManager -import com.lambda.util.player.RotationUtils.getVisibleSurfaces import com.lambda.interaction.material.StackSelection.Companion.selectStack import com.lambda.interaction.material.container.ContainerHandler.transfer import com.lambda.interaction.material.container.containers.HotbarContainer @@ -40,7 +40,6 @@ import com.lambda.threading.runSafeAutomated import com.lambda.threading.runSafeGameScheduled import com.lambda.util.BlockUtils.blockState import com.lambda.util.CommunicationUtils.info -import com.lambda.util.NamedEnum import com.lambda.util.PacketUtils.sendPacket import com.lambda.util.Timer import com.lambda.util.collections.LimitedDecayQueue @@ -53,6 +52,7 @@ import com.lambda.util.math.flooredBlockPos import com.lambda.util.math.getHitVec import com.lambda.util.math.minus import com.lambda.util.math.plus +import com.lambda.util.player.RotationUtils.getVisibleSurfaces import com.lambda.util.player.SlotUtils.hotbarStacks import com.lambda.util.world.fastEntitySearch import net.minecraft.block.Blocks @@ -78,40 +78,41 @@ object CrystalAura : Module( description = "Automatically attacks entities with crystals", tag = ModuleTag.COMBAT, ) { - /* General */ - private val rotate by setting("Rotate", true).group(Group.General) - private val updateMode by setting("Update Mode", UpdateMode.Async).group(Group.General) - private val updateDelaySetting by setting("Update Delay", 25L, 5L..200L, 5L, unit = " ms") { updateMode == UpdateMode.Async }.group(Group.General) - private val maxUpdatesPerFrame by setting("Max Updates Per Frame", 5, 1..20, 1) { updateMode == UpdateMode.Async }.group(Group.General) - private val updateDelay get() = if (updateMode == UpdateMode.Async) updateDelaySetting else 0L - private val debug by setting("Debug", false).group(Group.General) - - /* Placement */ - private val placeRange by setting("Place Range", 4.6, 1.0..7.0, 0.1, "Range to place crystals", " blocks").group(Group.Placement) - private val placeDelay by setting("Place Delay", 50L, 0L..1000L, 1L, "Delay between placement attempts", " ms").group(Group.Placement) - private val swap by setting("Swap", true, "Swaps to crystals").group(Group.Placement) - private val swapHand by setting("Swap Hand", Hand.MAIN_HAND, "Which hand to swap the crystal to") { swap }.group(Group.Placement) - private val priorityMode by setting("Crystal Priority", Priority.Damage).group(Group.Placement) - private val minDamageAdvantage by setting("Min Damage Advantage", 4.0, 1.0..10.0, 0.5) { priorityMode == Priority.Advantage }.group(Group.Placement) - private val minTargetDamage by setting("Min Target Damage", 8.0, 0.0..20.0, 0.5, "Minimum target damage to use crystals").group(Group.Placement) - private val maxSelfDamage by setting("Max Self Damage", 8.0, 0.0..36.0, 0.5, "Maximum self damage to use crystals").group(Group.Placement) - private val minPlaceHealth by setting("Min Place Health", 5.0, 0.0..36.0, 0.5, "Minimum player health to place crystals").group(Group.Placement) - private val preventDeath by setting("Prevent Death", true, "Prevent death by crystal").group(Group.Placement) - private val oldPlace by setting("1.12 Placement", false).group(Group.Placement) - - /* Exploding */ - private val explodeRange by setting("Explode Range", 3.0, 1.0..7.0, 0.1, "Range to explode crystals", " blocks").group(Group.Exploding) - private val explodeDelay by setting("Explode Delay", 10L, 0L..1000L, 1L, "Delay between explosion attempts", " ms").group(Group.Exploding) - - /* Prediction */ - private val prediction by setting("Prediction", PredictionMode.None).group(Group.Prediction) - private val packetPredictions by setting("Packet Predictions", 1, 0..20, 1) { prediction.onPacket }.group(Group.Prediction) - private val placePostPause by setting("Place Post Pause", true) { prediction.onPacket }.group(Group.Prediction) - private val placePredictions by setting("Place Predictions", 4, 1..20, 1) { prediction.onPlace }.group(Group.Prediction) - private val packetLifetime by setting("Packet Lifetime", 500L, 50L..1000L) { prediction.onPlace }.group(Group.Prediction) - - /* Targeting */ - private val targetingSettings = TargetingSettings.CombatSettings(c = this, Group.Targeting, defaultRange = 10.0) + private const val GENERAL_TAB = "General" + private const val PLACEMENT_TAB = "Placement" + private const val EXPLODING_TAB = "Exploding" + private const val PREDICTION_TAB = "Prediction" + private const val TARGETING_TAB = "Targeting" + + @Tab(GENERAL_TAB) private val rotate by setting("Rotate", true) + @Tab(GENERAL_TAB) private val updateMode by setting("Update Mode", UpdateMode.Async) + @Tab(GENERAL_TAB) private val updateDelaySetting by setting("Update Delay", 25L, 5L..200L, 5L, unit = " ms") { updateMode == UpdateMode.Async } + @Tab(GENERAL_TAB) private val maxUpdatesPerFrame by setting("Max Updates Per Frame", 5, 1..20, 1) { updateMode == UpdateMode.Async } + @Tab(GENERAL_TAB) private val updateDelay get() = if (updateMode == UpdateMode.Async) updateDelaySetting else 0L + @Tab(GENERAL_TAB) private val debug by setting("Debug", false) + + @Tab(PLACEMENT_TAB) private val placeRange by setting("Place Range", 4.6, 1.0..7.0, 0.1, "Range to place crystals", " blocks") + @Tab(PLACEMENT_TAB) private val placeDelay by setting("Place Delay", 50L, 0L..1000L, 1L, "Delay between placement attempts", " ms") + @Tab(PLACEMENT_TAB) private val swap by setting("Swap", true, "Swaps to crystals") + @Tab(PLACEMENT_TAB) private val swapHand by setting("Swap Hand", Hand.MAIN_HAND, "Which hand to swap the crystal to") { swap } + @Tab(PLACEMENT_TAB) private val priorityMode by setting("Crystal Priority", Priority.Damage) + @Tab(PLACEMENT_TAB) private val minDamageAdvantage by setting("Min Damage Advantage", 4.0, 1.0..10.0, 0.5) { priorityMode == Priority.Advantage } + @Tab(PLACEMENT_TAB) private val minTargetDamage by setting("Min Target Damage", 8.0, 0.0..20.0, 0.5, "Minimum target damage to use crystals") + @Tab(PLACEMENT_TAB) private val maxSelfDamage by setting("Max Self Damage", 8.0, 0.0..36.0, 0.5, "Maximum self damage to use crystals") + @Tab(PLACEMENT_TAB) private val minPlaceHealth by setting("Min Place Health", 5.0, 0.0..36.0, 0.5, "Minimum player health to place crystals") + @Tab(PLACEMENT_TAB) private val preventDeath by setting("Prevent Death", true, "Prevent death by crystal") + @Tab(PLACEMENT_TAB) private val oldPlace by setting("1.12 Placement", false) + + @Tab(EXPLODING_TAB) private val explodeRange by setting("Explode Range", 3.0, 1.0..7.0, 0.1, "Range to explode crystals", " blocks") + @Tab(EXPLODING_TAB) private val explodeDelay by setting("Explode Delay", 10L, 0L..1000L, 1L, "Delay between explosion attempts", " ms") + + @Tab(PREDICTION_TAB) private val prediction by setting("Prediction", PredictionMode.None) + @Tab(PREDICTION_TAB) private val packetPredictions by setting("Packet Predictions", 1, 0..20, 1) { prediction.onPacket } + @Tab(PREDICTION_TAB) private val placePostPause by setting("Place Post Pause", true) { prediction.onPacket } + @Tab(PREDICTION_TAB) private val placePredictions by setting("Place Predictions", 4, 1..20, 1) { prediction.onPlace } + @Tab(PREDICTION_TAB) private val packetLifetime by setting("Packet Lifetime", 500L, 50L..1000L) { prediction.onPlace } + + @Tab(PREDICTION_TAB) private val targetingSettings = settingBlock(TargetingSettings.CombatSettings(this, 10.0)) private val blueprint = mutableMapOf() private var activeOpportunity: Opportunity? = null @@ -145,7 +146,7 @@ object CrystalAura : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllGroupsExcept(buildConfig, rotationConfig, hotbarConfig, inventoryConfig) + hideAllBlocksExcept(buildConfig, rotationConfig, hotbarConfig, inventoryConfig) buildConfig.apply { hide( ::pathing, ::stayInRange, ::collectDrops, ::spleefEntities, @@ -552,15 +553,6 @@ object CrystalAura : Module( ) } - private enum class Group(override val displayName: String): NamedEnum { - General("General"), - Placement("Placement"), - Exploding("Exploding"), - Prediction("Prediction"), - Targeting("Targeting"), - Rotation("Rotation") - } - private enum class UpdateMode { Async, Ticked diff --git a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt index bc38a7d72..938c729b5 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt @@ -17,8 +17,9 @@ package com.lambda.module.modules.combat -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.Tab import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.groups.TargetingSettings import com.lambda.context.SafeContext import com.lambda.event.events.InventoryEvent @@ -26,7 +27,6 @@ import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.hotbar.HotbarRequest import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest -import com.lambda.interaction.managers.rotating.visibilty.lookAtEntity import com.lambda.interaction.material.StackSelection.Companion.selectStack import com.lambda.module.Module import com.lambda.module.tag.ModuleTag @@ -35,6 +35,7 @@ import com.lambda.util.NamedEnum import com.lambda.util.item.ItemStackUtils.attackDamage import com.lambda.util.item.ItemStackUtils.attackSpeed import com.lambda.util.math.random +import com.lambda.util.player.RotationUtils.lookAtEntity import com.lambda.util.player.SlotUtils.hotbarStacks import net.minecraft.entity.Entity import net.minecraft.item.ItemStack @@ -47,18 +48,19 @@ object KillAura : Module( description = "Attacks entities", tag = ModuleTag.COMBAT, ) { - // Interact - private val rotate by setting("Rotate", true).group(Group.General) - private val swap by setting("Swap", true, "Swap to the item with the highest damage").group(Group.General) - private val disableWhileGliding by setting("Disable While Gliding", false, "Disables when gliding with an elytra").group(Group.General) - private val damageMode by setting("Damage Mode", DamageMode.DPS).group(Group.General) - private val attackMode by setting("Attack Mode", AttackMode.Cooldown).group(Group.General) - private val cooldownShrink by setting("Cooldown Offset", 0, 0..5, 1) { attackMode == AttackMode.Cooldown }.group(Group.General) - private val hitDelay1 by setting("Hit Delay 1", 2.0, 0.0..20.0, 1.0) { attackMode == AttackMode.Delay }.group(Group.General) - private val hitDelay2 by setting("Hit Delay 2", 6.0, 0.0..20.0, 1.0) { attackMode == AttackMode.Delay }.group(Group.General) - - // Targeting - private val targetingSettings = TargetingSettings.CombatSettings(c = this, Group.Targeting) + private const val GENERAL_TAB = "General" + private const val TARGETING_TAB = "Targeting" + + @Tab(GENERAL_TAB) private val rotate by setting("Rotate", true) + @Tab(GENERAL_TAB) private val swap by setting("Swap", true, "Swap to the item with the highest damage") + @Tab(GENERAL_TAB) private val disableWhileGliding by setting("Disable While Gliding", false, "Disables when gliding with an elytra") + @Tab(GENERAL_TAB) private val damageMode by setting("Damage Mode", DamageMode.DPS) + @Tab(GENERAL_TAB) private val attackMode by setting("Attack Mode", AttackMode.Cooldown) + @Tab(GENERAL_TAB) private val cooldownShrink by setting("Cooldown Offset", 0, 0..5, 1) { attackMode == AttackMode.Cooldown } + @Tab(GENERAL_TAB) private val hitDelay1 by setting("Hit Delay 1", 2.0, 0.0..20.0, 1.0) { attackMode == AttackMode.Delay } + @Tab(GENERAL_TAB) private val hitDelay2 by setting("Hit Delay 2", 6.0, 0.0..20.0, 1.0) { attackMode == AttackMode.Delay } + + @Tab(TARGETING_TAB) private val targetingSettings = settingBlock(TargetingSettings.CombatSettings(this)) val target: Entity? get() = targetingSettings.target() @@ -90,7 +92,7 @@ object KillAura : Module( setModulePriority(90) setDefaultAutomationConfig { applyEdits { - hideAllGroupsExcept(buildConfig, hotbarConfig, rotationConfig) + hideAllBlocksExcept(buildConfig, hotbarConfig, rotationConfig) buildConfig.apply { hide( ::pathing, ::stayInRange, ::collectDrops, diff --git a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt index 7ea991cef..984e8e35b 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.combat -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.context.SafeContext import com.lambda.friend.FriendHandler.isFriend import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint @@ -63,7 +63,7 @@ object PlayerTrap : Module( ::collectDrops ) { defaultValue(false); hide() } } - hideGroup(eatConfig) + hideBlock(eatConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt b/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt index 20b82ead4..252bd7982 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.combat -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint import com.lambda.interaction.construction.verify.TargetState import com.lambda.module.Module @@ -53,7 +53,7 @@ object Surround : Module( ::collectDrops ) { defaultValue(false); hide() } } - hideGroup(eatConfig) + hideBlock(eatConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt index 052ed150b..6e8a3e4a0 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt @@ -17,14 +17,12 @@ package com.lambda.module.modules.debug -import com.lambda.config.automation.AutomationConfig -import com.lambda.config.groups.RotationSettings import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest -import com.lambda.interaction.managers.rotating.visibilty.lookAt import com.lambda.module.Module import com.lambda.module.tag.ModuleTag +import com.lambda.util.player.RotationUtils.lookAt import net.minecraft.util.hit.HitResult @Suppress("unused") @@ -32,7 +30,6 @@ object RotationTest : Module( name = "RotationTest", tag = ModuleTag.DEBUG, ) { - override val rotationConfig = RotationSettings(this, AutomationConfig.Group.Rotation) var hitPos: HitResult? = null init { diff --git a/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt b/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt index 7691b8ff4..dfd7d7fa8 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt @@ -17,6 +17,7 @@ package com.lambda.module.modules.debug +import com.lambda.config.Tab import com.lambda.config.groups.ScreenLineSettings import com.lambda.config.groups.ScreenTextSettings import com.lambda.config.groups.WorldLineSettings @@ -30,36 +31,15 @@ object SettingsTestModule : Module( description = "Test module for Line and Text Config Settings", tag = ModuleTag.DEBUG ) { - private enum class Page(override val displayName: String) : com.lambda.util.NamedEnum { - WorldLine("World Line"), - ScreenLine("Screen Line"), - WorldText("World Text"), - ScreenText("Screen Text") - } + private const val WORLD_LINE_TAB = "World Line" + private const val SCREEN_LINE_TAB = "Screen Line" + private const val WORLD_TEXT_TAB = "World Text" + private const val SCREEN_TEXT_TAB = "Screen Text" - private val worldLineConfig = WorldLineSettings( - this, - Page.WorldLine, - prefix = "World Line " - ) - - private val screenLineConfig = ScreenLineSettings( - this, - Page.ScreenLine, - prefix = "Screen Line " - ) - - private val worldTextConfig = WorldTextSettings( - this, - Page.WorldText, - prefix = "World Text " - ) - - private val textConfig = ScreenTextSettings( - this, - Page.ScreenText, - prefix = "Screen Text " - ) + @Tab(WORLD_LINE_TAB) private val worldLineConfig = settingBlock(WorldLineSettings(this)) + @Tab(SCREEN_LINE_TAB) private val screenLineConfig = settingBlock(ScreenLineSettings(this)) + @Tab(WORLD_TEXT_TAB) private val worldTextConfig = settingBlock(WorldTextSettings(this)) + @Tab(SCREEN_TEXT_TAB) private val textConfig = settingBlock(ScreenTextSettings(this)) // private val renderer = ImmediateRenderer("SettingsTestRenderer") diff --git a/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt b/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt index 988bb586f..c48c7f704 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt @@ -31,11 +31,7 @@ object SilentSwap : Module( description = "SilentSwap", tag = ModuleTag.DEBUG, ) { - private enum class Group(override val displayName: String) : NamedEnum { - Hotbar("Hotbar") - } - - override val hotbarConfig = HotbarSettings(this, Group.Hotbar) + override val hotbarConfig = HotbarSettings(this) init { listen { diff --git a/src/main/kotlin/com/lambda/module/modules/debug/StateInfo.kt b/src/main/kotlin/com/lambda/module/modules/debug/StateInfo.kt index 6d67b5067..1cf5a0a47 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/StateInfo.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/StateInfo.kt @@ -33,6 +33,7 @@ object StateInfo : Module( description = "Prints the target block's state into chat", tag = ModuleTag.DEBUG, ) { + @Suppress("unused") private val printBind by setting("Print", KeyCode.Unbound, "The bind used to print the info to chat") .onPress { val crosshair = mc.crosshairTarget ?: return@onPress diff --git a/src/main/kotlin/com/lambda/module/modules/movement/AutoSpiral.kt b/src/main/kotlin/com/lambda/module/modules/movement/AutoSpiral.kt index 9d4f4060e..67ee5d119 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/AutoSpiral.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/AutoSpiral.kt @@ -23,11 +23,11 @@ import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest -import com.lambda.interaction.managers.rotating.visibilty.lookAt import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.BlockPosIterators import com.lambda.util.extension.isNether +import com.lambda.util.player.RotationUtils.lookAt import net.minecraft.util.math.BlockPos import kotlin.math.sqrt diff --git a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt index ae0f59255..b253bba02 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt @@ -71,6 +71,7 @@ object BetterFirework : Module( if (player.canOpenElytra || player.isGliding) takeoffState = TakeoffState.StartFlying else if (player.canTakeoff) takeoffState = TakeoffState.Jumping } + @Suppress("unused") private var midFlightActivationKey by setting("Mid-Flight Activation Key", Bind.EMPTY, "Firework use key for mid flight activation") .onPress { if (player.isGliding) takeoffState = TakeoffState.StartFlying } private var middleClickCancel by setting("Middle Click Cancel", false, description = "Cancel pick block action on middle mouse click") { activateButton.key != KeyCode.Unbound.code } @@ -100,7 +101,7 @@ object BetterFirework : Module( setModulePriority(1) setDefaultAutomationConfig { applyEdits { - hideAllGroupsExcept(hotbarConfig, inventoryConfig) + hideAllBlocksExcept(hotbarConfig, inventoryConfig) hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) } inventoryConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) } } diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt index c05622e46..03266508c 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt @@ -17,6 +17,7 @@ package com.lambda.module.modules.movement +import com.lambda.config.Tab import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits import com.lambda.event.events.TickEvent @@ -27,7 +28,6 @@ import com.lambda.module.modules.movement.BetterFirework.startFirework import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe import com.lambda.util.CommunicationUtils.info -import com.lambda.util.NamedEnum import com.lambda.util.SpeedUnit import com.lambda.util.Timer import com.lambda.util.player.hasFirework @@ -43,22 +43,31 @@ object ElytraAltitudeControl : Module( description = "Automatically control attitude or speed while elytra flying", tag = ModuleTag.MOVEMENT, ) { + enum class Mode { + Speed, + Altitude + } + + private const val SPEED_CONTROL_TAB = "Speed Control" + private const val ALTITUDE_CONTROL_TAB = "Altitude Control" + private const val PITCH40_CONTROL_TAB = "Pitch 40 Control" + val controlValue by setting("Control Value", Mode.Altitude) val maxPitchAngle by setting("Max Pitch Angle", 45.0, 0.0..90.0, 1.0, unit = "°", description = "Maximum pitch angle") val disableOnFirework by setting("Disable On Firework", false, description = "Disables the module when a firework is used") val targetAltitude by setting("Target Altitude", 120, 0..256, 10, unit = " blocks", description = "Adjusts pitch to control altitude") { controlValue == Mode.Altitude } - val altitudeControllerP by setting("Altitude Control P", 1.2, 0.0..2.0, 0.05).group(Group.AltitudeControl) - val altitudeControllerD by setting("Altitude Control D", 0.85, 0.0..1.0, 0.05).group(Group.AltitudeControl) - val altitudeControllerI by setting("Altitude Control I", 0.04, 0.0..1.0, 0.05).group(Group.AltitudeControl) - val altitudeControllerConst by setting("Altitude Control Const", 0.0, 0.0..10.0, 0.1).group(Group.AltitudeControl) + @Tab(ALTITUDE_CONTROL_TAB) val altitudeControllerP by setting("Altitude Control P", 1.2, 0.0..2.0, 0.05) + @Tab(ALTITUDE_CONTROL_TAB) val altitudeControllerD by setting("Altitude Control D", 0.85, 0.0..1.0, 0.05) + @Tab(ALTITUDE_CONTROL_TAB) val altitudeControllerI by setting("Altitude Control I", 0.04, 0.0..1.0, 0.05) + @Tab(ALTITUDE_CONTROL_TAB) val altitudeControllerConst by setting("Altitude Control Const", 0.0, 0.0..10.0, 0.1) val targetSpeed by setting("Target Speed", 20.0, 0.1..50.0, 0.1, unit = " m/s", description = "Adjusts pitch to control speed") { controlValue == Mode.Speed } val horizontalSpeed by setting("Horizontal Speed", false, description = "Uses horizontal speed instead of total speed for speed control") { controlValue == Mode.Speed } - val speedControllerP by setting("Speed Control P", 6.75, 0.0..10.0, 0.05).group(Group.SpeedControl) - val speedControllerD by setting("Speed Control D", 4.5, 0.0..5.0, 0.05).group(Group.SpeedControl) - val speedControllerI by setting("Speed Control I", 0.3, 0.0..1.0, 0.05).group(Group.SpeedControl) + @Tab(SPEED_CONTROL_TAB) val speedControllerP by setting("Speed Control P", 6.75, 0.0..10.0, 0.05) + @Tab(SPEED_CONTROL_TAB) val speedControllerD by setting("Speed Control D", 4.5, 0.0..5.0, 0.05) + @Tab(SPEED_CONTROL_TAB) val speedControllerI by setting("Speed Control I", 0.3, 0.0..1.0, 0.05) val useFireworkOnHeight by setting("Use Firework On Height", false, "Use fireworks when below a certain height") val minHeight by setting("Min Height", 50, 0..256, 10, unit = " blocks", description = "Minimum height to use firework") { useFireworkOnHeight } @@ -71,14 +80,14 @@ object ElytraAltitudeControl : Module( val altitudeController: PIController = PIController({ altitudeControllerP }, { altitudeControllerD }, { altitudeControllerI }, { altitudeControllerConst }) val usePitch40OnHeight by setting("Use Pitch 40 On Height", false, "Use Pitch 40 to gain height and speed") - val logHeightGain by setting("Log Height Gain", false, "Logs the height gained each cycle to the chat") { usePitch40OnHeight }.group(Group.Pitch40Control) - val minHeightForPitch40 by setting("Min Height For Pitch 40", 120, 0..256, 10, unit = " blocks", description = "Minimum height to use Pitch 40") { usePitch40OnHeight }.group(Group.Pitch40Control) - val pitch40ExitHeight by setting("Exit height", 190, 0..256, 10, unit = " blocks", description = "Height to exit Pitch 40 mode") { usePitch40OnHeight }.group(Group.Pitch40Control) - val pitch40UpStartAngle by setting("Up Start Angle", -49f, -90f..0f, .5f, description = "Start angle when going back up. negative pitch = looking up") { usePitch40OnHeight }.group(Group.Pitch40Control) - val pitch40DownAngle by setting("Down Angle", 33f, 0f..90f, .5f, description = "Angle to dive down at to gain speed") { usePitch40OnHeight }.group(Group.Pitch40Control) - val pitch40AngleChangeRate by setting("Angle Change Rate", 0.5f, 0.1f..5f, 0.01f, description = "Rate at which to increase pitch while in the fly up curve") { usePitch40OnHeight }.group(Group.Pitch40Control) - val pitch40SpeedThreshold by setting("Speed Threshold", 41f, 10f..100f, .5f, description = "Speed at which to start pitching up") { usePitch40OnHeight }.group(Group.Pitch40Control) - val pitch40UseFireworkOnUpTrajectory by setting("Use Firework On Up Trajectory", false, "Use fireworks when converting speed to altitude in the Pitch 40 maneuver") { usePitch40OnHeight }.group(Group.Pitch40Control) + @Tab(PITCH40_CONTROL_TAB) val logHeightGain by setting("Log Height Gain", false, "Logs the height gained each cycle to the chat") { usePitch40OnHeight } + @Tab(PITCH40_CONTROL_TAB) val minHeightForPitch40 by setting("Min Height For Pitch 40", 120, 0..256, 10, unit = " blocks", description = "Minimum height to use Pitch 40") { usePitch40OnHeight } + @Tab(PITCH40_CONTROL_TAB) val pitch40ExitHeight by setting("Exit height", 190, 0..256, 10, unit = " blocks", description = "Height to exit Pitch 40 mode") { usePitch40OnHeight } + @Tab(PITCH40_CONTROL_TAB) val pitch40UpStartAngle by setting("Up Start Angle", -49f, -90f..0f, .5f, description = "Start angle when going back up. negative pitch = looking up") { usePitch40OnHeight } + @Tab(PITCH40_CONTROL_TAB) val pitch40DownAngle by setting("Down Angle", 33f, 0f..90f, .5f, description = "Angle to dive down at to gain speed") { usePitch40OnHeight } + @Tab(PITCH40_CONTROL_TAB) val pitch40AngleChangeRate by setting("Angle Change Rate", 0.5f, 0.1f..5f, 0.01f, description = "Rate at which to increase pitch while in the fly up curve") { usePitch40OnHeight } + @Tab(PITCH40_CONTROL_TAB) val pitch40SpeedThreshold by setting("Speed Threshold", 41f, 10f..100f, .5f, description = "Speed at which to start pitching up") { usePitch40OnHeight } + @Tab(PITCH40_CONTROL_TAB) val pitch40UseFireworkOnUpTrajectory by setting("Use Firework On Up Trajectory", false, "Use fireworks when converting speed to altitude in the Pitch 40 maneuver") { usePitch40OnHeight } var controlState = ControlState.AttitudeControl var state = Pitch40State.GainSpeed @@ -91,7 +100,7 @@ object ElytraAltitudeControl : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllGroupsExcept(rotationConfig) + hideAllBlocksExcept(rotationConfig) } } @@ -221,23 +230,11 @@ object ElytraAltitudeControl : Module( return SpeedUnit.MetersPerSecond.convertFromMinecraft(delta.length()).toFloat() } - enum class Mode { - Speed, - Altitude; - } - enum class ControlState { AttitudeControl, Pitch40Fly } - enum class Group(override val displayName: String) : NamedEnum { - SpeedControl("Speed Control"), - AltitudeControl("Altitude Control"), - Pitch40Control("Pitch 40 Control"), - Rotation("Rotation") - } - enum class Pitch40State { GainSpeed, PitchUp, diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt index 87bbf213b..6a4e778b2 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt @@ -109,7 +109,7 @@ object ElytraFly : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllGroupsExcept(inventoryConfig, rotationConfig) + hideAllBlocksExcept(inventoryConfig, rotationConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt index 109c7b196..c2d712fdb 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt @@ -17,14 +17,14 @@ package com.lambda.module.modules.movement +import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.context.SafeContext import com.lambda.event.events.ClientEvent import com.lambda.event.events.MovementEvent import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest -import com.lambda.config.groups.RotationConfig -import com.lambda.interaction.managers.rotating.RotationMode import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.NamedEnum @@ -49,19 +49,18 @@ object Speed : Module( tag = ModuleTag.MOVEMENT, ) { @JvmStatic - val mode by setting("Mode", Mode.GrimStrafe).onValueChange { _, _ -> reset() } + val mode by setting("Mode", Mode.GrimStrafe) + .onValueChange { _, _ -> reset() } // Grim - private val diagonal by setting("Diagonal", true).group(Mode.GrimStrafe) - private val grimBoatBoost by setting("Boat Boost", 0.4, 0.0..1.7, 0.01).group(Mode.GrimStrafe) + private val diagonal by setting("Diagonal", true) { mode == Mode.GrimStrafe } + private val grimBoatBoost by setting("Boat Boost", 0.4, 0.0..1.7, 0.01) { mode == Mode.GrimStrafe } // NCP - private val strict by setting("Strict", true).group(Mode.NcpStrafe) - private val lowerJump by setting("Lower Jump", true).group(Mode.NcpStrafe) - private val ncpAutoJump by setting("Auto Jump", false).group(Mode.NcpStrafe) - private val ncpTimerBoost by setting("Timer Boost", 1.08, 1.0..1.1, 0.01).group(Mode.NcpStrafe) - - override val rotationConfig = RotationConfig.Instant(RotationMode.Sync) + private val strict by setting("Strict", true) { mode == Mode.NcpStrafe } + private val lowerJump by setting("Lower Jump", true) { mode == Mode.NcpStrafe } + private val ncpAutoJump by setting("Auto Jump", false) { mode == Mode.NcpStrafe } + private val ncpTimerBoost by setting("Timer Boost", 1.08, 1.0..1.1, 0.01) { mode == Mode.NcpStrafe } // NCP state variables const val NCP_BASE_SPEED = 0.2873 @@ -82,6 +81,12 @@ object Speed : Module( } init { + setDefaultAutomationConfig { + applyEdits { + hideAllBlocksExcept(rotationConfig) + } + } + listen { if (!shouldWork()) { reset() diff --git a/src/main/kotlin/com/lambda/module/modules/movement/TargetStrafe.kt b/src/main/kotlin/com/lambda/module/modules/movement/TargetStrafe.kt index 019df5b8c..57ece652e 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/TargetStrafe.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/TargetStrafe.kt @@ -38,7 +38,10 @@ object TargetStrafe : Module( private val stabilize by setting("Stabilize", StabilizationMode.Normal) enum class StabilizationMode { - None, Weak, Normal, Strong + None, + Weak, + Normal, + Strong } private var forwardDirection = 1.0 diff --git a/src/main/kotlin/com/lambda/module/modules/network/PacketLimiter.kt b/src/main/kotlin/com/lambda/module/modules/network/PacketLimiter.kt index 4e927ae85..52e7cb594 100644 --- a/src/main/kotlin/com/lambda/module/modules/network/PacketLimiter.kt +++ b/src/main/kotlin/com/lambda/module/modules/network/PacketLimiter.kt @@ -22,8 +22,8 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.CommunicationUtils.info +import com.lambda.util.ReflectionUtils.className import com.lambda.util.collections.LimitedDecayQueue -import com.lambda.util.className import net.minecraft.network.packet.c2s.common.CommonPongC2SPacket import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket.Full import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket.LookAndOnGround diff --git a/src/main/kotlin/com/lambda/module/modules/player/AntiAim.kt b/src/main/kotlin/com/lambda/module/modules/player/AntiAim.kt index 4b4aa19b5..07cb1c3ce 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/AntiAim.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/AntiAim.kt @@ -17,7 +17,6 @@ package com.lambda.module.modules.player -import com.lambda.config.groups.RotationSettings import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -25,7 +24,6 @@ import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotat import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.NamedEnum import com.lambda.util.math.distSq import net.minecraft.entity.Entity import net.minecraft.entity.player.PlayerEntity @@ -38,38 +36,24 @@ object AntiAim : Module( description = "Rotates the player using the given configs", tag = ModuleTag.MOVEMENT, ) { - private enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Rotation("Rotation") - } + private const val GENERAL_TAB = "General" + private const val ROTATION_TAB = "Rotation" - private val yaw by setting("Yaw Mode", YawMode.Spin, "The mode used when setting the players yaw").group(Group.General) - .onValueChange { _, to -> - if (to == YawMode.Custom) { - // To bypass recursion issue - setConfigCustomYaw(player.yaw) - } - } - private val spinMode by setting("Spin Mode", LeftRight.Right) { yaw == YawMode.Spin }.group(Group.General) - private val sideMode by setting("Side Mode", LeftRight.Left) { yaw == YawMode.Sideways }.group(Group.General) - private var customYaw by setting("Custom Yaw", 0f, -179f..180f, 1f) { yaw == YawMode.Custom }.group(Group.General) - private val yawPlayerMode by setting("Yaw Player mode", PlayerMode.Closest) { yaw == YawMode.Player }.group(Group.General) - - private val pitch by setting("Pitch Mode", PitchMode.UpAndDown, "The mode used when setting the players pitch").group(Group.General) - .onValueChange { _, to -> - if (to == PitchMode.Custom) { - // To bypass recursion issue - setConfigCustomPitch(player.pitch) - } - } - private val verticalMode by setting("Vertical Mode", VerticalMode.Up) { pitch == PitchMode.Vertical }.group(Group.General) - private var customPitch by setting("Custom Pitch", 0f, -90f..90f, 1f) { pitch == PitchMode.Custom }.group(Group.General) - private val pitchPlayerMode by setting("Pitch Player Mode", PlayerMode.Closest) { pitch == PitchMode.Player }.group(Group.General) + private val yaw by setting("Yaw Mode", YawMode.Spin, "The mode used when setting the players yaw") + .onValueChange { _, to -> if (to == YawMode.Custom) customYaw = player.yaw } + private val spinMode by setting("Spin Mode", LeftRight.Right) { yaw == YawMode.Spin } + private val sideMode by setting("Side Mode", LeftRight.Left) { yaw == YawMode.Sideways } + private var customYaw: Float by setting("Custom Yaw", 0f, -179f..180f, 1f) { yaw == YawMode.Custom } + private val yawPlayerMode by setting("Yaw Player mode", PlayerMode.Closest) { yaw == YawMode.Player } - private val yawSpeed by setting("Yaw Speed", 30, 1..90, 1, "Yaw rotation degrees per tick", "°") { yaw != YawMode.None }.group(Group.General) - private val pitchSpeed by setting("Pitch Speed", 30, 1..90, 1, "Pitch rotation degrees per tick", "°") { pitch != PitchMode.None }.group(Group.General) + private val pitch by setting("Pitch Mode", PitchMode.UpAndDown, "The mode used when setting the players pitch") + .onValueChange { _, to -> if (to == PitchMode.Custom) customPitch = player.pitch } + private val upDownMode by setting("Vertical Mode", UpDown.Up) { pitch == PitchMode.Vertical } + private var customPitch: Float by setting("Custom Pitch", 0f, -90f..90f, 1f) { pitch == PitchMode.Custom } + private val pitchPlayerMode by setting("Pitch Player Mode", PlayerMode.Closest) { pitch == PitchMode.Player } - override val rotationConfig = RotationSettings(this, Group.Rotation) + private val yawSpeed by setting("Yaw Speed", 30, 1..90, 1, "Yaw rotation degrees per tick", "°") { yaw != YawMode.None } + private val pitchSpeed by setting("Pitch Speed", 30, 1..90, 1, "Pitch rotation degrees per tick", "°") { pitch != PitchMode.None } private var currentYaw = 0.0f private var currentPitch = 0.0f @@ -142,9 +126,9 @@ object AntiAim : Module( } } PitchMode.Vertical -> { - when (verticalMode) { - VerticalMode.Up -> -90f - VerticalMode.Down -> 90f + when (upDownMode) { + UpDown.Up -> -90f + UpDown.Down -> 90f } } PitchMode.Custom -> customPitch @@ -177,10 +161,6 @@ object AntiAim : Module( customYaw = newYaw } - private fun setConfigCustomPitch(newPitch: Float) { - customPitch = newPitch - } - private enum class YawMode { None, Spin, @@ -211,7 +191,7 @@ object AntiAim : Module( Player } - private enum class VerticalMode { + private enum class UpDown { Up, Down } diff --git a/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt b/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt index 8bb4c17a1..13e2db754 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.player -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.groups.EatConfig.Companion.reasonEating import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -40,7 +40,7 @@ object AutoEat : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllGroupsExcept(eatConfig) + hideAllBlocksExcept(eatConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt index 2938ade84..d9f78c303 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.player -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.event.events.PlayerEvent import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -40,7 +40,7 @@ object FastBreak : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllGroupsExcept(buildConfig, breakConfig, rotationConfig, hotbarConfig) + hideAllBlocksExcept(buildConfig, breakConfig, rotationConfig, hotbarConfig) buildConfig.apply { hide( ::pathing, diff --git a/src/main/kotlin/com/lambda/module/modules/player/Interact.kt b/src/main/kotlin/com/lambda/module/modules/player/Interact.kt index 22adf4154..48fec9a24 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/Interact.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/Interact.kt @@ -25,9 +25,6 @@ object Interact : Module( description = "Modify players interaction with the world", tag = ModuleTag.PLAYER, ) { - @JvmStatic - val placeDelay by setting("Item Use / Place Delay", 4, 0..20, 1, "Sets the delay between placing blocks or using items") - - @JvmStatic - val multiAction by setting("Multi Action", false, "Allows to use many items while breaking blocks") + @JvmStatic val placeDelay by setting("Item Use / Place Delay", 4, 0..20, 1, "Sets the delay between placing blocks or using items") + @JvmStatic val multiAction by setting("Multi Action", false, "Allows to use many items while breaking blocks") } diff --git a/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt b/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt index 9bb2471c6..f7df53467 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt @@ -18,11 +18,11 @@ package com.lambda.module.modules.player import com.lambda.Lambda.mc +import com.lambda.config.groups.RotationConfig import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.gui.LambdaScreen import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest -import com.lambda.config.groups.RotationConfig import com.lambda.interaction.managers.rotating.RotationMode import com.lambda.module.Module import com.lambda.module.tag.ModuleTag @@ -52,7 +52,7 @@ object InventoryMove : Module( private val disableSneak by setting("Disable Sneak", false) private val arrowKeys by setting("Arrow Keys", false, "Allows rotating the players camera using the arrow keys") private val speed by setting("Rotation Speed", 5, 1..20, 1, unit = "°/tick") { arrowKeys } - override val rotationConfig = RotationConfig.Instant(RotationMode.Lock) + override val rotationConfig = settingBlock(RotationConfig.Instant(this, RotationMode.Lock)) @JvmStatic val shouldMove get() = isEnabled && !mc.currentScreen.hasInputOrNull diff --git a/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt b/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt index 206c4e51c..17f17a283 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.player -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.event.events.InventoryEvent import com.lambda.event.events.PlayerEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -49,7 +49,7 @@ object InventoryTweaks : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllGroupsExcept(breakConfig, interactConfig, inventoryConfig, hotbarConfig) + hideAllBlocksExcept(breakConfig, interactConfig, inventoryConfig, hotbarConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt index d26fe6f32..e8e88fab2 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt @@ -17,8 +17,10 @@ package com.lambda.module.modules.player -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.Group import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.groups.BreakConfig import com.lambda.context.SafeContext import com.lambda.event.events.PlayerEvent import com.lambda.event.events.TickEvent @@ -29,7 +31,6 @@ import com.lambda.interaction.construction.simulation.context.BreakContext import com.lambda.interaction.construction.simulation.context.BuildContext import com.lambda.interaction.construction.simulation.result.results.BreakResult import com.lambda.interaction.construction.verify.TargetState -import com.lambda.config.groups.BreakConfig import com.lambda.interaction.managers.breaking.BreakRequest.Companion.breakRequest import com.lambda.module.Module import com.lambda.module.tag.ModuleTag @@ -51,33 +52,30 @@ object PacketMine : Module( description = "automatically breaks blocks, and does it faster", tag = ModuleTag.PLAYER ) { - private enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Renders("Renders") - } + private const val GENERAL_GROUP = "General" + private const val RENDERS_GROUP = "Renders" - private val ignoreWhenHolding by setting("Ignore When Holding", emptySet(), description = "These items won't initiate a break if held when attacking a block").group(Group.General) - private val rebreakMode by setting("Rebreak Mode", RebreakMode.Manual, "The method used to re-break blocks after they've been broken once").disabled { !breakConfig.rebreak }.group(Group.General) - private val breakRadius by setting("Break Radius", 0, 0..5, 1, "Selects and breaks all blocks within the break radius of the selected block").group(Group.General) - private val flatten by setting("Flatten", true, "Wont allow breaking extra blocks under your players position") { breakRadius > 0 }.group(Group.General) - private val queue by setting("Queue", false, "Queues blocks to break so you can select multiple at once").group(Group.General) + @Group(GENERAL_GROUP) private val ignoreWhenHolding by setting("Ignore When Holding", emptySet(), description = "These items won't initiate a break if held when attacking a block") + @Group(GENERAL_GROUP) private val rebreakMode by setting("Rebreak Mode", RebreakMode.Manual, "The method used to re-break blocks after they've been broken once").disabled { !breakConfig.rebreak } + @Group(GENERAL_GROUP) private val breakRadius by setting("Break Radius", 0, 0..5, 1, "Selects and breaks all blocks within the break radius of the selected block") + @Group(GENERAL_GROUP) private val flatten by setting("Flatten", true, "Wont allow breaking extra blocks under your players position") { breakRadius > 0 } + @Group(GENERAL_GROUP) private val queue by setting("Queue", false, "Queues blocks to break so you can select multiple at once") .onValueChange { _, to -> if (!to) queuePositions.clear() } - private val queueOrder by setting("Queue Order", QueueOrder.Standard, "Which end of the queue to break blocks from") { queue }.group(Group.General) + @Group(GENERAL_GROUP) private val queueOrder by setting("Queue Order", QueueOrder.Standard, "Which end of the queue to break blocks from") { queue } - private val renderRebreak by setting("Render Rebreak", true, "Displays what block is being checked for rebreak").group(Group.Renders) - private val rebreakColor by setting("Rebreak Color", Color.RED) { renderRebreak }.group(Group.Renders) - private val renderQueue by setting("Render Queue", true, "Adds renders to signify what block positions are queued").group(Group.Renders) - private val renderSize by setting("Queue Render Size", 0.3f, 0.01f..1f, 0.01f, "The scale of the queue renders") { renderQueue }.group(Group.Renders) - private val renderMode by setting("Queue Render Mode", RenderMode.State, "The style of the queue renders") { renderQueue }.group(Group.Renders) - private val dynamicColor by setting("Queue Dynamic Color", true, "Interpolates the color between start and end") { renderQueue }.group(Group.Renders) - private val staticColor by setting("Queue Color", Color(255, 0, 0, 60)) { renderQueue && !dynamicColor }.group(Group.Renders) - private val startColor by setting("Queue Start Color", Color(255, 255, 0, 60), "The color of the start (closest to breaking) of the queue") { renderQueue && dynamicColor }.group(Group.Renders) - private val endColor by setting("Queue End Color", Color(255, 0, 0, 60), "The color of the end (farthest from breaking) of the queue") { renderQueue && dynamicColor }.group(Group.Renders) + @Group(RENDERS_GROUP) private val renderRebreak by setting("Render Rebreak", true, "Displays what block is being checked for rebreak") + @Group(RENDERS_GROUP) private val rebreakColor by setting("Rebreak Color", Color.RED) { renderRebreak } + @Group(RENDERS_GROUP) private val renderQueue by setting("Render Queue", true, "Adds renders to signify what block positions are queued") + @Group(RENDERS_GROUP) private val renderSize by setting("Queue Render Size", 0.3f, 0.01f..1f, 0.01f, "The scale of the queue renders") { renderQueue } + @Group(RENDERS_GROUP) private val renderMode by setting("Queue Render Mode", RenderMode.State, "The style of the queue renders") { renderQueue } + @Group(RENDERS_GROUP) private val dynamicColor by setting("Queue Dynamic Color", true, "Interpolates the color between start and end") { renderQueue } + @Group(RENDERS_GROUP) private val staticColor by setting("Queue Color", Color(255, 0, 0, 60)) { renderQueue && !dynamicColor } + @Group(RENDERS_GROUP) private val startColor by setting("Queue Start Color", Color(255, 255, 0, 60), "The color of the start (closest to breaking) of the queue") { renderQueue && dynamicColor } + @Group(RENDERS_GROUP) private val endColor by setting("Queue End Color", Color(255, 0, 0, 60), "The color of the end (farthest from breaking) of the queue") { renderQueue && dynamicColor } private val pendingActions = ConcurrentLinkedQueue() private var breaks = 0 - private var itemDrops = 0 private val breakPositions = arrayOfNulls(2) private val queuePositions = ArrayList>() @@ -101,7 +99,7 @@ object PacketMine : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllGroupsExcept(buildConfig, breakConfig, breakConfig.outlineConfig, rotationConfig, hotbarConfig) + hideAllBlocksExcept(buildConfig, breakConfig, breakConfig.outlineConfig, rotationConfig, hotbarConfig) buildConfig.apply { hide( ::pathing, diff --git a/src/main/kotlin/com/lambda/module/modules/player/Replay.kt b/src/main/kotlin/com/lambda/module/modules/player/Replay.kt index 92631d1a1..5c9d84508 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/Replay.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/Replay.kt @@ -26,6 +26,9 @@ import com.google.gson.JsonNull import com.google.gson.JsonSerializationContext import com.google.gson.JsonSerializer import com.lambda.brigadier.CommandResult +import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.groups.RotationConfig import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.context.SafeContext import com.lambda.core.TimerHandler @@ -36,7 +39,6 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.gui.components.ClickGuiLayout import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest import com.lambda.interaction.managers.rotating.Rotation -import com.lambda.config.groups.RotationConfig import com.lambda.interaction.managers.rotating.RotationMode import com.lambda.module.Module import com.lambda.module.modules.player.Replay.InputAction.Companion.toAction @@ -103,7 +105,7 @@ object Replay : Module( private val deviationThreshold by setting("Deviation threshold", 0.1, 0.1..5.0, 0.1, description = "The threshold for the deviation to cancel the replay.") { cancelOnDeviation } private val lockCamera by setting("Lock Camera", true) - override val rotationConfig = object : RotationConfig.Instant(RotationMode.Sync) { + override val rotationConfig = object : RotationConfig.Instant(this, RotationMode.Sync) { override val rotationMode = if (lockCamera) RotationMode.Lock else RotationMode.Sync } diff --git a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt index a7a9694b4..7a106b81b 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt @@ -18,14 +18,13 @@ package com.lambda.module.modules.player import com.lambda.config.applyEdits -import com.lambda.config.groups.RotationSettings +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest import com.lambda.interaction.managers.rotating.RotationMode import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.NamedEnum import kotlin.math.roundToInt @Suppress("unused") @@ -34,26 +33,23 @@ object RotationLock : Module( description = "Locks the player rotation to the given configuration", tag = ModuleTag.PLAYER, ) { - private enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Rotation("Rotation") - } - - @JvmStatic val yawMode by setting("Yaw Mode", Mode.Snap).group(Group.General) - private val yawStep by setting("Yaw Step", 45.0, 1.0..180.0, 0.1) { yawMode == Mode.Snap }.group(Group.General) - private val customYaw by setting("Custom Yaw", 0.0, -179.0..180.0, 0.1) { yawMode == Mode.Custom }.group(Group.General) - @JvmStatic val pitchMode by setting("Pitch Mode", Mode.None).group(Group.General) - private val pitchStep by setting("Pitch Step", 45.0, 1.0..90.0, 0.1) { pitchMode == Mode.Snap }.group(Group.General) - private val customPitch by setting("Custom Pitch", 0.0, -90.0..90.0, 0.1) { pitchMode == Mode.Custom }.group(Group.General) - - override val rotationConfig = RotationSettings(this, Group.Rotation).apply { - applyEdits { - ::rotationMode.edit { defaultValue(RotationMode.Lock) } - } - } + @JvmStatic val yawMode by setting("Yaw Mode", Mode.Snap) + private val yawStep by setting("Yaw Step", 45.0, 1.0..180.0, 0.1) { yawMode == Mode.Snap } + private val customYaw by setting("Custom Yaw", 0.0, -179.0..180.0, 0.1) { yawMode == Mode.Custom } + @JvmStatic val pitchMode by setting("Pitch Mode", Mode.None) + private val pitchStep by setting("Pitch Step", 45.0, 1.0..90.0, 0.1) { pitchMode == Mode.Snap } + private val customPitch by setting("Custom Pitch", 0.0, -90.0..90.0, 0.1) { pitchMode == Mode.Custom } init { setModulePriority(100) + + setDefaultAutomationConfig { + applyEdits { + hideAllBlocksExcept(rotationConfig) + rotationConfig::rotationMode.edit { defaultValue(RotationMode.Lock) } + } + } + listen { val yaw = when (yawMode) { Mode.Custom -> customYaw diff --git a/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt b/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt index b44851bc6..ecedade9f 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.player -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -43,7 +43,7 @@ object StackReplenish : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllGroupsExcept(inventoryConfig) + hideAllBlocksExcept(inventoryConfig) inventoryConfig.apply { hide(::disposables, ::swapWithDisposables, ::providerPriority, ::storePriority) } diff --git a/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt b/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt index 0638f9933..4a0e51a2c 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.player -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.event.events.ContainerEvent import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -45,7 +45,7 @@ object ToolSaver : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllGroupsExcept(inventoryConfig) + hideAllBlocksExcept(inventoryConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt b/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt index d83670267..042f9fb26 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt @@ -17,6 +17,7 @@ package com.lambda.module.modules.render +import com.lambda.config.Group import com.lambda.config.applyEdits import com.lambda.config.groups.OutlineSettings import com.lambda.config.groups.WorldLineSettings @@ -26,7 +27,6 @@ import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRend import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.BlockUtils.blockState -import com.lambda.util.NamedEnum import com.lambda.util.extension.tickDelta import com.lambda.util.math.lerp import com.lambda.util.world.raycast.RayCastUtils.blockResult @@ -43,26 +43,26 @@ object BlockOutline : Module( Outline } - private enum class BoxGroup(override val displayName: String) : NamedEnum { - Fill("Fill"), - Outline("Outline") - } - private val mode by setting("Mode", Mode.Boxes) private val interpolate by setting("Interpolate", true) { mode == Mode.Boxes } private val depthTest by setting("Depth Test", true) - private val fill by setting("Fill", true) { mode == Mode.Boxes }.group(BoxGroup.Fill) - private val fillColor by setting("Fill Color", Color(255, 255, 255, 20)) { fill && mode == Mode.Boxes }.group(BoxGroup.Fill) - private val boxOutline by setting("Box Outline", true) { mode == Mode.Boxes }.group(BoxGroup.Outline, WorldLineSettings.Group.General) - private val boxOutlineColor by setting("Box Outline Color", Color(255, 255, 255, 120)) { boxOutline && mode == Mode.Boxes }.group(BoxGroup.Outline, WorldLineSettings.Group.General) - private val lineConfig = WorldLineSettings(this, BoxGroup.Outline, prefix = "Outline ") { boxOutline && mode == Mode.Boxes }.apply { - applyEdits { - hide(::startColor, ::endColor) - } - } - private val outlineColor by setting("Outline Color", boxOutlineColor) { mode == Mode.Outline } - private val outlineStyle = OutlineSettings(this, prefix = "Outline") { mode == Mode.Outline } + private const val BOX_FILL_GROUP = "Box Fill" + private const val BOX_OUTLINE_GROUP = "Box Outline" + private const val OUTLINE_GROUP = "Outline" + + @Group(BOX_FILL_GROUP) private val fill by setting("Fill", true) { mode == Mode.Boxes } + @Group(BOX_FILL_GROUP) private val fillColor by setting("Fill Color", Color(255, 255, 255, 20)) { fill && mode == Mode.Boxes } + @Group(BOX_OUTLINE_GROUP) private val boxOutline by setting("Box Outline", true) { mode == Mode.Boxes } + @Group(BOX_OUTLINE_GROUP) private val boxOutlineColor by setting("Box Outline Color", Color(255, 255, 255, 120)) { boxOutline && mode == Mode.Boxes } + @Group(BOX_OUTLINE_GROUP) private val lineConfig = + settingBlock( + WorldLineSettings(this), + { boxOutline && mode == Mode.Boxes } + ) { applyEdits { hide(::startColor, ::endColor) } } + + @Group(OUTLINE_GROUP) private val outlineColor by setting("Outline Color", boxOutlineColor) { mode == Mode.Outline } + @Group(OUTLINE_GROUP) private val outlineStyle = settingBlock(OutlineSettings(this), { mode == Mode.Outline }) var previous: List? = null diff --git a/src/main/kotlin/com/lambda/module/modules/render/CameraTweaks.kt b/src/main/kotlin/com/lambda/module/modules/render/CameraTweaks.kt index 8822e1b32..21c383419 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/CameraTweaks.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/CameraTweaks.kt @@ -25,9 +25,6 @@ object CameraTweaks : Module( description = "Adjusts camera settings", tag = ModuleTag.RENDER, ) { - @JvmStatic - val camDistance by setting("Camera Distance", 4.0f, 1.0f..20.0f, 0.1f) - - @JvmStatic - val noClipCam by setting("No Clip Camera", true) + @JvmStatic val camDistance by setting("Camera Distance", 4.0f, 1.0f..20.0f, 0.1f) + @JvmStatic val noClipCam by setting("No Clip Camera", true) } diff --git a/src/main/kotlin/com/lambda/module/modules/render/ContainerPreview.kt b/src/main/kotlin/com/lambda/module/modules/render/ContainerPreview.kt index ca2e2d52e..ce91e71c8 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/ContainerPreview.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/ContainerPreview.kt @@ -18,15 +18,14 @@ package com.lambda.module.modules.render import com.lambda.Lambda.mc +import com.lambda.config.Tab import com.lambda.config.settings.complex.Bind import com.lambda.interaction.material.container.containers.EnderChestContainer import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe -import com.lambda.util.Describable import com.lambda.util.InputUtils.isSatisfied import com.lambda.util.KeyCode -import com.lambda.util.NamedEnum import com.lambda.util.item.ItemStackUtils.bundleContents import com.lambda.util.item.ItemStackUtils.shulkerBoxContents import com.lambda.util.item.ItemUtils.bundles @@ -57,23 +56,23 @@ import net.minecraft.world.World import org.joml.Matrix3x2f import kotlin.math.max - object ContainerPreview : Module( name = "ContainerPreview", description = "Renders shulker box contents visually in tooltips", tag = ModuleTag.RENDER, ) { - private val lockKey by setting("Lock Key", Bind(KeyCode.LeftShift.code, 0, -1), "Key to lock the tooltip in place for item interaction").group(Group.ContainerTooltip) - private val colorTint by setting("Color Tint", true, "Tint the background with the shulker box color").group(Group.ContainerTooltip) - - private val contentPreview by setting("Content Preview", true, "Show a preview of the most common item in a container on the container item in inventories").group(Group.ContentPreview) - private val previewItemScale by setting("Item Scale", 11f, 1f..32f, 0.1f, "Scale of the item icons on a container item") { contentPreview }.group(Group.ContentPreview) - private val previewItemXOffset by setting("Item X Offset", -2f, -32f..32f, 0.1f, "X offset of the item icons on a container item") { contentPreview }.group(Group.ContentPreview) - private val previewItemYOffset by setting("Item Y Offset", 2f, -32f..32f, 0.1f, "Y offset of the item icons on a container item") { contentPreview }.group(Group.ContentPreview) - private val previewItemWeightedCount by setting("Weighted Count", true, description = "Count items for preview in containers relative to max stack size") { contentPreview }.group(Group.ContentPreview) - .onValueChange { _, _ -> - containerCache.clear() - } + private const val CONTAINER_TOOLTIP_TAB = "Container Tooltip" + private const val CONTENT_PREVIEW_TAB = "Content Preview" + + @Tab(CONTAINER_TOOLTIP_TAB) private val lockKey by setting("Lock Key", Bind(KeyCode.LeftShift.code, 0, -1), "Key to lock the tooltip in place for item interaction") + @Tab(CONTAINER_TOOLTIP_TAB) private val colorTint by setting("Color Tint", true, "Tint the background with the shulker box color") + + @Tab(CONTENT_PREVIEW_TAB) private val contentPreview by setting("Content Preview", true, "Show a preview of the most common item in a container on the container item in inventories") + @Tab(CONTENT_PREVIEW_TAB) private val previewItemScale by setting("Item Scale", 11f, 1f..32f, 0.1f, "Scale of the item icons on a container item") { contentPreview } + @Tab(CONTENT_PREVIEW_TAB) private val previewItemXOffset by setting("Item X Offset", -2f, -32f..32f, 0.1f, "X offset of the item icons on a container item") { contentPreview } + @Tab(CONTENT_PREVIEW_TAB) private val previewItemYOffset by setting("Item Y Offset", 2f, -32f..32f, 0.1f, "Y offset of the item icons on a container item") { contentPreview } + @Tab(CONTENT_PREVIEW_TAB) private val previewItemWeightedCount by setting("Weighted Count", true, description = "Count items for preview in containers relative to max stack size") { contentPreview } + .onValueChange { _, _ -> containerCache.clear() } private val background = Identifier.ofVanilla("textures/gui/container/shulker_box.png") @@ -428,11 +427,6 @@ object ContainerPreview : Module( } } - enum class Group(override val displayName: String, override val description: String) : NamedEnum, Describable { - ContentPreview("Preview", "Settings related to the item preview rendered on container items in inventories"), - ContainerTooltip("Container", "Settings related to container tooltip previews") - } - open class ContainerComponent(val stack: ItemStack) : TooltipData, TooltipComponent { override fun drawItems(textRenderer: TextRenderer, x: Int, y: Int, width: Int, height: Int, context: DrawContext) {} override fun getHeight(textRenderer: TextRenderer): Int = 0 diff --git a/src/main/kotlin/com/lambda/module/modules/render/ESP.kt b/src/main/kotlin/com/lambda/module/modules/render/ESP.kt index cd1fddadc..1dab2a16a 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/ESP.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/ESP.kt @@ -17,6 +17,8 @@ package com.lambda.module.modules.render +import com.lambda.config.Group +import com.lambda.config.Tab import com.lambda.config.applyEdits import com.lambda.config.groups.EntityColorSettings import com.lambda.config.groups.EntitySelectionSettings @@ -40,39 +42,45 @@ object ESP : Module( description = "Highlight entities with smooth interpolated rendering", tag = ModuleTag.RENDER ) { - private enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Shader("Shader"), - Box("Box"), -// Frame("Frame"), - Entities("Entities"), - Colors("Colors") + private enum class EspMode { + Shader, + Box, + //ToDo: Implement +// Frame } + private const val GENERAL_TAB = "General" + private const val ENTITIES_TAB = "Entities" + private const val COLORS_TAB = "Colors" + + private const val BOX_OUTLINE_GROUP = "Outline" + private enum class BoxGroup(override val displayName: String) : NamedEnum { Fill("Fill"), Outline("Outline") } - private val mode by setting("Mode", EspMode.Shader).group(Group.General) - private val depthTest by setting("Depth Test", false, "Blend ESP renders into the world").group(Group.General) + @Tab(GENERAL_TAB) private val mode by setting("Mode", EspMode.Shader) + @Tab(GENERAL_TAB) private val depthTest by setting("Depth Test", false, "Blend ESP renders into the world") - private val outlineStyle = OutlineSettings(this, Group.Shader) { mode == EspMode.Shader } + //Shader Outline + @Tab(GENERAL_TAB) private val outlineStyle = settingBlock(OutlineSettings(this), { mode == EspMode.Shader }) - private var drawFilled: Boolean by setting("Box Fill", true, "Fill entity boxes") { mode == EspMode.Box }.group(Group.Box, BoxGroup.Fill) + //Box + @Tab(GENERAL_TAB) private var drawFilled: Boolean by setting("Box Fill", true, "Fill entity boxes") { mode == EspMode.Box } .onValueChange { _, to -> if (!to && !drawOutline) drawOutline = true } - private var drawOutline: Boolean by setting("Box Outline", true, "Draw box outlines") { mode == EspMode.Box }.group(Group.Box, BoxGroup.Outline, WorldLineSettings.Group.General) + @Tab(GENERAL_TAB) private val fillAlpha by setting("Filled Alpha", 0.2, 0.0..1.0, 0.05) { mode == EspMode.Box && drawFilled } + @Tab(GENERAL_TAB) @Group(BOX_OUTLINE_GROUP) private var drawOutline: Boolean by setting("Box Outline", true, "Draw box outlines") { mode == EspMode.Box } .onValueChange { _, to -> if (!to && !drawFilled) drawFilled = true } - private val boxOutlineSettings = WorldLineSettings(this, Group.Box, BoxGroup.Outline) { mode == EspMode.Box && drawOutline }.apply { - applyEdits { - hide(::startColor, ::endColor) - } - } - private val fillAlpha by setting("Filled Alpha", 0.2, 0.0..1.0, 0.05) { mode == EspMode.Box && drawFilled }.group(Group.Box) - private val outlineAlpha by setting("Outline Alpha", 0.8, 0.0..1.0, 0.05) { mode == EspMode.Box && drawOutline }.group(Group.Box) + @Tab(GENERAL_TAB) @Group(BOX_OUTLINE_GROUP) private val outlineAlpha by setting("Outline Alpha", 0.8, 0.0..1.0, 0.05) { mode == EspMode.Box && drawOutline } + @Tab(GENERAL_TAB) @Group(BOX_OUTLINE_GROUP) private val boxOutlineSettings = + settingBlock( + WorldLineSettings(this), + { mode == EspMode.Box && drawOutline } + ) { applyEdits { hide(::startColor, ::endColor) } } - private val entitySettings = EntitySelectionSettings(this, Group.Entities) - private val entityColors = EntityColorSettings(this, Group.Colors) + @Tab(ENTITIES_TAB) private val entitySettings = EntitySelectionSettings(this) + @Tab(COLORS_TAB) private val entityColors = EntityColorSettings(this) init { immediateRenderer("EntityESP Immediate Renderer", depthTest = { depthTest }) { safeContext -> @@ -127,11 +135,4 @@ object ESP : Module( } } } - - private enum class EspMode { - Shader, - Box, - //ToDo: Implement -// Frame - } } diff --git a/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt b/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt index 41f6e0e4d..25fe54004 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt @@ -18,8 +18,8 @@ package com.lambda.module.modules.render import com.lambda.Lambda.mc -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.context.SafeContext import com.lambda.event.events.MovementEvent import com.lambda.event.events.PlayerEvent @@ -29,7 +29,6 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest import com.lambda.interaction.managers.rotating.Rotation import com.lambda.interaction.managers.rotating.RotationMode -import com.lambda.interaction.managers.rotating.visibilty.lookAt import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe @@ -51,6 +50,7 @@ import com.lambda.util.player.MovementUtils.newMovementInput import com.lambda.util.player.MovementUtils.roundedForward import com.lambda.util.player.MovementUtils.roundedStrafing import com.lambda.util.player.MovementUtils.verticalMovement +import com.lambda.util.player.RotationUtils.lookAt import com.lambda.util.world.raycast.RayCastUtils.orMiss import net.minecraft.client.network.ClientPlayerEntity import net.minecraft.client.option.Perspective @@ -127,7 +127,7 @@ object Freecam : Module( rotationConfig::rotationMode.edit { defaultValue(RotationMode.Lock) } - hideAllGroupsExcept(rotationConfig) + hideAllBlocksExcept(rotationConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt b/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt index 1295bcb5a..4e61e75cc 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt @@ -17,6 +17,7 @@ package com.lambda.module.modules.render +import com.lambda.config.Group import com.lambda.config.applyEdits import com.lambda.config.groups.WorldLineSettings import com.lambda.context.SafeContext @@ -28,7 +29,6 @@ import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe import com.lambda.util.BlockUtils.blockState -import com.lambda.util.NamedEnum import com.lambda.util.math.flooredBlockPos import com.lambda.util.math.setAlpha import com.lambda.util.math.vec3d @@ -46,10 +46,8 @@ object LightLevels : Module( description = "Shows light level. Helpful for mob-proofing areas", tag = ModuleTag.RENDER ) { - private enum class Group(override val displayName: String) : NamedEnum { - Fill("Fill"), - Line("Line") - } + private const val FILL_GROUP = "Fill" + private const val LINE_GROUP = "Line" private val mode: Mode by setting("Mode", Mode.Chunked) .onValueChange { _, _ -> chunkedRenderer.clear(); refreshChunkedRenderer(this) } @@ -59,15 +57,16 @@ object LightLevels : Module( private val skyLightColor by setting("Sky Light Color", Color.YELLOW).onValueChange(::refreshChunkedRenderer) private val blockLightColor by setting("Block Light Color", Color.RED).onValueChange(::refreshChunkedRenderer) private val size by setting("Size", 14, 1..16).onValueChange(::refreshChunkedRenderer) - private val fill by setting("Fill", false) { renderMode == RenderMode.Square }.group(Group.Fill).onValueChange(::refreshChunkedRenderer) - private val fillAlpha by setting("Fill Alpha", 0.2, 0.0..1.0, 0.01) { renderMode == RenderMode.Square && fill }.group(Group.Fill).onValueChange(::refreshChunkedRenderer) - private val outline by setting("Outline", true) { renderMode == RenderMode.Square }.group(Group.Line, WorldLineSettings.Group.General).onValueChange(::refreshChunkedRenderer) - private val worldLineConfig = WorldLineSettings(this, Group.Line) { renderMode != RenderMode.Square || outline }.apply { - applyEdits { - hide(::startColor, ::endColor) - settings.forEach { it.onValueChange(::refreshChunkedRenderer) } + @Group(FILL_GROUP) private val fill by setting("Fill", false) { renderMode == RenderMode.Square }.onValueChange(::refreshChunkedRenderer) + @Group(FILL_GROUP) private val fillAlpha by setting("Fill Alpha", 0.2, 0.0..1.0, 0.01) { renderMode == RenderMode.Square && fill }.onValueChange(::refreshChunkedRenderer) + @Group(LINE_GROUP) private val outline by setting("Outline", true) { renderMode == RenderMode.Square }.onValueChange(::refreshChunkedRenderer) + @Group(LINE_GROUP) private val worldLineConfig = + settingBlock(WorldLineSettings(this), { renderMode != RenderMode.Square || outline }) { + applyEdits { + hide(::startColor, ::endColor) + forEachSetting { it.onValueChange(::refreshChunkedRenderer) } + } } - } private val depthTest by setting("Depth Test", false, "Shows renders through terrain") private val horizontalRange by setting("Horizontal Range", 16, 1..32) { mode == Mode.Radius } private val verticalRange by setting("Vertical Range", 8, 1..32) { mode == Mode.Radius } diff --git a/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt b/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt index 796275f63..9bd5312a3 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt @@ -18,6 +18,8 @@ package com.lambda.module.modules.render import com.lambda.Lambda.mc +import com.lambda.config.Group +import com.lambda.config.Tab import com.lambda.config.applyEdits import com.lambda.config.groups.EntitySelectionSettings import com.lambda.config.groups.ScreenTextSettings @@ -29,7 +31,6 @@ import com.lambda.graphics.text.FontHandler import com.lambda.graphics.util.DynamicAABB.Companion.interpolatedBox import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.NamedEnum import com.lambda.util.extension.fullHealth import com.lambda.util.extension.maxFullHealth import com.lambda.util.math.MathUtils.roundToStep @@ -51,48 +52,50 @@ object Nametags : Module( description = "Displays information about entities above them", tag = ModuleTag.RENDER ) { - @Suppress("unused") - private enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Entities("Entities"), - Background("Background"), - Text("Text") - } - - private enum class TextGroup(override val displayName: String): NamedEnum { - Other("Other"), - Friend("Friend") - } + private const val GENERAL_TAB = "General" + private const val ENTITY_TAB = "Entities" + private const val BACKGROUND_TAB = "Background" + private const val TEXT_TAB = "Text" - private val itemScale by setting("Item Scale", 3f, 0.4f..5f, 0.01f).group(Group.General) - private val yOffset by setting("Y Offset", 0.2, 0.0..1.0, 0.01).group(Group.General) - private val spacing by setting("Spacing", 0, 0..10, 1).group(Group.General) - private val health by setting("Health", true).group(Group.General) - private val ping by setting("Ping", true).group(Group.General) - private val gear by setting("Gear", true).group(Group.General) - private val mainItem by setting("Main Item", true) { gear }.group(Group.General) - private val offhandItem by setting("Offhand Item", true) { gear }.group(Group.General) - private val itemName by setting("Item Name", true).group(Group.General) - private val itemNameScale by setting("Item Name Scale", 0.7f, 0.1f..1.0f, 0.01f) { itemName }.group(Group.General) - private val itemCount by setting("Item Count", true).group(Group.General) - private val durabilityMode by setting("Durability Mode", DurabilityMode.Text) { gear }.group(Group.General) - private val entitySelectionSettings = EntitySelectionSettings(this, Group.Entities).apply { - applyEdits { - hide(::blockEntities) - } - } - private val background by setting("Background", true).group(Group.Background) - private val backgroundColor by setting("Background Color", Color(0, 0, 0, 60)) { background }.group(Group.Background) - private val backgroundSize by setting("Background Size", 1.0f, 1.0f..2.0f, 0.01f) { background }.group(Group.Background) + @Tab(GENERAL_TAB) private val textSize by setting("Text Size", 18, 1..50, 1) + @Tab(GENERAL_TAB) private val itemScale by setting("Item Scale", 3f, 0.4f..5f, 0.01f) + @Tab(GENERAL_TAB) private val yOffset by setting("Y Offset", 0.2, 0.0..1.0, 0.01) + @Tab(GENERAL_TAB) private val spacing by setting("Spacing", 0, 0..10, 1) + @Tab(GENERAL_TAB) private val health by setting("Health", true) + @Tab(GENERAL_TAB) private val ping by setting("Ping", true) + @Tab(GENERAL_TAB) private val gear by setting("Gear", true) + @Tab(GENERAL_TAB) private val mainItem by setting("Main Item", true) { gear } + @Tab(GENERAL_TAB) private val offhandItem by setting("Offhand Item", true) { gear } //ToDo: Implement // private val enchantments by setting("Enchantments", false) { gear } + @Tab(GENERAL_TAB) private val itemName by setting("Item Name", true) + @Tab(GENERAL_TAB) private val itemNameScale by setting("Item Name Scale", 0.7f, 0.1f..1.0f, 0.01f) { itemName } + @Tab(GENERAL_TAB) private val itemCount by setting("Item Count", true) + @Tab(GENERAL_TAB) private val durabilityMode by setting("Durability Mode", DurabilityMode.Text) { gear } - private val friendTextConfig = ScreenTextSettings(this, TextGroup.Friend, prefix = "Friend ").apply { - applyEdits { - ::textColor.edit { defaultValue(Color(0, 255, 255, 255)) } + @Tab(ENTITY_TAB) private val entitySelectionSettings = + settingBlock(EntitySelectionSettings(this)) { + applyEdits { + hide(::blockEntities) + } } - } - private val otherTextConfig = ScreenTextSettings(this, TextGroup.Other, prefix = "Other ") + + @Tab(BACKGROUND_TAB) private val background by setting("Background", true) + @Tab(BACKGROUND_TAB) private val backgroundColor by setting("Background Color", Color(0, 0, 0, 60)) { background } + @Tab(BACKGROUND_TAB) private val backgroundSize by setting("Background Size", 1.0f, 1.0f..2.0f, 0.01f) { background } + + private const val FRIEND_GROUP = "Friends" + private const val OTHER_GROUP = "Others" + + @Tab(TEXT_TAB) @Group(FRIEND_GROUP) private val friendTextConfig = + settingBlock(ScreenTextSettings(this)) { + applyEdits { + hide(::sizeSetting) + ::textColor.edit { defaultValue(Color(0, 255, 255, 255)) } + } + } + @Tab(TEXT_TAB) @Group(OTHER_GROUP) private val otherTextConfig = + settingBlock(ScreenTextSettings(this)) { applyEdits { hide(::sizeSetting) } } var heightWidthRatio = 0f var trueItemScaleX = 0f @@ -121,9 +124,9 @@ object Nametags : Module( if (entity is PlayerEntity && entity.isFriend) friendTextConfig else otherTextConfig val textStyle = textConfig.getSDFStyle() - val textSize = textConfig.size + val size = textSize * 0.001f val nameText = entity.displayName?.string ?: return@forEach - val nameWidth = FontHandler.getStringWidthNormalized(nameText, textSize) + val nameWidth = FontHandler.getStringWidthNormalized(nameText, size) val box = entity.interpolatedBox val boxCenter = box.center var (anchorX, anchorY) = @@ -134,22 +137,22 @@ object Nametags : Module( if (entity !is LivingEntity) { if (background) { - screenRect(anchorX - halfNameWidth - trueBGSizeX, anchorY - trueBGSizeY, nameWidth + (trueBGSizeX * 2), textSize + (trueBGSizeY * 2), backgroundColor) + screenRect(anchorX - halfNameWidth - trueBGSizeX, anchorY - trueBGSizeY, nameWidth + (trueBGSizeX * 2), size + (trueBGSizeY * 2), backgroundColor) } - screenText(nameText, anchorX, anchorY, textSize, style = textStyle, centered = true) + screenText(nameText, anchorX, anchorY, size, style = textStyle, centered = true) return@forEach } val healthCount = if (health) entity.fullHealth else -1.0 val healthText = if (health) " ${healthCount.roundToStep(0.01)}" else "" val healthWidth = - FontHandler.getStringWidthNormalized(healthText, textSize) + FontHandler.getStringWidthNormalized(healthText, size) .let { if (healthCount > 0) it + trueSpacingX else it } val pingCount = if (ping && entity is PlayerEntity) connection.getPlayerListEntry(entity.uuid)?.latency ?: -1 else -1 val pingText = if (pingCount >= 0) " [$pingCount]" else "" val pingWidth = - FontHandler.getStringWidthNormalized(pingText, textSize) + FontHandler.getStringWidthNormalized(pingText, size) .let { if (pingCount >= 0) it + trueSpacingX else it } var combinedWidth = nameWidth + healthWidth + pingWidth @@ -157,7 +160,7 @@ object Nametags : Module( val itemName = itemName && !entity.mainHandStack.isEmpty val itemNameText = if (itemName) entity.mainHandStack.name.string else "" - val itemNameSize = if (itemName) textSize * itemNameScale else 0f + val itemNameSize = if (itemName) size * itemNameScale else 0f if (background) { anchorY += trueBGSizeY @@ -165,21 +168,21 @@ object Nametags : Module( val maxWidth = if (itemName) max(itemNameWidth, combinedWidth) else combinedWidth - screenRect((anchorX - (maxWidth * 0.5f)) - trueBGSizeX, anchorY - trueBGSizeY, maxWidth + (trueBGSizeX * 2), textSize + itemNameSize + trueSpacingY + (trueBGSizeY * 2), backgroundColor) + screenRect((anchorX - (maxWidth * 0.5f)) - trueBGSizeX, anchorY - trueBGSizeY, maxWidth + (trueBGSizeX * 2), size + itemNameSize + trueSpacingY + (trueBGSizeY * 2), backgroundColor) } if (itemName) { screenText(itemNameText, anchorX, anchorY, itemNameSize, centered = true) anchorY += (itemNameSize * 1.1f) + trueSpacingY } - screenText(nameText, nameX, anchorY, textSize, style = textStyle) + screenText(nameText, nameX, anchorY, size, style = textStyle) if (healthCount >= 0) { val healthColor = lerp(entity.fullHealth / entity.maxFullHealth, Color.RED, Color.GREEN).brighter() - screenText(healthText, nameX + nameWidth + trueSpacingX, anchorY, textSize, style = textStyle.apply { color = healthColor }) + screenText(healthText, nameX + nameWidth + trueSpacingX, anchorY, size, style = textStyle.apply { color = healthColor }) } if (pingCount >= 0) { val pingColor = lerp(pingCount / 500.0, Color.GREEN, Color.RED).brighter() - screenText(pingText, nameX + nameWidth + healthWidth + trueSpacingX, anchorY, textSize, style = textStyle.apply { color = pingColor }) + screenText(pingText, nameX + nameWidth + healthWidth + trueSpacingX, anchorY, size, style = textStyle.apply { color = pingColor }) } if (!gear) return@forEach @@ -187,12 +190,12 @@ object Nametags : Module( if (background) anchorY += trueBGSizeY if (EquipmentSlot.entries.none { it.index in 1..4 && !entity.getEquippedStack(it).isEmpty }) { - anchorY -= textSize * 0.5f + anchorY -= size * 0.5f if (mainItem && !entity.mainHandStack.isEmpty) renderItem(entity.mainHandStack, nameX - trueItemScaleX - trueSpacingX, anchorY) if (offhandItem && !entity.offHandStack.isEmpty) renderItem(entity.offHandStack, anchorX + (combinedWidth * 0.5f) + trueSpacingX, anchorY) - } else drawArmorAndItems(entity, anchorX, anchorY + textSize + trueSpacingY) + } else drawArmorAndItems(entity, anchorX, anchorY + size + trueSpacingY) } } } diff --git a/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt b/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt index a9a0e053f..dd2f7025e 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt @@ -17,13 +17,13 @@ package com.lambda.module.modules.render +import com.lambda.config.Tab import com.lambda.config.applyEdits import com.lambda.config.groups.EntitySelectionSettings import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.EntityUtils.createNameMap -import com.lambda.util.NamedEnum -import com.lambda.util.scanResult +import com.lambda.util.ReflectionUtils.scanResult import net.minecraft.block.entity.BlockEntity import net.minecraft.client.particle.Particle import net.minecraft.entity.Entity @@ -36,61 +36,56 @@ object NoRender : Module( ) { private val particleMap = createParticleNameMap() - private enum class Group(override val displayName: String) : NamedEnum { - Hud("Hud"), - Entity("Entity"), - World("World"), - Effect("Effect") - } + private const val EFFECT_TAB = "Effect" + private const val HUD_TAB = "Hud" + private const val ENTITY_TAB = "Entity" + private const val WORLD_TAB = "World" - @JvmStatic val noBlindness by setting("No Blindness", true).group(Group.Effect) - @JvmStatic val noDarkness by setting("No Darkness", true).group(Group.Effect) - @JvmStatic val noNausea by setting("No Nausea", true).group(Group.Effect) + @Tab(EFFECT_TAB) @JvmStatic val noBlindness by setting("No Blindness", true) + @Tab(EFFECT_TAB) @JvmStatic val noDarkness by setting("No Darkness", true) + @Tab(EFFECT_TAB) @JvmStatic val noNausea by setting("No Nausea", true) - @JvmStatic val noFireOverlay by setting("No Fire Overlay", false).group(Group.Hud) - @JvmStatic val fireOverlayYOffset by setting("Fire Overlay Y Offset", 0.0, -0.4..0.4, 0.02) { !noFireOverlay }.group(Group.Hud) - @JvmStatic val noPortalOverlay by setting("No Portal Overlay", true).group(Group.Hud) - @JvmStatic val noFluidOverlay by setting("No Fluid Overlay", true).group(Group.Hud) - @JvmStatic val noPowderedSnowOverlay by setting("No Powdered Snow Overlay", true).group(Group.Hud) - @JvmStatic val noInWall by setting("No In Wall Overlay", true).group(Group.Hud) - @JvmStatic val noPumpkinOverlay by setting("No Pumpkin Overlay", true).group(Group.Hud) - @JvmStatic val noVignette by setting("No Vignette", true).group(Group.Hud) - @JvmStatic val noChatVerificationToast by setting("No Chat Verification Toast", true).group(Group.Hud) - @JvmStatic val noSpyglassOverlay by setting("No Spyglass Overlay", false).group(Group.Hud) - @JvmStatic val noGuiShadow by setting("No Gui Shadow", false).group(Group.Hud) - @JvmStatic val noFloatingItemAnimation by setting("No Floating Item Animation", false, "Disables floating item animations, typically used when a totem pops").group(Group.Hud) - @JvmStatic val noCrosshair by setting("No Crosshair", false).group(Group.Hud) - @JvmStatic val noBossBar by setting("No Boss Bar", false).group(Group.Hud) - @JvmStatic val noScoreBoard by setting("No Score Board", false).group(Group.Hud) - @JvmStatic val noStatusEffects by setting("No Status Effects", false).group(Group.Hud) - @JvmStatic val no2b2tActionText by setting("No 2b2t Action Text", true, description = "Blocks the '2b2t.org' text from the action bar 2b2t randomly sends").group(Group.Hud) + @Tab(HUD_TAB) @JvmStatic val noFireOverlay by setting("No Fire Overlay", false) + @Tab(HUD_TAB) @JvmStatic val fireOverlayYOffset by setting("Fire Overlay Y Offset", 0.0, -0.4..0.4, 0.02) { !noFireOverlay } + @Tab(HUD_TAB) @JvmStatic val noPortalOverlay by setting("No Portal Overlay", true) + @Tab(HUD_TAB) @JvmStatic val noFluidOverlay by setting("No Fluid Overlay", true) + @Tab(HUD_TAB) @JvmStatic val noPowderedSnowOverlay by setting("No Powdered Snow Overlay", true) + @Tab(HUD_TAB) @JvmStatic val noInWall by setting("No In Wall Overlay", true) + @Tab(HUD_TAB) @JvmStatic val noPumpkinOverlay by setting("No Pumpkin Overlay", true) + @Tab(HUD_TAB) @JvmStatic val noVignette by setting("No Vignette", true) + @Tab(HUD_TAB) @JvmStatic val noChatVerificationToast by setting("No Chat Verification Toast", true) + @Tab(HUD_TAB) @JvmStatic val noSpyglassOverlay by setting("No Spyglass Overlay", false) + @Tab(HUD_TAB) @JvmStatic val noGuiShadow by setting("No Gui Shadow", false) + @Tab(HUD_TAB) @JvmStatic val noFloatingItemAnimation by setting("No Floating Item Animation", false, "Disables floating item animations, typically used when a totem pops") + @Tab(HUD_TAB) @JvmStatic val noCrosshair by setting("No Crosshair", false) + @Tab(HUD_TAB) @JvmStatic val noBossBar by setting("No Boss Bar", false) + @Tab(HUD_TAB) @JvmStatic val noScoreBoard by setting("No Score Board", false) + @Tab(HUD_TAB) @JvmStatic val noStatusEffects by setting("No Status Effects", false) + @Tab(HUD_TAB) @JvmStatic val no2b2tActionText by setting("No 2b2t Action Text", true, description = "Blocks the '2b2t.org' text from the action bar 2b2t randomly sends") - @JvmStatic val noArmor by setting("No Armor", false).group(Group.Entity) - @JvmStatic val includeNoOtherHeadItems by setting("Include No Other Head Items", false) { noArmor }.group(Group.Entity) - @JvmStatic val noElytra by setting("No Elytra", false).group(Group.Entity) - @JvmStatic val noInvisibility by setting("No Invisibility", true).group(Group.Entity) - @JvmStatic val noGlow by setting("No Glow", false).group(Group.Entity) - @JvmStatic val noNametags by setting("No Nametags", false).group(Group.Entity) + @Tab(ENTITY_TAB) @JvmStatic val noArmor by setting("No Armor", false) + @Tab(ENTITY_TAB) @JvmStatic val includeNoOtherHeadItems by setting("Include No Other Head Items", false) { noArmor } + @Tab(ENTITY_TAB) @JvmStatic val noElytra by setting("No Elytra", false) + @Tab(ENTITY_TAB) @JvmStatic val noInvisibility by setting("No Invisibility", true) + @Tab(ENTITY_TAB) @JvmStatic val noGlow by setting("No Glow", false) + @Tab(ENTITY_TAB) @JvmStatic val noNametags by setting("No Nametags", false) // RenderLayer.getArmorEntityGlint(), RenderLayer.getGlint(), RenderLayer.getGlintTranslucent(), RenderLayer.getEntityGlint() // @JvmStatic val noEnchantmentGlint by setting("No Enchantment Glint", false).group(Group.Entity) // @JvmStatic val noDeadEntities by setting("No Dead Entities", false).group(Group.Entity) - private val entitySettings = EntitySelectionSettings(this, Group.Entity).apply { - applyEdits { - editTyped(::playerEntities, ::mobEntities, ::bossEntities) { - defaultValue(mutableSetOf()) - } + @Tab(ENTITY_TAB) private val entitySettings = + settingBlock(EntitySelectionSettings(this)) { + applyEdits { editTyped(::playerEntities, ::mobEntities, ::bossEntities) { defaultValue(mutableSetOf()) } } } - } - @JvmStatic val noTerrainFog by setting("No Terrain Fog", false).group(Group.World) - @JvmStatic val noSignText by setting("No Sign Text", false).group(Group.World) - @JvmStatic val noWorldBorder by setting("No World Border", false).group(Group.World) - @JvmStatic val noEnchantingTableBook by setting("No Enchanting Table Book", false).group(Group.World) + @Tab(WORLD_TAB) @JvmStatic val noTerrainFog by setting("No Terrain Fog", false) + @Tab(WORLD_TAB) @JvmStatic val noSignText by setting("No Sign Text", false) + @Tab(WORLD_TAB) @JvmStatic val noWorldBorder by setting("No World Border", false) + @Tab(WORLD_TAB) @JvmStatic val noEnchantingTableBook by setting("No Enchanting Table Book", false) // Couldn't get to work with block entities without crashing with sodium on boot // @JvmStatic val noBlockBreakingOverlay by setting("No Block Breaking Overlay", false).group(Group.World) - @JvmStatic val noBeaconBeams by setting("No Beacon Beams", false).group(Group.World) - @JvmStatic val noSpawnerMob by setting("No Spawner Mob", false).group(Group.World) - private val particles by setting("Particles", emptySet(), particleMap.values.toSet(), "Particles to omit from rendering").group(Group.World) + @Tab(WORLD_TAB) @JvmStatic val noBeaconBeams by setting("No Beacon Beams", false) + @Tab(WORLD_TAB) @JvmStatic val noSpawnerMob by setting("No Spawner Mob", false) + @Tab(WORLD_TAB) private val particles by setting("Particles", emptySet(), particleMap.values.toSet(), "Particles to omit from rendering") private fun createParticleNameMap() = scanResult diff --git a/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt b/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt index c7995b0a9..f964f4bb2 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt @@ -17,6 +17,8 @@ package com.lambda.module.modules.render +import com.lambda.config.Group +import com.lambda.config.Tab import com.lambda.config.applyEdits import com.lambda.config.groups.WorldLineSettings import com.lambda.context.SafeContext @@ -27,7 +29,6 @@ import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe import com.lambda.util.BlockUtils.blockState -import com.lambda.util.NamedEnum import com.lambda.util.math.setAlpha import com.lambda.util.world.toBlockPos import net.minecraft.block.Blocks @@ -41,32 +42,29 @@ object RadiusESP : Module( description = "Shows the radius for blocks with abnormal functionality", tag = ModuleTag.RENDER ) { - private enum class Group(override val displayName: String) : NamedEnum { - Blocks("Blocks"), - Render("Render") - } - - private enum class RenderGroup(override val displayName: String) : NamedEnum { - General("General"), - Outline("Outline") - } + private const val RENDER_GROUP = "Render" + private const val OUTLINE_GROUP = "Outline" - private val beacons by setting("Beacons", true).group(Group.Blocks).onValueChange(::rebuildMesh) - private val spawners by setting("Spawners", true).group(Group.Blocks).onValueChange(::rebuildMesh) + private val beacons by setting("Beacons", true).onValueChange(::rebuildMesh) + private val spawners by setting("Spawners", true).onValueChange(::rebuildMesh) - private val beaconColor by setting("Beacon Color", Color(0, 255, 255, 255)) { beacons }.group(Group.Render, RenderGroup.General).onValueChange(::rebuildMesh) - private val spawnerColor by setting("Spawner Color", Color(255, 0, 0, 255)) { spawners }.group(Group.Render, RenderGroup.General).onValueChange(::rebuildMesh) - private var fill: Boolean by setting("Fill", true).group(Group.Render, RenderGroup.General).onValueChange(::rebuildMesh) + @Group(RENDER_GROUP) private val beaconColor by setting("Beacon Color", Color(0, 255, 255, 255)) { beacons }.onValueChange(::rebuildMesh) + @Group(RENDER_GROUP) private val spawnerColor by setting("Spawner Color", Color(255, 0, 0, 255)) { spawners }.onValueChange(::rebuildMesh) + @Group(RENDER_GROUP) private var fill: Boolean by setting("Fill", true).onValueChange(::rebuildMesh) .onValueChange { _, to -> if (!to) outline = true } - private var outline: Boolean by setting("Outline", true).group(Group.Render, RenderGroup.General).onValueChange(::rebuildMesh) + @Group(RENDER_GROUP) private var outline: Boolean by setting("Outline", true).onValueChange(::rebuildMesh) .onValueChange { _, to -> if (!to) fill = true } - private val fillAlpha by setting("Fill Alpha", 0.1, 0.0..1.0, 0.01).group(Group.Render, RenderGroup.General).onValueChange(::rebuildMesh) - private val worldLineConfig = WorldLineSettings(this, Group.Render, RenderGroup.Outline) { outline }.apply { - applyEdits { - hide(::startColor, ::endColor) - settings.forEach { it.onValueChange(::rebuildMesh) } + @Group(RENDER_GROUP) private val fillAlpha by setting("Fill Alpha", 0.1, 0.0..1.0, 0.01).onValueChange(::rebuildMesh) + @Group(RENDER_GROUP, OUTLINE_GROUP) private val worldLineConfig = + settingBlock( + WorldLineSettings(this), + { outline } + ) { + applyEdits { + hide(::startColor, ::endColor) + forEachSetting { it.onValueChange(::rebuildMesh) } + } } - } private val chunkedRenderer = chunkedRenderer("RadiusESP Chunked Renderer") { _, pos -> runSafe { diff --git a/src/main/kotlin/com/lambda/module/modules/render/Search.kt b/src/main/kotlin/com/lambda/module/modules/render/Search.kt index 6e193ff0a..15d6c9c8c 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Search.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Search.kt @@ -17,6 +17,8 @@ package com.lambda.module.modules.render +import com.lambda.config.Group +import com.lambda.config.Tab import com.lambda.config.applyEdits import com.lambda.config.groups.ScreenLineSettings import com.lambda.config.groups.WorldLineSettings @@ -58,49 +60,55 @@ object Search : Module( description = "Highlight blocks within the rendered world", tag = ModuleTag.RENDER, ) { - private enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Fill("Fill"), - Outline("Outline"), - Tracers("Tracers") - } + private const val FILL_GROUP = "Fill" + private const val OUTLINE_GROUP = "Outline" + private const val TRACERS_GROUP = "Tracers" - private val blocks by setting("Blocks", setOf(Blocks.CHEST, Blocks.ENDER_CHEST, Blocks.NETHER_PORTAL, Blocks.END_PORTAL, Blocks.END_PORTAL_FRAME, Blocks.END_GATEWAY), description = "Render blocks").group(Group.General) + private val blocks by setting("Blocks", setOf(Blocks.CHEST, Blocks.ENDER_CHEST, Blocks.NETHER_PORTAL, Blocks.END_PORTAL, Blocks.END_PORTAL_FRAME, Blocks.END_GATEWAY), description = "Render blocks") .onSelect { rebuildMesh(this) }.onDeselect { rebuildMesh(this) } - private val entities by setting("Entities", decorationEntityMap.values).group(Group.General) + private val entities by setting("Entities", decorationEntityMap.values) .onSelect { rebuildMesh(this) }.onDeselect { rebuildMesh(this) } - private var fill: Boolean by setting("Fill", true, "Fill the faces of blocks").group(Group.Fill).onValueChange(::rebuildMesh) + private val mesh by setting("Mesh", true, "Connect similar adjacent blocks").onValueChange(::rebuildMesh) + + private val useNaturalColor by setting("Use Natural Color", true, "Use the color of the block instead").onValueChange(::rebuildMesh) + private val naturalColorAlpha by setting("Natural Color Alpha", 0.3, 0.1..1.0, 0.05) { useNaturalColor }.onValueChange(::rebuildMesh) + private val naturalTracerAlpha by setting("Natural Tracer Alpha", 1.0, 0.1..1.0, 0.05) { useNaturalColor }.onValueChange(::rebuildMesh) + private val minimumNaturalBrightness by setting("Min Brightness", 150, 0..255, 1) { useNaturalColor }.onValueChange(::rebuildMesh) + + @Group(FILL_GROUP) private var fill: Boolean by setting("Fill", true, "Fill the faces of blocks").onValueChange(::rebuildMesh) .onValueChange { _, to -> if (!to) outline = true } - private var outline: Boolean by setting("Outline", true, "Draw the outlines of blocks").group(Group.Outline).onValueChange(::rebuildMesh) + @Group(FILL_GROUP) private val blockFillColor by setting("Block Fill Color", Color(100, 150, 255, 51), "Color of the surfaces") { fill && !useNaturalColor }.onValueChange(::rebuildMesh) + @Group(FILL_GROUP) private val entityFillColor by setting("Entity Fill Color", Color(100, 150, 255, 51)) { fill && !useNaturalColor }.onValueChange(::rebuildMesh) + + @Group(OUTLINE_GROUP) private var outline: Boolean by setting("Outline", true, "Draw the outlines of blocks").onValueChange(::rebuildMesh) .onValueChange { _, to -> if (!to) fill = true } - private val mesh by setting("Mesh", true, "Connect similar adjacent blocks").group(Group.General).onValueChange(::rebuildMesh) - - private val useNaturalColor by setting("Use Natural Color", true, "Use the color of the block instead").group(Group.General).onValueChange(::rebuildMesh) - private val naturalColorAlpha by setting("Natural Color Alpha", 0.3, 0.1..1.0, 0.05) { useNaturalColor }.group(Group.General).onValueChange(::rebuildMesh) - private val naturalTracerAlpha by setting("Natural Tracer Alpha", 1.0, 0.1..1.0, 0.05) { useNaturalColor }.group(Group.General).onValueChange(::rebuildMesh) - private val minimumNaturalBrightness by setting("Min Brightness", 150, 0..255, 1) { useNaturalColor }.group(Group.General).onValueChange(::rebuildMesh) - - private val blockFillColor by setting("Block Fill Color", Color(100, 150, 255, 51), "Color of the surfaces") { fill && !useNaturalColor }.group(Group.Fill).onValueChange(::rebuildMesh) - private val blockLineColor by setting("Block Line Color", Color(100, 150, 255, 128)) { outline && !useNaturalColor }.group(Group.Outline).onValueChange(::rebuildMesh) - private val entityFillColor by setting("Entity Fill Color", Color(100, 150, 255, 51)) { fill && !useNaturalColor }.group(Group.Fill).onValueChange(::rebuildMesh) - private val entityOutlineColor by setting("Entity Outline Color", Color(100, 150, 255, 128)) { outline && !useNaturalColor }.group(Group.Outline).onValueChange(::rebuildMesh) - - private val blockOutlineMode by setting("Block Outline Mode", DirectionMask.OutlineMode.And, "Outline mode") { outline }.group(Group.Outline, WorldLineSettings.Group.General).onValueChange(::rebuildMesh) - private val outlineConfig = WorldLineSettings(this, Group.Outline, prefix = "Outline ") { outline }.apply { - applyEdits { - hide(::startColor, ::endColor) - settings.forEach { it.onValueChange(::rebuildMesh) } + @Group(OUTLINE_GROUP) private val blockLineColor by setting("Block Line Color", Color(100, 150, 255, 128)) { outline && !useNaturalColor }.onValueChange(::rebuildMesh) + @Group(OUTLINE_GROUP) private val entityOutlineColor by setting("Entity Outline Color", Color(100, 150, 255, 128)) { outline && !useNaturalColor }.onValueChange(::rebuildMesh) + + @Group(OUTLINE_GROUP) private val blockOutlineMode by setting("Block Outline Mode", DirectionMask.OutlineMode.And, "Outline mode") { outline }.onValueChange(::rebuildMesh) + @Group(OUTLINE_GROUP) private val outlineConfig = + settingBlock( + WorldLineSettings(this), + { outline } + ) { + applyEdits { + hide(::startColor, ::endColor) + forEachSetting { it.onValueChange(::rebuildMesh) } + } } - } - private val tracers by setting("Tracers", true, "Draw a line from your cursor to the highlighted position").group(Group.Tracers) - private val tracerConfig = ScreenLineSettings(this, Group.Tracers, prefix = "Tracer ") { tracers }.apply { - applyEdits { - editTyped(::startColor, ::endColor) { - visibility { { !useNaturalColor } } + @Group(TRACERS_GROUP) private val tracers by setting("Tracers", true, "Draw a line from your cursor to the highlighted position") + @Group(TRACERS_GROUP) private val tracerConfig = + settingBlock( + ScreenLineSettings(this), + { tracers } + ) { + applyEdits { + editTyped(::startColor, ::endColor) { + visibility { { !useNaturalColor } } + } } } - } private val tracerBlockPositions = ConcurrentMap>>() diff --git a/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt b/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt index 63e433d83..641a79136 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt @@ -17,7 +17,8 @@ package com.lambda.module.modules.render -import com.lambda.config.Config.StandardTabs.GENERAL_TAB +import com.lambda.config.Group +import com.lambda.config.Tab import com.lambda.config.applyEdits import com.lambda.config.groups.EntityColorSettings import com.lambda.config.groups.EntitySelectionSettings @@ -47,21 +48,31 @@ object Tracers : Module( Friend("Friend") } + private const val GENERAL_TAB = "General" + private const val ENTITY_TAB = "Entities" + private const val COLOR_TAB = "Colors" + private const val TRACERS_GROUP = "Tracers" + + private const val FRIENDS_LINE_GROUP = "Friends" + private const val OTHERS_LINE_GROUP = "Others" + @Tab(GENERAL_TAB) private val target by setting("Target", TracerMode.Feet) @Tab(GENERAL_TAB) private val stem by setting("Stem", true) - private val entitySettings = EntitySelectionSettings(this, Group.Entities).apply { - applyEdits { - hide(::self, ::blockEntities) + + @Tab(GENERAL_TAB) @Group(FRIENDS_LINE_GROUP) private val friendLineConfig = + settingBlock(ScreenLineSettings(this)) { + applyEdits { hide(::startColor, ::endColor) } + } + @Tab(GENERAL_TAB) @Group(OTHERS_LINE_GROUP) private val otherLineConfig = + settingBlock(ScreenLineSettings(this)) { + applyEdits { hide(::startColor, ::endColor) } } - } - private val entityColors = EntityColorSettings(this, Group.Colors) - private val friendLineConfig = ScreenLineSettings(this, Group.LineStyle, LineGroup.Friend, prefix = "Friend ").apply { - applyEdits { hide(::startColor, ::endColor) } - } - private val otherLineConfig = ScreenLineSettings(this, Group.LineStyle, LineGroup.Other, prefix = "Other ").apply { - applyEdits { hide(::startColor, ::endColor) } - } + @Tab(ENTITY_TAB) private val entitySettings = + settingBlock(EntitySelectionSettings(this)) { + applyEdits { hide(::self, ::blockEntities) } + } + @Tab(COLOR_TAB) private val entityColors = settingBlock(EntityColorSettings(this)) init { immediateRenderer("Tracers Immediate Renderer") { safeContext -> diff --git a/src/main/kotlin/com/lambda/module/modules/render/ViewModel.kt b/src/main/kotlin/com/lambda/module/modules/render/ViewModel.kt index bd5123b55..599226a19 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/ViewModel.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/ViewModel.kt @@ -18,12 +18,12 @@ package com.lambda.module.modules.render import com.lambda.Lambda.mc +import com.lambda.config.Tab import com.lambda.event.events.ButtonEvent import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.NamedEnum import net.minecraft.client.network.AbstractClientPlayerEntity import net.minecraft.client.util.math.MatrixStack import net.minecraft.item.ItemStack @@ -41,69 +41,76 @@ object ViewModel : Module( description = "Adjusts hand and held item rendering", tag = ModuleTag.RENDER, ) { - private val swingMode by setting("Swing Mode", SwingMode.Standard, "Changes which hands swing").group(Group.General) - val swingDuration by setting("Swing Duration", 6, 0..20, 1, "Adjusts how fast the player swings", "ticks").group(Group.General) - private val noSwingDelay by setting("No Swing Delay", false, "Removes the delay between swings").group(Group.General) - val mainSwingProgress by setting("Main Swing Progress", 0.0f, 0.0f..1.0f, 0.025f, "Renders as if the players main hand was this progress through the swing animation").group(Group.General) - val offhandSwingProgress by setting("Offhand Swing Progress", 0.0f, 0.0f..1.0f, 0.025f, "Renders as if the players offhand was this progress through the swing animation").group(Group.General) - val oldAnimations by setting("Old Animations", false, "Adjusts the animations to look like they did in 1.8").group(Group.General) - val swapAnimation by setting("Swap Animation", true, "If disabled, removes the drop down animation when swapping item") { oldAnimations }.group(Group.General) + private const val GENERAL_TAB = "General" + private const val SCALE_TAB = "Scale" + private const val POSITION_TAB = "Position" + private const val ROTATION_TAB = "Rotation" + private const val FOV_TAB = "FOV" + private const val HAND_TAB = "Hand" + + @Tab(GENERAL_TAB) private val swingMode by setting("Swing Mode", SwingMode.Standard, "Changes which hands swing") + @Tab(GENERAL_TAB)val swingDuration by setting("Swing Duration", 6, 0..20, 1, "Adjusts how fast the player swings", "ticks") + @Tab(GENERAL_TAB)private val noSwingDelay by setting("No Swing Delay", false, "Removes the delay between swings") + @Tab(GENERAL_TAB)val mainSwingProgress by setting("Main Swing Progress", 0.0f, 0.0f..1.0f, 0.025f, "Renders as if the players main hand was this progress through the swing animation") + @Tab(GENERAL_TAB)val offhandSwingProgress by setting("Offhand Swing Progress", 0.0f, 0.0f..1.0f, 0.025f, "Renders as if the players offhand was this progress through the swing animation") + @Tab(GENERAL_TAB)val oldAnimations by setting("Old Animations", false, "Adjusts the animations to look like they did in 1.8") + @Tab(GENERAL_TAB)val swapAnimation by setting("Swap Animation", true, "If disabled, removes the drop down animation when swapping item") { oldAnimations } //ToDo: Implement // val shadow by setting("Shadows", true, "If disabled, removes shadows on the model") { page == Page.General } - private val splitScale by setting("Split Scale", false, "Splits left and right hand scale settings").group(Group.Scale) - private val xScale by setting("X Scale", 1.0f, 0.0f..2.0f, 0.025f) { !splitScale }.onValueChange { _, to -> leftXScale = to; rightXScale = to }.group(Group.Scale) - private val yScale by setting("Y Scale", 1.0f, 0.0f..2.0f, 0.025f) { !splitScale }.onValueChange { _, to -> leftYScale = to; rightYScale = to }.group(Group.Scale) - private val zScale by setting("Z Scale", 1.0f, 0.0f..2.0f, 0.025f) { !splitScale }.onValueChange { _, to -> leftZScale = to; rightZScale = to }.group(Group.Scale) - private var leftXScale by setting("Left X Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale }.group(Group.Scale) - private var leftYScale by setting("Left Y Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale }.group(Group.Scale) - private var leftZScale by setting("Left Z Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale }.group(Group.Scale) - private var rightXScale by setting("Right X Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale }.group(Group.Scale) - private var rightYScale by setting("Right Y Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale }.group(Group.Scale) - private var rightZScale by setting("Right Z Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale }.group(Group.Scale) - - private val splitPosition by setting("Split Position", false, "Splits left and right position settings").group(Group.Position) - private val xPosition by setting("X Position", 0.0f, -1.0f..1.0f, 0.025f) { !splitPosition }.onValueChange { _, to -> leftXPosition = to; rightXPosition = to }.group(Group.Position) - private val yPosition by setting("Y Position", 0.0f, -1.0f..1.0f, 0.025f) { !splitPosition }.onValueChange { _, to -> leftYPosition = to; rightYPosition = to }.group(Group.Position) - private val zPosition by setting("Z Position", 0.0f, -1.0f..1.0f, 0.025f) { !splitPosition }.onValueChange { _, to -> leftZPosition = to; rightZPosition = to }.group(Group.Position) - private var leftXPosition by setting("Left X Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition }.group(Group.Position) - private var leftYPosition by setting("Left Y Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition }.group(Group.Position) - private var leftZPosition by setting("Left Z Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition }.group(Group.Position) - private var rightXPosition by setting("Right X Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition }.group(Group.Position) - private var rightYPosition by setting("Right Y Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition }.group(Group.Position) - private var rightZPosition by setting("Right Z Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition }.group(Group.Position) - - private val splitRotation by setting("Split Rotation", false, "Splits left and right rotation settings").group(Group.Rotation) - private val xRotation by setting("X Rotation", 0, -180..180, 1) { !splitRotation }.onValueChange { _, to -> leftXRotation = to; rightXRotation = to }.group(Group.Rotation) - private val yRotation by setting("Y Rotation", 0, -180..180, 1) { !splitRotation }.onValueChange { _, to -> leftYRotation = to; rightYRotation = to }.group(Group.Rotation) - private val zRotation by setting("Z Rotation", 0, -180..180, 1) { !splitRotation }.onValueChange { _, to -> leftZRotation = to; rightZRotation = to }.group(Group.Rotation) - private var leftXRotation by setting("Left X Rotation", 0, -180..180, 1) { splitRotation }.group(Group.Rotation) - private var leftYRotation by setting("Left Y Rotation", 0, -180..180, 1) { splitRotation }.group(Group.Rotation) - private var leftZRotation by setting("Left Z Rotation", 0, -180..180, 1) { splitRotation }.group(Group.Rotation) - private var rightXRotation by setting("Right X Rotation", 0, -180..180, 1) { splitRotation }.group(Group.Rotation) - private var rightYRotation by setting("Right Y Rotation", 0, -180..180, 1) { splitRotation }.group(Group.Rotation) - private var rightZRotation by setting("Right Z Rotation", 0, -180..180, 1) { splitRotation }.group(Group.Rotation) - - private val splitFov by setting("Split FOV", false, "Splits left and right Fov settings").group(Group.Fov) - private val fov by setting("FOV", 70, 10..180, 1) { !splitFov }.onValueChange { _, to -> leftFov = to; rightFov = to }.group(Group.Fov) - private val fovAnchorDistance by setting("Anchor Distance", 0.5f, 0.0f..1.0f, 0.01f, "The distance to anchor the FOV transformation from") { !splitFov }.onValueChange { _, to -> leftFovAnchorDistance = to; rightFovAnchorDistance = to }.group(Group.Fov) - private var leftFov by setting("Left FOV", 70, 10..180, 1) { splitFov }.group(Group.Fov) - private var leftFovAnchorDistance by setting("Left Anchor Distance", 0.5f, 0.0f..1.0f, 0.01f, "The distance to anchor the left FOV transformation from") { splitFov }.group(Group.Fov) - private var rightFov by setting("Right FOV", 70, 10..180, 1) { splitFov }.group(Group.Fov) - private var rightFovAnchorDistance by setting("Right Anchor Distance", 0.5f, 0.0f..1.0f, 0.01f, "The distance to anchor the right FOV transformation from") { splitFov }.group(Group.Fov) - - private val enableHand by setting("Hand", false, "Enables settings for the players hand").group(Group.Hand) - private val handXScale by setting("Hand X Scale", 1.0f, 0.0f..2.0f, 0.025f) { enableHand }.group(Group.Hand) - private val handYScale by setting("Hand Y Scale", 1.0f, 0.0f..2.0f, 0.025f) { enableHand }.group(Group.Hand) - private val handZScale by setting("Hand Z Scale", 1.0f, 0.0f..2.0f, 0.025f) { enableHand }.group(Group.Hand) - private val handXPosition by setting("Hand X Position", 0.0f, -1.0f..1.0f, 0.025f) { enableHand }.group(Group.Hand) - private val handYPosition by setting("Hand Y Position", 0.0f, -1.0f..1.0f, 0.025f) { enableHand }.group(Group.Hand) - private val handZPosition by setting("Hand Z Position", 0.0f, -1.0f..1.0f, 0.025f) { enableHand }.group(Group.Hand) - private val handXRotation by setting("Hand X Rotation", 0, -180..180, 1) { enableHand }.group(Group.Hand) - private val handYRotation by setting("Hand Y Rotation", 0, -180..180, 1) { enableHand }.group(Group.Hand) - private val handZRotation by setting("Hand Z Rotation", 0, -180..180, 1) { enableHand }.group(Group.Hand) - private val handFov by setting("Hand FOV", 70, 10..180, 1) { enableHand }.group(Group.Hand) - private val handFovAnchorDistance by setting("Hand FOV Anchor Distance", 0.5f, 0.0f..1.0f, 0.01f, "The distance to anchor the hands FOV transformation from") { enableHand }.group(Group.Hand) + @Tab(SCALE_TAB) private val splitScale by setting("Split Scale", false, "Splits left and right hand scale settings") + @Tab(SCALE_TAB) private val xScale by setting("X Scale", 1.0f, 0.0f..2.0f, 0.025f) { !splitScale }.onValueChange { _, to -> leftXScale = to; rightXScale = to } + @Tab(SCALE_TAB) private val yScale by setting("Y Scale", 1.0f, 0.0f..2.0f, 0.025f) { !splitScale }.onValueChange { _, to -> leftYScale = to; rightYScale = to } + @Tab(SCALE_TAB) private val zScale by setting("Z Scale", 1.0f, 0.0f..2.0f, 0.025f) { !splitScale }.onValueChange { _, to -> leftZScale = to; rightZScale = to } + @Tab(SCALE_TAB) private var leftXScale by setting("Left X Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } + @Tab(SCALE_TAB) private var leftYScale by setting("Left Y Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } + @Tab(SCALE_TAB) private var leftZScale by setting("Left Z Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } + @Tab(SCALE_TAB) private var rightXScale by setting("Right X Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } + @Tab(SCALE_TAB) private var rightYScale by setting("Right Y Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } + @Tab(SCALE_TAB) private var rightZScale by setting("Right Z Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } + + @Tab(POSITION_TAB) private val splitPosition by setting("Split Position", false, "Splits left and right position settings") + @Tab(POSITION_TAB) private val xPosition by setting("X Position", 0.0f, -1.0f..1.0f, 0.025f) { !splitPosition }.onValueChange { _, to -> leftXPosition = to; rightXPosition = to } + @Tab(POSITION_TAB) private val yPosition by setting("Y Position", 0.0f, -1.0f..1.0f, 0.025f) { !splitPosition }.onValueChange { _, to -> leftYPosition = to; rightYPosition = to } + @Tab(POSITION_TAB) private val zPosition by setting("Z Position", 0.0f, -1.0f..1.0f, 0.025f) { !splitPosition }.onValueChange { _, to -> leftZPosition = to; rightZPosition = to } + @Tab(POSITION_TAB) private var leftXPosition by setting("Left X Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } + @Tab(POSITION_TAB) private var leftYPosition by setting("Left Y Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } + @Tab(POSITION_TAB) private var leftZPosition by setting("Left Z Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } + @Tab(POSITION_TAB) private var rightXPosition by setting("Right X Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } + @Tab(POSITION_TAB) private var rightYPosition by setting("Right Y Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } + @Tab(POSITION_TAB) private var rightZPosition by setting("Right Z Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } + + @Tab(ROTATION_TAB) private val splitRotation by setting("Split Rotation", false, "Splits left and right rotation settings") + @Tab(ROTATION_TAB) private val xRotation by setting("X Rotation", 0, -180..180, 1) { !splitRotation }.onValueChange { _, to -> leftXRotation = to; rightXRotation = to } + @Tab(ROTATION_TAB) private val yRotation by setting("Y Rotation", 0, -180..180, 1) { !splitRotation }.onValueChange { _, to -> leftYRotation = to; rightYRotation = to } + @Tab(ROTATION_TAB) private val zRotation by setting("Z Rotation", 0, -180..180, 1) { !splitRotation }.onValueChange { _, to -> leftZRotation = to; rightZRotation = to } + @Tab(ROTATION_TAB) private var leftXRotation by setting("Left X Rotation", 0, -180..180, 1) { splitRotation } + @Tab(ROTATION_TAB) private var leftYRotation by setting("Left Y Rotation", 0, -180..180, 1) { splitRotation } + @Tab(ROTATION_TAB) private var leftZRotation by setting("Left Z Rotation", 0, -180..180, 1) { splitRotation } + @Tab(ROTATION_TAB) private var rightXRotation by setting("Right X Rotation", 0, -180..180, 1) { splitRotation } + @Tab(ROTATION_TAB) private var rightYRotation by setting("Right Y Rotation", 0, -180..180, 1) { splitRotation } + @Tab(ROTATION_TAB) private var rightZRotation by setting("Right Z Rotation", 0, -180..180, 1) { splitRotation } + + @Tab(FOV_TAB) private val splitFov by setting("Split FOV", false, "Splits left and right Fov settings") + @Tab(FOV_TAB) private val fov by setting("FOV", 70, 10..180, 1) { !splitFov }.onValueChange { _, to -> leftFov = to; rightFov = to } + @Tab(FOV_TAB) private val fovAnchorDistance by setting("Anchor Distance", 0.5f, 0.0f..1.0f, 0.01f, "The distance to anchor the FOV transformation from") { !splitFov }.onValueChange { _, to -> leftFovAnchorDistance = to; rightFovAnchorDistance = to } + @Tab(FOV_TAB) private var leftFov by setting("Left FOV", 70, 10..180, 1) { splitFov } + @Tab(FOV_TAB) private var leftFovAnchorDistance by setting("Left Anchor Distance", 0.5f, 0.0f..1.0f, 0.01f, "The distance to anchor the left FOV transformation from") { splitFov } + @Tab(FOV_TAB) private var rightFov by setting("Right FOV", 70, 10..180, 1) { splitFov } + @Tab(FOV_TAB) private var rightFovAnchorDistance by setting("Right Anchor Distance", 0.5f, 0.0f..1.0f, 0.01f, "The distance to anchor the right FOV transformation from") { splitFov } + + @Tab(HAND_TAB) private val enableHand by setting("Hand", false, "Enables settings for the players hand") + @Tab(HAND_TAB) private val handXScale by setting("Hand X Scale", 1.0f, 0.0f..2.0f, 0.025f) { enableHand } + @Tab(HAND_TAB) private val handYScale by setting("Hand Y Scale", 1.0f, 0.0f..2.0f, 0.025f) { enableHand } + @Tab(HAND_TAB) private val handZScale by setting("Hand Z Scale", 1.0f, 0.0f..2.0f, 0.025f) { enableHand } + @Tab(HAND_TAB) private val handXPosition by setting("Hand X Position", 0.0f, -1.0f..1.0f, 0.025f) { enableHand } + @Tab(HAND_TAB) private val handYPosition by setting("Hand Y Position", 0.0f, -1.0f..1.0f, 0.025f) { enableHand } + @Tab(HAND_TAB) private val handZPosition by setting("Hand Z Position", 0.0f, -1.0f..1.0f, 0.025f) { enableHand } + @Tab(HAND_TAB) private val handXRotation by setting("Hand X Rotation", 0, -180..180, 1) { enableHand } + @Tab(HAND_TAB) private val handYRotation by setting("Hand Y Rotation", 0, -180..180, 1) { enableHand } + @Tab(HAND_TAB) private val handZRotation by setting("Hand Z Rotation", 0, -180..180, 1) { enableHand } + @Tab(HAND_TAB) private val handFov by setting("Hand FOV", 70, 10..180, 1) { enableHand } + @Tab(HAND_TAB) private val handFovAnchorDistance by setting("Hand FOV Anchor Distance", 0.5f, 0.0f..1.0f, 0.01f, "The distance to anchor the hands FOV transformation from") { enableHand } private var attackKeyTicksPressed = -1 @@ -236,15 +243,6 @@ object ViewModel : Module( } } - private enum class Group(override val displayName: String): NamedEnum { - General("General"), - Scale("Scale"), - Position("Position"), - Rotation("Rotation"), - Fov("FOV"), - Hand("Hand") - } - private enum class Side { Left, Right } diff --git a/src/main/kotlin/com/lambda/module/modules/render/Weather.kt b/src/main/kotlin/com/lambda/module/modules/render/Weather.kt index 5b3d3c539..3c540fd51 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Weather.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Weather.kt @@ -17,6 +17,7 @@ package com.lambda.module.modules.render +import com.lambda.config.Tab import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe @@ -28,16 +29,14 @@ object Weather : Module( description = "Modifies the client side weather", tag = ModuleTag.RENDER ) { - private enum class Group(override val displayName: String) : NamedEnum { - Overworld("Overworld"), - Nether("Nether"), - End("End") - } + private const val OVERWORLD_TAB = "Overworld" + private const val NETHER_TAB = "Nether" + private const val END_TAB = "End" - @JvmStatic val overworldMode by setting("Overworld Mode", WeatherMode.Clear).group(Group.Overworld) - @JvmStatic val overrideSnow by setting("Override Snow", false) { overworldMode == WeatherMode.Rain }.group(Group.Overworld) - @JvmStatic val netherMode by setting("Nether Mode", WeatherMode.Clear).group(Group.Nether) - @JvmStatic val endMode by setting("End Mode", WeatherMode.Clear).group(Group.End) + @Tab(OVERWORLD_TAB) @JvmStatic val overworldMode by setting("Overworld Mode", WeatherMode.Clear) + @Tab(OVERWORLD_TAB) @JvmStatic val overrideSnow by setting("Override Snow", false) { overworldMode == WeatherMode.Rain } + @Tab(NETHER_TAB) @JvmStatic val netherMode by setting("Nether Mode", WeatherMode.Clear) + @Tab(END_TAB) @JvmStatic val endMode by setting("End Mode", WeatherMode.Clear) @JvmStatic fun getWeatherMode() = runSafe { diff --git a/src/main/kotlin/com/lambda/module/modules/render/WorldColors.kt b/src/main/kotlin/com/lambda/module/modules/render/WorldColors.kt index 80b6bbba4..227d0e209 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/WorldColors.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/WorldColors.kt @@ -29,29 +29,14 @@ object WorldColors : Module( description = "Changes the color of the sky, clouds and fog", tag = ModuleTag.RENDER, ) { - @JvmStatic - val customSky by setting("Custom Sky", true) - - @JvmStatic - val skyColor by setting("Sky Color", Color(255, 24, 75), "The color of your sky") { customSky } - - @JvmStatic - val customFogOfWar by setting("Custom Fog of War", false) - - @JvmStatic - val fogOfWarColor by setting("Fog of War Color", Color(255, 24, 75, 255), "The color of your fog") { customFogOfWar } - - @JvmStatic - val customClouds by setting("Custom Clouds", false) - - @JvmStatic - val cloudColor by setting("Cloud Color", Color(255, 24, 75)) { customClouds } - - @JvmStatic - val customWaterFog by setting("Custom Water Fog", true) - - @JvmStatic - val waterFogColor by setting("Water Fog Color", Color(255, 24, 75, 255), "The color of your water fog") { customWaterFog } + @JvmStatic val customSky by setting("Custom Sky", true) + @JvmStatic val skyColor by setting("Sky Color", Color(255, 24, 75), "The color of your sky") { customSky } + @JvmStatic val customFogOfWar by setting("Custom Fog of War", false) + @JvmStatic val fogOfWarColor by setting("Fog of War Color", Color(255, 24, 75, 255), "The color of your fog") { customFogOfWar } + @JvmStatic val customClouds by setting("Custom Clouds", false) + @JvmStatic val cloudColor by setting("Cloud Color", Color(255, 24, 75)) { customClouds } + @JvmStatic val customWaterFog by setting("Custom Water Fog", true) + @JvmStatic val waterFogColor by setting("Water Fog Color", Color(255, 24, 75, 255), "The color of your water fog") { customWaterFog } @JvmStatic fun fogOfWarColor(base: Vec3d) = diff --git a/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt b/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt index 84dfd3e48..8113e9682 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt @@ -18,8 +18,9 @@ package com.lambda.module.modules.world import com.lambda.Lambda.mc -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.Group import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.complex.Bind import com.lambda.context.SafeContext import com.lambda.event.events.ButtonEvent @@ -62,19 +63,16 @@ object AirPlace : Module( description = "Allows placing blocks in air", tag = ModuleTag.WORLD ) { - private enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Render("Render") - } + private const val RENDER_GROUP = "Renders" - private var distance by setting("Distance", 4.0, 1.0..7.0, 0.01).group(Group.General) - private val distanceScrollBind by setting("Distance Scroll Bind", Bind(KeyCode.Unbound.code, GLFW.GLFW_MOD_CONTROL), "Allows you to hold the given key and scroll to adjust distance").group(Group.General) + private var distance by setting("Distance", 4.0, 1.0..7.0, 0.01) + private val distanceScrollBind by setting("Distance Scroll Bind", Bind(KeyCode.Unbound.code, GLFW.GLFW_MOD_CONTROL), "Allows you to hold the given key and scroll to adjust distance") // Credit to THCFree for the rotation scroll idea - private val rotationScrollBind by setting("Rotation Scroll Bind", Bind(KeyCode.Unbound.code, GLFW.GLFW_MOD_ALT), "Allows you to hold the given key and scroll to adjust the rotation of the block you're placing").group(Group.General) + private val rotationScrollBind by setting("Rotation Scroll Bind", Bind(KeyCode.Unbound.code, GLFW.GLFW_MOD_ALT), "Allows you to hold the given key and scroll to adjust the rotation of the block you're placing") - private val renderState by setting("Render State", true).group(Group.Render) - private val lineColor by setting("Line Color", Color.WHITE).group(Group.Render) - private val stateAlpha by setting("State Alpha", 0.5, 0.01..1.0, 0.01).group(Group.Render) + @Group(RENDER_GROUP) private val renderState by setting("Render State", true) + @Group(RENDER_GROUP) private val lineColor by setting("Line Color", Color.WHITE) + @Group(RENDER_GROUP) private val stateAlpha by setting("State Alpha", 0.5, 0.01..1.0, 0.01) private var placementPos: BlockPos? = null private var backingState: BlockState? = null @@ -96,7 +94,7 @@ object AirPlace : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllGroupsExcept(interactConfig) + hideAllBlocksExcept(interactConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt index 4ca31e6c5..bd3f940fa 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt @@ -18,8 +18,9 @@ package com.lambda.module.modules.world import baritone.api.pathing.goals.GoalBlock -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.Group import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.groups.WorldLineSettings import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress @@ -46,7 +47,6 @@ import com.lambda.task.tasks.BuildTask.Companion.build import com.lambda.util.BlockUtils.blockState import com.lambda.util.BlockUtils.isEmpty import com.lambda.util.BlockUtils.isNotEmpty -import com.lambda.util.NamedEnum import com.lambda.util.PacketUtils.sendPacket import com.lambda.util.extension.blockColor import com.lambda.util.extension.tickDelta @@ -73,17 +73,11 @@ object AutoPortal : Module( description = "Automatically places and lights a nether portal", tag = ModuleTag.WORLD ) { - private enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Render("Render") - } - - private enum class RenderGroup(override val displayName: String) : NamedEnum { - Fill("Fill"), - Outline("Outline") - } + private const val RENDER_GROUP = "Renders" + private const val FILL_GROUP = "Fill" + private const val OUTLINE_GROUP = "Outline" - private val previewPlace by setting("Preview Place", Bind.EMPTY, "The keybind to preview the portal placement and subsequentially place the portal").group(Group.General) + private val previewPlace by setting("Preview Place", Bind.EMPTY, "The keybind to preview the portal placement and subsequentially place the portal") .onPress { preview = true } .onRelease { preview = false @@ -109,25 +103,25 @@ object AutoPortal : Module( } .run() } - private val corners by setting("Corners", false).group(Group.General) - private val light by setting("Light", true, "Attempts to automatically light the portal after building").group(Group.General) - private val walkIn by setting("Walk In", true, "Automatically paths into the portal with baritone") { light }.group(Group.General) - private val inventory by setting("Inventory", true, "Allows access to the players inventory when retrieving a flint and steel for lighting the portal").group(Group.General) - private val forwardOffset by setting("Forward Offset", 3, 0..10).group(Group.General) - private val sidewaysOffset by setting("Sideways Offset", 0, -5..5).group(Group.General) - private val yOffset by setting("Y Offset", 0, -5..5).group(Group.General) - private val lockToGround by setting("Lock To Ground", true).group(Group.General) - private val allowUpwardShift by setting("Allow Upward Shift", true, "Allows shifting the portal up to find ground when it would be placed inside blocks") { lockToGround }.group(Group.General) - - private val renders by setting("Renders", true).group(Group.Render) - private val interpolate by setting("Interpolate", true, "Interpolates the portal renders from position to position") { renders }.group(Group.Render) - private val depthTest by setting("Depth Test", false) { renders }.group(Group.Render) - private val fillAlpha by setting("Fill Alpha", 0.3, 0.0..1.0, 0.01) { renders }.group(Group.Render, RenderGroup.Fill) - private val outlineConfig = WorldLineSettings(this, Group.Render, RenderGroup.Outline) { renders }.apply { - applyEdits { - hide(::startColor, ::endColor) - } - } + private val corners by setting("Corners", false) + private val light by setting("Light", true, "Attempts to automatically light the portal after building") + private val walkIn by setting("Walk In", true, "Automatically paths into the portal with baritone") { light } + private val inventory by setting("Inventory", true, "Allows access to the players inventory when retrieving a flint and steel for lighting the portal") + private val forwardOffset by setting("Forward Offset", 3, 0..10) + private val sidewaysOffset by setting("Sideways Offset", 0, -5..5) + private val yOffset by setting("Y Offset", 0, -5..5) + private val lockToGround by setting("Lock To Ground", true) + private val allowUpwardShift by setting("Allow Upward Shift", true, "Allows shifting the portal up to find ground when it would be placed inside blocks") { lockToGround } + + @Group(RENDER_GROUP) private val renders by setting("Renders", true) + @Group(RENDER_GROUP) private val interpolate by setting("Interpolate", true, "Interpolates the portal renders from position to position") { renders } + @Group(RENDER_GROUP) private val depthTest by setting("Depth Test", false) { renders } + @Group(RENDER_GROUP, FILL_GROUP) private val fillAlpha by setting("Fill Alpha", 0.3, 0.0..1.0, 0.01) { renders } + @Group(RENDER_GROUP, OUTLINE_GROUP) private val outlineConfig = + settingBlock( + WorldLineSettings(this), + { renders } + ) { applyEdits { hide(::startColor, ::endColor) } } private var preview = false private var buildTask: Task<*>? = null @@ -135,7 +129,7 @@ object AutoPortal : Module( init { setDefaultAutomationConfig { applyEdits { - hideGroup(eatConfig) + hideBlock(eatConfig) hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre, TickEvent.Input.Post)) } diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt index 43c7061ba..0b55ff9ca 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt @@ -17,8 +17,9 @@ package com.lambda.module.modules.world -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.Group import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.context.SafeContext @@ -29,7 +30,6 @@ import com.lambda.interaction.construction.blueprint.Blueprint.Companion.toStruc import com.lambda.interaction.construction.blueprint.StaticBlueprint.Companion.toBlueprint import com.lambda.interaction.construction.verify.TargetState import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest -import com.lambda.interaction.managers.rotating.visibilty.lookAtEntity import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.sound.SoundHandler.playSound @@ -42,6 +42,7 @@ import com.lambda.util.BlockUtils.isEmpty import com.lambda.util.CommunicationUtils.info import com.lambda.util.CommunicationUtils.logError import com.lambda.util.NamedEnum +import com.lambda.util.player.RotationUtils.lookAtEntity import com.lambda.util.world.closestEntity import net.minecraft.block.Blocks import net.minecraft.component.DataComponentTypes @@ -62,19 +63,14 @@ object AutoVillagerCycle : Module( description = "Automatically cycles librarian villagers with lecterns until a desired enchanted book is found", tag = ModuleTag.WORLD ) { - private enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Enchantments("Enchantments") - } - private val allEnchantments = ArrayList() - private val lecternPos by setting("Lectern Pos", BlockPos.ORIGIN, "Position where the lectern should be placed/broken").group(Group.General) - private val logFoundBooks by setting("Log Found Books", true, "Log all enchanted books found during cycling").group(Group.General) - private val interactDelay by setting("Interact Delay", 20, 1..40, 1, "Ticks to wait before interacting with the villager", " ticks").group(Group.General) - private val breakDelay by setting("Break Delay", 5, 1..20, 1, "Ticks to wait after breaking the lectern", " ticks").group(Group.General) - private val searchRange by setting("Search Range", 5.0, 1.0..10.0, 0.5, "Range to search for nearby villagers", " blocks").group(Group.General) - private val startCyclingBind by setting("Start Cycling", Bind.EMPTY, "Press to start/stop cycling").group(Group.General) + private val lecternPos by setting("Lectern Pos", BlockPos.ORIGIN, "Position where the lectern should be placed/broken") + private val logFoundBooks by setting("Log Found Books", true, "Log all enchanted books found during cycling") + private val interactDelay by setting("Interact Delay", 20, 1..40, 1, "Ticks to wait before interacting with the villager", " ticks") + private val breakDelay by setting("Break Delay", 5, 1..20, 1, "Ticks to wait after breaking the lectern", " ticks") + private val searchRange by setting("Search Range", 5.0, 1.0..10.0, 0.5, "Range to search for nearby villagers", " blocks") + private val startCyclingBind by setting("Start Cycling", Bind.EMPTY, "Press to start/stop cycling") .onPress { if (cycleState != CycleState.Idle) { info("Stopped villager cycling.") @@ -86,8 +82,10 @@ object AutoVillagerCycle : Module( switchState(CycleState.PlaceLectern) } } - private val desiredEnchantments by setting("Desired Enchantments", emptySet(), allEnchantments).group(Group.Enchantments) - private val minLevel by setting("Min Level", 1, 1..5, 1, "Minimum enchantment level to look for").group(Group.Enchantments) + + private const val ENCHANTMENTS_GROUP = "Enchantments" + @Group(ENCHANTMENTS_GROUP) private val desiredEnchantments by setting("Desired Enchantments", emptySet(), allEnchantments) + @Group(ENCHANTMENTS_GROUP) private val minLevel by setting("Min Level", 1, 1..5, 1, "Minimum enchantment level to look for") private var cycleState = CycleState.Idle private var tickCounter = 0 @@ -97,7 +95,7 @@ object AutoVillagerCycle : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllGroupsExcept(rotationConfig, inventoryConfig, breakConfig, interactConfig, buildConfig) + hideAllBlocksExcept(rotationConfig, inventoryConfig, breakConfig, interactConfig, buildConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt b/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt index b427550dc..23c106802 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.world -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.construction.blueprint.Blueprint.Companion.emptyStructure import com.lambda.interaction.construction.blueprint.PropagatingBlueprint.Companion.propagatingBlueprint diff --git a/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt b/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt index 591f56d4c..51df8bc89 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.world -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.context.SafeContext import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint import com.lambda.interaction.construction.verify.TargetState diff --git a/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt b/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt index e0707fd8f..7cae267c0 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt @@ -17,8 +17,9 @@ package com.lambda.module.modules.world -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.groups.InteractConfig import com.lambda.config.settings.complex.Bind import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent @@ -26,7 +27,6 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.construction.simulation.BuildSimulator.simulate import com.lambda.interaction.construction.simulation.context.BuildContext import com.lambda.interaction.construction.verify.TargetState -import com.lambda.config.groups.InteractConfig import com.lambda.interaction.managers.interacting.InteractRequest.Companion.interactRequest import com.lambda.interaction.material.StackSelection.Companion.selectStack import com.lambda.interaction.material.container.containers.HotbarContainer @@ -73,7 +73,7 @@ object Scaffold : Module( ::mean.edit { defaultValue(120.0) } ::spread.edit { defaultValue(0.0) } } - hideAllGroupsExcept(buildConfig, interactConfig, rotationConfig, hotbarConfig) + hideAllBlocksExcept(buildConfig, interactConfig, rotationConfig, hotbarConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt index 8d32d6ccd..7f37a5110 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt @@ -19,8 +19,10 @@ package com.lambda.module.modules.world import baritone.api.pathing.goals.GoalBlock import com.lambda.Lambda.mc -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.Tab import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.groups.InteractConfig import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.context.SafeContext @@ -35,7 +37,6 @@ import com.lambda.graphics.mc.renderer.TickedRenderer.Companion.tickedRenderer import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.construction.verify.TargetState import com.lambda.interaction.managers.hotbar.HotbarRequest -import com.lambda.config.groups.InteractConfig import com.lambda.interaction.managers.inventory.InventoryRequest.Companion.inventoryRequest import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest import com.lambda.interaction.managers.rotating.Rotation @@ -98,10 +99,8 @@ object StashMover : Module( description = "Moves items from one stash location to another", tag = ModuleTag.WORLD ) { - private enum class Group(override val displayName: String) : NamedEnum { - General("General"), - CommandBinds("Command Binds") - } + private const val GENERAL_TAB = "General" + private const val COMMAND_BINDS_TAB = "Command Binds" enum class Role(val createTask: () -> Task<*>) { MoverBot({ MoverBot() }), @@ -113,70 +112,45 @@ object StashMover : Module( Drop("Drop") } - val role: Role by setting("Role", Role.MoverBot).group(Group.General) + @Tab(GENERAL_TAB) val role: Role by setting("Role", Role.MoverBot) .onValueChange { _, _ -> clearModule() } - private val pearlBotName by setting("PearlBot Name", "Steve") { role == Role.MoverBot }.group(Group.General) - private val moverBotName by setting("MoverBot Name", "Steve") { role == Role.PearlBot }.group(Group.General) - private val dropOffMode by setting("Drop-Off Mode", DropOffMode.Chests) { role == Role.MoverBot }.group(Group.General) - private var chestPullSelMode: Boolean by setting("Chest Pull Sel Mode", false, "Enables the mode to select the stash containers you want to move items from") { role == Role.MoverBot }.group(Group.General) + @Tab(GENERAL_TAB) private val pearlBotName by setting("PearlBot Name", "Steve") { role == Role.MoverBot } + @Tab(GENERAL_TAB) private val moverBotName by setting("MoverBot Name", "Steve") { role == Role.PearlBot } + @Tab(GENERAL_TAB) private val dropOffMode by setting("Drop-Off Mode", DropOffMode.Chests) { role == Role.MoverBot } + @Tab(GENERAL_TAB) private var chestPullSelMode: Boolean by setting("Chest Pull Sel Mode", false, "Enables the mode to select the stash containers you want to move items from") { role == Role.MoverBot } .onValueChange { _, to -> if (to) { chestPutSelMode = false; StashMover.info("Enabled chest pull selection mode!") } } - private var chestPutSelMode: Boolean by setting("Chest Put Sel Mode", false, "Enables the mod to select the stash containers you want to move items into") { role == Role.MoverBot }.group(Group.General) + @Tab(GENERAL_TAB) private var chestPutSelMode: Boolean by setting("Chest Put Sel Mode", false, "Enables the mod to select the stash containers you want to move items into") { role == Role.MoverBot } .onValueChange { _, to -> if (to) { chestPullSelMode = false; StashMover.info("Enabled chest put selection mode!") } } - private val pearlMsgTimeout by setting("Pearl Msg Timeout", 100, 0..1500, 1, "Ticks before messaging the pearl bot again", "ticks") { role == Role.MoverBot }.group(Group.General) - private val pearlButtonTimeout by setting("Pearl Button Timeout", 100, 0..1500, 1, "Ticks before pressing the pearl dispenser button again", "ticks") { role == Role.MoverBot }.group(Group.General) - private val killRespawnTimeout by setting("Kill/Respawn Timeout", 100, 0..1500, 1, "Ticks before sending the kill command or attempting to respawn again", "ticks") { role == Role.MoverBot }.group(Group.General) - private val actionDelay by setting("Action Delay", 3, 0..20, 1, "The delay after performing one action, before the next") { role == Role.MoverBot }.group(Group.General) - private val useEnderChest by setting("Use Ender Chest", false, "Uses the ender chest to move more items at once. (Ender chests are included in the pull/put selections)") { role == Role.MoverBot }.group(Group.General) + @Tab(GENERAL_TAB) private val pearlMsgTimeout by setting("Pearl Msg Timeout", 100, 0..1500, 1, "Ticks before messaging the pearl bot again", "ticks") { role == Role.MoverBot } + @Tab(GENERAL_TAB) private val pearlButtonTimeout by setting("Pearl Button Timeout", 100, 0..1500, 1, "Ticks before pressing the pearl dispenser button again", "ticks") { role == Role.MoverBot } + @Tab(GENERAL_TAB) private val killRespawnTimeout by setting("Kill/Respawn Timeout", 100, 0..1500, 1, "Ticks before sending the kill command or attempting to respawn again", "ticks") { role == Role.MoverBot } + @Tab(GENERAL_TAB) private val actionDelay by setting("Action Delay", 3, 0..20, 1, "The delay after performing one action, before the next") { role == Role.MoverBot } + @Tab(GENERAL_TAB) private val useEnderChest by setting("Use Ender Chest", false, "Uses the ender chest to move more items at once. (Ender chests are included in the pull/put selections)") { role == Role.MoverBot } .onValueChange { _, to -> if (!to) { putEnderChests.clear() pullEnderChests.clear() } } - private val breakEmptyPullContainers by setting("Break Empty Pull Containers", false, "Breaks empty pull containers after taking their items") { role == Role.MoverBot }.group(Group.General) - private val disconnectOnFinish by setting("Disconnect On Finish", false, "Disconnects the mover bot when it's finished") { role == Role.MoverBot }.group(Group.General) - private val disconnectOnFail by setting("Disconnect On Fail", false, "Disconnects the mover bot if it fails") { role == Role.MoverBot }.group(Group.General) - private val startStop by setting("Start/Stop", Bind.EMPTY, "Starts and stops the selected role").group(Group.General) - .onPress { event -> - event.cancel() - startStop() - } - private val pauseUnpause by setting("Pause/Unpause", Bind.EMPTY, "Pauses and unpauses the selected role").group(Group.General) - .onPress { event -> - event.cancel() - pauseUnpause() - } - - private val indexSelectedContainers by setting("Index Selected Containers", Bind.EMPTY, "Indexes the selected containers to pull/push items from/to") { role == Role.MoverBot }.group(Group.CommandBinds) - .onPress { event -> - event.cancel() - indexSelectedContainers() - } - private val removeSelectedContainers by setting("Remove Selected Containers", Bind.EMPTY, "Removes the selected containers from being pull/pushed from/to") { role == Role.MoverBot }.group(Group.CommandBinds) - .onPress { event -> - event.cancel() - removeSelectedContainers() - } - private val setItemThrowPosAndRotation by setting("Set Item Throw", Bind.EMPTY, "Sets the item throw position and rotation. (This is usually set to throw into hoppers to pickup the items)") { role == Role.MoverBot }.group(Group.CommandBinds) - .onPress { event -> - event.cancel() - setItemThrow() - } - private val setPearlButtonPos by setting("Set Pearl Button Pos", Bind.EMPTY, "Sets the button used to dispense a pearl for the player") { role == Role.MoverBot }.group(Group.CommandBinds) - .onPress { event -> - event.cancel() - setPearlButtonPos() - } - private val setPearlThrowPosAndRotation by setting("Set Pearl Throw", Bind.EMPTY, "Sets the pearl throw position and rotation. (This is best if you throw somewhat sideways into a line of bubble columns)") { role == Role.MoverBot }.group(Group.CommandBinds) - .onPress { event -> - event.cancel() - setPearlThrow() - } - private val setPearlBotButton by setting("Set PearlBot Button", Bind.EMPTY, "Sets the button position for the pearl bot to press to load the mover bot") { role == Role.PearlBot }.group(Group.CommandBinds) - .onPress { event -> - event.cancel() - setPearlBotButton() - } + @Tab(GENERAL_TAB) private val breakEmptyPullContainers by setting("Break Empty Pull Containers", false, "Breaks empty pull containers after taking their items") { role == Role.MoverBot } + @Tab(GENERAL_TAB) private val disconnectOnFinish by setting("Disconnect On Finish", false, "Disconnects the mover bot when it's finished") { role == Role.MoverBot } + @Tab(GENERAL_TAB) private val disconnectOnFail by setting("Disconnect On Fail", false, "Disconnects the mover bot if it fails") { role == Role.MoverBot } + @Tab(GENERAL_TAB) private val startStop by setting("Start/Stop", Bind.EMPTY, "Starts and stops the selected role") + .onPress { event -> event.cancel(); startStop() } + @Tab(GENERAL_TAB) private val pauseUnpause by setting("Pause/Unpause", Bind.EMPTY, "Pauses and unpauses the selected role") + .onPress { event -> event.cancel(); pauseUnpause() } + @Tab(COMMAND_BINDS_TAB) private val indexSelectedContainers by setting("Index Selected Containers", Bind.EMPTY, "Indexes the selected containers to pull/push items from/to") { role == Role.MoverBot } + .onPress { event -> event.cancel(); indexSelectedContainers() } + @Tab(COMMAND_BINDS_TAB) private val removeSelectedContainers by setting("Remove Selected Containers", Bind.EMPTY, "Removes the selected containers from being pull/pushed from/to") { role == Role.MoverBot } + .onPress { event -> event.cancel(); removeSelectedContainers() } + @Tab(COMMAND_BINDS_TAB) private val setItemThrowPosAndRotation by setting("Set Item Throw", Bind.EMPTY, "Sets the item throw position and rotation. (This is usually set to throw into hoppers to pickup the items)") { role == Role.MoverBot } + .onPress { event -> event.cancel(); setItemThrow() } + @Tab(COMMAND_BINDS_TAB) private val setPearlButtonPos by setting("Set Pearl Button Pos", Bind.EMPTY, "Sets the button used to dispense a pearl for the player") { role == Role.MoverBot } + .onPress { event -> event.cancel(); setPearlButtonPos() } + @Tab(COMMAND_BINDS_TAB) private val setPearlThrowPosAndRotation by setting("Set Pearl Throw", Bind.EMPTY, "Sets the pearl throw position and rotation. (This is best if you throw somewhat sideways into a line of bubble columns)") { role == Role.MoverBot } + .onPress { event -> event.cancel(); setPearlThrow() } + @Tab(COMMAND_BINDS_TAB) private val setPearlBotButton by setting("Set PearlBot Button", Bind.EMPTY, "Sets the button position for the pearl bot to press to load the mover bot") { role == Role.PearlBot } + .onPress { event -> event.cancel(); setPearlBotButton() } private var sel1: BlockPos? = null private var sel2: BlockPos? = null @@ -206,7 +180,7 @@ object StashMover : Module( buildConfig.apply { editTyped(::pathing, ::stayInRange, ::checkSideVisibility) { defaultValue(true) } hide(::pathing, ::stayInRange, ::collectDrops, ::spleefEntities, ::entityReach) - hideGroup(eatConfig) + hideBlock(eatConfig) } interactConfig::airPlace.edit { defaultValue(InteractConfig.AirPlaceMode.None) } breakConfig.apply { diff --git a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt index d6accc558..888ca5370 100644 --- a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt +++ b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt @@ -73,7 +73,7 @@ import net.minecraft.network.packet.s2c.play.ChunkDeltaUpdateS2CPacket import net.minecraft.network.packet.s2c.play.EntityPositionS2CPacket import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket import net.minecraft.util.math.BlockPos -import java.util.Collections +import java.util.* import java.util.concurrent.ConcurrentLinkedQueue import kotlin.coroutines.cancellation.CancellationException import kotlin.math.sqrt diff --git a/src/main/kotlin/com/lambda/util/EntityUtils.kt b/src/main/kotlin/com/lambda/util/EntityUtils.kt index f0af2a7e9..3a3fea047 100644 --- a/src/main/kotlin/com/lambda/util/EntityUtils.kt +++ b/src/main/kotlin/com/lambda/util/EntityUtils.kt @@ -18,6 +18,7 @@ package com.lambda.util import com.lambda.util.DynamicReflectionSerializer.remappedName +import com.lambda.util.ReflectionUtils.scanResult import com.lambda.util.math.MathUtils.floorToInt import io.github.classgraph.ClassInfo import net.minecraft.block.entity.BlockEntity @@ -25,7 +26,6 @@ import net.minecraft.entity.Entity import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Box import net.minecraft.util.math.Vec3d -import kotlin.jvm.java @Suppress("unused") object EntityUtils { diff --git a/src/main/kotlin/com/lambda/util/FormattingUtils.kt b/src/main/kotlin/com/lambda/util/FormattingUtils.kt index 8d4e1ce09..3088913b9 100644 --- a/src/main/kotlin/com/lambda/util/FormattingUtils.kt +++ b/src/main/kotlin/com/lambda/util/FormattingUtils.kt @@ -17,7 +17,6 @@ package com.lambda.util -import com.lambda.config.Setting import com.lambda.config.groups.FormatterConfig import com.lambda.util.math.Vec2d import net.minecraft.util.math.Vec2f @@ -124,8 +123,6 @@ object FormattingUtils { } object Default : FormatterConfig { - override val settings = mutableListOf>() - override val visibility: () -> Boolean = { true } override val locale: Locale = Locale.US override val separator: String = "," override val prefix: String = "(" diff --git a/src/main/kotlin/com/lambda/util/player/RotationUtils.kt b/src/main/kotlin/com/lambda/util/player/RotationUtils.kt index 8d7bce80e..29888425a 100644 --- a/src/main/kotlin/com/lambda/util/player/RotationUtils.kt +++ b/src/main/kotlin/com/lambda/util/player/RotationUtils.kt @@ -42,8 +42,7 @@ import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Box import net.minecraft.util.math.Direction import net.minecraft.util.math.Vec3d -import java.util.EnumSet -import kotlin.collections.minus +import java.util.* import kotlin.math.atan2 import kotlin.math.hypot import kotlin.math.max diff --git a/src/main/kotlin/com/lambda/util/text/TextDsl.kt b/src/main/kotlin/com/lambda/util/text/TextDsl.kt index 9fe7ea476..1f209f697 100644 --- a/src/main/kotlin/com/lambda/util/text/TextDsl.kt +++ b/src/main/kotlin/com/lambda/util/text/TextDsl.kt @@ -17,7 +17,7 @@ package com.lambda.util.text -import com.lambda.module.modules.client.StyleEditor +import com.lambda.module.modules.client.Client import net.minecraft.text.ClickEvent import net.minecraft.text.HoverEvent import net.minecraft.text.MutableText @@ -218,7 +218,7 @@ inline fun TextBuilder.color(color: Color?, action: TextBuilder.() -> Unit) { @TextDsl fun TextBuilder.highlighted(value: String) { - color(StyleEditor.highlightColor) { + color(Client.highlightColor) { literal(value) } } From ff5937de9df28a2896f66ccdac25ab054f340455 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Fri, 8 May 2026 02:21:37 +0100 Subject: [PATCH 09/40] another checkpoint --- .../com/lambda/mixin/CrashReportMixin.java | 4 +- .../lambda/mixin/MinecraftClientMixin.java | 2 +- src/main/kotlin/com/lambda/Lambda.kt | 16 +- .../com/lambda/command/CommandHandler.kt | 6 +- .../lambda/command/commands/ConfigCommand.kt | 171 +++++-- .../lambda/command/commands/FriendCommand.kt | 2 +- .../lambda/command/commands/PrefixCommand.kt | 8 +- src/main/kotlin/com/lambda/config/Config.kt | 424 ++++++++++-------- .../com/lambda/config/ConfigCategory.kt | 22 +- .../kotlin/com/lambda/config/ConfigEditor.kt | 143 ++---- .../kotlin/com/lambda/config/ConfigLoader.kt | 16 - src/main/kotlin/com/lambda/config/Setting.kt | 17 +- .../kotlin/com/lambda/config/SettingBlock.kt | 22 + .../com/lambda/config/SettingBlockWrapper.kt | 29 ++ .../config/automation/AutomationConfig.kt | 42 +- .../automation/IMutableAutomationConfig.kt | 45 +- .../com/lambda/config/groups/BreakSettings.kt | 100 ----- .../com/lambda/config/groups/BuildSettings.kt | 58 --- .../lambda/config/groups/InventorySettings.kt | 43 -- .../config/groups/ScreenLineSettings.kt | 48 -- .../config/groups/ScreenTextSettings.kt | 49 -- .../lambda/config/groups/WorldTextSettings.kt | 50 --- .../com/lambda/config/migration/Migrations.kt | 14 +- .../migrations/AutomationConfigMigration.kt | 4 +- .../migrations/FriendConfigMigration.kt | 4 +- .../com/lambda/config/settings/CharSetting.kt | 2 +- .../lambda/config/settings/NumericSetting.kt | 2 +- .../blocks}/ActionConfig.kt | 5 +- .../blocks}/BreakConfig.kt | 2 +- .../config/settings/blocks/BreakSettings.kt | 99 ++++ .../blocks}/BuildConfig.kt | 4 +- .../config/settings/blocks/BuildSettings.kt | 58 +++ .../{groups => settings/blocks}/EatConfig.kt | 4 +- .../blocks}/EatSettings.kt | 2 +- .../blocks}/EntityColorSettings.kt | 2 +- .../blocks}/EntityColorsConfig.kt | 4 +- .../blocks}/EntitySelectionConfig.kt | 4 +- .../blocks}/EntitySelectionSettings.kt | 2 +- .../blocks}/FormatterConfig.kt | 3 +- .../blocks}/FormatterSettings.kt | 4 +- .../blocks}/HotbarConfig.kt | 4 +- .../blocks}/HotbarSettings.kt | 4 +- .../blocks}/InteractConfig.kt | 2 +- .../blocks}/InteractSettings.kt | 11 +- .../blocks}/InventoryConfig.kt | 4 +- .../settings/blocks/InventorySettings.kt | 42 ++ .../{groups => settings/blocks}/LineConfig.kt | 5 +- .../config/settings/blocks/OutlineConfig.kt | 26 ++ .../blocks}/OutlineSettings.kt | 33 +- .../blocks}/ReplaceConfig.kt | 4 +- .../blocks}/RotationConfig.kt | 6 +- .../blocks}/RotationSettings.kt | 4 +- .../settings/blocks/ScreenLineSettings.kt | 47 ++ .../settings/blocks/ScreenTextSettings.kt | 49 ++ .../blocks}/TargetingConfig.kt | 6 +- .../blocks}/TargetingSettings.kt | 13 +- .../{groups => settings/blocks}/TextConfig.kt | 4 +- .../blocks}/WorldLineSettings.kt | 24 +- .../settings/blocks/WorldTextSettings.kt | 49 ++ .../collections/BlockCollectionSetting.kt | 2 +- .../collections/ClassCollectionSetting.kt | 2 +- .../settings/collections/CollectionSetting.kt | 2 +- .../collections/ItemCollectionSetting.kt | 2 +- .../config/settings/collections/MapSetting.kt | 2 +- .../config/settings/complex/BlockSetting.kt | 2 +- .../kotlin/com/lambda/context/Automated.kt | 14 +- src/main/kotlin/com/lambda/core/Loader.kt | 8 +- .../kotlin/com/lambda/core/TimerHandler.kt | 4 +- .../com/lambda/graphics/mc/BoxBuilder.kt | 18 +- .../com/lambda/graphics/mc/RenderBuilder.kt | 34 +- .../graphics/mc/renderer/ChunkedRenderer.kt | 2 + .../graphics/mc/renderer/ImmediateRenderer.kt | 2 + .../graphics/mc/renderer/TickedRenderer.kt | 2 + .../com/lambda/graphics/text/FontHandler.kt | 8 +- .../com/lambda/graphics/util/DirectionMask.kt | 30 +- src/main/kotlin/com/lambda/gui/DearImGui.kt | 18 +- src/main/kotlin/com/lambda/gui/MenuBar.kt | 29 +- .../lambda/gui/components/ClickGuiLayout.kt | 241 +++++----- .../com/lambda/gui/components/HudGuiLayout.kt | 41 +- .../com/lambda/gui/components/QuickSearch.kt | 28 +- .../lambda/gui/components/SettingsWidget.kt | 52 +-- .../com/lambda/interaction/BaritoneHandler.kt | 2 +- .../construction/StructureRegistry.kt | 4 +- .../simulation/checks/BasicChecker.kt | 2 +- .../simulation/context/BuildContext.kt | 2 +- .../simulation/result/Contextual.kt | 2 +- .../managers/PacketLimitHandler.kt | 2 +- .../managers/breaking/BreakInfo.kt | 2 +- .../managers/breaking/BreakManager.kt | 6 +- .../managers/breaking/BrokenBlockHandler.kt | 2 +- .../managers/breaking/RebreakHandler.kt | 2 +- .../interaction/managers/breaking/SwapInfo.kt | 2 +- .../managers/hotbar/HotbarManager.kt | 4 +- .../managers/interacting/InteractInfo.kt | 2 +- .../managers/interacting/InteractManager.kt | 4 +- .../interacting/InteractedBlockHandler.kt | 2 +- .../interaction/material/StackSelection.kt | 6 +- src/main/kotlin/com/lambda/module/Module.kt | 2 +- .../com/lambda/module/ModuleRegistry.kt | 2 +- .../com/lambda/module/hud/AccountName.kt | 2 +- .../kotlin/com/lambda/module/hud/Baritone.kt | 2 +- .../com/lambda/module/hud/Coordinates.kt | 26 +- src/main/kotlin/com/lambda/module/hud/FPS.kt | 2 +- .../com/lambda/module/hud/ModuleList.kt | 2 +- .../kotlin/com/lambda/module/hud/Rotation.kt | 4 +- .../com/lambda/module/hud/Speedometer.kt | 2 +- src/main/kotlin/com/lambda/module/hud/TPS.kt | 2 +- .../com/lambda/module/hud/TaskFlowHUD.kt | 2 +- .../kotlin/com/lambda/module/hud/Watermark.kt | 2 +- .../lambda/module/modules/chat/AntiSpam.kt | 6 +- .../module/modules/chat/ChatTimestamp.kt | 17 +- .../lambda/module/modules/chat/CustomChat.kt | 2 +- .../lambda/module/modules/chat/FancyChat.kt | 2 +- .../module/modules/chat/FriendHighlight.kt | 2 +- .../module/modules/client/AutoUpdater.kt | 44 +- .../com/lambda/module/modules/client/Capes.kt | 2 +- .../lambda/module/modules/client/Client.kt | 36 +- .../lambda/module/modules/client/Discord.kt | 12 +- .../lambda/module/modules/combat/AutoArmor.kt | 2 +- .../module/modules/combat/AutoDisconnect.kt | 2 +- .../lambda/module/modules/combat/AutoTotem.kt | 2 +- .../lambda/module/modules/combat/Criticals.kt | 2 +- .../module/modules/combat/CrystalAura.kt | 74 +-- .../module/modules/combat/FakePlayer.kt | 2 +- .../lambda/module/modules/combat/KillAura.kt | 30 +- .../module/modules/combat/PlayerTrap.kt | 2 +- .../lambda/module/modules/combat/Surround.kt | 2 +- .../module/modules/debug/BaritoneTest.kt | 2 +- .../lambda/module/modules/debug/BlockTest.kt | 2 +- .../module/modules/debug/ContainerTest.kt | 2 +- .../modules/debug/DebugRendererModule.kt | 2 +- .../lambda/module/modules/debug/FallTest.kt | 2 +- .../module/modules/debug/InventoryDebug.kt | 10 +- .../module/modules/debug/PropertyPrinter.kt | 2 +- .../lambda/module/modules/debug/RenderTest.kt | 2 +- .../modules/debug/RendererTestModule.kt | 6 +- .../module/modules/debug/RotationTest.kt | 2 +- .../modules/debug/SettingsTestModule.kt | 26 +- .../lambda/module/modules/debug/SilentSwap.kt | 5 +- .../lambda/module/modules/debug/StateInfo.kt | 2 +- .../lambda/module/modules/debug/TimerTest.kt | 2 +- .../module/modules/movement/AutoSpiral.kt | 2 +- .../module/modules/movement/AutoWalk.kt | 2 +- .../module/modules/movement/BackTrack.kt | 10 +- .../module/modules/movement/BetterFirework.kt | 2 +- .../lambda/module/modules/movement/Blink.kt | 2 +- .../modules/movement/ElytraAltitudeControl.kt | 39 +- .../module/modules/movement/ElytraFly.kt | 2 +- .../module/modules/movement/EntityControl.kt | 2 +- .../lambda/module/modules/movement/Jesus.kt | 8 +- .../lambda/module/modules/movement/NoFall.kt | 2 +- .../module/modules/movement/NoJumpCooldown.kt | 2 +- .../module/modules/movement/SafeWalk.kt | 2 +- .../lambda/module/modules/movement/Speed.kt | 20 +- .../lambda/module/modules/movement/Sprint.kt | 2 +- .../module/modules/movement/TargetStrafe.kt | 2 +- .../module/modules/movement/TickShift.kt | 2 +- .../lambda/module/modules/movement/Timer.kt | 2 +- .../module/modules/movement/Velocity.kt | 2 +- .../module/modules/network/PacketDelay.kt | 2 +- .../module/modules/network/PacketLimiter.kt | 2 +- .../module/modules/network/PacketLogger.kt | 4 +- .../module/modules/network/Rubberband.kt | 2 +- .../module/modules/network/ServerSpoof.kt | 2 +- .../lambda/module/modules/player/AntiAFK.kt | 2 +- .../lambda/module/modules/player/AntiAim.kt | 6 +- .../lambda/module/modules/player/AutoEat.kt | 4 +- .../module/modules/player/ClickFriend.kt | 2 +- .../lambda/module/modules/player/FastBreak.kt | 2 +- .../lambda/module/modules/player/Interact.kt | 2 +- .../module/modules/player/InventoryMove.kt | 4 +- .../module/modules/player/InventoryTweaks.kt | 2 +- .../module/modules/player/NoForceRotate.kt | 2 +- .../module/modules/player/PacketMine.kt | 38 +- .../lambda/module/modules/player/PortalGui.kt | 2 +- .../lambda/module/modules/player/Replay.kt | 6 +- .../module/modules/player/RotationLock.kt | 2 +- .../module/modules/player/StackReplenish.kt | 2 +- .../lambda/module/modules/player/ToolSaver.kt | 2 +- .../module/modules/render/BlockOutline.kt | 26 +- .../lambda/module/modules/render/Bobbing.kt | 2 +- .../module/modules/render/CameraTweaks.kt | 2 +- .../module/modules/render/ContainerPreview.kt | 72 +-- .../com/lambda/module/modules/render/ESP.kt | 38 +- .../lambda/module/modules/render/ExtraTab.kt | 2 +- .../lambda/module/modules/render/FreeLook.kt | 8 +- .../lambda/module/modules/render/Freecam.kt | 7 +- .../module/modules/render/Fullbright.kt | 2 +- .../module/modules/render/LightLevels.kt | 16 +- .../module/modules/render/MapPreview.kt | 2 +- .../lambda/module/modules/render/Nametags.kt | 61 ++- .../lambda/module/modules/render/NoRender.kt | 80 ++-- .../lambda/module/modules/render/RadiusESP.kt | 21 +- .../lambda/module/modules/render/Search.kt | 38 +- .../com/lambda/module/modules/render/Time.kt | 2 +- .../lambda/module/modules/render/Tracers.kt | 31 +- .../lambda/module/modules/render/ViewModel.kt | 136 +++--- .../lambda/module/modules/render/Weather.kt | 17 +- .../module/modules/render/WorldColors.kt | 2 +- .../com/lambda/module/modules/render/XRay.kt | 2 +- .../com/lambda/module/modules/render/Zoom.kt | 2 +- .../lambda/module/modules/world/AirPlace.kt | 11 +- .../lambda/module/modules/world/AutoPortal.kt | 20 +- .../lambda/module/modules/world/AutoSign.kt | 2 +- .../module/modules/world/AutoVillagerCycle.kt | 9 +- .../module/modules/world/HighwayTools.kt | 2 +- .../module/modules/world/MapDownloader.kt | 2 +- .../com/lambda/module/modules/world/Nuker.kt | 2 +- .../lambda/module/modules/world/Printer.kt | 2 +- .../lambda/module/modules/world/Scaffold.kt | 4 +- .../lambda/module/modules/world/StashMover.kt | 52 +-- .../kotlin/com/lambda/module/tag/ModuleTag.kt | 22 +- .../kotlin/com/lambda/network/CapeHandler.kt | 6 +- .../kotlin/com/lambda/network/LambdaAPI.kt | 4 +- src/main/kotlin/com/lambda/task/Task.kt | 8 +- .../kotlin/com/lambda/task/tasks/BuildTask.kt | 6 +- .../kotlin/com/lambda/task/tasks/EatTask.kt | 4 +- .../com/lambda/util/CommunicationUtils.kt | 8 +- .../kotlin/com/lambda/util/Diagnostics.kt | 2 +- .../util/DynamicReflectionSerializer.kt | 12 +- .../kotlin/com/lambda/util/FormattingUtils.kt | 2 +- src/main/kotlin/com/lambda/util/KeyCode.kt | 4 +- .../kotlin/com/lambda/util/StringUtils.kt | 2 +- .../kotlin/com/lambda/util/VarIntIterator.kt | 8 +- .../kotlin/com/lambda/util/WindowUtils.kt | 8 +- .../kotlin/com/lambda/util/math/MathUtils.kt | 6 +- .../com/lambda/util/player/PlayerUtils.kt | 2 +- .../kotlin/com/lambda/util/world/Position.kt | 44 +- .../com/lambda/util/world/WorldUtils.kt | 8 +- src/test/kotlin/FastVectorTest.kt | 8 +- 230 files changed, 1998 insertions(+), 1856 deletions(-) create mode 100644 src/main/kotlin/com/lambda/config/SettingBlock.kt create mode 100644 src/main/kotlin/com/lambda/config/SettingBlockWrapper.kt delete mode 100644 src/main/kotlin/com/lambda/config/groups/BreakSettings.kt delete mode 100644 src/main/kotlin/com/lambda/config/groups/BuildSettings.kt delete mode 100644 src/main/kotlin/com/lambda/config/groups/InventorySettings.kt delete mode 100644 src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt delete mode 100644 src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt delete mode 100644 src/main/kotlin/com/lambda/config/groups/WorldTextSettings.kt rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/ActionConfig.kt (92%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/BreakConfig.kt (99%) create mode 100644 src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/BuildConfig.kt (97%) create mode 100644 src/main/kotlin/com/lambda/config/settings/blocks/BuildSettings.kt rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/EatConfig.kt (98%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/EatSettings.kt (98%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/EntityColorSettings.kt (99%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/EntityColorsConfig.kt (93%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/EntitySelectionConfig.kt (94%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/EntitySelectionSettings.kt (99%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/FormatterConfig.kt (98%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/FormatterSettings.kt (93%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/HotbarConfig.kt (95%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/HotbarSettings.kt (93%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/InteractConfig.kt (97%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/InteractSettings.kt (82%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/InventoryConfig.kt (97%) create mode 100644 src/main/kotlin/com/lambda/config/settings/blocks/InventorySettings.kt rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/LineConfig.kt (90%) create mode 100644 src/main/kotlin/com/lambda/config/settings/blocks/OutlineConfig.kt rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/OutlineSettings.kt (65%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/ReplaceConfig.kt (95%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/RotationConfig.kt (91%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/RotationSettings.kt (95%) create mode 100644 src/main/kotlin/com/lambda/config/settings/blocks/ScreenLineSettings.kt create mode 100644 src/main/kotlin/com/lambda/config/settings/blocks/ScreenTextSettings.kt rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/TargetingConfig.kt (86%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/TargetingSettings.kt (97%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/TextConfig.kt (95%) rename src/main/kotlin/com/lambda/config/{groups => settings/blocks}/WorldLineSettings.kt (55%) create mode 100644 src/main/kotlin/com/lambda/config/settings/blocks/WorldTextSettings.kt diff --git a/src/main/java/com/lambda/mixin/CrashReportMixin.java b/src/main/java/com/lambda/mixin/CrashReportMixin.java index 29633b767..60ef27a3e 100644 --- a/src/main/java/com/lambda/mixin/CrashReportMixin.java +++ b/src/main/java/com/lambda/mixin/CrashReportMixin.java @@ -54,7 +54,7 @@ void injectConstructor(String message, Throwable cause, CallbackInfo ci) { @WrapMethod(method = "asString(Lnet/minecraft/util/crash/ReportType;Ljava/util/List;)Ljava/lang/String;") String injectString(ReportType type, List extraInfo, Operation original) { var list = new ArrayList<>(extraInfo); - list.add("If this issue is related to Lambda, check if other users have experienced this too, or create a new issue at " + Lambda.REPO_URL + "/issues.\n\n"); + list.add("If this issue is related to Lambda, check if other users have experienced this too, or create a new issue at " + Lambda.RepoUrl + "/issues.\n\n"); if (MinecraftClient.getInstance() != null) { list.add("Enabled modules:"); @@ -65,7 +65,7 @@ String injectString(ReportType type, List extraInfo, Operation o .forEach(module -> { list.add(String.format("\t%s", module.getName())); - module.getSettingContainers() + module.getSettingLayers() .stream() .filter(Setting::isModified) .forEach(setting -> list.add(String.format("\t\t%s -> %s", setting.getName(), setting.getValue()))); diff --git a/src/main/java/com/lambda/mixin/MinecraftClientMixin.java b/src/main/java/com/lambda/mixin/MinecraftClientMixin.java index 97b83eafe..3c356673d 100644 --- a/src/main/java/com/lambda/mixin/MinecraftClientMixin.java +++ b/src/main/java/com/lambda/mixin/MinecraftClientMixin.java @@ -197,7 +197,7 @@ void injectItemPick(Operation original) { float getTargetMillisPerTick(float millis, Operation original) { var length = TimerHandler.INSTANCE.getLength(); - if (length == TimerHandler.DEFAULT_LENGTH) return original.call(millis); + if (length == TimerHandler.DefaultLength) return original.call(millis); else return (float) TimerHandler.INSTANCE.getLength(); } diff --git a/src/main/kotlin/com/lambda/Lambda.kt b/src/main/kotlin/com/lambda/Lambda.kt index 10893ab4b..6dcb49f85 100644 --- a/src/main/kotlin/com/lambda/Lambda.kt +++ b/src/main/kotlin/com/lambda/Lambda.kt @@ -33,16 +33,16 @@ import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger object Lambda : ClientModInitializer { - const val MOD_NAME = "Lambda" - const val MOD_ID = "lambda" - const val SYMBOL = "λ" - const val APP_ID = "1221289599427416127" - const val REPO_URL = "https://github.com/lambda-client/lambda" - val VERSION: String = FabricLoader.getInstance() + const val ModName = "Lambda" + const val ModId = "lambda" + const val Symbol = "λ" + const val AppId = "1221289599427416127" + const val RepoUrl = "https://github.com/lambda-client/lambda" + val Version: String = FabricLoader.getInstance() .getModContainer("lambda").orElseThrow() .metadata.version.friendlyString - val LOG: Logger = LogManager.getLogger(SYMBOL) + val Log: Logger = LogManager.getLogger(Symbol) @JvmStatic val mc: MinecraftClient by lazy { MinecraftClient.getInstance() } @@ -64,7 +64,7 @@ object Lambda : ClientModInitializer { init { // We want the opengl context to be created listenOnceUnsafe({ Int.MAX_VALUE }) { - LOG.info("$MOD_NAME $VERSION initialized in ${Loader.initialize()} ms\n") + Log.info("$ModName $Version initialized in ${Loader.initialize()} ms\n") if (ClickGuiLayout.setLambdaWindowIcon) setLambdaWindowIcon() true } diff --git a/src/main/kotlin/com/lambda/command/CommandHandler.kt b/src/main/kotlin/com/lambda/command/CommandHandler.kt index 881abc037..cfede3547 100644 --- a/src/main/kotlin/com/lambda/command/CommandHandler.kt +++ b/src/main/kotlin/com/lambda/command/CommandHandler.kt @@ -40,7 +40,7 @@ import kotlin.math.min object CommandHandler { - private const val ERROR_PADDING = 10 + private const val ErrorPadding = 10 val dispatcher by lazy { CommandDispatcher() } @@ -97,10 +97,10 @@ object CommandHandler { player.sendMessage(buildText { clickEvent(suggestCommand("$prefix${reader.string}")) { color(Color.GRAY) { - if (position > ERROR_PADDING) { + if (position > ErrorPadding) { literal("...") } - literal(syntax.input.substring(max(0, (position - ERROR_PADDING)), position)) + literal(syntax.input.substring(max(0, (position - ErrorPadding)), position)) } if (position < syntax.input.length) { styled(color = CommunicationUtils.LogLevel.Error.logoColor, underlined = true) { diff --git a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt index 5f5725d7b..b1d799381 100644 --- a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt @@ -17,6 +17,7 @@ package com.lambda.command.commands +import com.google.gson.JsonParser import com.lambda.brigadier.CommandResult.Companion.failure import com.lambda.brigadier.CommandResult.Companion.success import com.lambda.brigadier.argument.literal @@ -25,18 +26,25 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required import com.lambda.command.LambdaCommand +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.ConfigLoader +import com.lambda.config.Setting import com.lambda.util.CommunicationUtils.info import com.lambda.util.extension.CommandBuilder +import com.mojang.brigadier.context.CommandContext +import net.minecraft.command.CommandSource import net.minecraft.command.CommandSource.suggestMatching object ConfigCommand : LambdaCommand( name = "config", aliases = setOf("cfg", "settings", "setting"), - usage = "config ", - description = "Save or load configuration files, or set any settings value", + usage = "config [group/tab...] [value]", + description = "Save or load configuration files, or set/reset any settings value", examples = listOf("config save", "config load", "config set HighwayTools Pavement_Material minecraft:obsidian") ) { + private const val MaxPathDepth = 6 + override fun CommandBuilder.create() { required(literal("save")) { executeWithResult { @@ -57,42 +65,149 @@ object ConfigCommand : LambdaCommand( } } required(literal("reset")) { - required(string("config")) { config -> + required(string("config")) { configArg -> suggests { _, builder -> suggestMatching(ConfigLoader.configs.map { it.commandName }, builder) } - required(string("setting")) { setting -> - suggests { ctx, builder -> - val conf = config(ctx).value() - ConfigLoader.configByName(conf)?.let { config -> - suggestMatching(config.settingContainers.map { it.commandName }, builder) - } ?: builder.buildFuture() - } - executeWithResult { - val confName = this.config().value() - val settingName = setting().value() - val config = ConfigLoader.configByCommandName(confName) - ?: return@executeWithResult failure("$confName is not a valid config.") - val setting = ConfigLoader.settingByCommandName(config, settingName) - ?: return@executeWithResult failure("$settingName is not a valid setting for $confName.") - setting.reset() - return@executeWithResult success() + buildResetPath(0) + } + } + required(literal("set")) { + required(string("config")) { configArg -> + suggests { _, builder -> + suggestMatching(ConfigLoader.configs.map { it.commandName }, builder) + } + buildSetPath(0) + } + } + } + + /** + * Recursively registers path arguments for `reset`. + * At each depth, a string argument suggests layer names (settings + groups/tabs). + * If it resolves to a setting, reset it. If it could go deeper, recurse. + */ + private fun CommandBuilder.buildResetPath(depth: Int) { + val argName = "path$depth" + required(string(argName)) { + suggests { ctx, builder -> + val layers = resolveLayersAtDepth(ctx, depth) + layers?.forEach { layer -> + when (layer) { + is SettingLayer.Single -> builder.suggest(layer.setting.commandName) + is SettingLayer.Multiple -> builder.suggest(layer.commandName) } } + builder.buildFuture() + } + executeWithResult { + val setting = resolveSettingAtDepth(this, depth + 1) + ?: return@executeWithResult failure("Not a valid setting path.") + setting.reset() + return@executeWithResult success() + } + if (depth < MaxPathDepth) { + buildResetPath(depth + 1) } } - required(literal("set")) { - ConfigLoader.configs.forEach { config -> - required(literal(config.commandName)) { - config.settingContainers.forEach { setting -> - required(literal(setting.commandName)) { - with(setting) { - buildCommand(registry) - } - } + } + + /** + * Recursively registers path arguments for `set`. + * Same tree-walking as reset, but at each depth where the path could resolve + * to a setting, registers a value argument using JSON-based parsing. + */ + private fun CommandBuilder.buildSetPath(depth: Int) { + val argName = "path$depth" + required(string(argName)) { + suggests { ctx, builder -> + val layers = resolveLayersAtDepth(ctx, depth) + layers?.forEach { layer -> + when (layer) { + is SettingLayer.Single -> builder.suggest(layer.setting.commandName) + is SettingLayer.Multiple -> builder.suggest(layer.commandName) + } + } + builder.buildFuture() + } + // Register value argument — if the path resolves to a setting, set its value + required(string("value")) { valueArg -> + executeWithResult { + val setting = resolveSettingAtDepth(this, depth + 1) + ?: return@executeWithResult failure("Not a valid setting path.") + val valueString = valueArg(this).value() + val parsed = try { + JsonParser.parseString("\"$valueString\"") + } catch (_: Exception) { + return@executeWithResult failure("$valueString is not a valid value.") } + val previous = setting.core.value + try { + setting.core.loadFromJson(parsed) + } catch (_: Exception) { + return@executeWithResult failure("Failed to set $valueString for ${setting.name}.") + } + this@ConfigCommand.info("Set ${setting.name} from $previous to ${setting.core.value}") + return@executeWithResult success() } } + buildSetPath(depth + 1) + } + } + + /** + * Resolves the [Config] from the "config" argument in the command context. + */ + private fun resolveConfig(ctx: CommandContext): Config? { + val configName = try { + ctx.getArgument("config", String::class.java) + } catch (_: Exception) { return null } + return ConfigLoader.configByCommandName(configName) + } + + /** + * Resolves the [SettingLayer] list at the given depth by reading + * path0..path(depth-1) from the command context and walking the tree. + */ + private fun resolveLayersAtDepth(ctx: CommandContext, depth: Int): List? { + val config = resolveConfig(ctx) ?: return null + var layers: List = config.settingLayers + for (i in 0 until depth) { + val argValue = try { + ctx.getArgument("path$i", String::class.java) + } catch (_: Exception) { return null } + val container = layers + .filterIsInstance() + .find { it.commandName == argValue } + ?: return null + layers = container.layers + } + return layers + } + + /** + * Resolves a [Setting] by reading config + path0..path(depth-1) from context. + * The last path argument is expected to be the setting name. + */ + private fun resolveSettingAtDepth(ctx: CommandContext, depth: Int): Setting<*, *>? { + val config = resolveConfig(ctx) ?: return null + var layers: List = config.settingLayers + for (i in 0 until depth - 1) { + val argValue = try { + ctx.getArgument("path$i", String::class.java) + } catch (_: Exception) { return null } + val container = layers + .filterIsInstance() + .find { it.commandName == argValue } + ?: return null + layers = container.layers } + val settingName = try { + ctx.getArgument("path${depth - 1}", String::class.java) + } catch (_: Exception) { return null } + return layers + .filterIsInstance() + .find { it.setting.commandName == settingName } + ?.setting } } diff --git a/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt b/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt index 3b0a1fa26..38cf16a4c 100644 --- a/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/FriendCommand.kt @@ -77,7 +77,7 @@ object FriendCommand : LambdaCommand( styled( color = Color.CYAN, underlined = true, - clickEvent = ClickEvents.openFile(FriendCategory.primary.path), + clickEvent = ClickEvents.openFile(FriendCategory.primaryFile.path), ) { literal("Click to open your friends list as a file") } diff --git a/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt b/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt index cc6365e35..cf0e04ff1 100644 --- a/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt @@ -29,6 +29,7 @@ import com.lambda.command.LambdaCommand import com.lambda.config.ConfigLoader import com.lambda.config.Setting import com.lambda.config.SettingCore +import com.lambda.config.settings.CharSetting import com.lambda.util.CommunicationUtils.info import com.lambda.util.extension.CommandBuilder import com.lambda.util.text.buildText @@ -52,11 +53,8 @@ object PrefixCommand : LambdaCommand( return@executeWithResult failure("Prefix must be a single non-alphanumeric ASCII character, excluding spaces.") } val prefixChar = prefix.first() - val config = ConfigLoader.configByName("command") ?: return@executeWithResult failure("No command config found.") - @Suppress("UNCHECKED_CAST") - val setting = config.settingContainers.find { it.name == "prefix" } as? Setting, Char> - ?: return@executeWithResult failure("Prefix setting is not a Char or can not be found.") - setting.trySetValue(prefixChar) + @Suppress("unchecked_cast") + (CommandRegistry::prefix.getDelegate() as? Setting<*, Char>)?.trySetValue(prefixChar) return@executeWithResult success() } } diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index fe5aee31d..ee77de019 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -52,12 +52,11 @@ import net.minecraft.registry.Registries import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Vec3d import java.awt.Color +import kotlin.collections.toMutableList import kotlin.jvm.java import kotlin.reflect.KClass import kotlin.reflect.KProperty -import kotlin.reflect.KProperty1 import kotlin.reflect.full.declaredMemberProperties -import kotlin.reflect.jvm.isAccessible import kotlin.reflect.jvm.javaField @DslMarker @@ -69,143 +68,115 @@ private annotation class SettingDsl * * This class also provides a series of helper methods ([setting]) for creating different types of settings. * - * @property settingContainers A set of [SettingCore]s that this config manages. + * @property settingLayers A set of [SettingCore]s that this config manages. */ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { - val settingContainers = mutableListOf() - private val registrationQueue = ArrayDeque>() + internal val settingLayers = SettingLayer.Root() + internal val settingBlockLayers = BlockLayer.Root() + private val registrationQueue = ArrayDeque>() init { if (configs.any { it.name == name }) throw IllegalStateException("Configs with name $name already exists") - enqueueProperties(this::class, emptyList()) + enqueueProperties(this::class, emptyList(), emptyList()) configCategory.configs.add(this) } - /** - * Recursively reflects over [klass]'s declared properties to build the [registrationQueue]. - * For each property: - * - If its backing field is a [Setting], enqueue its annotation path. - * - If its backing field is a [SettingBlock], recurse into that class with the current path as outer context. - * - If it has no backing field (computed property), skip it. - */ - private fun enqueueProperties(klass: KClass<*>, outerPath: List) { - forEachSettingProperty( - klass, - onSetting = { setting -> - registrationQueue.addLast(outerPath + buildPathFromAnnotations(setting)) - }, - onSettingBlock = { settingBlock, blockClass -> - enqueueProperties(blockClass, outerPath + buildPathFromAnnotations(settingBlock)) - } - ) - } - - /** - * Reads [Tab] and [Group] annotations from a property and builds a nesting path. - * Annotation order in source determines nesting order. - */ - private fun buildPathFromAnnotations(property: KProperty<*>): List { - val path = mutableListOf() - property.annotations.forEach { annotation -> - when (annotation) { - is Tab -> annotation.tabs.forEach { path.add(ContainerSpec(ContainerType.Tab, it)) } - is Group -> annotation.groups.forEach { path.add(ContainerSpec(ContainerType.Group, it)) } - } - } - return path - } - - /** - * Registers a [Setting] into the [settingContainers] tree. - * Dequeues the next path from [registrationQueue] and navigates/creates - * the container hierarchy, coalescing containers with the same name and type. - */ - fun register(setting: Setting<*, *>) { - val path = try { - registrationQueue.removeFirst() - } catch(_: NoSuchElementException) { - logError("Setting registered from an unknown location; layer path was not queued before setting initialization") - return + private fun enqueueProperties(klass: KClass<*>, outerPath: List, outerBlockPath: List) { + var childBlockIndex = 0 + forEachConfigProperty( + klass, + onSetting = { setting -> + registrationQueue.addLast(outerPath + buildPathFromAnnotations(setting)) + }, + onSettingBlock = { settingBlock, blockClass -> + enqueueProperties( + blockClass, + outerPath + buildPathFromAnnotations(settingBlock), + outerBlockPath + childBlockIndex + ) + childBlockIndex++ + } + ) + } + + private fun forEachConfigProperty( + klass: KClass<*>, + onSetting: (property: KProperty<*>) -> Unit = {}, + onSettingBlock: (property: KProperty<*>, blockClass: KClass<*>) -> Unit = { _, _ -> } + ) { + klass.declaredMemberProperties.forEach { property -> + val fieldType = property.javaField?.type ?: return@forEach + when { + Setting::class.java.isAssignableFrom(fieldType) -> onSetting(property) + SettingBlock::class.java.isAssignableFrom(fieldType) -> onSettingBlock(property, fieldType.kotlin) + } } - var currentList = settingContainers - - path.forEach { spec -> - val existing = currentList - .asSequence() - .filterIsInstance() - .filter { it.name == spec.name } - .firstOrNull { - (spec.type == ContainerType.Tab && it is SettingContainer.Tab) || - (spec.type == ContainerType.Group && it is SettingContainer.Group) - } - - if (existing != null) currentList = existing.settings - else { - val newContainer = when (spec.type) { - ContainerType.Tab -> SettingContainer.Tab(spec.name, mutableListOf()) - ContainerType.Group -> SettingContainer.Group(spec.name, mutableListOf()) - } - currentList.add(newContainer) - currentList = newContainer.settings - } - } - - currentList.add(SettingContainer.Single(setting)) - } + } + + private fun buildPathFromAnnotations(property: KProperty<*>): List { + val path = mutableListOf() + property.annotations.forEach { annotation -> + when (annotation) { + is Tab -> annotation.tabs.forEach { path.add(SettingLayerSpec(SettingLayerType.Tab, it)) } + is Group -> annotation.groups.forEach { path.add(SettingLayerSpec(SettingLayerType.Group, it)) } + } + } + return path + } final override fun toJson() = JsonObject().apply { - fun JsonObject.addSettings(settings: Collection) { - settings.forEach { container -> - when (container) { - is SettingContainer.Single -> + fun JsonObject.addSettings(settings: Collection) { + settings.forEach { layer -> + when (layer) { + is SettingLayer.Single<*, *> -> try { - add(container.setting.name, container.setting.toJson()) + add(layer.setting.name, layer.setting.toJson()) } catch(e: Throwable) { - logError("Failed to serialize '${container.setting}' in ${this::class.simpleName}", e) + logError("Failed to serialize '${layer.setting}' in ${this::class.simpleName}", e) } - is SettingContainer.Multiple -> { + is SettingLayer.Multiple -> { val grouped = JsonObject() - grouped.addSettings(container.settings) + grouped.addSettings(layer.layers) try { - add(container.name, grouped) + add(layer.name, grouped) } catch(e: Throwable) { - logError("Failed to serialize ${container.typeStr}: ${container.name} in ${this::class.simpleName}", e) + logError("Failed to serialize ${layer.type.toString().lowercase()}: ${layer.name} in ${this::class.simpleName}", e) } } } } } - addSettings(settingContainers) + addSettings(settingLayers.layers) } final override fun loadFromJson(serialized: JsonElement) { val rootObj = serialized.asJsonObject - fun loadFromObject(obj: JsonObject, containers: Collection) { - containers.forEach { container -> - when (container) { - is SettingContainer.Single -> { - val jsonValue = obj[container.setting.name] + fun loadFromObject(obj: JsonObject, layers: Collection) { + layers.forEach { layer -> + when (layer) { + is SettingLayer.Single<*, *> -> { + val jsonValue = obj[layer.setting.name] if (jsonValue != null) { try { - container.setting.loadFromJson(jsonValue) + layer.setting.loadFromJson(jsonValue) } catch (e: Throwable) { - logError("Failed to deserialize setting '${container.setting.name}'", e) + logError("Failed to deserialize setting '${layer.setting.name}'", e) } - } else logError("No saved value for setting '${container.setting.name}' in ${this::class.simpleName}") + } else logError("No saved value for setting '${layer.setting.name}' in ${this::class.simpleName}") } - is SettingContainer.Multiple -> { - val nestedObj = obj[container.name]?.asJsonObject + is SettingLayer.Multiple -> { + val nestedObj = obj[layer.name]?.asJsonObject if (nestedObj != null) { - loadFromObject(nestedObj, container.settings) - } else logError("No data for group/tab '${container.name}' in ${this::class.simpleName}") + loadFromObject(nestedObj, layer.layers) + } else logError("No data for group/tab '${layer.name}' in ${this::class.simpleName}") } } } } - loadFromObject(rootObj, settingContainers) + loadFromObject(rootObj, settingLayers.layers) } @SettingDsl @@ -214,15 +185,15 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { defaultValue: Boolean, description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, BooleanSetting(defaultValue), this, visibility) + ) = setting(name, description, BooleanSetting(defaultValue), visibility) @SettingDsl - inline fun > setting( + fun > setting( name: String, defaultValue: T, description: String = "", - noinline visibility: () -> Boolean = { true }, - ) = Setting(name, description,EnumSetting(defaultValue), this, visibility) + visibility: () -> Boolean = { true }, + ) = setting(name, description,EnumSetting(defaultValue), visibility) @SettingDsl fun setting( @@ -230,7 +201,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { defaultValue: Char, description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, CharSetting(defaultValue), this, visibility) + ) = setting(name, description, CharSetting(defaultValue), visibility) @SettingDsl fun setting( @@ -240,7 +211,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { flags: Int = ImGuiInputTextFlags.None, description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, StringSetting(defaultValue, multiline, flags), this, visibility) + ) = setting(name, description, StringSetting(defaultValue, multiline, flags), visibility) @SettingDsl @JvmName("collectionSetting1") @@ -250,7 +221,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { immutableCollection: Collection = Registries.BLOCK.toList(), description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, BlockCollectionSetting(immutableCollection, defaultValue.toMutableList()), this, visibility) + ) = setting(name, description, BlockCollectionSetting(immutableCollection, defaultValue.toMutableList()), visibility) @SettingDsl @JvmName("collectionSetting2") @@ -260,7 +231,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { immutableCollection: Collection = Registries.ITEM.toList(), description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, ItemCollectionSetting(immutableCollection, defaultValue.toMutableList()), this, visibility) + ) = setting(name, description, ItemCollectionSetting(immutableCollection, defaultValue.toMutableList()), visibility) @SettingDsl @JvmName("collectionSetting3") @@ -272,30 +243,28 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { displayClassName: Boolean = false, serialize: Boolean = false, noinline visibility: () -> Boolean = { true }, - ) = Setting( + ) = setting( name, description, if (displayClassName) ClassCollectionSetting(immutableList, defaultValue.toMutableList()) else CollectionSetting(defaultValue.toMutableList(), immutableList, TypeToken.getParameterized(Collection::class.java, T::class.java).type, serialize), - this, visibility ) @SettingDsl // ToDo: Actually implement maps - inline fun setting( + inline fun setting( name: String, defaultValue: Map, description: String = "", noinline visibility: () -> Boolean = { true }, - ) = Setting( + ) = setting( name, description, MapSetting( defaultValue.toMutableMap(), TypeToken.getParameterized(MutableMap::class.java, K::class.java, V::class.java).type ), - this, visibility ) @@ -308,7 +277,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { description: String = "", unit: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, DoubleSetting(defaultValue, range, step, unit), this, visibility) + ) = setting(name, description, DoubleSetting(defaultValue, range, step, unit), visibility) @SettingDsl fun setting( @@ -319,7 +288,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { description: String = "", unit: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, FloatSetting(defaultValue, range, step, unit), this, visibility) + ) = setting(name, description, FloatSetting(defaultValue, range, step, unit), visibility) @SettingDsl fun setting( @@ -330,7 +299,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { description: String = "", unit: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, IntegerSetting(defaultValue, range, step, unit), this, visibility) + ) = setting(name, description, IntegerSetting(defaultValue, range, step, unit), visibility) @SettingDsl fun setting( @@ -341,7 +310,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { description: String = "", unit: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, LongSetting(defaultValue, range, step, unit), this, visibility) + ) = setting(name, description, LongSetting(defaultValue, range, step, unit), visibility) @SettingDsl fun setting( @@ -351,7 +320,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { alwaysListening: Boolean = false, screenCheck: Boolean = true, visibility: () -> Boolean = { true }, - ) = Setting(name, description, KeybindSetting(defaultValue, this as? Muteable, alwaysListening, screenCheck), this, visibility) + ) = setting(name, description, KeybindSetting(defaultValue, this as? Muteable, alwaysListening, screenCheck), visibility) @SettingDsl fun setting( @@ -361,7 +330,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { alwaysListening: Boolean = false, screenCheck: Boolean = true, visibility: () -> Boolean = { true }, - ) = Setting(name, description, KeybindSetting(defaultValue, this as? Muteable, alwaysListening, screenCheck), this, visibility) + ) = setting(name, description, KeybindSetting(defaultValue, this as? Muteable, alwaysListening, screenCheck), visibility) @SettingDsl fun setting( @@ -369,7 +338,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { defaultValue: Color, description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, ColorSetting(defaultValue), this, visibility) + ) = setting(name, description, ColorSetting(defaultValue), visibility) @SettingDsl fun setting( @@ -377,7 +346,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { defaultValue: Vec3d, description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, Vec3dSetting(defaultValue), this, visibility) + ) = setting(name, description, Vec3dSetting(defaultValue), visibility) @SettingDsl fun setting( @@ -385,7 +354,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { defaultValue: BlockPos.Mutable, description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, BlockPosSetting(defaultValue), this, visibility) + ) = setting(name, description, BlockPosSetting(defaultValue), visibility) @SettingDsl fun setting( @@ -393,7 +362,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { defaultValue: BlockPos, description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, BlockPosSetting(defaultValue), this, visibility) + ) = setting(name, description, BlockPosSetting(defaultValue), visibility) @SettingDsl fun setting( @@ -401,7 +370,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { defaultValue: Block, description: String = "", visibility: () -> Boolean = { true }, - ) = Setting(name, description, BlockSetting(defaultValue), this, visibility) + ) = setting(name, description, BlockSetting(defaultValue), visibility) @SettingDsl fun setting( @@ -409,89 +378,176 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { defaultValue: () -> Unit, description: String = "", visibility: () -> Boolean = { true } - ) = Setting(name, description, FunctionSetting(defaultValue), this, visibility) + ) = setting(name, description, FunctionSetting(defaultValue), visibility) @SettingDsl - fun settingBlock(settingBlock: T, visibility: (() -> Boolean)? = null, block: (T.() -> Unit)? = null) = + fun settingBlock( + settingBlock: T, + visibility: (() -> Boolean)? = null, + block: (T.() -> Unit)? = null + ): SettingBlockWrapper = settingBlock .apply { block?.invoke(this) } .also { if (visibility != null) forEachSetting(settingBlock) { it.visibility = { it.visibility() && visibility() } } } + .let { settingBlock -> + val path = try { + settingBlockRegistration.removeFirst() + } catch(_: NoSuchElementException) { + throw IllegalStateException("Setting block registered from an unknown location; layer path was not queued before setting initialization") + } - /** - * Collects all [SettingBlock] instances declared as fields on this [Config]. - */ - fun collectSettingBlocks(): List { - val result = mutableListOf() - forEachSettingProperty(this::class, - onSettingBlock = { property, _ -> - val field = property.javaField ?: return@forEachSettingProperty - field.isAccessible = true - (field.get(this) as? SettingBlock)?.let { result.add(it) } - } - ) - return result - } + var currentLayer: BlockLayer = settingBlockLayers - private enum class ContainerType { Tab, Group } - private data class ContainerSpec(val type: ContainerType, val name: String) + path.forEach { index -> + val existing = currentLayer.layers.getOrNull(index) + if (existing != null) currentLayer = existing + else { + val layer = BlockLayer.Block(settingBlock, currentLayer) + currentLayer.layers[index] = layer + currentLayer = layer + } + } - sealed interface SettingContainer { - class Single(val setting: Setting<*, *>) : SettingContainer + SettingBlockWrapper(settingBlock, currentLayer) + } + + @PublishedApi + internal fun , R : Any> setting(name: String, description: String, settingCore: T, visibility: () -> Boolean): Setting { + val path = try { + registrationQueue.removeFirst() + } catch(_: NoSuchElementException) { + throw IllegalStateException("Setting registered from an unknown location; layer path was not queued before setting initialization") + } + var currentLayer: SettingLayer.Multiple = settingLayers + + path.forEach { spec -> + val existing = currentLayer.layers + .asSequence() + .filterIsInstance() + .filter { it.name == spec.name } + .also { + if (it.any { layer -> + spec.type == SettingLayerType.Tab && layer is SettingLayer.Group || + spec.type == SettingLayerType.Group && layer is SettingLayer.Tab + }) throw IllegalStateException("Duplicate setting layer names with differing types: ${spec.type}") + } + .firstOrNull() + + if (existing != null) currentLayer = existing + else { + val newContainer = when (spec.type) { + SettingLayerType.Tab -> SettingLayer.Tab(spec.name, mutableListOf(), currentLayer) + SettingLayerType.Group -> SettingLayer.Group(spec.name, mutableListOf(), currentLayer) + SettingLayerType.Root -> throw IllegalStateException("Multiple root setting layers; only the base class root layer should ever be created") + } + currentLayer.layers.add(newContainer) + currentLayer = newContainer + } + } + + val layer = SettingLayer.Single(currentLayer, name, description, settingCore, this@Config, visibility) + currentLayer.layers.add(layer) + return layer.setting + } + + enum class SettingLayerType { Root, Tab, Group } + private data class SettingLayerSpec(val type: SettingLayerType, val name: String) + + sealed interface SettingLayer { + val parent: SettingLayer? + + class Single, R : Any>( + override val parent: Multiple, + name: String, + description: String, + settingCore: T, + config: Config, + visibility: () -> Boolean, + ) : SettingLayer { + val setting = Setting(name, description, settingCore, config, this, visibility) + } sealed class Multiple( - override val name: String, - val settings: MutableList - ) : SettingContainer, Nameable { - abstract val typeStr: String + override val name: String, + val layers: MutableList, + override val parent: Multiple? + ) : SettingLayer, Nameable { + abstract val type: SettingLayerType } + class Root : Multiple( + "Root", + mutableListOf(), + null + ) { + override val type = SettingLayerType.Root + } + class Tab( - name: String, - settings: MutableList - ) : Multiple(name, settings) { - override val typeStr = "tab" + name: String, + layers: MutableList, + parent: Multiple + ) : Multiple(name, layers, parent) { + override val type = SettingLayerType.Tab } class Group( - name: String, - settings: MutableList - ) : Multiple(name, settings) { - override val typeStr = "group" + name: String, + layers: MutableList, + parent: Multiple + ) : Multiple(name, layers, parent) { + override val type = SettingLayerType.Group } } + sealed interface BlockLayer { + val parent: BlockLayer? + val layers: MutableList + + class Root : BlockLayer { + override val parent = null + override val layers = mutableListOf() + } + + class Block( + val settingBlock: SettingBlock, + override val parent: BlockLayer? + ) : BlockLayer { + override val layers = mutableListOf() + } + } + companion object { - @Suppress("unchecked_cast") - fun forEachSetting(instance: Any, block: (Setting<*, *>) -> Unit) { + fun forEachSetting( + instance: Any, + block: (Setting<*, *>) -> Unit + ) { instance::class.declaredMemberProperties.forEach { property -> - property.isAccessible = true - val fieldType = property.javaField?.type ?: return@forEach + val field = property.javaField ?: return@forEach + field.isAccessible = true + val fieldValue = field.get(instance) ?: return@forEach when { - Setting::class.java.isAssignableFrom(fieldType) -> - block((property as KProperty1).get(instance) as Setting<*, *>) - SettingBlock::class.java.isAssignableFrom(fieldType) -> - forEachSetting((property as KProperty1).get(instance) as SettingBlock, block) + Setting::class.java.isAssignableFrom(field.type) -> + block(fieldValue as Setting<*, *>) + SettingBlockWrapper::class.java.isAssignableFrom(field.type) -> + forEachSetting(fieldValue as SettingBlockWrapper<*>, block) } } } - /** - * Iterates over declared properties of [klass], invoking [onSetting] for fields - * assignable to [Setting] and [onSettingBlock] for fields assignable to [SettingBlock]. - */ - fun forEachSettingProperty( - klass: KClass<*>, - onSetting: (property: KProperty<*>) -> Unit = {}, - onSettingBlock: (property: KProperty<*>, blockClass: KClass<*>) -> Unit = { _, _ -> } - ) { - klass.declaredMemberProperties.forEach { property -> - val fieldType = property.javaField?.type ?: return@forEach - when { - Setting::class.java.isAssignableFrom(fieldType) -> onSetting(property) - SettingBlock::class.java.isAssignableFrom(fieldType) -> onSettingBlock(property, fieldType.kotlin) - } - } - } + fun forEachSettingBlockWrapper( + instance: Any, + block: (SettingBlockWrapper) -> Unit + ) { + instance::class.java.declaredFields.forEach { field -> + field.isAccessible = true + val fieldValue = field.get(instance) ?: return@forEach + if (SettingBlockWrapper::class.java.isAssignableFrom(field.type)) { + block(fieldValue as SettingBlockWrapper) + forEachSettingBlockWrapper(fieldValue, block) + } + } + } } } @@ -501,8 +557,4 @@ annotation class Tab(vararg val tabs: String) @Target(AnnotationTarget.PROPERTY) @Retention(AnnotationRetention.RUNTIME) -annotation class Group(vararg val groups: String) - -interface SettingBlock { - val c: Config -} \ No newline at end of file +annotation class Group(vararg val groups: String) \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/ConfigCategory.kt b/src/main/kotlin/com/lambda/config/ConfigCategory.kt index a5a66f68e..34dc48b90 100644 --- a/src/main/kotlin/com/lambda/config/ConfigCategory.kt +++ b/src/main/kotlin/com/lambda/config/ConfigCategory.kt @@ -22,7 +22,7 @@ import com.google.gson.JsonIOException import com.google.gson.JsonObject import com.google.gson.JsonParser import com.google.gson.JsonSyntaxException -import com.lambda.Lambda.LOG +import com.lambda.Lambda.Log import com.lambda.Lambda.gson import com.lambda.config.ConfigLoader.configByName import com.lambda.config.ConfigLoader.configCategories @@ -94,7 +94,7 @@ abstract class ConfigCategory( val latestSchemaVersion = ConfigMigrations.latestVersion(configName) if (latestSchemaVersion > 1) { addProperty( - ConfigMigrations.schemaVersionKey(configName) ?: ConfigMigrations.DEFAULT_SCHEMA_VERSION_KEY, + ConfigMigrations.schemaVersionKey(configName) ?: ConfigMigrations.DefaultSchemaVersionKey, latestSchemaVersion ) } @@ -104,12 +104,12 @@ abstract class ConfigCategory( } final override fun loadFromJson(serialized: JsonElement) { - val schemaKey = ConfigMigrations.schemaVersionKey(configName) ?: ConfigMigrations.DEFAULT_SCHEMA_VERSION_KEY + val schemaKey = ConfigMigrations.schemaVersionKey(configName) ?: ConfigMigrations.DefaultSchemaVersionKey serialized.asJsonObject.entrySet().forEach { (name, value) -> if (name == schemaKey) return@forEach configByName(name) ?.loadFromJson(value) - ?: LOG.warn("No matching setting found for saved setting $name with $value in ${configName.capitalize()} config") + ?: Log.warn("No matching setting found for saved setting $name with $value in ${configName.capitalize()} config") } } @@ -117,21 +117,21 @@ abstract class ConfigCategory( loadFromFile(primaryFile) .onSuccess { val message = "${configName.capitalize()} config loaded." - LOG.info(message) + Log.info(message) info(message) } .onFailure { primaryError -> - LOG.error(primaryError) + Log.error(primaryError) runCatching { loadFromFile(backup) } .onSuccess { val message = "${configName.capitalize()} config loaded from backup" - LOG.info(message) + Log.info(message) info(message) } .onFailure { error -> val message = "Failed to load ${configName.capitalize()} config from backup, unrecoverable error" - LOG.error(message, error) + Log.error(message, error) logError(message) } } @@ -141,12 +141,12 @@ abstract class ConfigCategory( saveToFile() .onSuccess { val message = "Saved ${configName.capitalize()} config." - LOG.info(message) + Log.info(message) if (logToChat) info(message) } .onFailure { val message = "Failed to save ${configName.capitalize()} config" - LOG.error(message, it) + Log.error(message, it) logError(message) } } @@ -156,7 +156,7 @@ abstract class ConfigCategory( * Encapsulates [JsonIOException] and [JsonSyntaxException] in a runCatching block */ private fun loadFromFile(file: File) = runCatching { - file.ifNotExists { LOG.warn("No configuration file found for ${configName.capitalize()}. Creating new file when saving.") } + file.ifNotExists { Log.warn("No configuration file found for ${configName.capitalize()}. Creating new file when saving.") } .ifExists { val parsed = JsonParser.parseReader(it.reader()).asJsonObject val migrationResult = ConfigMigrations.migrate(configName, parsed) diff --git a/src/main/kotlin/com/lambda/config/ConfigEditor.kt b/src/main/kotlin/com/lambda/config/ConfigEditor.kt index 361d63247..3dcfb8fc1 100644 --- a/src/main/kotlin/com/lambda/config/ConfigEditor.kt +++ b/src/main/kotlin/com/lambda/config/ConfigEditor.kt @@ -19,8 +19,10 @@ package com.lambda.config -import com.lambda.config.Config.SettingContainer +import com.lambda.config.Config.Companion.forEachSetting +import com.lambda.config.Config.SettingLayer import kotlin.reflect.KProperty0 +import kotlin.reflect.full.declaredMemberProperties import kotlin.reflect.jvm.isAccessible import kotlin.reflect.jvm.javaField @@ -33,92 +35,79 @@ fun T.applyEdits(edits: ConfigEditor.() -> Unit) { } class ConfigEditor(val c: T) { - private val KProperty0<*>.delegate + private typealias Property = KProperty0 + private typealias SettingProperty = KProperty0 + private typealias SettingBlockProperty = KProperty0 + + private val Property<*>.delegate get() = try { apply { isAccessible = true }.getDelegate() } catch (e: Exception) { throw IllegalStateException("Could not access delegate for property $name", e) } - private fun KProperty0.setting() = - this.delegate as? Setting, T> - ?: throw IllegalStateException("Setting delegate did not match current value's type") + private val SettingProperty.setting + get() = this.delegate as? Setting, T> + ?: throw IllegalStateException("Setting delegate did not match the given type") + + private val SettingBlockProperty.settingBlock + get() = this.delegate as? SettingBlockWrapper + ?: throw IllegalStateException("SettingBlock delegate did not match the given type") - private fun KProperty0.settingCore() = setting().core + private fun SettingProperty.settingCore() = setting.core @SettingEditorDsl - fun KProperty0.edit(edits: TypedEditBuilder.(SettingCore) -> Unit) { - val delegate = setting() + fun SettingProperty.edit(edits: TypedEditBuilder.(SettingCore) -> Unit) { + val delegate = setting TypedEditBuilder(this@ConfigEditor, listOf(delegate)).edits(delegate.core) } - @SettingEditorDsl - fun KProperty0.editWith( - other: KProperty0, - edits: TypedEditBuilder.(SettingCore) -> Unit - ) = TypedEditBuilder(this@ConfigEditor, listOf(setting())).edits(other.settingCore()) - @SettingEditorDsl fun edit( - vararg settings: KProperty0<*>, + vararg settings: SettingProperty<*>, edits: BasicEditBuilder.() -> Unit - ) = BasicEditBuilder(this, settings.map { (it as KProperty0).setting() }).apply(edits) - - @SettingEditorDsl - fun editWith( - vararg settings: KProperty0<*>, - other: KProperty0, - edits: BasicEditBuilder.(SettingCore) -> Unit - ) = BasicEditBuilder(this, settings.map { (it as KProperty0).setting() }).edits(other.settingCore()) + ) = BasicEditBuilder(this, settings.map { (it as SettingProperty).setting }).apply(edits) @SettingEditorDsl fun editTyped( - vararg settings: KProperty0, + vararg settings: SettingProperty, edits: TypedEditBuilder.() -> Unit - ) = TypedEditBuilder(this, settings.map { it.setting() }).apply(edits) + ) = TypedEditBuilder(this, settings.map { it.setting }).apply(edits) @SettingEditorDsl - fun editTypedWith( - vararg settings: KProperty0, - other: KProperty0, - edits: TypedEditBuilder.(SettingCore) -> Unit - ) = TypedEditBuilder(this, settings.map { it.setting() }).edits(other.settingCore()) - - /** - * Recursively removes matching [Setting]s from the [Config.settingContainers] tree. - * After removal, any [SettingContainer.Multiple] (group/tab) left empty is also pruned. - */ - @SettingEditorDsl - fun hide(settings: Collection>) { - removeFromContainers(c.settingContainers, settings.toSet()) - } + fun hide(vararg settings: SettingProperty) = + hide(settings.map { it.setting }) @SettingEditorDsl - fun hide(vararg settings: KProperty0) = - hide(settings.map { it.setting() }) + fun hideBlock(settingGroup: SettingBlockProperty) { + forEachSetting(settingGroup.settingBlock) { setting -> + hide(setting) + } + } @SettingEditorDsl - fun hideBlock(settingGroup: SettingBlock) = hide(settingGroup.collectSettings()) + fun hideBlocks(vararg settingGroups: SettingBlockProperty) = + settingGroups.forEach { hideBlock(it) } @SettingEditorDsl - fun hideBlockExcept(settingGroup: SettingBlock, vararg except: KProperty0) { - val exceptSettings = except.map { it.setting() } - hide(settingGroup.collectSettings().filter { it !in exceptSettings }) + fun hideBlockExcept(settingGroup: SettingBlockProperty, vararg except: SettingProperty) { + val exceptSettings = except.map { it.setting } + forEachSetting(settingGroup.settingBlock) { setting -> + if (setting !in exceptSettings) hide(setting) + } } @SettingEditorDsl - fun hideBlocks(vararg settingGroups: SettingBlock) = - settingGroups.forEach { hide(it.collectSettings()) } - - @SettingEditorDsl - fun hideAllBlocksExcept(vararg except: SettingBlock) { - val toHide = c.collectSettingBlocks().filter { it !in except } + fun hideAllBlocksExcept(vararg except: SettingBlockWrapper) { + Config.forEachSettingBlockWrapper(c) { block -> + if (block !in except) hideBlock(block) + } toHide.forEach { hide(it.collectSettings()) } } @SettingEditorDsl fun SettingBlock.forEachSetting(block: (Setting<*, *>) -> Unit) = - Config.forEachSetting(this, block) + forEachSetting(this, block) open class BasicEditBuilder(val c: ConfigEditor<*>, open val settings: Collection>) { @SettingEditorDsl @@ -144,50 +133,14 @@ class ConfigEditor(val c: T) { } } - /** - * Recursively removes [SettingContainer.Single] entries whose [Setting] is in [toRemove], - * and prunes any [SettingContainer.Multiple] (group/tab) left empty after removal. - */ - private fun removeFromContainers( - containers: MutableList, - toRemove: Set> - ) { - val iterator = containers.iterator() - while (iterator.hasNext()) { - when (val container = iterator.next()) { - is SettingContainer.Single -> { - if (container.setting in toRemove) iterator.remove() - } - is SettingContainer.Multiple -> { - removeFromContainers(container.settings, toRemove) - if (container.settings.isEmpty()) iterator.remove() - } - } - } - } - - /** - * Collects all [Setting] instances from a [SettingBlock] via reflection, - * recursing into nested [SettingBlock] fields. - */ - private fun SettingBlock.collectSettings(): List> { - val result = mutableListOf>() - collectSettingsRecursive(this, result) - return result + private fun hide(settings: Collection>) { + settings.forEach(::hide) } - private fun collectSettingsRecursive(instance: Any, result: MutableList>) { - Config.forEachSettingProperty(instance::class, - onSetting = { property -> - val field = property.javaField ?: return@forEachSettingProperty - field.isAccessible = true - (field.get(instance) as? Setting<*, *>)?.let { result.add(it) } - }, - onSettingBlock = { property, _ -> - val field = property.javaField ?: return@forEachSettingProperty - field.isAccessible = true - field.get(instance)?.let { collectSettingsRecursive(it, result) } - } - ) + private fun hide(setting: Setting<*, *>) { + val parentLayer = setting.layer.parent + parentLayer.layers.remove(setting.layer) + if (parentLayer.layers.isEmpty()) + parentLayer.parent?.layers?.remove(parentLayer) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/ConfigLoader.kt b/src/main/kotlin/com/lambda/config/ConfigLoader.kt index 70851fdb2..636b27bb9 100644 --- a/src/main/kotlin/com/lambda/config/ConfigLoader.kt +++ b/src/main/kotlin/com/lambda/config/ConfigLoader.kt @@ -36,20 +36,4 @@ object ConfigLoader: Loadable { fun configByCommandName(name: String) = configs.find { it.commandName == name } - - fun settingByCommandName(name: String, config: Config, vararg layers: String): Setting<*, *>? { - var settingContainers = config.settingContainers.asSequence() - layers.forEach { layer -> - settingContainers = settingContainers - .filterIsInstance() - .find { container -> - container.commandName == layer - }?.settings - ?.asSequence() ?: return null - } - return settingContainers - .filterIsInstance() - .find { it.setting.commandName == name } - ?.setting - } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/Setting.kt b/src/main/kotlin/com/lambda/config/Setting.kt index 70c152c4b..7969dde9c 100644 --- a/src/main/kotlin/com/lambda/config/Setting.kt +++ b/src/main/kotlin/com/lambda/config/Setting.kt @@ -20,7 +20,7 @@ package com.lambda.config import com.google.common.base.Defaults.defaultValue import com.google.gson.JsonElement import com.google.gson.JsonParser -import com.lambda.Lambda.LOG +import com.lambda.Lambda.Log import com.lambda.Lambda.gson import com.lambda.brigadier.CommandResult.Companion.failure import com.lambda.brigadier.CommandResult.Companion.success @@ -62,7 +62,7 @@ import kotlin.reflect.KProperty * Simple Usage: * ```kotlin * // this uses the delegate (by) association to access the setting value in the code directly. - * val mode by setting("Mode", Modes.FREEZE, { page == Page.CUSTOM }, "The mode of the module.") + * val mode by setting("Mode", Modes.Freeze, { page == Page.Custom }, "The mode of the module.") * * init { * listener { @@ -74,7 +74,7 @@ import kotlin.reflect.KProperty * Advanced usage with listeners: * ```kotlin * // notice how this does not use the delegate (by) association, to access the setting object to register listeners. - * val mode = setting("Mode", Modes.FREEZE, { page == Page.CUSTOM }, "The mode of the module.") + * val mode = setting("Mode", Modes.Freeze, { page == Page.Custom }, "The mode of the module.") * * init { * mode.listener { from, to -> @@ -85,7 +85,7 @@ import kotlin.reflect.KProperty * } * * listener { - * LOG.info("Mode: ${mode.value}") // indirect access of the value + * Log.info("Mode: ${mode.value}") // indirect access of the value * } * } * ``` @@ -99,7 +99,8 @@ class Setting, R>( override val description: String, var core: T, val config: Config, - var visibility: () -> Boolean, + val layer: Config.SettingLayer.Single<*, *>, + var visibility: () -> Boolean ) : Nameable, Describable, Jsonable { val originalCore = core var disabled = { false } @@ -109,10 +110,6 @@ class Setting, R>( val isModified get() = value != core.defaultValue - init { - config.register(this) - } - operator fun getValue(thisRef: Any?, property: KProperty<*>) = core.value operator fun setValue(thisRef: Any?, property: KProperty<*>, value: R) { core.value = value @@ -139,7 +136,7 @@ class Setting, R>( runCatching { originalCore.loadFromJson(serialized) }.onFailure { - LOG.warn("Failed to load setting $name with value $serialized. Resetting to default value ${core.defaultValue}") + Log.warn("Failed to load setting $name with value $serialized. Resetting to default value ${core.defaultValue}") } } diff --git a/src/main/kotlin/com/lambda/config/SettingBlock.kt b/src/main/kotlin/com/lambda/config/SettingBlock.kt new file mode 100644 index 000000000..1766e23ba --- /dev/null +++ b/src/main/kotlin/com/lambda/config/SettingBlock.kt @@ -0,0 +1,22 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config + +interface SettingBlock { + val c: Config +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/SettingBlockWrapper.kt b/src/main/kotlin/com/lambda/config/SettingBlockWrapper.kt new file mode 100644 index 000000000..43ec194d0 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/SettingBlockWrapper.kt @@ -0,0 +1,29 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config + +import com.lambda.config.Config.BlockLayer +import kotlin.reflect.KProperty + +class SettingBlockWrapper( + val settingBlock: T, + val layer: BlockLayer +) { + operator fun getValue(thisRef: Any?, property: KProperty<*>) = settingBlock + operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {} +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt index 389b5fcd8..b3633746f 100644 --- a/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt @@ -21,13 +21,13 @@ import com.lambda.config.Config import com.lambda.config.ConfigCategory import com.lambda.config.Tab import com.lambda.config.categories.AutomationCategory -import com.lambda.config.groups.BreakSettings -import com.lambda.config.groups.BuildSettings -import com.lambda.config.groups.EatSettings -import com.lambda.config.groups.HotbarSettings -import com.lambda.config.groups.InteractSettings -import com.lambda.config.groups.InventorySettings -import com.lambda.config.groups.RotationSettings +import com.lambda.config.settings.blocks.BreakSettings +import com.lambda.config.settings.blocks.BuildSettings +import com.lambda.config.settings.blocks.EatSettings +import com.lambda.config.settings.blocks.HotbarSettings +import com.lambda.config.settings.blocks.InteractSettings +import com.lambda.config.settings.blocks.InventorySettings +import com.lambda.config.settings.blocks.RotationSettings import com.lambda.context.Automated import com.lambda.module.Module @@ -36,22 +36,22 @@ open class AutomationConfig( override val name: String, configCategory: ConfigCategory = AutomationCategory ) : Config(configCategory), Automated { - @Tab(BUILD_TAB) override val buildConfig = BuildSettings(this) - @Tab(BREAK_TAB) override val breakConfig = BreakSettings(this) - @Tab(INTERACT_TAB) override val interactConfig = InteractSettings(this) - @Tab(ROTATION_TAB) override val rotationConfig = RotationSettings(this) - @Tab(INVENTORY_TAB) override val inventoryConfig = InventorySettings(this) - @Tab(HOTBAR_TAB) override val hotbarConfig = HotbarSettings(this) - @Tab(EAT_TAB) override val eatConfig = EatSettings(this) + @Tab(BuildTab) override val buildConfig = BuildSettings(this) + @Tab(BreakTab) override val breakConfig = BreakSettings(this) + @Tab(InteractTab) override val interactConfig = InteractSettings(this) + @Tab(RotationTab) override val rotationConfig = RotationSettings(this) + @Tab(InventoryTab) override val inventoryConfig = InventorySettings(this) + @Tab(HotbarTab) override val hotbarConfig = HotbarSettings(this) + @Tab(EatTab) override val eatConfig = EatSettings(this) companion object { - private const val BUILD_TAB = "Build" - private const val BREAK_TAB = "Break" - private const val INTERACT_TAB = "Interact" - private const val ROTATION_TAB = "Rotation" - private const val INVENTORY_TAB = "Inventory" - private const val HOTBAR_TAB = "Hotbar" - private const val EAT_TAB = "Eat" + private const val BuildTab = "Build" + private const val BreakTab = "Break" + private const val InteractTab = "Interact" + private const val RotationTab = "Rotation" + private const val InventoryTab = "Inventory" + private const val HotbarTab = "Hotbar" + private const val EatTab = "Eat" context(module: Module) fun IMutableAutomationConfig.setDefaultAutomationConfig( diff --git a/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt index 2f878fa7d..aea0f1506 100644 --- a/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt @@ -17,15 +17,16 @@ package com.lambda.config.automation +import com.lambda.config.Config import com.lambda.config.Setting import com.lambda.config.SettingCore -import com.lambda.config.groups.BreakConfig -import com.lambda.config.groups.BuildConfig -import com.lambda.config.groups.EatConfig -import com.lambda.config.groups.HotbarConfig -import com.lambda.config.groups.InteractConfig -import com.lambda.config.groups.InventoryConfig -import com.lambda.config.groups.RotationConfig +import com.lambda.config.settings.blocks.BreakConfig +import com.lambda.config.settings.blocks.BuildConfig +import com.lambda.config.settings.blocks.EatConfig +import com.lambda.config.settings.blocks.HotbarConfig +import com.lambda.config.settings.blocks.InteractConfig +import com.lambda.config.settings.blocks.InventoryConfig +import com.lambda.config.settings.blocks.RotationConfig import com.lambda.context.Automated interface IMutableAutomationConfig : Automated { @@ -33,13 +34,13 @@ interface IMutableAutomationConfig : Automated { var backingAutomationConfig: AutomationConfig var automationConfig: AutomationConfig - override val buildConfig: BuildConfig get() = automationConfig.buildConfig - override val breakConfig: BreakConfig get() = automationConfig.breakConfig - override val interactConfig: InteractConfig get() = automationConfig.interactConfig - override val rotationConfig: RotationConfig get() = automationConfig.rotationConfig - override val inventoryConfig: InventoryConfig get() = automationConfig.inventoryConfig - override val hotbarConfig: HotbarConfig get() = automationConfig.hotbarConfig - override val eatConfig: EatConfig get() = automationConfig.eatConfig + override val buildConfig get() = automationConfig.buildConfig + override val breakConfig get() = automationConfig.breakConfig + override val interactConfig get() = automationConfig.interactConfig + override val rotationConfig get() = automationConfig.rotationConfig + override val inventoryConfig get() = automationConfig.inventoryConfig + override val hotbarConfig get() = automationConfig.hotbarConfig + override val eatConfig get() = automationConfig.eatConfig } class MutableAutomationConfig : IMutableAutomationConfig { @@ -53,17 +54,15 @@ class MutableAutomationConfig : IMutableAutomationConfig { set(value) { if (value === defaultAutomationConfig) { if (backingAutomationConfig !== defaultAutomationConfig) { - field.settingContainers.forEach(Setting<*, *>::restoreOriginalCore) + Config.forEachSetting(field) { it.restoreOriginalCore() } } field = value - } else field.settingContainers.forEach { setting -> - value.settingContainers.forEach { newSetting -> - if (setting.name == newSetting.name) { - if (setting.core.type != newSetting.core.type) - throw IllegalStateException("Settings with the same name do not have the same type.") - @Suppress("UNCHECKED_CAST") - (setting as Setting, Any>).core = newSetting.core as SettingCore - } + } else { + Config.forEachMatchingSetting(field.settingLayers, value.settingLayers) { setting, newSetting -> + if (setting.core.type != newSetting.core.type) + throw IllegalStateException("Settings with the same name do not have the same type.") + @Suppress("UNCHECKED_CAST") + (setting as Setting, Any>).core = newSetting.core as SettingCore } } backingAutomationConfig = value diff --git a/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt b/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt deleted file mode 100644 index fabf2fedd..000000000 --- a/src/main/kotlin/com/lambda/config/groups/BreakSettings.kt +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.groups - -import com.lambda.config.Config -import com.lambda.config.Config.Group -import com.lambda.config.applyEdits -import com.lambda.config.groups.BreakConfig.AnimationMode -import com.lambda.config.groups.BreakConfig.BreakConfirmationMode -import com.lambda.config.groups.BreakConfig.BreakMode -import com.lambda.config.groups.BreakConfig.SwingMode -import com.lambda.config.groups.BreakConfig.WhitelistMode -import com.lambda.event.events.TickEvent -import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import net.minecraft.registry.Registries -import java.awt.Color - -class BreakSettings(override val c: Config) : BreakConfig { - companion object { - const val GENERAL_GROUP = "General" - const val COSMETIC_GROUP = "Cosmetic" - } - - // General - @Group(GENERAL_GROUP) override val breakMode by c.setting("Break Mode", BreakMode.Packet) - @Group(GENERAL_GROUP) override val sorter by c.setting("Break Sorter", ActionConfig.SortMode.Tool, "The order in which breaks are performed") - @Group(GENERAL_GROUP) override val rebreak by c.setting("Rebreak", true, "Re-breaks blocks after they've been broken once") - // Double break - @Group(GENERAL_GROUP) override val doubleBreak by c.setting("Double Break", true, "Allows breaking two blocks at once") - @Group(GENERAL_GROUP) override val unsafeCancels by c.setting("Unsafe Cancels", true, "Allows cancelling block breaking even if the server might continue breaking sever side, potentially causing unexpected state changes") { doubleBreak } - // Fixes / Delays - @Group(GENERAL_GROUP) override val breakThreshold by c.setting("Break Threshold", 0.70f, 0.1f..1.0f, 0.01f, "The break amount at which the block is considered broken") - @Group(GENERAL_GROUP) override val fudgeFactor by c.setting("Fudge Factor", 1, 0..5, 1, "The number of ticks to add to the break time, usually to account for server lag") - @Group(GENERAL_GROUP) override val serverSwapTicks by c.setting("Server Swap", 0, 0..5, 1, "The number of ticks to give the server time to recognize the player attributes on the swapped item", " tick(s)") -// @Group(GENERAL_GROUP) override val desyncFix by c.setting("Desync Fix", false, "Predicts if the players breaking will be slowed next tick as block break packets are processed using the players next position") { page == Page.General } - @Group(GENERAL_GROUP) override val breakDelay by c.setting("Break Delay", 0, 0..6, 1, "The delay between breaking blocks", " tick(s)") - // Timing - @Group(GENERAL_GROUP) override val tickStageMask by c.setting("Break Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), "The sub-tick timing at which break actions can be performed", displayClassName = true) - @Group(GENERAL_GROUP) override val swapMode by c.setting("Break Swap Mode", BreakConfig.SwapMode.End, "Decides when to swap to the best suited tool when breaking a block") - @Group(GENERAL_GROUP) override val swing by c.setting("Swing Mode", SwingMode.Constant, "The times at which to swing the players hand") - @Group(GENERAL_GROUP) override val swingType by c.setting("Break Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { swing != SwingMode.None } - // Rotate - @Group(GENERAL_GROUP) override val rotate by c.setting("Rotate For Break", false, "Rotate towards block while breaking") - // Pending / Post - @Group(GENERAL_GROUP) override val breakConfirmation by c.setting("Break Confirmation", BreakConfirmationMode.BreakThenAwait, "The style of confirmation used when breaking") - @Group(GENERAL_GROUP) override val breaksPerTick by c.setting("Breaks Per Tick", 30, 1..30, 1, "Maximum instant block breaks per tick") - @Group(GENERAL_GROUP) override val whitelistMode by c.setting("Whitelist Mode", WhitelistMode.None, "The type of block selection used") - @Group(GENERAL_GROUP) override val whitelist by c.setting("Whitelist", mutableSetOf(), Registries.BLOCK.toSet(), "Only these selected blocks are allowed to be broken") { whitelistMode == WhitelistMode.Whitelist } - @Group(GENERAL_GROUP) override val blacklist by c.setting("Blacklist", mutableSetOf(), Registries.BLOCK.toSet(), "These selected blocks are not allowed to be broken") { whitelistMode == WhitelistMode.Blacklist } - @Group(GENERAL_GROUP) override val avoidFluids by c.setting("Avoid Fluids", true, "Avoids breaking blocks that would cause fluids to spill") - @Group(GENERAL_GROUP) override val avoidSupporting by c.setting("Avoid Supporting", true, "Avoids breaking the block supporting the player") - @Group(GENERAL_GROUP) override val fillFluids by c.setting("Fill Fluids", true, "Fills fluids in order to break blocks that would initially spill them") { avoidFluids } - // Tool - @Group(GENERAL_GROUP) override val efficientOnly by c.setting("Efficient Tools Only", true, "Only use tools suitable for the given block (will get the item drop)") { swapMode.isEnabled() } - @Group(GENERAL_GROUP) override val suitableToolsOnly by c.setting("Suitable Tools Only", true, "Only use tools suitable for the given block (will get the item drop)") { swapMode.isEnabled() } - @Group(GENERAL_GROUP) override val forceSilkTouch by c.setting("Force Silk Touch", false, "Force silk touch when breaking blocks") { swapMode.isEnabled() } - @Group(GENERAL_GROUP) override val forceFortunePickaxe by c.setting("Force Fortune Pickaxe", false, "Force fortune pickaxe when breaking blocks") { swapMode.isEnabled() } - @Group(GENERAL_GROUP) override val minFortuneLevel by c.setting("Min Fortune Level", 1, 1..3, 1, "The minimum fortune level to use") { swapMode.isEnabled() && forceFortunePickaxe } - - // Cosmetics - @Group(COSMETIC_GROUP) override val sounds by c.setting("Break Sounds", true, "Plays the breaking sounds") - @Group(COSMETIC_GROUP) override val particles by c.setting("Particles", true, "Renders the breaking particles") - @Group(COSMETIC_GROUP) override val breakingTexture by c.setting("Breaking Overlay", true, "Overlays the breaking texture at its different stages") - // Modes - @Group(COSMETIC_GROUP) override val renders by c.setting("Renders", true, "Enables the render settings for breaking progress") - @Group(COSMETIC_GROUP) override val animation by c.setting("Animation", AnimationMode.Out, "The style of animation used for the box") { renders } - // Fill - @Group(COSMETIC_GROUP) override val fill by c.setting("Fill", true, "Renders the sides of the box to display break progress") { renders } - @Group(COSMETIC_GROUP) override val dynamicFillColor by c.setting("Dynamic Colour", true, "Enables fill color interpolation from start to finish for fill when breaking a block") { renders && fill } - @Group(COSMETIC_GROUP) override val staticFillColor by c.setting("Fill Color", Color(255, 0, 0, 60), "The color of the fill") { renders && !dynamicFillColor && fill } - @Group(COSMETIC_GROUP) override val startFillColor by c.setting("Start Fill Color", Color(255, 0, 0, 60), "The color of the fill at the start of breaking") { renders && dynamicFillColor && fill } - @Group(COSMETIC_GROUP) override val endFillColor by c.setting("End Fill Color", Color(0, 255, 0, 60), "The color of the fill at the end of breaking") { renders && dynamicFillColor && fill } - // Outline - @Group(COSMETIC_GROUP) override val outline by c.setting("Outline", true, "Renders the lines of the box to display break progress") { renders } - @Group(COSMETIC_GROUP) override val outlineConfig = - c.settingBlock(WorldLineSettings(c)) { - c.applyEdits { - hide(::startColor, ::endColor) - } - } - @Group(COSMETIC_GROUP) override val dynamicOutlineColor by c.setting("Dynamic Outline Color", true, "Enables color interpolation from start to finish for the outline when breaking a block") { renders && outline } - @Group(COSMETIC_GROUP) override val staticOutlineColor by c.setting("Outline Color", Color.RED, "The Color of the outline at the start of breaking") { renders && !dynamicOutlineColor && outline } - @Group(COSMETIC_GROUP) override val startOutlineColor by c.setting("Start Outline Color", Color.RED, "The color of the outline at the start of breaking") { renders && dynamicOutlineColor && outline } - @Group(COSMETIC_GROUP) override val endOutlineColor by c.setting("End Outline Color", Color.GREEN, "The color of the outline at the end of breaking") { renders && dynamicOutlineColor && outline } -} diff --git a/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt b/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt deleted file mode 100644 index cc96d3f0a..000000000 --- a/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.groups - -import com.lambda.config.Config -import com.lambda.config.Config.Group -import com.lambda.config.groups.BuildConfig.PointSelection -import kotlin.math.max - -class BuildSettings(override val c: Config) : BuildConfig { - companion object { - private const val GROUP_GENERAL = "General" - private const val GROUP_PACKET_LIMITS = "Packet Limits" - private const val GROUP_REACH = "Reach" - private const val GROUP_SCAN = "Scan" - } - - @Group(GROUP_GENERAL) override val breakBlocks by c.setting("Break", true, "Break blocks") - @Group(GROUP_GENERAL) override val placeBlocks by c.setting("Place", true, "Place blocks") - @Group(GROUP_GENERAL) override val interactBlocks by c.setting("Interact", true, "Interact blocks") - - @Group(GROUP_GENERAL) override val pathing by c.setting("Pathing", false, "Path to blocks") - @Group(GROUP_GENERAL) override val stayInRange by c.setting("Stay In Range", false, "Stay in range of blocks") - @Group(GROUP_GENERAL) override val collectDrops by c.setting("Collect All Drops", false, "Collect all drops when breaking blocks") - @Group(GROUP_GENERAL) override val spleefEntities by c.setting("Spleef Entities", false, "Breaks blocks beneath entities blocking placements to get them out of the way") - @Group(GROUP_GENERAL) override val maxPendingActions by c.setting("Max Pending Actions", 15, 1..30, 1, "The maximum count of pending interactions to allow before pausing future interactions") - @Group(GROUP_GENERAL) override val actionTimeout by c.setting("Action Timeout", 10, 1..30, 1, "Timeout for block breaks in ticks", unit = " ticks") - @Group(GROUP_GENERAL) override val maxBuildDependencies by c.setting("Max Sim Dependencies", 3, 0..10, 1, "Maximum dependency build results") - - @Group(GROUP_PACKET_LIMITS) override val limitTimeframe by c.setting("Limit Timeframe", 310, 50..1500, 1, "The timeframe in which the limit is bound to", "ms") - @Group(GROUP_PACKET_LIMITS) override val actionLimit by c.setting("Action Limit", 59, 1..100, 1, "The maximum allowed action packets to be sent to the server per given timeframe") - @Group(GROUP_PACKET_LIMITS) override val interactionLimit by c.setting("Interaction Limit", 9, 1..20, 1, "The maximum allowed interaction packets to be sent to the server per given timeframe") - @Group(GROUP_PACKET_LIMITS) override val inventoryLimit by c.setting("Inventory Limit", 5, 1..100, 1, "The maximum allowed inventory packets to be sent to the server per given timeframe") - - @Group(GROUP_REACH) override var blockReach by c.setting("Interact Reach", 4.5, 1.0..7.0, 0.01, "Maximum block interaction distance") - @Group(GROUP_REACH) override var entityReach by c.setting("Attack Reach", 3.0, 1.0..7.0, 0.01, "Maximum entity interaction distance") - override val scanReach: Double get() = max(entityReach, blockReach) - - @Group(GROUP_SCAN) override val checkSideVisibility by c.setting("Visibility Check", false, "Whether to check if an AABB side is visible") - @Group(GROUP_SCAN) override val strictRayCast by c.setting("Strict Raycast", false, "Whether to include the environment to the ray cast context") - @Group(GROUP_SCAN) override val resolution by c.setting("Resolution", 5, 1..20, 1, "The amount of grid divisions per surface of the hit box", "") { strictRayCast } - @Group(GROUP_SCAN) override val pointSelection by c.setting("Point Selection", PointSelection.Optimum, "The strategy to select the best hit point") -} diff --git a/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt b/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt deleted file mode 100644 index b5116c605..000000000 --- a/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.groups - -import com.lambda.config.Config -import com.lambda.config.Config.Group -import com.lambda.config.SettingBlock -import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -import com.lambda.util.item.ItemUtils - -class InventorySettings(override val c: Config) : SettingBlock, InventoryConfig { - companion object { - private const val GROUP_GENERAL = "General" - private const val GROUP_CONTAINER = "Container" - private const val GROUP_ACCESS = "Access" - } - - @Group(GROUP_GENERAL) override val tickStageMask by c.setting("Inventory Stage Mask", ALL_STAGES.toSet(), description = "The sub-tick timing at which inventory actions are performed", displayClassName = true) - @Group(GROUP_CONTAINER) override val disposables by c.setting("Disposables", ItemUtils.defaultDisposables, description = "Items that will be ignored when checking for a free slot") - @Group(GROUP_CONTAINER) override val swapWithDisposables by c.setting("Swap With Disposables", true, "Swap items with disposable ones") - @Group(GROUP_CONTAINER) override val providerPriority by c.setting("Provider Priority", InventoryConfig.Priority.WithMinItems, "What container to prefer when retrieving the item from") - @Group(GROUP_CONTAINER) override val storePriority by c.setting("Store Priority", InventoryConfig.Priority.WithMinItems, "What container to prefer when storing the item to") - - @Group(GROUP_ACCESS) override val accessShulkerBoxes by c.setting("Access Shulker Boxes", false, "Allow access to the player's shulker boxes") - @Group(GROUP_ACCESS) override val accessChests by c.setting("Access Chests", false, "Allow access to the player's normal chests") - @Group(GROUP_ACCESS) override val accessEnderChest by c.setting("Access Ender Chest", false, "Allow access to the player's ender chest") - @Group(GROUP_ACCESS) override val accessStashes by c.setting("Access Stashes", false, "Allow access to the player's stashes") -} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt b/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt deleted file mode 100644 index 6697de6fd..000000000 --- a/src/main/kotlin/com/lambda/config/groups/ScreenLineSettings.kt +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.groups - -import com.lambda.config.Config -import com.lambda.config.Config.Group -import com.lambda.config.Group -import com.lambda.config.SettingBlock -import java.awt.Color - -class ScreenLineSettings(override val c: Config) : SettingBlock, LineConfig { - companion object { - private const val GROUP_COLOR = "Color" - private const val GROUP_DASH = "Dash" - } - - val widthSetting by c.setting("Width", 20, 1..100, 1, "The width of the line") - override val width get() = widthSetting * 0.00005f - - @Group(GROUP_COLOR) override val startColor by c.setting("Start Color", Color.WHITE, "The color at the start of the line") - @Group(GROUP_COLOR) override val endColor by c.setting("End Color", Color.WHITE, "The color at the end of the line") - - @Group(GROUP_DASH) override val dashEnabled by c.setting("Dashed", false, "Enable dashed line pattern") - @Group(GROUP_DASH) val dashLengthSetting by c.setting("Dash Length", 30, 1..50, 1, "Length of each dash") { dashEnabled } - override val dashLength get() = dashLengthSetting * 0.001f - @Group(GROUP_DASH) val gapLengthSetting by c.setting("Gap Length", 15, 1..50, 1, "Length of gaps between dashes") { dashEnabled } - override val gapLength get() = gapLengthSetting * 0.001f - @Group(GROUP_DASH) override val animated by c.setting("Animated", true, "Animate the dash pattern") { dashEnabled } - @Group(GROUP_DASH) val dashOffsetSetting by c.setting("Dash Offset", 0, 0..100, 1, "Offset of the dash pattern") { dashEnabled && !animated } - override val dashOffset get() = dashOffsetSetting * 0.01f - @Group(GROUP_DASH) val animationSpeedSetting by c.setting("Animation Speed", 30, -100..100, 1, "Speed of dash animation (negative = reverse)") { dashEnabled && animated } - override val animationSpeed get() = animationSpeedSetting * 0.1f -} diff --git a/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt b/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt deleted file mode 100644 index 402520d40..000000000 --- a/src/main/kotlin/com/lambda/config/groups/ScreenTextSettings.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.groups - -import com.lambda.config.Config -import com.lambda.config.Group -import com.lambda.config.SettingBlock -import java.awt.Color - -class ScreenTextSettings(override val c: Config) : SettingBlock, TextConfig { - companion object { - private const val GROUP_OUTLINE = "Outline" - private const val GROUP_GLOW = "Glow" - private const val GROUP_SHADOW = "Shadow" - } - - override val textColor by c.setting("Text Color", Color.WHITE, "The main text color") - val sizeSetting by c.setting("Text Size", 18, 1..50, 1) - override val size get() = sizeSetting * 0.001f - - @Group(GROUP_OUTLINE) override val outlineEnabled by c.setting("Outline", false, "Enable text outline") - @Group(GROUP_OUTLINE) override val outlineColor by c.setting("Outline Color", Color.BLACK, "Color of the outline") { outlineEnabled } - @Group(GROUP_OUTLINE) override val outlineWidth by c.setting("Outline Width", 0.1f, 0f..0.4f, 0.005f, "Width of the outline") { outlineEnabled } - - @Group(GROUP_GLOW) override val glowEnabled by c.setting("Glow", false, "Enable text glow effect") - @Group(GROUP_GLOW) override val glowColor by c.setting("Glow Color", Color.WHITE, "Color of the glow") { glowEnabled } - @Group(GROUP_GLOW) override val glowRadius by c.setting("Glow Radius", 0.2f, 0f..0.5f, 0.01f, "Radius of the glow effect") { glowEnabled } - - @Group(GROUP_SHADOW) override val shadowEnabled by c.setting("Shadow", true, "Enable text shadow") - @Group(GROUP_SHADOW) override val shadowColor by c.setting("Shadow Color", Color(0, 0, 0, 180), "Color of the shadow") { shadowEnabled } - @Group(GROUP_SHADOW) override val shadowOffset by c.setting("Shadow Offset", 0.05f, 0f..0.5f, 0.005f, "Distance of shadow from text") { shadowEnabled } - @Group(GROUP_SHADOW) override val shadowAngle by c.setting("Shadow Angle", 135f, 0f..360f, 1f, "Angle of the shadow") { shadowEnabled } - @Group(GROUP_SHADOW) override val shadowSoftness by c.setting("Shadow Softness", 0f, 0f..0.5f, 0.01f, "Softness of shadow edges") { shadowEnabled } -} diff --git a/src/main/kotlin/com/lambda/config/groups/WorldTextSettings.kt b/src/main/kotlin/com/lambda/config/groups/WorldTextSettings.kt deleted file mode 100644 index ab99e4be5..000000000 --- a/src/main/kotlin/com/lambda/config/groups/WorldTextSettings.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.groups - -import com.lambda.config.Config -import com.lambda.config.Config.Group -import com.lambda.config.SettingBlock -import java.awt.Color - -class WorldTextSettings(override val c: Config) : SettingBlock, TextConfig { - companion object { - private const val GROUP_GENERAL = "General" - private const val GROUP_OUTLINE = "Outline" - private const val GROUP_GLOW = "Glow" - private const val GROUP_SHADOW = "Shadow" - } - - @Group(GROUP_GENERAL) override val textColor by c.setting("Text Color", Color.WHITE, "The main text color") - @Group(GROUP_GENERAL) val sizeSetting by c.setting("Text Size", 5, 1..50, 1) - override val size get() = sizeSetting * 0.1f - - @Group(GROUP_OUTLINE) override val outlineEnabled by c.setting("Outline", false, "Enable text outline") - @Group(GROUP_OUTLINE) override val outlineColor by c.setting("Outline Color", Color.BLACK, "Color of the outline") { outlineEnabled } - @Group(GROUP_OUTLINE) override val outlineWidth by c.setting("Outline Width", 0.1f, 0f..0.4f, 0.005f, "Width of the outline") { outlineEnabled } - - @Group(GROUP_GLOW) override val glowEnabled by c.setting("Glow", false, "Enable text glow effect") - @Group(GROUP_GLOW) override val glowColor by c.setting("Glow Color", Color.WHITE, "Color of the glow") { glowEnabled } - @Group(GROUP_GLOW) override val glowRadius by c.setting("Glow Radius", 0.2f, 0f..0.5f, 0.01f, "Radius of the glow effect") { glowEnabled } - - @Group(GROUP_SHADOW) override val shadowEnabled by c.setting("Shadow", true, "Enable text shadow") - @Group(GROUP_SHADOW) override val shadowColor by c.setting("Shadow Color", Color(0, 0, 0, 180), "Color of the shadow") { shadowEnabled } - @Group(GROUP_SHADOW) override val shadowOffset by c.setting("Shadow Offset", 0.05f, 0f..0.5f, 0.005f, "Distance of shadow from text") { shadowEnabled } - @Group(GROUP_SHADOW) override val shadowAngle by c.setting("Shadow Angle", 135f, 0f..360f, 1f, "Angle of the shadow") { shadowEnabled } - @Group(GROUP_SHADOW) override val shadowSoftness by c.setting("Shadow Softness", 0f, 0f..0.5f, 0.01f, "Softness of shadow edges") { shadowEnabled } -} diff --git a/src/main/kotlin/com/lambda/config/migration/Migrations.kt b/src/main/kotlin/com/lambda/config/migration/Migrations.kt index db3903eae..2eb15a950 100644 --- a/src/main/kotlin/com/lambda/config/migration/Migrations.kt +++ b/src/main/kotlin/com/lambda/config/migration/Migrations.kt @@ -20,7 +20,7 @@ package com.lambda.config.migration import com.google.gson.JsonArray import com.google.gson.JsonElement import com.google.gson.JsonObject -import com.lambda.Lambda.LOG +import com.lambda.Lambda.Log import com.lambda.core.Loadable import com.lambda.util.ReflectionUtils.getInstances import java.util.* @@ -29,7 +29,7 @@ import kotlin.math.max interface ConfigMigration { val configName: String val latestVersion: Int - val schemaVersionKey: String get() = ConfigMigrations.DEFAULT_SCHEMA_VERSION_KEY + val schemaVersionKey: String get() = ConfigMigrations.DefaultSchemaVersionKey fun applyStep(fromVersion: Int, root: JsonObject): StepResult? } @@ -59,7 +59,7 @@ abstract class StepConfigMigration : ConfigMigration { } object ConfigMigrations : Loadable { - const val DEFAULT_SCHEMA_VERSION_KEY = "_schemaVersion" + const val DefaultSchemaVersionKey = "_schemaVersion" override val priority: Int = 2 @Volatile @@ -93,7 +93,7 @@ object ConfigMigrations : Loadable { var migrated = false if (currentVersion > migration.latestVersion) { - LOG.warn( + Log.warn( "Config ${configName.replaceFirstChar { it.uppercase() }} has schema version $currentVersion " + "which is newer than supported ${migration.latestVersion}" ) @@ -105,7 +105,7 @@ object ConfigMigrations : Loadable { val fromVersion = currentVersion val stepResult = migration.applyStep(fromVersion, json) if (stepResult == null) { - LOG.warn( + Log.warn( "Missing migration step for ${configName.replaceFirstChar { it.uppercase() }} " + "schema version $fromVersion -> ?. Expected latest schema version is ${migration.latestVersion}" ) @@ -119,7 +119,7 @@ object ConfigMigrations : Loadable { migrated = true } } catch (t: Throwable) { - LOG.error( + Log.error( "Failed to migrate ${configName.replaceFirstChar { it.uppercase() }} config " + "from v$currentVersion to next version", t @@ -149,7 +149,7 @@ object ConfigMigrations : Loadable { val duplicates = discovered.groupBy { it.configName }.filter { it.value.size > 1 } if (duplicates.isNotEmpty()) { duplicates.keys.forEach { key -> - LOG.warn("Multiple config migrations found for '$key'. Using the last discovered migration.") + Log.warn("Multiple config migrations found for '$key'. Using the last discovered migration.") } } diff --git a/src/main/kotlin/com/lambda/config/migration/migrations/AutomationConfigMigration.kt b/src/main/kotlin/com/lambda/config/migration/migrations/AutomationConfigMigration.kt index da8d459f4..3c2a458b8 100644 --- a/src/main/kotlin/com/lambda/config/migration/migrations/AutomationConfigMigration.kt +++ b/src/main/kotlin/com/lambda/config/migration/migrations/AutomationConfigMigration.kt @@ -17,7 +17,7 @@ package com.lambda.config.migration.migrations -import com.lambda.Lambda.LOG +import com.lambda.Lambda.Log import com.lambda.config.migration.StepConfigMigration @Suppress("unused") @@ -39,7 +39,7 @@ object AutomationConfigMigration : StepConfigMigration() { } } - LOG.info("Migrated Automation config schema v1 -> v2: $updateCount settings updated") + Log.info("Migrated Automation config schema v1 -> v2: $updateCount settings updated") } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/migration/migrations/FriendConfigMigration.kt b/src/main/kotlin/com/lambda/config/migration/migrations/FriendConfigMigration.kt index 2f7f0a1be..8a32f01d9 100644 --- a/src/main/kotlin/com/lambda/config/migration/migrations/FriendConfigMigration.kt +++ b/src/main/kotlin/com/lambda/config/migration/migrations/FriendConfigMigration.kt @@ -18,7 +18,7 @@ package com.lambda.config.migration.migrations import com.google.gson.JsonArray -import com.lambda.Lambda.LOG +import com.lambda.Lambda.Log import com.lambda.config.migration.StepConfigMigration import com.lambda.config.migration.arrayOrCreate import com.lambda.config.migration.objectOrCreate @@ -47,7 +47,7 @@ object FriendConfigMigration : StepConfigMigration() { } config.add("friends", migrated) - LOG.info("Migrated Friend config schema v1 -> v2: ${migrated.size()} entries converted, $dropped entries dropped") + Log.info("Migrated Friend config schema v1 -> v2: ${migrated.size()} entries converted, $dropped entries dropped") } } } diff --git a/src/main/kotlin/com/lambda/config/settings/CharSetting.kt b/src/main/kotlin/com/lambda/config/settings/CharSetting.kt index c713570f8..712616fda 100644 --- a/src/main/kotlin/com/lambda/config/settings/CharSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/CharSetting.kt @@ -37,7 +37,7 @@ class CharSetting(defaultValue: Char) : SettingCore( defaultValue, TypeToken.get(Char::class.java).type ) { - context(setting: Setting<*, Char>) + context(_: Setting<*, Char>) override fun ImGuiBuilder.buildLayout() {} context(setting: Setting<*, Char>) diff --git a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt index 24215b06e..b095cb288 100644 --- a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt @@ -55,7 +55,7 @@ abstract class NumericSetting( /** * Subclasses must implement this to provide their specific slider widget. */ - context(setting: Setting<*, T>) + context(_: Setting<*, T>) protected abstract fun ImGuiBuilder.buildSlider() context(setting: Setting<*, T>) diff --git a/src/main/kotlin/com/lambda/config/groups/ActionConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/ActionConfig.kt similarity index 92% rename from src/main/kotlin/com/lambda/config/groups/ActionConfig.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/ActionConfig.kt index d30de5b5b..f1ff60dd3 100644 --- a/src/main/kotlin/com/lambda/config/groups/ActionConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/ActionConfig.kt @@ -15,14 +15,13 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks -import com.lambda.config.SettingBlock import com.lambda.event.events.TickEvent import com.lambda.util.Describable import com.lambda.util.NamedEnum -interface ActionConfig : SettingBlock { +interface ActionConfig { val sorter: SortMode val tickStageMask: Collection diff --git a/src/main/kotlin/com/lambda/config/groups/BreakConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/BreakConfig.kt similarity index 99% rename from src/main/kotlin/com/lambda/config/groups/BreakConfig.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/BreakConfig.kt index b62543d71..6c4d44764 100644 --- a/src/main/kotlin/com/lambda/config/groups/BreakConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/BreakConfig.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.util.Describable import com.lambda.util.NamedEnum diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt new file mode 100644 index 000000000..2ce651ab3 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt @@ -0,0 +1,99 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.settings.blocks + +import com.lambda.config.Config +import com.lambda.config.Group +import com.lambda.config.SettingBlock +import com.lambda.config.applyEdits +import com.lambda.config.settings.blocks.BreakConfig.AnimationMode +import com.lambda.config.settings.blocks.BreakConfig.BreakConfirmationMode +import com.lambda.config.settings.blocks.BreakConfig.BreakMode +import com.lambda.config.settings.blocks.BreakConfig.SwingMode +import com.lambda.config.settings.blocks.BreakConfig.WhitelistMode +import com.lambda.event.events.TickEvent +import com.lambda.event.events.TickEvent.Companion.ALL_STAGES +import net.minecraft.registry.Registries +import java.awt.Color + +class BreakSettings(override val c: Config) : BreakConfig, SettingBlock { + companion object { + const val GeneralGroup = "General" + const val CosmeticGroup = "Cosmetic" + } + + // General + @Group(GeneralGroup) override val breakMode by c.setting("Break Mode", BreakMode.Packet) + @Group(GeneralGroup) override val sorter by c.setting("Break Sorter", _root_ide_package_.com.lambda.config.settings.blocks.ActionConfig.SortMode.Tool, "The order in which breaks are performed") + @Group(GeneralGroup) override val rebreak by c.setting("Rebreak", true, "Re-breaks blocks after they've been broken once") + // Double break + @Group(GeneralGroup) override val doubleBreak by c.setting("Double Break", true, "Allows breaking two blocks at once") + @Group(GeneralGroup) override val unsafeCancels by c.setting("Unsafe Cancels", true, "Allows cancelling block breaking even if the server might continue breaking sever side, potentially causing unexpected state changes") { doubleBreak } + // Fixes / Delays + @Group(GeneralGroup) override val breakThreshold by c.setting("Break Threshold", 0.70f, 0.1f..1.0f, 0.01f, "The break amount at which the block is considered broken") + @Group(GeneralGroup) override val fudgeFactor by c.setting("Fudge Factor", 1, 0..5, 1, "The number of ticks to add to the break time, usually to account for server lag") + @Group(GeneralGroup) override val serverSwapTicks by c.setting("Server Swap", 0, 0..5, 1, "The number of ticks to give the server time to recognize the player attributes on the swapped item", " tick(s)") +// @Group(GeneralGroup) override val desyncFix by c.setting("Desync Fix", false, "Predicts if the players breaking will be slowed next tick as block break packets are processed using the players next position") { page == Page.General } + @Group(GeneralGroup) override val breakDelay by c.setting("Break Delay", 0, 0..6, 1, "The delay between breaking blocks", " tick(s)") + // Timing + @Group(GeneralGroup) override val tickStageMask by c.setting("Break Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), "The sub-tick timing at which break actions can be performed", displayClassName = true) + @Group(GeneralGroup) override val swapMode by c.setting("Break Swap Mode", _root_ide_package_.com.lambda.config.settings.blocks.BreakConfig.SwapMode.End, "Decides when to swap to the best suited tool when breaking a block") + @Group(GeneralGroup) override val swing by c.setting("Swing Mode", SwingMode.Constant, "The times at which to swing the players hand") + @Group(GeneralGroup) override val swingType by c.setting("Break Swing Type", _root_ide_package_.com.lambda.config.settings.blocks.BuildConfig.SwingType.Vanilla, "The style of swing") { swing != SwingMode.None } + // Rotate + @Group(GeneralGroup) override val rotate by c.setting("Rotate For Break", false, "Rotate towards block while breaking") + // Pending / Post + @Group(GeneralGroup) override val breakConfirmation by c.setting("Break Confirmation", BreakConfirmationMode.BreakThenAwait, "The style of confirmation used when breaking") + @Group(GeneralGroup) override val breaksPerTick by c.setting("Breaks Per Tick", 30, 1..30, 1, "Maximum instant block breaks per tick") + @Group(GeneralGroup) override val whitelistMode by c.setting("Whitelist Mode", WhitelistMode.None, "The type of block selection used") + @Group(GeneralGroup) override val whitelist by c.setting("Whitelist", mutableSetOf(), Registries.BLOCK.toSet(), "Only these selected blocks are allowed to be broken") { whitelistMode == WhitelistMode.Whitelist } + @Group(GeneralGroup) override val blacklist by c.setting("Blacklist", mutableSetOf(), Registries.BLOCK.toSet(), "These selected blocks are not allowed to be broken") { whitelistMode == WhitelistMode.Blacklist } + @Group(GeneralGroup) override val avoidFluids by c.setting("Avoid Fluids", true, "Avoids breaking blocks that would cause fluids to spill") + @Group(GeneralGroup) override val avoidSupporting by c.setting("Avoid Supporting", true, "Avoids breaking the block supporting the player") + @Group(GeneralGroup) override val fillFluids by c.setting("Fill Fluids", true, "Fills fluids in order to break blocks that would initially spill them") { avoidFluids } + // Tool + @Group(GeneralGroup) override val efficientOnly by c.setting("Efficient Tools Only", true, "Only use tools suitable for the given block (will get the item drop)") { swapMode.isEnabled() } + @Group(GeneralGroup) override val suitableToolsOnly by c.setting("Suitable Tools Only", true, "Only use tools suitable for the given block (will get the item drop)") { swapMode.isEnabled() } + @Group(GeneralGroup) override val forceSilkTouch by c.setting("Force Silk Touch", false, "Force silk touch when breaking blocks") { swapMode.isEnabled() } + @Group(GeneralGroup) override val forceFortunePickaxe by c.setting("Force Fortune Pickaxe", false, "Force fortune pickaxe when breaking blocks") { swapMode.isEnabled() } + @Group(GeneralGroup) override val minFortuneLevel by c.setting("Min Fortune Level", 1, 1..3, 1, "The minimum fortune level to use") { swapMode.isEnabled() && forceFortunePickaxe } + + // Cosmetics + @Group(CosmeticGroup) override val sounds by c.setting("Break Sounds", true, "Plays the breaking sounds") + @Group(CosmeticGroup) override val particles by c.setting("Particles", true, "Renders the breaking particles") + @Group(CosmeticGroup) override val breakingTexture by c.setting("Breaking Overlay", true, "Overlays the breaking texture at its different stages") + // Modes + @Group(CosmeticGroup) override val renders by c.setting("Renders", true, "Enables the render settings for breaking progress") + @Group(CosmeticGroup) override val animation by c.setting("Animation", AnimationMode.Out, "The style of animation used for the box") { renders } + // Fill + @Group(CosmeticGroup) override val fill by c.setting("Fill", true, "Renders the sides of the box to display break progress") { renders } + @Group(CosmeticGroup) override val dynamicFillColor by c.setting("Dynamic Colour", true, "Enables fill color interpolation from start to finish for fill when breaking a block") { renders && fill } + @Group(CosmeticGroup) override val staticFillColor by c.setting("Fill Color", Color(255, 0, 0, 60), "The color of the fill") { renders && !dynamicFillColor && fill } + @Group(CosmeticGroup) override val startFillColor by c.setting("Start Fill Color", Color(255, 0, 0, 60), "The color of the fill at the start of breaking") { renders && dynamicFillColor && fill } + @Group(CosmeticGroup) override val endFillColor by c.setting("End Fill Color", Color(0, 255, 0, 60), "The color of the fill at the end of breaking") { renders && dynamicFillColor && fill } + // Outline + @Group(CosmeticGroup) override val outline by c.setting("Outline", true, "Renders the lines of the box to display break progress") { renders } + @Group(CosmeticGroup) override val outlineConfig by + c.settingBlock(WorldLineSettings(c)) { + c.applyEdits { hide(::startColor, ::endColor) } + } + @Group(CosmeticGroup) override val dynamicOutlineColor by c.setting("Dynamic Outline Color", true, "Enables color interpolation from start to finish for the outline when breaking a block") { renders && outline } + @Group(CosmeticGroup) override val staticOutlineColor by c.setting("Outline Color", Color.RED, "The Color of the outline at the start of breaking") { renders && !dynamicOutlineColor && outline } + @Group(CosmeticGroup) override val startOutlineColor by c.setting("Start Outline Color", Color.RED, "The color of the outline at the start of breaking") { renders && dynamicOutlineColor && outline } + @Group(CosmeticGroup) override val endOutlineColor by c.setting("End Outline Color", Color.GREEN, "The color of the outline at the end of breaking") { renders && dynamicOutlineColor && outline } +} diff --git a/src/main/kotlin/com/lambda/config/groups/BuildConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/BuildConfig.kt similarity index 97% rename from src/main/kotlin/com/lambda/config/groups/BuildConfig.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/BuildConfig.kt index 20f339fa7..73b7a81fd 100644 --- a/src/main/kotlin/com/lambda/config/groups/BuildConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/BuildConfig.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.SettingBlock import com.lambda.interaction.managers.rotating.Rotation.Companion.dist @@ -26,7 +26,7 @@ import com.lambda.util.math.distSq import com.lambda.util.math.times import com.lambda.util.player.CheckedHit -interface BuildConfig : SettingBlock { +interface BuildConfig { val breakBlocks: Boolean val placeBlocks: Boolean val interactBlocks: Boolean diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/BuildSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/BuildSettings.kt new file mode 100644 index 000000000..b84fb0362 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/settings/blocks/BuildSettings.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.settings.blocks + +import com.lambda.config.Config +import com.lambda.config.Group +import com.lambda.config.SettingBlock +import kotlin.math.max + +class BuildSettings(override val c: Config) : BuildConfig, SettingBlock { + companion object { + private const val GeneralGroup = "General" + private const val PacketLimitsGroup = "Packet Limits" + private const val ReachGroup = "Reach" + private const val ScanGroup = "Scan" + } + + @Group(GeneralGroup) override val breakBlocks by c.setting("Break", true, "Break blocks") + @Group(GeneralGroup) override val placeBlocks by c.setting("Place", true, "Place blocks") + @Group(GeneralGroup) override val interactBlocks by c.setting("Interact", true, "Interact blocks") + + @Group(GeneralGroup) override val pathing by c.setting("Pathing", false, "Path to blocks") + @Group(GeneralGroup) override val stayInRange by c.setting("Stay In Range", false, "Stay in range of blocks") + @Group(GeneralGroup) override val collectDrops by c.setting("Collect All Drops", false, "Collect all drops when breaking blocks") + @Group(GeneralGroup) override val spleefEntities by c.setting("Spleef Entities", false, "Breaks blocks beneath entities blocking placements to get them out of the way") + @Group(GeneralGroup) override val maxPendingActions by c.setting("Max Pending Actions", 15, 1..30, 1, "The maximum count of pending interactions to allow before pausing future interactions") + @Group(GeneralGroup) override val actionTimeout by c.setting("Action Timeout", 10, 1..30, 1, "Timeout for block breaks in ticks", unit = " ticks") + @Group(GeneralGroup) override val maxBuildDependencies by c.setting("Max Sim Dependencies", 3, 0..10, 1, "Maximum dependency build results") + + @Group(PacketLimitsGroup) override val limitTimeframe by c.setting("Limit Timeframe", 310, 50..1500, 1, "The timeframe in which the limit is bound to", "ms") + @Group(PacketLimitsGroup) override val actionLimit by c.setting("Action Limit", 59, 1..100, 1, "The maximum allowed action packets to be sent to the server per given timeframe") + @Group(PacketLimitsGroup) override val interactionLimit by c.setting("Interaction Limit", 9, 1..20, 1, "The maximum allowed interaction packets to be sent to the server per given timeframe") + @Group(PacketLimitsGroup) override val inventoryLimit by c.setting("Inventory Limit", 5, 1..100, 1, "The maximum allowed inventory packets to be sent to the server per given timeframe") + + @Group(ReachGroup) override var blockReach by c.setting("Interact Reach", 4.5, 1.0..7.0, 0.01, "Maximum block interaction distance") + @Group(ReachGroup) override var entityReach by c.setting("Attack Reach", 3.0, 1.0..7.0, 0.01, "Maximum entity interaction distance") + override val scanReach: Double get() = max(entityReach, blockReach) + + @Group(ScanGroup) override val checkSideVisibility by c.setting("Visibility Check", false, "Whether to check if an AABB side is visible") + @Group(ScanGroup) override val strictRayCast by c.setting("Strict Raycast", false, "Whether to include the environment to the ray cast context") + @Group(ScanGroup) override val resolution by c.setting("Resolution", 5, 1..20, 1, "The amount of grid divisions per surface of the hit box", "") { strictRayCast } + @Group(ScanGroup) override val pointSelection by c.setting("Point Selection", BuildConfig.PointSelection.Optimum, "The strategy to select the best hit point") +} diff --git a/src/main/kotlin/com/lambda/config/groups/EatConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/EatConfig.kt similarity index 98% rename from src/main/kotlin/com/lambda/config/groups/EatConfig.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/EatConfig.kt index d2f24a8af..14b2b9aa7 100644 --- a/src/main/kotlin/com/lambda/config/groups/EatConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/EatConfig.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.SettingBlock import com.lambda.context.Automated @@ -29,7 +29,7 @@ import net.minecraft.entity.effect.StatusEffects import net.minecraft.item.Item import net.minecraft.item.ItemStack -interface EatConfig : SettingBlock { +interface EatConfig { val eatOnHunger: Boolean val minFoodLevel: Int val nutritiousFood: Collection diff --git a/src/main/kotlin/com/lambda/config/groups/EatSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/EatSettings.kt similarity index 98% rename from src/main/kotlin/com/lambda/config/groups/EatSettings.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/EatSettings.kt index dca1f6cbd..3e1533f49 100644 --- a/src/main/kotlin/com/lambda/config/groups/EatSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/EatSettings.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.Config import com.lambda.config.SettingBlock diff --git a/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/EntityColorSettings.kt similarity index 99% rename from src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/EntityColorSettings.kt index 71be13992..11308a9d6 100644 --- a/src/main/kotlin/com/lambda/config/groups/EntityColorSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/EntityColorSettings.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.Config import com.lambda.config.SettingBlock diff --git a/src/main/kotlin/com/lambda/config/groups/EntityColorsConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/EntityColorsConfig.kt similarity index 93% rename from src/main/kotlin/com/lambda/config/groups/EntityColorsConfig.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/EntityColorsConfig.kt index e118fe311..fe4f9804f 100644 --- a/src/main/kotlin/com/lambda/config/groups/EntityColorsConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/EntityColorsConfig.kt @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.SettingBlock import java.awt.Color -interface EntityColorsConfig : SettingBlock { +interface EntityColorsConfig { val useNaturalColors: Boolean val playerColor: Color val playerDistanceGradient: Boolean diff --git a/src/main/kotlin/com/lambda/config/groups/EntitySelectionConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/EntitySelectionConfig.kt similarity index 94% rename from src/main/kotlin/com/lambda/config/groups/EntitySelectionConfig.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/EntitySelectionConfig.kt index bd13bc653..87786feff 100644 --- a/src/main/kotlin/com/lambda/config/groups/EntitySelectionConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/EntitySelectionConfig.kt @@ -15,11 +15,11 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.SettingBlock -interface EntitySelectionConfig : SettingBlock { +interface EntitySelectionConfig { val self: Boolean val enablePlayerEntities: Boolean val playerEntities: Collection diff --git a/src/main/kotlin/com/lambda/config/groups/EntitySelectionSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/EntitySelectionSettings.kt similarity index 99% rename from src/main/kotlin/com/lambda/config/groups/EntitySelectionSettings.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/EntitySelectionSettings.kt index f00fc762a..fa06d2ad9 100644 --- a/src/main/kotlin/com/lambda/config/groups/EntitySelectionSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/EntitySelectionSettings.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.Lambda.mc import com.lambda.config.Config diff --git a/src/main/kotlin/com/lambda/config/groups/FormatterConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/FormatterConfig.kt similarity index 98% rename from src/main/kotlin/com/lambda/config/groups/FormatterConfig.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/FormatterConfig.kt index 0e5615cf1..232c2ce1e 100644 --- a/src/main/kotlin/com/lambda/config/groups/FormatterConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/FormatterConfig.kt @@ -15,9 +15,8 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks -import com.lambda.config.SettingBlock import com.lambda.util.Describable import com.lambda.util.NamedEnum import java.time.format.DateTimeFormatter diff --git a/src/main/kotlin/com/lambda/config/groups/FormatterSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/FormatterSettings.kt similarity index 93% rename from src/main/kotlin/com/lambda/config/groups/FormatterSettings.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/FormatterSettings.kt index f6b336a84..d91d42d21 100644 --- a/src/main/kotlin/com/lambda/config/groups/FormatterSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/FormatterSettings.kt @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.Config import com.lambda.config.SettingBlock -class FormatterSettings(override val c: Config) : SettingBlock, FormatterConfig { +class FormatterSettings(override val c: Config) : FormatterConfig, SettingBlock { val localeEnum by c.setting("Locale", FormatterConfig.Locales.US, "The regional formatting used for numbers") override val locale get() = localeEnum.locale diff --git a/src/main/kotlin/com/lambda/config/groups/HotbarConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/HotbarConfig.kt similarity index 95% rename from src/main/kotlin/com/lambda/config/groups/HotbarConfig.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/HotbarConfig.kt index a45c00851..656097b16 100644 --- a/src/main/kotlin/com/lambda/config/groups/HotbarConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/HotbarConfig.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.SettingBlock import com.lambda.event.events.TickEvent @@ -25,7 +25,7 @@ import com.lambda.event.events.TickEvent * * @param priority The priority of this configuration. */ -interface HotbarConfig : SettingBlock { +interface HotbarConfig { val swapMode: SwapMode /** * The number of ticks to keep the current hotbar selection active. diff --git a/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/HotbarSettings.kt similarity index 93% rename from src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/HotbarSettings.kt index 01d61790d..ab3c07f4d 100644 --- a/src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/HotbarSettings.kt @@ -15,14 +15,14 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.Config import com.lambda.config.SettingBlock import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -class HotbarSettings(override val c: Config) : HotbarConfig { +class HotbarSettings(override val c: Config) : HotbarConfig, SettingBlock { override val swapMode by c.setting("Swap Mode", HotbarConfig.SwapMode.Temporary) override val keepTicks by c.setting("Keep Ticks", 1, 0..20, 1, "The number of ticks to keep the current hotbar selection active", " ticks") { swapMode == HotbarConfig.SwapMode.Temporary } override val swapDelay by c.setting("Swap Delay", 0, 0..3, 1, "The number of ticks delay before allowing another hotbar selection swap", " ticks") diff --git a/src/main/kotlin/com/lambda/config/groups/InteractConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/InteractConfig.kt similarity index 97% rename from src/main/kotlin/com/lambda/config/groups/InteractConfig.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/InteractConfig.kt index 1f6359b6b..128f9a219 100644 --- a/src/main/kotlin/com/lambda/config/groups/InteractConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/InteractConfig.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.util.Describable import com.lambda.util.NamedEnum diff --git a/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/InteractSettings.kt similarity index 82% rename from src/main/kotlin/com/lambda/config/groups/InteractSettings.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/InteractSettings.kt index c2ae98907..9e9ea0de0 100644 --- a/src/main/kotlin/com/lambda/config/groups/InteractSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/InteractSettings.kt @@ -15,21 +15,20 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.Config -import com.lambda.config.groups.InteractConfig.AirPlaceMode -import com.lambda.config.groups.InteractConfig.InteractConfirmationMode +import com.lambda.config.SettingBlock import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -class InteractSettings(override val c: Config) : InteractConfig { +class InteractSettings(override val c: Config) : InteractConfig, SettingBlock { override val rotate by c.setting("Rotate For Interact", true, "Rotate towards block while placing") - override val airPlace by c.setting("Air Place", AirPlaceMode.Grim, "Allows for placing blocks without adjacent faces") + override val airPlace by c.setting("Air Place", InteractConfig.AirPlaceMode.Grim, "Allows for placing blocks without adjacent faces") override val axisRotateSetting by c.setting("Axis Rotate", true, "Overrides the Rotate For Place setting and rotates the player on each axis to air place rotational blocks") { airPlace.isEnabled } override val sorter by c.setting("Interaction Sorter", ActionConfig.SortMode.Tool, "The order in which placements are performed") override val tickStageMask by c.setting("Interaction Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), "The sub-tick timing at which place actions are performed", displayClassName = true) - override val interactConfirmationMode by c.setting("Interact Confirmation", InteractConfirmationMode.PlaceThenAwait, "Wait for block placement confirmation") + override val interactConfirmationMode by c.setting("Interact Confirmation", InteractConfig.InteractConfirmationMode.PlaceThenAwait, "Wait for block placement confirmation") override val interactDelay by c.setting("Interact Delay", 0, 0..3, 1, "Tick delay between interacting with another block") override val interactionsPerTick by c.setting("Interactions Per Tick", 9, 1..30, 1, "Maximum instant block places per tick") override val swing by c.setting("Swing On Interact", true, "Swings the players hand when placing") diff --git a/src/main/kotlin/com/lambda/config/groups/InventoryConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/InventoryConfig.kt similarity index 97% rename from src/main/kotlin/com/lambda/config/groups/InventoryConfig.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/InventoryConfig.kt index e49c2e2d9..21ec4f37f 100644 --- a/src/main/kotlin/com/lambda/config/groups/InventoryConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/InventoryConfig.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.SettingBlock import com.lambda.context.SafeContext @@ -27,7 +27,7 @@ import com.lambda.util.Describable import com.lambda.util.NamedEnum import net.minecraft.item.Item -interface InventoryConfig : SettingBlock { +interface InventoryConfig { val tickStageMask: Collection val disposables: Collection val swapWithDisposables: Boolean diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/InventorySettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/InventorySettings.kt new file mode 100644 index 000000000..01d9ddba9 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/settings/blocks/InventorySettings.kt @@ -0,0 +1,42 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.settings.blocks + +import com.lambda.config.Config +import com.lambda.config.Group +import com.lambda.config.SettingBlock +import com.lambda.event.events.TickEvent.Companion.ALL_STAGES +import com.lambda.util.item.ItemUtils + +class InventorySettings(override val c: Config) : SettingBlock, InventoryConfig { + companion object { + private const val ContainerGroup = "Container" + private const val AccessGroup = "Access" + } + + override val tickStageMask by c.setting("Inventory Stage Mask", ALL_STAGES.toSet(), description = "The sub-tick timing at which inventory actions are performed", displayClassName = true) + @Group(ContainerGroup) override val disposables by c.setting("Disposables", ItemUtils.defaultDisposables, description = "Items that will be ignored when checking for a free slot") + @Group(ContainerGroup) override val swapWithDisposables by c.setting("Swap With Disposables", true, "Swap items with disposable ones") + @Group(ContainerGroup) override val providerPriority by c.setting("Provider Priority", InventoryConfig.Priority.WithMinItems, "What container to prefer when retrieving the item from") + @Group(ContainerGroup) override val storePriority by c.setting("Store Priority", InventoryConfig.Priority.WithMinItems, "What container to prefer when storing the item to") + + @Group(AccessGroup) override val accessShulkerBoxes by c.setting("Access Shulker Boxes", false, "Allow access to the player's shulker boxes") + @Group(AccessGroup) override val accessChests by c.setting("Access Chests", false, "Allow access to the player's normal chests") + @Group(AccessGroup) override val accessEnderChest by c.setting("Access Ender Chest", false, "Allow access to the player's ender chest") + @Group(AccessGroup) override val accessStashes by c.setting("Access Stashes", false, "Allow access to the player's stashes") +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/groups/LineConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/LineConfig.kt similarity index 90% rename from src/main/kotlin/com/lambda/config/groups/LineConfig.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/LineConfig.kt index 6f2331446..e7c516156 100644 --- a/src/main/kotlin/com/lambda/config/groups/LineConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/LineConfig.kt @@ -15,13 +15,12 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks -import com.lambda.config.SettingBlock import com.lambda.graphics.mc.LineDashStyle import java.awt.Color -interface LineConfig : SettingBlock { +interface LineConfig { val startColor: Color val endColor: Color val width: Float diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/OutlineConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/OutlineConfig.kt new file mode 100644 index 000000000..881690211 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/settings/blocks/OutlineConfig.kt @@ -0,0 +1,26 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.settings.blocks + +interface OutlineConfig { + val thickness: Float + val glowIntensity: Float + val glowRadius: Float + val fill: Boolean + val fillOpacity: Float +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/groups/OutlineSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/OutlineSettings.kt similarity index 65% rename from src/main/kotlin/com/lambda/config/groups/OutlineSettings.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/OutlineSettings.kt index c8e97752e..63f304633 100644 --- a/src/main/kotlin/com/lambda/config/groups/OutlineSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/OutlineSettings.kt @@ -15,34 +15,35 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.Config import com.lambda.config.SettingBlock import com.lambda.graphics.outline.OutlineStyle import java.awt.Color -class OutlineSettings(override val c: Config) : SettingBlock { +class OutlineSettings(override val c: Config) : OutlineConfig, SettingBlock { val thicknessSetting by c.setting("Line Width", 25, 1..100, 1, "The width of the outline") - val thickness get() = thicknessSetting * 0.00005f + override val thickness get() = thicknessSetting * 0.00005f val glowIntensitySetting by c.setting("Glow Intensity", 50, 0..100, 1, "Intensity of the outline glow") - val glowIntensity get() = glowIntensitySetting * 0.01f + override val glowIntensity get() = glowIntensitySetting * 0.01f val glowRadiusSetting by c.setting("Glow Radius", 20, 0..100, 1, "Radius of the outline glow") - val glowRadius get() = glowRadiusSetting * 0.00005f + override val glowRadius get() = glowRadiusSetting * 0.00005f - val fill by c.setting("Fill", true, "Fill the entity silhouette") + override val fill by c.setting("Fill", true, "Fill the entity silhouette") val fillOpacitySetting by c.setting("Fill Opacity", 10, 0..100, 1, "Opacity of the fill") { fill } - val fillOpacity get() = fillOpacitySetting * 0.01f - - fun toStyle(color: Color) = OutlineStyle( - color = color, - thickness = thickness, - glowIntensity = glowIntensity, - glowRadius = glowRadius, - fill = fill, - fillOpacity = fillOpacity - ) + override val fillOpacity get() = fillOpacitySetting * 0.01f + + fun toStyle(color: Color) = + OutlineStyle( + color = color, + thickness = thickness, + glowIntensity = glowIntensity, + glowRadius = glowRadius, + fill = fill, + fillOpacity = fillOpacity + ) } diff --git a/src/main/kotlin/com/lambda/config/groups/ReplaceConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/ReplaceConfig.kt similarity index 95% rename from src/main/kotlin/com/lambda/config/groups/ReplaceConfig.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/ReplaceConfig.kt index d35f4851f..bf2a1451e 100644 --- a/src/main/kotlin/com/lambda/config/groups/ReplaceConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/ReplaceConfig.kt @@ -15,12 +15,12 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.SettingBlock import com.lambda.util.Describable -interface ReplaceConfig : SettingBlock { +interface ReplaceConfig { val action: ActionStrategy val replace: ReplaceStrategy diff --git a/src/main/kotlin/com/lambda/config/groups/RotationConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/RotationConfig.kt similarity index 91% rename from src/main/kotlin/com/lambda/config/groups/RotationConfig.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/RotationConfig.kt index a37b1da17..d4e8ab7d6 100644 --- a/src/main/kotlin/com/lambda/config/groups/RotationConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/RotationConfig.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.Config import com.lambda.config.SettingBlock @@ -23,7 +23,7 @@ import com.lambda.event.events.TickEvent import com.lambda.interaction.managers.rotating.RotationManager import com.lambda.interaction.managers.rotating.RotationMode -interface RotationConfig : SettingBlock { +interface RotationConfig { /** * - [RotationMode.Silent] Spoofing server-side rotation. * - [RotationMode.Sync] Spoofing server-side rotation and adjusting client-side movement based on reported rotation (for Grim). @@ -48,7 +48,7 @@ interface RotationConfig : SettingBlock { val tickStageMask: Set - open class Instant(override val c: Config, mode: RotationMode) : RotationConfig { + open class Instant(mode: RotationMode) : RotationConfig { override val rotationMode = mode override val keepTicks = 1 override val decayTicks = 1 diff --git a/src/main/kotlin/com/lambda/config/groups/RotationSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/RotationSettings.kt similarity index 95% rename from src/main/kotlin/com/lambda/config/groups/RotationSettings.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/RotationSettings.kt index 93343813d..33a0bef57 100644 --- a/src/main/kotlin/com/lambda/config/groups/RotationSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/RotationSettings.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.Config import com.lambda.config.SettingBlock @@ -29,7 +29,7 @@ import kotlin.math.ln import kotlin.math.sqrt import kotlin.random.Random -class RotationSettings(override val c: Config) : SettingBlock, RotationConfig { +class RotationSettings(override val c: Config) : RotationConfig, SettingBlock { override var rotationMode by c.setting("Mode", RotationMode.Sync, "How the player is being rotated on interaction") /** How many ticks to keep the rotation before resetting */ diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/ScreenLineSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/ScreenLineSettings.kt new file mode 100644 index 000000000..42c3a4abf --- /dev/null +++ b/src/main/kotlin/com/lambda/config/settings/blocks/ScreenLineSettings.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.settings.blocks + +import com.lambda.config.Config +import com.lambda.config.Group +import com.lambda.config.SettingBlock +import java.awt.Color + +class ScreenLineSettings(override val c: Config) : LineConfig, SettingBlock { + companion object { + private const val ColorGroup = "Color" + private const val DashGroup = "Dash" + } + + val widthSetting by c.setting("Width", 20, 1..100, 1, "The width of the line") + override val width get() = widthSetting * 0.00005f + + @Group(ColorGroup) override val startColor by c.setting("Start Color", Color.WHITE, "The color at the start of the line") + @Group(ColorGroup) override val endColor by c.setting("End Color", Color.WHITE, "The color at the end of the line") + + @Group(DashGroup) override val dashEnabled by c.setting("Dashed", false, "Enable dashed line pattern") + @Group(DashGroup) val dashLengthSetting by c.setting("Dash Length", 30, 1..50, 1, "Length of each dash") { dashEnabled } + override val dashLength get() = dashLengthSetting * 0.001f + @Group(DashGroup) val gapLengthSetting by c.setting("Gap Length", 15, 1..50, 1, "Length of gaps between dashes") { dashEnabled } + override val gapLength get() = gapLengthSetting * 0.001f + @Group(DashGroup) override val animated by c.setting("Animated", true, "Animate the dash pattern") { dashEnabled } + @Group(DashGroup) val dashOffsetSetting by c.setting("Dash Offset", 0, 0..100, 1, "Offset of the dash pattern") { dashEnabled && !animated } + override val dashOffset get() = dashOffsetSetting * 0.01f + @Group(DashGroup) val animationSpeedSetting by c.setting("Animation Speed", 30, -100..100, 1, "Speed of dash animation (negative = reverse)") { dashEnabled && animated } + override val animationSpeed get() = animationSpeedSetting * 0.1f +} diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/ScreenTextSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/ScreenTextSettings.kt new file mode 100644 index 000000000..6c807ad3b --- /dev/null +++ b/src/main/kotlin/com/lambda/config/settings/blocks/ScreenTextSettings.kt @@ -0,0 +1,49 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.settings.blocks + +import com.lambda.config.Config +import com.lambda.config.Group +import com.lambda.config.SettingBlock +import java.awt.Color + +class ScreenTextSettings(override val c: Config) : TextConfig, SettingBlock { + companion object { + private const val OutlineGroup = "Outline" + private const val GlowGroup = "Glow" + private const val ShadowGroup = "Shadow" + } + + override val textColor by c.setting("Text Color", Color.WHITE, "The main text color") + val sizeSetting by c.setting("Text Size", 18, 1..50, 1) + override val size get() = sizeSetting * 0.001f + + @Group(OutlineGroup) override val outlineEnabled by c.setting("Outline", false, "Enable text outline") + @Group(OutlineGroup) override val outlineColor by c.setting("Outline Color", Color.BLACK, "Color of the outline") { outlineEnabled } + @Group(OutlineGroup) override val outlineWidth by c.setting("Outline Width", 0.1f, 0f..0.4f, 0.005f, "Width of the outline") { outlineEnabled } + + @Group(GlowGroup) override val glowEnabled by c.setting("Glow", false, "Enable text glow effect") + @Group(GlowGroup) override val glowColor by c.setting("Glow Color", Color.WHITE, "Color of the glow") { glowEnabled } + @Group(GlowGroup) override val glowRadius by c.setting("Glow Radius", 0.2f, 0f..0.5f, 0.01f, "Radius of the glow effect") { glowEnabled } + + @Group(ShadowGroup) override val shadowEnabled by c.setting("Shadow", true, "Enable text shadow") + @Group(ShadowGroup) override val shadowColor by c.setting("Shadow Color", Color(0, 0, 0, 180), "Color of the shadow") { shadowEnabled } + @Group(ShadowGroup) override val shadowOffset by c.setting("Shadow Offset", 0.05f, 0f..0.5f, 0.005f, "Distance of shadow from text") { shadowEnabled } + @Group(ShadowGroup) override val shadowAngle by c.setting("Shadow Angle", 135f, 0f..360f, 1f, "Angle of the shadow") { shadowEnabled } + @Group(ShadowGroup) override val shadowSoftness by c.setting("Shadow Softness", 0f, 0f..0.5f, 0.01f, "Softness of shadow edges") { shadowEnabled } +} diff --git a/src/main/kotlin/com/lambda/config/groups/TargetingConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/TargetingConfig.kt similarity index 86% rename from src/main/kotlin/com/lambda/config/groups/TargetingConfig.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/TargetingConfig.kt index 469b9e64e..4a5fd0147 100644 --- a/src/main/kotlin/com/lambda/config/groups/TargetingConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/TargetingConfig.kt @@ -15,11 +15,9 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks -import com.lambda.config.SettingBlock - -interface TargetingConfig : SettingBlock { +interface TargetingConfig { val targetingRange: Double val targets: EntitySelectionConfig } diff --git a/src/main/kotlin/com/lambda/config/groups/TargetingSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt similarity index 97% rename from src/main/kotlin/com/lambda/config/groups/TargetingSettings.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt index dd2fd8477..3589566ea 100644 --- a/src/main/kotlin/com/lambda/config/groups/TargetingSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.Config import com.lambda.config.SettingBlock @@ -52,18 +52,15 @@ abstract class TargetingSettings( override val c: Config, defaultRange: Double, maxRange: Double, -) : SettingBlock, TargetingConfig { - +) : TargetingConfig, SettingBlock { /** * The range within which entities can be targeted. This value is config and constrained * between 1.0 and [maxRange]. */ override val targetingRange by c.setting("Targeting Range", defaultRange, 1.0..maxRange, 0.05) - override val targets = EntitySelectionSettings(c).apply { - applyEdits { - hide(::self, ::blockEntities) - } - } + override val targets = c.settingBlock(EntitySelectionSettings(c)) { + c.applyEdits { hide(::self, ::blockEntities) } + } /** * Validates whether a given entity is targetable by the player based on current settings. diff --git a/src/main/kotlin/com/lambda/config/groups/TextConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/TextConfig.kt similarity index 95% rename from src/main/kotlin/com/lambda/config/groups/TextConfig.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/TextConfig.kt index 6877ffec5..b7a5dba25 100644 --- a/src/main/kotlin/com/lambda/config/groups/TextConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/TextConfig.kt @@ -15,13 +15,13 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.SettingBlock import com.lambda.graphics.mc.RenderBuilder import java.awt.Color -interface TextConfig : SettingBlock { +interface TextConfig { val size: Float val textColor: Color diff --git a/src/main/kotlin/com/lambda/config/groups/WorldLineSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/WorldLineSettings.kt similarity index 55% rename from src/main/kotlin/com/lambda/config/groups/WorldLineSettings.kt rename to src/main/kotlin/com/lambda/config/settings/blocks/WorldLineSettings.kt index 7c486ad46..c42dcdf6a 100644 --- a/src/main/kotlin/com/lambda/config/groups/WorldLineSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/WorldLineSettings.kt @@ -15,17 +15,17 @@ * along with this program. If not, see . */ -package com.lambda.config.groups +package com.lambda.config.settings.blocks import com.lambda.config.Config import com.lambda.config.Group import com.lambda.config.SettingBlock import java.awt.Color -class WorldLineSettings(override val c: Config) : SettingBlock, LineConfig { +class WorldLineSettings(override val c: Config) : LineConfig, SettingBlock { companion object { - private const val COLOR_GROUP = "Color" - private const val DASH_GROUP = "Dash" + private const val ColorGroup = "Color" + private const val DashGroup = "Dash" } val distanceScaling by c.setting("Distance Scaling", true, "Line width stays constant on screen regardless of distance") @@ -36,17 +36,17 @@ class WorldLineSettings(override val c: Config) : SettingBlock, LineConfig { if (distanceScaling) -screenWidthSetting * 0.00005f else worldWidthSetting * 0.001f - @Group(COLOR_GROUP) override val startColor by c.setting("Start Color", Color.WHITE, "The color at the start of the line") - @Group(COLOR_GROUP) override val endColor by c.setting("End Color", Color.WHITE, "The color at the end of the line") + @Group(ColorGroup) override val startColor by c.setting("Start Color", Color.WHITE, "The color at the start of the line") + @Group(ColorGroup) override val endColor by c.setting("End Color", Color.WHITE, "The color at the end of the line") - @Group(DASH_GROUP) override val dashEnabled by c.setting("Dashed", false, "Enable dashed line pattern") - @Group(DASH_GROUP) val dashLengthSetting by c.setting("Dash Length", 50, 1..200, 1, "Length of each dash") { dashEnabled } + @Group(DashGroup) override val dashEnabled by c.setting("Dashed", false, "Enable dashed line pattern") + @Group(DashGroup) val dashLengthSetting by c.setting("Dash Length", 50, 1..200, 1, "Length of each dash") { dashEnabled } override val dashLength get() = dashLengthSetting * 0.01f - @Group(DASH_GROUP) val gapLengthSetting by c.setting("Gap Length", 25, 1..200, 1, "Length of gaps between dashes") { dashEnabled } + @Group(DashGroup) val gapLengthSetting by c.setting("Gap Length", 25, 1..200, 1, "Length of gaps between dashes") { dashEnabled } override val gapLength get() = gapLengthSetting * 0.01f - @Group(DASH_GROUP) override val animated by c.setting("Animated", true, "Animate the dash pattern") { dashEnabled } - @Group(DASH_GROUP) val dashOffsetSetting by c.setting("Dash Offset", 0, 0..100, 1, "Offset of the dash pattern") { dashEnabled && !animated } + @Group(DashGroup) override val animated by c.setting("Animated", true, "Animate the dash pattern") { dashEnabled } + @Group(DashGroup) val dashOffsetSetting by c.setting("Dash Offset", 0, 0..100, 1, "Offset of the dash pattern") { dashEnabled && !animated } override val dashOffset get() = dashOffsetSetting * 0.01f - @Group(DASH_GROUP) val animationSpeedSetting by c.setting("Animation Speed", 30, -100..100, 1, "Speed of dash animation (negative = reverse)") { dashEnabled && animated } + @Group(DashGroup) val animationSpeedSetting by c.setting("Animation Speed", 30, -100..100, 1, "Speed of dash animation (negative = reverse)") { dashEnabled && animated } override val animationSpeed get() = animationSpeedSetting * 0.1f } diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/WorldTextSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/WorldTextSettings.kt new file mode 100644 index 000000000..b6fda0f40 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/settings/blocks/WorldTextSettings.kt @@ -0,0 +1,49 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.settings.blocks + +import com.lambda.config.Config +import com.lambda.config.Group +import com.lambda.config.SettingBlock +import java.awt.Color + +class WorldTextSettings(override val c: Config) : TextConfig, SettingBlock { + companion object { + private const val OutlineGroup = "Outline" + private const val GlowGroup = "Glow" + private const val ShadowGroup = "Shadow" + } + + override val textColor by c.setting("Text Color", Color.WHITE, "The main text color") + val sizeSetting by c.setting("Text Size", 5, 1..50, 1) + override val size get() = sizeSetting * 0.1f + + @Group(OutlineGroup) override val outlineEnabled by c.setting("Outline", false, "Enable text outline") + @Group(OutlineGroup) override val outlineColor by c.setting("Outline Color", Color.BLACK, "Color of the outline") { outlineEnabled } + @Group(OutlineGroup) override val outlineWidth by c.setting("Outline Width", 0.1f, 0f..0.4f, 0.005f, "Width of the outline") { outlineEnabled } + + @Group(GlowGroup) override val glowEnabled by c.setting("Glow", false, "Enable text glow effect") + @Group(GlowGroup) override val glowColor by c.setting("Glow Color", Color.WHITE, "Color of the glow") { glowEnabled } + @Group(GlowGroup) override val glowRadius by c.setting("Glow Radius", 0.2f, 0f..0.5f, 0.01f, "Radius of the glow effect") { glowEnabled } + + @Group(ShadowGroup) override val shadowEnabled by c.setting("Shadow", true, "Enable text shadow") + @Group(ShadowGroup) override val shadowColor by c.setting("Shadow Color", Color(0, 0, 0, 180), "Color of the shadow") { shadowEnabled } + @Group(ShadowGroup) override val shadowOffset by c.setting("Shadow Offset", 0.05f, 0f..0.5f, 0.005f, "Distance of shadow from text") { shadowEnabled } + @Group(ShadowGroup) override val shadowAngle by c.setting("Shadow Angle", 135f, 0f..360f, 1f, "Angle of the shadow") { shadowEnabled } + @Group(ShadowGroup) override val shadowSoftness by c.setting("Shadow Softness", 0f, 0f..0.5f, 0.01f, "Softness of shadow edges") { shadowEnabled } +} diff --git a/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt index 0a066533a..971351e00 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt @@ -32,6 +32,6 @@ class BlockCollectionSetting( TypeToken.getParameterized(Collection::class.java, Block::class.java).type, serialize = true, ) { - context(setting: Setting<*, MutableCollection>) + context(_: Setting<*, MutableCollection>) override fun ImGuiBuilder.buildLayout() = buildDualPane("block") { BlockCodec.stringify(it) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt index 51c819b96..0ea823e8a 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt @@ -37,7 +37,7 @@ class ClassCollectionSetting( TypeToken.getParameterized(Collection::class.java, Any::class.java).type, serialize = false, ) { - context(setting: Setting<*, MutableCollection>) + context(_: Setting<*, MutableCollection>) override fun ImGuiBuilder.buildLayout() = buildDualPane("item") { it.className } // When serializing the list to json we do not want to serialize the elements' classes, but their stringified representation. diff --git a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt index 1e0963b75..b5d5cca92 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt @@ -68,7 +68,7 @@ open class CollectionSetting( val selectListeners = mutableListOf Unit>() val deselectListeners = mutableListOf Unit>() - context(setting: Setting<*, MutableCollection>) + context(_: Setting<*, MutableCollection>) override fun ImGuiBuilder.buildLayout() = buildDualPane("item") { it.toString() } context(setting: Setting<*, MutableCollection>) diff --git a/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt index 637277af4..1888547ea 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt @@ -32,6 +32,6 @@ class ItemCollectionSetting( TypeToken.getParameterized(Collection::class.java, Item::class.java).type, serialize = true, ) { - context(setting: Setting<*, MutableCollection>) + context(_: Setting<*, MutableCollection>) override fun ImGuiBuilder.buildLayout() = buildDualPane("item") { ItemCodec.stringify(it) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt index 81b3acfeb..683098db6 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt @@ -32,6 +32,6 @@ class MapSetting( defaultValue, type ) { - context(setting: Setting<*, MutableMap>) + context(_: Setting<*, MutableMap>) override fun ImGuiBuilder.buildLayout() {} } diff --git a/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt index 048d448d1..10b88f54c 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt @@ -36,7 +36,7 @@ class BlockSetting(defaultValue: Block) : SettingCore( defaultValue, TypeToken.get(Block::class.java).type ) { - context(setting: Setting<*, Block>) + context(_: Setting<*, Block>) override fun ImGuiBuilder.buildLayout() {} context(setting: Setting<*, Block>) diff --git a/src/main/kotlin/com/lambda/context/Automated.kt b/src/main/kotlin/com/lambda/context/Automated.kt index 939c54213..681f3e310 100644 --- a/src/main/kotlin/com/lambda/context/Automated.kt +++ b/src/main/kotlin/com/lambda/context/Automated.kt @@ -17,13 +17,13 @@ package com.lambda.context -import com.lambda.config.groups.BuildConfig -import com.lambda.config.groups.EatConfig -import com.lambda.config.groups.BreakConfig -import com.lambda.config.groups.HotbarConfig -import com.lambda.config.groups.InteractConfig -import com.lambda.config.groups.InventoryConfig -import com.lambda.config.groups.RotationConfig +import com.lambda.config.settings.blocks.BreakConfig +import com.lambda.config.settings.blocks.BuildConfig +import com.lambda.config.settings.blocks.EatConfig +import com.lambda.config.settings.blocks.HotbarConfig +import com.lambda.config.settings.blocks.InteractConfig +import com.lambda.config.settings.blocks.InventoryConfig +import com.lambda.config.settings.blocks.RotationConfig interface Automated { val buildConfig: BuildConfig diff --git a/src/main/kotlin/com/lambda/core/Loader.kt b/src/main/kotlin/com/lambda/core/Loader.kt index 88e0a416f..d629acc28 100644 --- a/src/main/kotlin/com/lambda/core/Loader.kt +++ b/src/main/kotlin/com/lambda/core/Loader.kt @@ -18,7 +18,7 @@ package com.lambda.core import com.lambda.Lambda -import com.lambda.Lambda.LOG +import com.lambda.Lambda.Log import com.lambda.util.CommunicationUtils.ascii import com.lambda.util.ReflectionUtils.getInstances import kotlin.system.measureTimeMillis @@ -33,14 +33,14 @@ object Loader { private val loadables = getInstances() fun initialize(): Long { - ascii.split("\n").forEach { LOG.info(it) } - LOG.info("Initializing ${Lambda.MOD_NAME} ${Lambda.VERSION} (${loadables.size} loaders)...") + ascii.split("\n").forEach { Log.info(it) } + Log.info("Initializing ${Lambda.ModName} ${Lambda.Version} (${loadables.size} loaders)...") val initTime = measureTimeMillis { loadables.sortedByDescending { it.priority }.forEach { var response: String val time = measureTimeMillis { response = it.load() } - if (response.isNotBlank()) LOG.info("$response ($time ms)") + if (response.isNotBlank()) Log.info("$response ($time ms)") } } diff --git a/src/main/kotlin/com/lambda/core/TimerHandler.kt b/src/main/kotlin/com/lambda/core/TimerHandler.kt index c7c9ea83f..786f56784 100644 --- a/src/main/kotlin/com/lambda/core/TimerHandler.kt +++ b/src/main/kotlin/com/lambda/core/TimerHandler.kt @@ -23,14 +23,14 @@ import kotlin.concurrent.fixedRateTimer import kotlin.time.Duration.Companion.milliseconds object TimerHandler : Loadable { - const val DEFAULT_LENGTH = 50.0 + const val DefaultLength = 50.0 var lastTickLength = 50.0 override fun load() = "Loaded Timer Manager" val length: Double get() { - var length = DEFAULT_LENGTH + var length = DefaultLength ClientEvent.TimerUpdate(1.0).post { length /= speed diff --git a/src/main/kotlin/com/lambda/graphics/mc/BoxBuilder.kt b/src/main/kotlin/com/lambda/graphics/mc/BoxBuilder.kt index acd76c20f..8e92f69b0 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/BoxBuilder.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/BoxBuilder.kt @@ -17,14 +17,14 @@ package com.lambda.graphics.mc -import com.lambda.config.groups.LineConfig +import com.lambda.config.blocks.LineConfig import com.lambda.graphics.util.DirectionMask import net.minecraft.util.math.Direction import java.awt.Color class BoxBuilder(lineConfig: LineConfig?) { - var outlineSides: Int = DirectionMask.ALL - var fillSides: Int = DirectionMask.ALL + var outlineSides: Int = DirectionMask.All + var fillSides: Int = DirectionMask.All var outlineMode: DirectionMask.OutlineMode = DirectionMask.OutlineMode.And var lineWidth = lineConfig?.width ?: -0.0005f @@ -213,24 +213,24 @@ class BoxBuilder(lineConfig: LineConfig?) { @RenderDsl fun hideOutline() { - outlineSides = DirectionMask.NONE + outlineSides = DirectionMask.None } @RenderDsl fun hideFill() { - fillSides = DirectionMask.NONE + fillSides = DirectionMask.None } @RenderDsl fun outlineOnly() { - outlineSides = DirectionMask.ALL - fillSides = DirectionMask.NONE + outlineSides = DirectionMask.All + fillSides = DirectionMask.None } @RenderDsl fun fillOnly() { - outlineSides = DirectionMask.NONE - fillSides = DirectionMask.ALL + outlineSides = DirectionMask.None + fillSides = DirectionMask.All } @RenderDsl diff --git a/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt b/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt index f810ed49f..922853664 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt @@ -18,7 +18,7 @@ package com.lambda.graphics.mc import com.lambda.Lambda.mc -import com.lambda.config.groups.LineConfig +import com.lambda.config.blocks.LineConfig import com.lambda.context.SafeContext import com.lambda.graphics.outline.OutlineHandler import com.lambda.graphics.outline.OutlineStyle @@ -102,8 +102,8 @@ class RenderBuilder(private val cameraPos: Vec3d, var depthTest: Boolean = false builder: (BoxBuilder.() -> Unit)? = null ) { val boxBuilder = BoxBuilder(lineConfig).apply { builder?.invoke(this) } - if (boxBuilder.fillSides != DirectionMask.NONE) boxBuilder.boxFaces(box) - if (boxBuilder.outlineSides != DirectionMask.NONE) boxBuilder.boxOutline(box) + if (boxBuilder.fillSides != DirectionMask.None) boxBuilder.boxFaces(box) + if (boxBuilder.outlineSides != DirectionMask.None) boxBuilder.boxOutline(box) } context(safeContext: SafeContext) @@ -116,8 +116,8 @@ class RenderBuilder(private val cameraPos: Vec3d, var depthTest: Boolean = false val boxes = state.getOutlineShape(world, pos).boundingBoxes.map { it.offset(pos) } val boxBuilder = BoxBuilder(lineConfig).apply { builder?.invoke(this) } boxes.forEach { box -> - if (boxBuilder.fillSides != DirectionMask.NONE) boxBuilder.boxFaces(box) - if (boxBuilder.outlineSides != DirectionMask.NONE) boxBuilder.boxOutline(box) + if (boxBuilder.fillSides != DirectionMask.None) boxBuilder.boxFaces(box) + if (boxBuilder.outlineSides != DirectionMask.None) boxBuilder.boxOutline(box) } } @@ -1306,7 +1306,7 @@ class RenderBuilder(private val cameraPos: Vec3d, var depthTest: Boolean = false } private fun BoxBuilder.boxFaces(box: Box) { - if (fillSides.hasDirection(DirectionMask.EAST)) { + if (fillSides.hasDirection(DirectionMask.East)) { filledQuadGradient( box.maxX, box.minY, box.minZ, fillBottomNorthEast, box.maxX, box.maxY, box.minZ, fillTopNorthEast, @@ -1314,7 +1314,7 @@ class RenderBuilder(private val cameraPos: Vec3d, var depthTest: Boolean = false box.maxX, box.minY, box.maxZ, fillBottomSouthEast ) } - if (fillSides.hasDirection(DirectionMask.WEST)) { + if (fillSides.hasDirection(DirectionMask.West)) { filledQuadGradient( box.minX, box.minY, box.minZ, fillBottomNorthWest, box.minX, box.minY, box.maxZ, fillBottomSouthWest, @@ -1322,7 +1322,7 @@ class RenderBuilder(private val cameraPos: Vec3d, var depthTest: Boolean = false box.minX, box.maxY, box.minZ, fillTopNorthWest ) } - if (fillSides.hasDirection(DirectionMask.UP)) { + if (fillSides.hasDirection(DirectionMask.Up)) { filledQuadGradient( box.minX, box.maxY, box.minZ, fillTopNorthWest, box.minX, box.maxY, box.maxZ, fillTopSouthWest, @@ -1330,7 +1330,7 @@ class RenderBuilder(private val cameraPos: Vec3d, var depthTest: Boolean = false box.maxX, box.maxY, box.minZ, fillTopNorthEast ) } - if (fillSides.hasDirection(DirectionMask.DOWN)) { + if (fillSides.hasDirection(DirectionMask.Down)) { filledQuadGradient( box.minX, box.minY, box.minZ, fillBottomNorthWest, box.maxX, box.minY, box.minZ, fillBottomNorthEast, @@ -1338,7 +1338,7 @@ class RenderBuilder(private val cameraPos: Vec3d, var depthTest: Boolean = false box.minX, box.minY, box.maxZ, fillBottomSouthWest ) } - if (fillSides.hasDirection(DirectionMask.SOUTH)) { + if (fillSides.hasDirection(DirectionMask.South)) { filledQuadGradient( box.minX, box.minY, box.maxZ, fillBottomSouthWest, box.maxX, box.minY, box.maxZ, fillBottomSouthEast, @@ -1346,7 +1346,7 @@ class RenderBuilder(private val cameraPos: Vec3d, var depthTest: Boolean = false box.minX, box.maxY, box.maxZ, fillTopSouthWest ) } - if (fillSides.hasDirection(DirectionMask.NORTH)) { + if (fillSides.hasDirection(DirectionMask.North)) { filledQuadGradient( box.minX, box.minY, box.minZ, fillBottomNorthWest, box.minX, box.maxY, box.minZ, fillTopNorthWest, @@ -1357,12 +1357,12 @@ class RenderBuilder(private val cameraPos: Vec3d, var depthTest: Boolean = false } private fun BoxBuilder.boxOutline(box: Box) { - val hasEast = outlineSides.hasDirection(DirectionMask.EAST) - val hasWest = outlineSides.hasDirection(DirectionMask.WEST) - val hasUp = outlineSides.hasDirection(DirectionMask.UP) - val hasDown = outlineSides.hasDirection(DirectionMask.DOWN) - val hasSouth = outlineSides.hasDirection(DirectionMask.SOUTH) - val hasNorth = outlineSides.hasDirection(DirectionMask.NORTH) + val hasEast = outlineSides.hasDirection(DirectionMask.East) + val hasWest = outlineSides.hasDirection(DirectionMask.West) + val hasUp = outlineSides.hasDirection(DirectionMask.Up) + val hasDown = outlineSides.hasDirection(DirectionMask.Down) + val hasSouth = outlineSides.hasDirection(DirectionMask.South) + val hasNorth = outlineSides.hasDirection(DirectionMask.North) if (outlineMode.check(hasUp, hasNorth)) { lineGradient( diff --git a/src/main/kotlin/com/lambda/graphics/mc/renderer/ChunkedRenderer.kt b/src/main/kotlin/com/lambda/graphics/mc/renderer/ChunkedRenderer.kt index 91d52c3d9..453520d41 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/renderer/ChunkedRenderer.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/renderer/ChunkedRenderer.kt @@ -28,6 +28,7 @@ import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.graphics.RenderMain import com.lambda.graphics.mc.RegionRenderer import com.lambda.graphics.mc.RenderBuilder +import com.lambda.graphics.mc.RenderDsl import com.lambda.module.Module import com.lambda.module.modules.client.Client import com.lambda.util.world.FastVector @@ -182,6 +183,7 @@ class ChunkedRenderer( } companion object { + @RenderDsl fun Any.chunkedRenderer( name: String, depthTest: SafeContext.() -> Boolean = { false }, diff --git a/src/main/kotlin/com/lambda/graphics/mc/renderer/ImmediateRenderer.kt b/src/main/kotlin/com/lambda/graphics/mc/renderer/ImmediateRenderer.kt index 3d81e28bb..7b9ba01b9 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/renderer/ImmediateRenderer.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/renderer/ImmediateRenderer.kt @@ -23,6 +23,7 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.graphics.RenderMain import com.lambda.graphics.mc.RegionRenderer import com.lambda.graphics.mc.RenderBuilder +import com.lambda.graphics.mc.RenderDsl import com.mojang.blaze3d.buffers.GpuBufferSlice import com.mojang.blaze3d.systems.RenderSystem import org.joml.Vector3f @@ -71,6 +72,7 @@ class ImmediateRenderer( override fun getScreenRenderers() = if (renderer.hasScreenData()) listOf(renderer) else emptyList() companion object { + @RenderDsl fun Any.immediateRenderer( name: String, depthTest: SafeContext.() -> Boolean = { false }, diff --git a/src/main/kotlin/com/lambda/graphics/mc/renderer/TickedRenderer.kt b/src/main/kotlin/com/lambda/graphics/mc/renderer/TickedRenderer.kt index d60eb6633..cf02c7bf5 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/renderer/TickedRenderer.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/renderer/TickedRenderer.kt @@ -25,6 +25,7 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.graphics.RenderMain import com.lambda.graphics.mc.RegionRenderer import com.lambda.graphics.mc.RenderBuilder +import com.lambda.graphics.mc.RenderDsl import com.mojang.blaze3d.buffers.GpuBufferSlice import com.mojang.blaze3d.systems.RenderSystem import net.minecraft.util.math.Vec3d @@ -86,6 +87,7 @@ class TickedRenderer( override fun getScreenRenderers() = if (renderer.hasScreenData()) listOf(renderer) else emptyList() companion object { + @RenderDsl fun Any.tickedRenderer( name: String, depthTest: SafeContext.() -> Boolean = { false }, diff --git a/src/main/kotlin/com/lambda/graphics/text/FontHandler.kt b/src/main/kotlin/com/lambda/graphics/text/FontHandler.kt index 261dcb665..0c963c9d1 100644 --- a/src/main/kotlin/com/lambda/graphics/text/FontHandler.kt +++ b/src/main/kotlin/com/lambda/graphics/text/FontHandler.kt @@ -17,7 +17,7 @@ package com.lambda.graphics.text -import com.lambda.Lambda.LOG +import com.lambda.Lambda.Log import com.lambda.config.Config import com.lambda.config.categories.FontCategory import com.lambda.core.Loadable @@ -106,7 +106,7 @@ object FontHandler : Loadable, Config(FontCategory) { discoveredFonts.sortBy { it.displayName } - LOG.info("[FontHandler] Discovered ${discoveredFonts.size} fonts") + Log.info("[FontHandler] Discovered ${discoveredFonts.size} fonts") } /** @@ -126,10 +126,10 @@ object FontHandler : Loadable, Config(FontCategory) { return loadedAtlases.getOrPut(key) { try { - LOG.info("[FontHandler] Loading SDF atlas for: ${fontInfo.displayName}") + Log.info("[FontHandler] Loading SDF atlas for: ${fontInfo.displayName}") SDFFontAtlas(fontInfo.path, fontInfo.userFont, fontInfo.size).apply { upload() } } catch (e: Exception) { - LOG.error("[FontHandler] Failed to load font: ${fontInfo.path} - ${e.message}") + Log.error("[FontHandler] Failed to load font: ${fontInfo.path} - ${e.message}") return null } } diff --git a/src/main/kotlin/com/lambda/graphics/util/DirectionMask.kt b/src/main/kotlin/com/lambda/graphics/util/DirectionMask.kt index 2966954c1..9c55031d1 100644 --- a/src/main/kotlin/com/lambda/graphics/util/DirectionMask.kt +++ b/src/main/kotlin/com/lambda/graphics/util/DirectionMask.kt @@ -25,17 +25,17 @@ import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Direction object DirectionMask { - const val EAST = 1 // X + - const val WEST = 2 // X - + const val East = 1 // X + + const val West = 2 // X - - const val UP = 4 // Y + - const val DOWN = 8 // Y - + const val Up = 4 // Y + + const val Down = 8 // Y - - const val SOUTH = 16 // Z + - const val NORTH = 32 // Z - + const val South = 16 // Z + + const val North = 32 // Z - - const val ALL = EAST or WEST or UP or DOWN or SOUTH or NORTH - const val NONE = 0 + const val All = East or West or Up or Down or South or North + const val None = 0 fun Int.include(dir: Int) = this or dir fun Int.include(direction: Direction) = include(direction.mask) @@ -47,7 +47,7 @@ object DirectionMask { buildSideMesh(position.toFastVec()) { filter(it.toBlockPos()) } fun buildSideMesh(position: FastVector, filter: (FastVector) -> Boolean): Int { - var sides = ALL + var sides = All Direction.entries .filter { filter(position.offset(it)) } @@ -58,12 +58,12 @@ object DirectionMask { val Direction.mask get() = when (this) { - Direction.DOWN -> DOWN - Direction.UP -> UP - Direction.NORTH -> NORTH - Direction.SOUTH -> SOUTH - Direction.WEST -> WEST - Direction.EAST -> EAST + Direction.DOWN -> Down + Direction.UP -> Up + Direction.NORTH -> North + Direction.SOUTH -> South + Direction.WEST -> West + Direction.EAST -> East } enum class OutlineMode(val check: (Boolean, Boolean) -> Boolean) { diff --git a/src/main/kotlin/com/lambda/gui/DearImGui.kt b/src/main/kotlin/com/lambda/gui/DearImGui.kt index 69bc256fd..13e8bd106 100644 --- a/src/main/kotlin/com/lambda/gui/DearImGui.kt +++ b/src/main/kotlin/com/lambda/gui/DearImGui.kt @@ -42,12 +42,12 @@ object DearImGui : Loadable { val implGlfw = ImGuiImplGlfw() val implGl3 = ImGuiImplGl3() - const val EXTERNAL_LINK = '↗' - const val BREADCRUMB_SEPARATOR = '»' - const val BASE_FONT_SCALE = 13f + const val ExternalLink = '↗' + const val BreadCrumbSeparator = '»' + const val BaseFontScale = 13f val io: ImGuiIO get() = ImGui.getIO() - const val DEFAULT_FLAGS = ImGuiConfigFlags.NavEnableKeyboard or // Enable Keyboard Controls + const val DefaultFlags = ImGuiConfigFlags.NavEnableKeyboard or // Enable Keyboard Controls ImGuiConfigFlags.NavEnableSetMousePos or // Move the cursor using the keyboard ImGuiConfigFlags.DockingEnable @@ -60,11 +60,11 @@ object DearImGui : Loadable { val glyphRanges = ImFontGlyphRangesBuilder().apply { addRanges(io.fonts.glyphRangesDefault) addRanges(io.fonts.glyphRangesGreek) - addChar(EXTERNAL_LINK) - addChar(BREADCRUMB_SEPARATOR) + addChar(ExternalLink) + addChar(BreadCrumbSeparator) }.buildRanges() val fontConfig = ImFontConfig() - val size = BASE_FONT_SCALE * scale + val size = BaseFontScale * scale with(io.fonts) { clear() addFontFromMemoryTTF("fonts/FiraSans-Regular.ttf".stream.readAllBytes(), size, fontConfig, glyphRanges) @@ -78,7 +78,7 @@ object DearImGui : Loadable { fun render() { val userPercent = ClickGuiLayout.scaleSetting / 100.0 val dpi = ClickGuiLayout.deviceScaleMultiplier() - val base = ClickGuiLayout.BASE_SCALE_MULTI * dpi + val base = ClickGuiLayout.BaseScaleMulti * dpi val fontScaleSetting = ClickGuiLayout.fontScale val scale = (base * userPercent * fontScaleSetting).toFloat() @@ -136,7 +136,7 @@ object DearImGui : Loadable { ImGui.createContext() ImPlot.createContext() - io.configFlags = DEFAULT_FLAGS + io.configFlags = DefaultFlags io.iniFilename = "lambda.ini" implGlfw.init(mc.window.handle, true) diff --git a/src/main/kotlin/com/lambda/gui/MenuBar.kt b/src/main/kotlin/com/lambda/gui/MenuBar.kt index 9fc138477..27d36d4f9 100644 --- a/src/main/kotlin/com/lambda/gui/MenuBar.kt +++ b/src/main/kotlin/com/lambda/gui/MenuBar.kt @@ -18,17 +18,18 @@ package com.lambda.gui import com.lambda.Lambda -import com.lambda.Lambda.REPO_URL +import com.lambda.Lambda.RepoUrl import com.lambda.Lambda.mc import com.lambda.command.CommandRegistry import com.lambda.config.ConfigLoader +import com.lambda.config.ConfigLoader.configs import com.lambda.config.automation.AutomationConfig import com.lambda.config.automation.UserAutomationConfig import com.lambda.config.categories.UserAutomationCategory import com.lambda.core.Loader import com.lambda.event.EventFlow import com.lambda.graphics.texture.TextureOwner.upload -import com.lambda.gui.DearImGui.EXTERNAL_LINK +import com.lambda.gui.DearImGui.ExternalLink import com.lambda.gui.components.ClickGuiLayout import com.lambda.gui.components.HudGuiLayout import com.lambda.gui.components.QuickSearch @@ -443,19 +444,19 @@ object MenuBar { menuItem("Quick Search...", "Shift+Shift") { QuickSearch.open() } - menuItem("Documentation $EXTERNAL_LINK") { - Util.getOperatingSystem().open("$REPO_URL/wiki") + menuItem("Documentation $ExternalLink") { + Util.getOperatingSystem().open("$RepoUrl/wiki") } - menuItem("Report Issue $EXTERNAL_LINK") { + menuItem("Report Issue $ExternalLink") { mc.keyboard.clipboard = gatherDiagnostics() info("Copied diagnostics to clipboard. Please paste it in a new issue on GitHub and click “Submit new issue”. Thank you!") - Util.getOperatingSystem().open("$REPO_URL/issues") + Util.getOperatingSystem().open("$RepoUrl/issues") } - menuItem("Check for Updates $EXTERNAL_LINK") { + menuItem("Check for Updates $ExternalLink") { // ToDo: // - Check for a newer version, show availability & changelog, and allow opening release page. // - Needs UpdateManager - Util.getOperatingSystem().open("$REPO_URL/releases") + Util.getOperatingSystem().open("$RepoUrl/releases") } } @@ -463,13 +464,13 @@ object MenuBar { popupModal("About Lambda", ImGuiWindowFlags.AlwaysAutoResize or ImGuiWindowFlags.NoTitleBar) { imageHorizontallyCentered(headerLogo.id.toLong(), 553f, 200f) group { - text("Version: ${Lambda.VERSION}") + text("Version: ${Lambda.Version}") if (Lambda.isDebug) text("Development Environment") text("Runtime: ${Loader.runtime}") text("Modules: ${ModuleRegistry.modules.size}") text("Commands: ${CommandRegistry.commands.size}") val totalSettings = ConfigLoader.configCategories.sumOf { cfg -> - cfg.configs.sumOf { it.settingContainers.size } + cfg.configs.sumOf { it.settingLayers.size } } text("Settings: $totalSettings") text("Synchronous listeners: ${EventFlow.syncListeners.size}") @@ -495,8 +496,8 @@ object MenuBar { ImGui.setClipboardText(gatherDiagnostics()) } sameLine() - button("View License $EXTERNAL_LINK") { - Util.getOperatingSystem().open("$REPO_URL/blob/master/LICENSE.md") + button("View License $ExternalLink") { + Util.getOperatingSystem().open("$RepoUrl/blob/master/LICENSE.md") } sameLine() button("Close") { @@ -520,9 +521,9 @@ object MenuBar { withStyleColor(ImGuiCol.ButtonHovered, 0x22FFFFFF) { withStyleColor(ImGuiCol.ButtonActive, 0x44FFFFFF) { val clicked = ImGui.imageButton("##github", githubLogo.id.toLong(), iconSize, iconSize) - lambdaTooltip("Open GitHub Repository $EXTERNAL_LINK") + lambdaTooltip("Open GitHub Repository $ExternalLink") if (clicked) { - Util.getOperatingSystem().open(REPO_URL) + Util.getOperatingSystem().open(RepoUrl) } } } diff --git a/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt b/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt index b8d078309..589296dc1 100644 --- a/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt +++ b/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt @@ -19,6 +19,7 @@ package com.lambda.gui.components import com.lambda.Lambda.mc import com.lambda.config.Config +import com.lambda.config.Tab import com.lambda.config.categories.GuiCategory import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.core.Loadable @@ -82,14 +83,12 @@ object ClickGuiLayout : Loadable, Config(GuiCategory) { private val pendingPositions = mutableMapOf>() private val snapOverlays = mutableMapOf() - private enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Snapping("Snapping"), - Sizing("Sizing"), - Rounding("Rounding"), - Colors("Colors"), - Font("Font") - } + private const val GeneralTab = "General" + private const val SnappingTab = "Snapping" + private const val SizingTab = "Sizing" + private const val RoundingTab = "Rounding" + private const val ColorsTab = "Colors" + private const val FontTab = "Font" @Suppress("unused") enum class TooltipType( @@ -103,8 +102,8 @@ object ClickGuiLayout : Loadable, Config(GuiCategory) { LongDelay("Long Delay", "Show tooltip after a longer delay (~0.40s), and only after the mouse has been still briefly on the item.", ImGuiHoveredFlags.DelayNormal) } - const val BASE_SCALE = 100 - const val BASE_SCALE_MULTI = 1.8 + const val BaseScale = 100 + const val BaseScaleMulti = 1.8 fun deviceScaleMultiplier() = try { val monitorWidth = mc.window.monitor!!.currentVideoMode!!.width.toDouble() @@ -114,11 +113,11 @@ object ClickGuiLayout : Loadable, Config(GuiCategory) { } // General - internal val scaleSetting by setting("Scale", BASE_SCALE, 50..300, 1, unit = "%").group(Group.General) - val alpha by setting("Alpha", 1.0f, 0.0f..1.0f, 0.01f).group(Group.General) - val disabledAlpha by setting("Disabled Alpha", 0.6f, 0.0f..1.0f, 0.01f).group(Group.General) - val tooltipType by setting("Tooltip Type", TooltipType.Stationary, description = "When to show the tooltip.").group(Group.General) - val setLambdaWindowIcon by setting("Set Lambda Window Icon", true).group(Group.General).onValueChange { _, to -> + @Tab(GeneralTab) internal val scaleSetting by setting("Scale", BaseScale, 50..300, 1, unit = "%") + @Tab(GeneralTab) val alpha by setting("Alpha", 1.0f, 0.0f..1.0f, 0.01f) + @Tab(GeneralTab) val disabledAlpha by setting("Disabled Alpha", 0.6f, 0.0f..1.0f, 0.01f) + @Tab(GeneralTab) val tooltipType by setting("Tooltip Type", TooltipType.Stationary, description = "When to show the tooltip.") + @Tab(GeneralTab) val setLambdaWindowIcon by setting("Set Lambda Window Icon", true).onValueChange { _, to -> if (to) { setLambdaWindowIcon() } else { @@ -127,121 +126,121 @@ object ClickGuiLayout : Loadable, Config(GuiCategory) { } } @JvmStatic - val setLambdaWindowTitle by setting("Set Lambda Window Title", true).onValueChange { _, _ -> mc.updateWindowTitle() }.group(Group.General) - val lambdaTitleAppendixName by setting("Append Username", true) { setLambdaWindowTitle }.onValueChange { _, _ -> mc.updateWindowTitle() }.group(Group.General) - val backgroundBlur by setting("Background Blur", true).group(Group.General) - val backgroundDarkening by setting("Background Darkening", true).group(Group.General) + @Tab(GeneralTab) val setLambdaWindowTitle by setting("Set Lambda Window Title", true).onValueChange { _, _ -> mc.updateWindowTitle() } + @Tab(GeneralTab) val lambdaTitleAppendixName by setting("Append Username", true) { setLambdaWindowTitle }.onValueChange { _, _ -> mc.updateWindowTitle() } + @Tab(GeneralTab) val backgroundBlur by setting("Background Blur", true) + @Tab(GeneralTab) val backgroundDarkening by setting("Background Darkening", true) // Snapping - val snapEnabled by setting("Enable Snapping", true, "Master toggle for GUI/HUD snapping").group(Group.Snapping) - val gridSize by setting("Grid Size", 25f, 2f..128f, 1f, "Grid step in pixels") { snapEnabled }.group(Group.Snapping) - val snapToEdges by setting("Snap To Element Edges", true) { snapEnabled }.group(Group.Snapping) - val snapToCenters by setting("Snap To Element Centers", true) { snapEnabled }.group(Group.Snapping) - val snapToScreenCenter by setting("Snap To Screen Center", true) { snapEnabled }.group(Group.Snapping) - val snapToGrid by setting("Snap To Grid", true) { snapEnabled }.group(Group.Snapping) - val snapDistanceElement by setting("Snap Distance (Elements)", 20f, 1f..48f, 1f, "Distance threshold in px") { snapEnabled }.group(Group.Snapping) - val snapDistanceScreen by setting("Snap Distance (Screen Center)", 14f, 1f..48f, 1f) { snapEnabled }.group(Group.Snapping) - val snapDistanceGrid by setting("Snap Distance (Grid)", 12f, 1f..48f, 1f) { snapEnabled }.group(Group.Snapping) - val snapLineColor by setting("Snap Line Color", Color(255, 160, 0, 220)) { snapEnabled }.group(Group.Snapping) + @Tab(SnappingTab) val snapEnabled by setting("Enable Snapping", true, "Master toggle for GUI/HUD snapping") + @Tab(SnappingTab) val gridSize by setting("Grid Size", 25f, 2f..128f, 1f, "Grid step in pixels") { snapEnabled } + @Tab(SnappingTab) val snapToEdges by setting("Snap To Element Edges", true) { snapEnabled } + @Tab(SnappingTab) val snapToCenters by setting("Snap To Element Centers", true) { snapEnabled } + @Tab(SnappingTab) val snapToScreenCenter by setting("Snap To Screen Center", true) { snapEnabled } + @Tab(SnappingTab) val snapToGrid by setting("Snap To Grid", true) { snapEnabled } + @Tab(SnappingTab) val snapDistanceElement by setting("Snap Distance (Elements)", 20f, 1f..48f, 1f, "Distance threshold in px") { snapEnabled } + @Tab(SnappingTab) val snapDistanceScreen by setting("Snap Distance (Screen Center)", 14f, 1f..48f, 1f) { snapEnabled } + @Tab(SnappingTab) val snapDistanceGrid by setting("Snap Distance (Grid)", 12f, 1f..48f, 1f) { snapEnabled } + @Tab(SnappingTab) val snapLineColor by setting("Snap Line Color", Color(255, 160, 0, 220)) { snapEnabled } // Sizing - val windowPaddingX by setting("Window Padding X", 8.0f, 0.0f..20.0f, 0.1f).group(Group.Sizing) - val windowPaddingY by setting("Window Padding Y", 8.0f, 0.0f..20.0f, 0.1f).group(Group.Sizing) - val windowMinSizeX by setting("Window Min Size X", 32.0f, 0.0f..100.0f, 1.0f).group(Group.Sizing) - val windowMinSizeY by setting("Window Min Size Y", 32.0f, 0.0f..100.0f, 1.0f).group(Group.Sizing) - val windowTitleAlignX by setting("Window Title Align X", 0.0f, 0.0f..1.0f, 0.01f).group(Group.Sizing) - val windowTitleAlignY by setting("Window Title Align Y", 0.5f, 0.0f..1.0f, 0.01f).group(Group.Sizing) - val framePaddingX by setting("Frame Padding X", 4.0f, 0.0f..20.0f, 0.1f).group(Group.Sizing) - val framePaddingY by setting("Frame Padding Y", 3.0f, 0.0f..20.0f, 0.1f).group(Group.Sizing) - val itemSpacingX by setting("Item Spacing X", 8.0f, 0.0f..20.0f, 0.1f).group(Group.Sizing) - val itemSpacingY by setting("Item Spacing Y", 4.0f, 0.0f..20.0f, 0.1f).group(Group.Sizing) - val itemInnerSpacingX by setting("Item Inner Spacing X", 4.0f, 0.0f..20.0f, 0.1f).group(Group.Sizing) - val itemInnerSpacingY by setting("Item Inner Spacing Y", 4.0f, 0.0f..20.0f, 0.1f).group(Group.Sizing) - val indentSpacing by setting("Indent Spacing", 21.0f, 0.0f..50.0f, 0.1f).group(Group.Sizing) - val scrollbarSize by setting("Scrollbar Size", 8.4f, 0.0f..30.0f, 0.1f).group(Group.Sizing) - val grabMinSize by setting("Grab Min Size", 10.0f, 0.0f..30.0f, 0.1f).group(Group.Sizing) - val windowBorderSize by setting("Window Border Size", 1.0f, 0.0f..5.0f, 0.1f).group(Group.Sizing) - val childBorderSize by setting("Child Border Size", 1.0f, 0.0f..5.0f, 0.1f).group(Group.Sizing) - val popupBorderSize by setting("Popup Border Size", 1.0f, 0.0f..5.0f, 0.1f).group(Group.Sizing) - val frameBorderSize by setting("Frame Border Size", 0.0f, 0.0f..5.0f, 0.1f).group(Group.Sizing) - val tabBorderSize by setting("Tab Border Size", 0.0f, 0.0f..5.0f, 0.1f).group(Group.Sizing) + @Tab(SizingTab) val windowPaddingX by setting("Window Padding X", 8.0f, 0.0f..20.0f, 0.1f) + @Tab(SizingTab) val windowPaddingY by setting("Window Padding Y", 8.0f, 0.0f..20.0f, 0.1f) + @Tab(SizingTab) val windowMinSizeX by setting("Window Min Size X", 32.0f, 0.0f..100.0f, 1.0f) + @Tab(SizingTab) val windowMinSizeY by setting("Window Min Size Y", 32.0f, 0.0f..100.0f, 1.0f) + @Tab(SizingTab) val windowTitleAlignX by setting("Window Title Align X", 0.0f, 0.0f..1.0f, 0.01f) + @Tab(SizingTab) val windowTitleAlignY by setting("Window Title Align Y", 0.5f, 0.0f..1.0f, 0.01f) + @Tab(SizingTab) val framePaddingX by setting("Frame Padding X", 4.0f, 0.0f..20.0f, 0.1f) + @Tab(SizingTab) val framePaddingY by setting("Frame Padding Y", 3.0f, 0.0f..20.0f, 0.1f) + @Tab(SizingTab) val itemSpacingX by setting("Item Spacing X", 8.0f, 0.0f..20.0f, 0.1f) + @Tab(SizingTab) val itemSpacingY by setting("Item Spacing Y", 4.0f, 0.0f..20.0f, 0.1f) + @Tab(SizingTab) val itemInnerSpacingX by setting("Item Inner Spacing X", 4.0f, 0.0f..20.0f, 0.1f) + @Tab(SizingTab) val itemInnerSpacingY by setting("Item Inner Spacing Y", 4.0f, 0.0f..20.0f, 0.1f) + @Tab(SizingTab) val indentSpacing by setting("Indent Spacing", 21.0f, 0.0f..50.0f, 0.1f) + @Tab(SizingTab) val scrollbarSize by setting("Scrollbar Size", 8.4f, 0.0f..30.0f, 0.1f) + @Tab(SizingTab) val grabMinSize by setting("Grab Min Size", 10.0f, 0.0f..30.0f, 0.1f) + @Tab(SizingTab) val windowBorderSize by setting("Window Border Size", 1.0f, 0.0f..5.0f, 0.1f) + @Tab(SizingTab) val childBorderSize by setting("Child Border Size", 1.0f, 0.0f..5.0f, 0.1f) + @Tab(SizingTab) val popupBorderSize by setting("Popup Border Size", 1.0f, 0.0f..5.0f, 0.1f) + @Tab(SizingTab) val frameBorderSize by setting("Frame Border Size", 0.0f, 0.0f..5.0f, 0.1f) + @Tab(SizingTab) val tabBorderSize by setting("Tab Border Size", 0.0f, 0.0f..5.0f, 0.1f) // Rounding - val windowRounding by setting("Window Rounding", 4.6f, 0.0f..12.0f, 0.1f).group(Group.Rounding) - val childRounding by setting("Child Rounding", 0.0f, 0.0f..12.0f, 0.1f).group(Group.Rounding) - val frameRounding by setting("Frame Rounding", 4.6f, 0.0f..12.0f, 0.1f).group(Group.Rounding) - val popupRounding by setting("Popup Rounding", 4.6f, 0.0f..12.0f, 0.1f).group(Group.Rounding) - val scrollbarRounding by setting("Scrollbar Rounding", 9.0f, 0.0f..12.0f, 0.1f).group(Group.Rounding) - val grabRounding by setting("Grab Rounding", 4.6f, 0.0f..12.0f, 0.1f).group(Group.Rounding) - val tabRounding by setting("Tab Rounding", 4.6f, 0.0f..12.0f, 0.1f).group(Group.Rounding) - val curveTessellationTol by setting("Curve Tessellation Tol", 1.25f, 0.1f..10.0f, 0.05f).group(Group.Rounding) + @Tab(RoundingTab) val windowRounding by setting("Window Rounding", 4.6f, 0.0f..12.0f, 0.1f) + @Tab(RoundingTab) val childRounding by setting("Child Rounding", 0.0f, 0.0f..12.0f, 0.1f) + @Tab(RoundingTab) val frameRounding by setting("Frame Rounding", 4.6f, 0.0f..12.0f, 0.1f) + @Tab(RoundingTab) val popupRounding by setting("Popup Rounding", 4.6f, 0.0f..12.0f, 0.1f) + @Tab(RoundingTab) val scrollbarRounding by setting("Scrollbar Rounding", 9.0f, 0.0f..12.0f, 0.1f) + @Tab(RoundingTab) val grabRounding by setting("Grab Rounding", 4.6f, 0.0f..12.0f, 0.1f) + @Tab(RoundingTab) val tabRounding by setting("Tab Rounding", 4.6f, 0.0f..12.0f, 0.1f) + @Tab(RoundingTab) val curveTessellationTol by setting("Curve Tessellation Tol", 1.25f, 0.1f..10.0f, 0.05f) // Font - val fontScale by setting("Font Scale", 1.0, 0.5..2.0, 0.1).group(Group.Font) + @Tab(FontTab) val fontScale by setting("Font Scale", 1.0, 0.5..2.0, 0.1) // Colors - val primaryColor by setting("Primary Color", Color(130, 200, 255)).group(Group.Colors) - val secondaryColor by setting("Secondary Color", Color(225, 130, 225)).group(Group.Colors) - - val shade by setting("Shade", true).group(Group.Colors) - val colorWidth by setting("Shade Width", 200.0, 10.0..1000.0, 10.0).group(Group.Colors) - val colorHeight by setting("Shade Height", 200.0, 10.0..1000.0, 10.0).group(Group.Colors) - val colorSpeed by setting("Color Speed", 1.0, 0.1..5.0, 0.1).group(Group.Colors) - val text by setting("Text", Color(255, 255, 255, 255)).group(Group.Colors) - val textDisabled by setting("Text Disabled", Color(128, 128, 128, 255)).group(Group.Colors) - val windowBg by setting("Window Background", Color(35, 0, 14, 240)).group(Group.Colors) - val childBg by setting("Child Background", Color(35, 0, 14, 240)).group(Group.Colors) - val popupBg by setting("Popup Background", Color(35, 0, 14, 240)).group(Group.Colors) - val border by setting("Border", Color(130, 12, 60, 240)).group(Group.Colors) - val borderShadow by setting("Border Shadow", Color(51, 0, 21, 240)).group(Group.Colors) - val frameBg by setting("Frame Background", Color(171, 32, 93, 102)).group(Group.Colors) - val frameBgHovered by setting("Frame Background Hovered", Color(214, 45, 119, 102)).group(Group.Colors) - val frameBgActive by setting("Frame Background Active", Color(255, 50, 140, 102)).group(Group.Colors) - val titleBg by setting("Title Background", Color(125, 0, 50, 240)).group(Group.Colors) - val titleBgActive by setting("Title Background Active", Color(162, 0, 68, 240)).group(Group.Colors) - val titleBgCollapsed by setting("Title Background Collapsed", Color(35, 0, 14, 240)).group(Group.Colors) - val menuBarBg by setting("MenuBar Background", Color(35, 0, 14, 240)).group(Group.Colors) - val scrollbarBg by setting("Scrollbar Background", Color(35, 0, 14, 240)).group(Group.Colors) - val scrollbarGrab by setting("Scrollbar Grab", Color(159, 30, 83, 240)).group(Group.Colors) - val scrollbarGrabHovered by setting("Scrollbar Grab Hovered", Color(198, 40, 105, 240)).group(Group.Colors) - val scrollbarGrabActive by setting("Scrollbar Grab Active", Color(235, 49, 126, 240)).group(Group.Colors) - val checkMark by setting("Check Mark", Color(255, 64, 148, 220)).group(Group.Colors) - val sliderGrab by setting("Slider Grab", Color(207, 46, 117, 200)).group(Group.Colors) - val sliderGrabActive by setting("Slider Grab Active", Color(241, 67, 143, 200)).group(Group.Colors) - val button by setting("Button", Color(171, 32, 93, 102)).group(Group.Colors) - val buttonHovered by setting("Button Hovered", Color(214, 45, 119, 102)).group(Group.Colors) - val buttonActive by setting("Button Active", Color(255, 50, 140, 102)).group(Group.Colors) - val header by setting("Header", Color(192, 30, 94, 115)).group(Group.Colors) - val headerHovered by setting("Header Hovered", Color(255, 59, 136, 115)).group(Group.Colors) - val headerActive by setting("Header Active", Color(202, 36, 101, 115)).group(Group.Colors) - val separator by setting("Separator", Color(107, 0, 47, 128)).group(Group.Colors) - val separatorHovered by setting("Separator Hovered", Color(146, 0, 64, 128)).group(Group.Colors) - val separatorActive by setting("Separator Active", Color(186, 0, 82, 128)).group(Group.Colors) - val resizeGrip by setting("Resize Grip", Color(214, 45, 119, 102)).group(Group.Colors) - val resizeGripHovered by setting("Resize Grip Hovered", Color(214, 45, 119, 102)).group(Group.Colors) - val resizeGripActive by setting("Resize Grip Active", Color(214, 45, 119, 102)).group(Group.Colors) - val tab by setting("Tab", Color(121, 21, 65, 140)).group(Group.Colors) - val tabHovered by setting("Tab Hovered", Color(169, 34, 94, 140)).group(Group.Colors) - val tabActive by setting("Tab Active", Color(209, 34, 112, 140)).group(Group.Colors) - val tabUnfocused by setting("Tab Unfocused", Color(121, 21, 65, 120)).group(Group.Colors) - val tabUnfocusedActive by setting("Tab Unfocused Active", Color(196, 36, 107, 120)).group(Group.Colors) - val dockingPreview by setting("Docking Preview", Color(208, 47, 117, 102)).group(Group.Colors) - val dockingEmptyBg by setting("Docking Empty Background", Color(35, 0, 14, 240)).group(Group.Colors) - val plotLines by setting("Plot Lines", Color(178, 36, 95, 240)).group(Group.Colors) - val plotLinesHovered by setting("Plot Lines Hovered", Color(209, 40, 110, 240)).group(Group.Colors) - val plotHistogram by setting("Plot Histogram", Color(192, 32, 91, 255)).group(Group.Colors) - val plotHistogramHovered by setting("Plot Histogram Hovered", Color(226, 38, 108, 255)).group(Group.Colors) - val tableHeaderBg by setting("Table Header Background", Color(75, 0, 31, 240)).group(Group.Colors) - val tableBorderStrong by setting("Table Border Strong", Color(88, 0, 36, 240)).group(Group.Colors) - val tableBorderLight by setting("Table Border Light", Color(67, 0, 28, 240)).group(Group.Colors) - val tableRowBg by setting("Table Row Background", Color(35, 0, 14, 240)).group(Group.Colors) - val tableRowBgAlt by setting("Table Row Background Alt", Color(242, 140, 182, 240)).group(Group.Colors) - val textSelectedBg by setting("Text Selected Background", Color(218, 54, 121, 240)).group(Group.Colors) - val dragDropTarget by setting("Drag Drop Target", Color(218, 54, 121, 240)).group(Group.Colors) - val navHighlight by setting("Nav Highlight", Color(218, 54, 121, 240)).group(Group.Colors) - val navWindowingHighlight by setting("Nav Windowing Highlight", Color(242, 140, 182, 240)).group(Group.Colors) - val navWindowingDimBg by setting("Nav Windowing Dim Background", Color(242, 140, 182, 240)).group(Group.Colors) - val modalWindowDimBg by setting("Modal Window Dim Background", Color(35, 0, 14, 90)).group(Group.Colors) + @Tab(ColorsTab) val primaryColor by setting("Primary Color", Color(130, 200, 255)) + @Tab(ColorsTab) val secondaryColor by setting("Secondary Color", Color(225, 130, 225)) + + @Tab(ColorsTab) val shade by setting("Shade", true) + @Tab(ColorsTab) val colorWidth by setting("Shade Width", 200.0, 10.0..1000.0, 10.0) + @Tab(ColorsTab) val colorHeight by setting("Shade Height", 200.0, 10.0..1000.0, 10.0) + @Tab(ColorsTab) val colorSpeed by setting("Color Speed", 1.0, 0.1..5.0, 0.1) + @Tab(ColorsTab) val text by setting("Text", Color(255, 255, 255, 255)) + @Tab(ColorsTab) val textDisabled by setting("Text Disabled", Color(128, 128, 128, 255)) + @Tab(ColorsTab) val windowBg by setting("Window Background", Color(35, 0, 14, 240)) + @Tab(ColorsTab) val childBg by setting("Child Background", Color(35, 0, 14, 240)) + @Tab(ColorsTab) val popupBg by setting("Popup Background", Color(35, 0, 14, 240)) + @Tab(ColorsTab) val border by setting("Border", Color(130, 12, 60, 240)) + @Tab(ColorsTab) val borderShadow by setting("Border Shadow", Color(51, 0, 21, 240)) + @Tab(ColorsTab) val frameBg by setting("Frame Background", Color(171, 32, 93, 102)) + @Tab(ColorsTab) val frameBgHovered by setting("Frame Background Hovered", Color(214, 45, 119, 102)) + @Tab(ColorsTab) val frameBgActive by setting("Frame Background Active", Color(255, 50, 140, 102)) + @Tab(ColorsTab) val titleBg by setting("Title Background", Color(125, 0, 50, 240)) + @Tab(ColorsTab) val titleBgActive by setting("Title Background Active", Color(162, 0, 68, 240)) + @Tab(ColorsTab) val titleBgCollapsed by setting("Title Background Collapsed", Color(35, 0, 14, 240)) + @Tab(ColorsTab) val menuBarBg by setting("MenuBar Background", Color(35, 0, 14, 240)) + @Tab(ColorsTab) val scrollbarBg by setting("Scrollbar Background", Color(35, 0, 14, 240)) + @Tab(ColorsTab) val scrollbarGrab by setting("Scrollbar Grab", Color(159, 30, 83, 240)) + @Tab(ColorsTab) val scrollbarGrabHovered by setting("Scrollbar Grab Hovered", Color(198, 40, 105, 240)) + @Tab(ColorsTab) val scrollbarGrabActive by setting("Scrollbar Grab Active", Color(235, 49, 126, 240)) + @Tab(ColorsTab) val checkMark by setting("Check Mark", Color(255, 64, 148, 220)) + @Tab(ColorsTab) val sliderGrab by setting("Slider Grab", Color(207, 46, 117, 200)) + @Tab(ColorsTab) val sliderGrabActive by setting("Slider Grab Active", Color(241, 67, 143, 200)) + @Tab(ColorsTab) val button by setting("Button", Color(171, 32, 93, 102)) + @Tab(ColorsTab) val buttonHovered by setting("Button Hovered", Color(214, 45, 119, 102)) + @Tab(ColorsTab) val buttonActive by setting("Button Active", Color(255, 50, 140, 102)) + @Tab(ColorsTab) val header by setting("Header", Color(192, 30, 94, 115)) + @Tab(ColorsTab) val headerHovered by setting("Header Hovered", Color(255, 59, 136, 115)) + @Tab(ColorsTab) val headerActive by setting("Header Active", Color(202, 36, 101, 115)) + @Tab(ColorsTab) val separator by setting("Separator", Color(107, 0, 47, 128)) + @Tab(ColorsTab) val separatorHovered by setting("Separator Hovered", Color(146, 0, 64, 128)) + @Tab(ColorsTab) val separatorActive by setting("Separator Active", Color(186, 0, 82, 128)) + @Tab(ColorsTab) val resizeGrip by setting("Resize Grip", Color(214, 45, 119, 102)) + @Tab(ColorsTab) val resizeGripHovered by setting("Resize Grip Hovered", Color(214, 45, 119, 102)) + @Tab(ColorsTab) val resizeGripActive by setting("Resize Grip Active", Color(214, 45, 119, 102)) + @Tab(ColorsTab) val tab by setting("Tab", Color(121, 21, 65, 140)) + @Tab(ColorsTab) val tabHovered by setting("Tab Hovered", Color(169, 34, 94, 140)) + @Tab(ColorsTab) val tabActive by setting("Tab Active", Color(209, 34, 112, 140)) + @Tab(ColorsTab) val tabUnfocused by setting("Tab Unfocused", Color(121, 21, 65, 120)) + @Tab(ColorsTab) val tabUnfocusedActive by setting("Tab Unfocused Active", Color(196, 36, 107, 120)) + @Tab(ColorsTab) val dockingPreview by setting("Docking Preview", Color(208, 47, 117, 102)) + @Tab(ColorsTab) val dockingEmptyBg by setting("Docking Empty Background", Color(35, 0, 14, 240)) + @Tab(ColorsTab) val plotLines by setting("Plot Lines", Color(178, 36, 95, 240)) + @Tab(ColorsTab) val plotLinesHovered by setting("Plot Lines Hovered", Color(209, 40, 110, 240)) + @Tab(ColorsTab) val plotHistogram by setting("Plot Histogram", Color(192, 32, 91, 255)) + @Tab(ColorsTab) val plotHistogramHovered by setting("Plot Histogram Hovered", Color(226, 38, 108, 255)) + @Tab(ColorsTab) val tableHeaderBg by setting("Table Header Background", Color(75, 0, 31, 240)) + @Tab(ColorsTab) val tableBorderStrong by setting("Table Border Strong", Color(88, 0, 36, 240)) + @Tab(ColorsTab) val tableBorderLight by setting("Table Border Light", Color(67, 0, 28, 240)) + @Tab(ColorsTab) val tableRowBg by setting("Table Row Background", Color(35, 0, 14, 240)) + @Tab(ColorsTab) val tableRowBgAlt by setting("Table Row Background Alt", Color(242, 140, 182, 240)) + @Tab(ColorsTab) val textSelectedBg by setting("Text Selected Background", Color(218, 54, 121, 240)) + @Tab(ColorsTab) val dragDropTarget by setting("Drag Drop Target", Color(218, 54, 121, 240)) + @Tab(ColorsTab) val navHighlight by setting("Nav Highlight", Color(218, 54, 121, 240)) + @Tab(ColorsTab) val navWindowingHighlight by setting("Nav Windowing Highlight", Color(242, 140, 182, 240)) + @Tab(ColorsTab) val navWindowingDimBg by setting("Nav Windowing Dim Background", Color(242, 140, 182, 240)) + @Tab(ColorsTab) val modalWindowDimBg by setting("Modal Window Dim Background", Color(35, 0, 14, 90)) init { listen { @@ -280,7 +279,7 @@ object ClickGuiLayout : Loadable, Config(GuiCategory) { } } - val tags = if (developerMode) shownTags + ModuleTag.DEBUG else shownTags + val tags = if (developerMode) shownTags + ModuleTag.Debug else shownTags if (tags.isEmpty()) return@buildLayout var nextX = 20f diff --git a/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt b/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt index 20c1d4fea..1afdaa825 100644 --- a/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt +++ b/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt @@ -39,26 +39,21 @@ import com.lambda.imgui.flag.ImGuiStyleVar import com.lambda.imgui.flag.ImGuiWindowFlags import com.lambda.module.HudModule import com.lambda.module.ModuleRegistry -import com.lambda.util.NamedEnum import java.awt.Color import kotlin.math.PI object HudGuiLayout : Loadable, Config(HudCategory) { override val name = "HUD" - enum class Group(override val displayName: String) : NamedEnum { - HudOutline("HUD Outline") - } - // HUD Outline - val hudOutlineCornerRadius by setting("HUD Corner Radius", 6.0f, 0.5f..24.0f, 0.5f).group(Group.HudOutline) - val hudOutlineHaloColor by setting("HUD Corner Halo Color", Color(140, 140, 140, 90)).group(Group.HudOutline) - val hudOutlineBorderColor by setting("HUD Corner Border Color", Color(190, 190, 190, 200)).group(Group.HudOutline) - val hudOutlineHaloThickness by setting("HUD Corner Halo Thickness", 3.0f, 1.0f..6.0f, 0.5f).group(Group.HudOutline) - val hudOutlineBorderThickness by setting("HUD Corner Border Thickness", 1.5f, 1.0f..4.0f, 0.5f).group(Group.HudOutline) - val hudOutlineCornerInflate by setting("HUD Corner Inflate", 1.0f, 0.0f..4.0f, 0.5f, "Extra radius for the halo arc").group(Group.HudOutline) - - const val DEFAULT_HUD_FLAGS = + val hudOutlineCornerRadius by setting("HUD Corner Radius", 6.0f, 0.5f..24.0f, 0.5f) + val hudOutlineHaloColor by setting("HUD Corner Halo Color", Color(140, 140, 140, 90)) + val hudOutlineBorderColor by setting("HUD Corner Border Color", Color(190, 190, 190, 200)) + val hudOutlineHaloThickness by setting("HUD Corner Halo Thickness", 3.0f, 1.0f..6.0f, 0.5f) + val hudOutlineBorderThickness by setting("HUD Corner Border Thickness", 1.5f, 1.0f..4.0f, 0.5f) + val hudOutlineCornerInflate by setting("HUD Corner Inflate", 1.0f, 0.0f..4.0f, 0.5f, "Extra radius for the halo arc") + + const val DefaultHudFlags = ImGuiWindowFlags.NoDecoration or ImGuiWindowFlags.NoBackground or ImGuiWindowFlags.AlwaysAutoResize or @@ -75,10 +70,10 @@ object HudGuiLayout : Loadable, Config(HudCategory) { var isShownInGUI = true var isLocked = false - private const val PI_F = PI.toFloat() - private const val HALF_PI_F = (0.5f * PI).toFloat() - private const val THREE_HALVES_PI_F = (1.5f * PI).toFloat() - private const val TWO_PI_F = (2f * PI).toFloat() + private const val PiF = PI.toFloat() + private const val HalfPiF = (0.5f * PI).toFloat() + private const val ThreeHalvesPiF = (1.5f * PI).toFloat() + private const val TwoPiF = (2f * PI).toFloat() init { listen { @@ -148,8 +143,8 @@ object HudGuiLayout : Loadable, Config(HudCategory) { val bg = hud.backgroundColor.value val hasBg = bg.alpha > 0 val baseFlags = if (hasBg) { - DEFAULT_HUD_FLAGS and ImGuiWindowFlags.NoBackground.inv() - } else DEFAULT_HUD_FLAGS + DefaultHudFlags and ImGuiWindowFlags.NoBackground.inv() + } else DefaultHudFlags var hudFlags = if (!ClickGuiLayout.open || isLocked) { baseFlags or ImGuiWindowFlags.NoMove } else baseFlags @@ -286,12 +281,12 @@ object HudGuiLayout : Loadable, Config(HudCategory) { } // TL: pi -> 1.5pi - strokeArc(tlCx, tlCy, PI_F, THREE_HALVES_PI_F) + strokeArc(tlCx, tlCy, PiF, ThreeHalvesPiF) // TR: 1.5pi -> 2pi - strokeArc(trCx, trCy, THREE_HALVES_PI_F, TWO_PI_F) + strokeArc(trCx, trCy, ThreeHalvesPiF, TwoPiF) // BR: 0 -> 0.5pi - strokeArc(brCx, brCy, 0f, HALF_PI_F) + strokeArc(brCx, brCy, 0f, HalfPiF) // BL: 0.5pi -> pi - strokeArc(blCx, blCy, HALF_PI_F, PI_F) + strokeArc(blCx, blCy, HalfPiF, PiF) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt index 6a6e8c1df..e25752c61 100644 --- a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt +++ b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt @@ -54,9 +54,9 @@ object QuickSearch { private var lastShiftPressTime = 0L private var lastShiftKeyCode = -1 - private const val DOUBLE_SHIFT_WINDOW_MS = 500L - private const val MAX_RESULTS = 50 - const val WINDOW_FLAGS = + private const val DoubleShiftWindowMs = 500L + private const val MaxResults = 50 + const val WindowFlags = ImGuiWindowFlags.AlwaysAutoResize or ImGuiWindowFlags.NoTitleBar or ImGuiWindowFlags.NoMove or @@ -146,7 +146,7 @@ object QuickSearch { ImGui.setNextWindowSize(maxW, 0f) ImGui.setNextWindowSizeConstraints(0f, 0f, maxW, maxH) - popupModal("QuickSearch", WINDOW_FLAGS) { + popupModal("QuickSearch", WindowFlags) { if (shouldFocus) { ImGui.setKeyboardFocusHere() shouldFocus = false @@ -195,9 +195,9 @@ object QuickSearch { private object SearchService { private data class RankedSearchResult(val result: SearchResult, val score: Int) - private const val MODULE_PRIORITY_BONUS = 300 - private const val HUD_MODULE_PRIORITY_BONUS = 270 - private const val COMMAND_PRIORITY_BONUS = 200 + private const val ModulePriorityBonus = 300 + private const val HudModulePriorityBonus = 270 + private const val CommandPriorityBonus = 200 /** * Calculates a relevance score for a query against a target string. @@ -245,8 +245,8 @@ object QuickSearch { if (bestScore > 0) { when(module) { - is HudModule -> RankedSearchResult(ModuleResult(module), bestScore + HUD_MODULE_PRIORITY_BONUS) - else -> RankedSearchResult(ModuleResult(module), bestScore + MODULE_PRIORITY_BONUS) + is HudModule -> RankedSearchResult(ModuleResult(module), bestScore + HudModulePriorityBonus) + else -> RankedSearchResult(ModuleResult(module), bestScore + ModulePriorityBonus) } } else null } @@ -257,13 +257,13 @@ object QuickSearch { val bestScore = max(nameScore, aliasScore) if (bestScore > 0) { - RankedSearchResult(CommandResult(command), bestScore + COMMAND_PRIORITY_BONUS) + RankedSearchResult(CommandResult(command), bestScore + CommandPriorityBonus) } else null } val settingResults = ConfigLoader.configCategories.flatMap { it.configs.flatMap { config -> - config.settingContainers + config.settingLayers .filter { setting -> setting.visibility() } .mapNotNull { setting -> val score = calculateScore(lowerCaseQuery, setting.name.lowercase(), lenient) @@ -286,14 +286,14 @@ object QuickSearch { return strictResults .sortedByDescending { it.score } .map { it.result } - .take(MAX_RESULTS) + .take(MaxResults) } // Second pass: if nothing was found, perform a more generous fuzzy search. return searchInternal(query, lenient = true) .sortedByDescending { it.score } .map { it.result } - .take(MAX_RESULTS) + .take(MaxResults) } } @@ -312,7 +312,7 @@ object QuickSearch { val currentTime = System.currentTimeMillis() if (lastShiftKeyCode == event.keyCode && - currentTime - lastShiftPressTime <= DOUBLE_SHIFT_WINDOW_MS + currentTime - lastShiftPressTime <= DoubleShiftWindowMs ) { open() lastShiftPressTime = 0L diff --git a/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt b/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt index 11362ba0b..0221fb3f9 100644 --- a/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt +++ b/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt @@ -51,7 +51,7 @@ object SettingsWidget { with(config.backgroundColor) { buildLayout() } } smallButton("Reset") { - resetContainers(config.settingContainers) + resetContainers(config.settingLayers) } } } @@ -86,25 +86,25 @@ object SettingsWidget { } } - if (!hasVisibleSettings(config.settingContainers)) return + if (!hasVisibleSettings(config.settingLayers)) return separator() - renderContainers(config.settingContainers, config.name) + renderContainers(config.settingLayers, config.name) } /** - * Recursively renders [Config.SettingContainer]s in order. - * - [Config.SettingContainer.Single]: renders the setting with visibility/disabled checks. - * - [Config.SettingContainer.Tab]: renders as ImGui tab bar with tab items. - * - [Config.SettingContainer.Group]: renders as a collapsible tree node with indent. + * Recursively renders [Config.SettingLayer]s in order. + * - [Config.SettingLayer.Single]: renders the setting with visibility/disabled checks. + * - [Config.SettingLayer.Tab]: renders as ImGui tab bar with tab items. + * - [Config.SettingLayer.Group]: renders as a collapsible tree node with indent. */ - private fun ImGuiBuilder.renderContainers(containers: List, idPrefix: String) { + private fun ImGuiBuilder.renderContainers(containers: List, idPrefix: String) { val runs = mutableListOf() containers.forEach { container -> - if (container is Config.SettingContainer.Tab) { + if (container is Config.SettingLayer.Tab) { val last = runs.lastOrNull() if (last is MutableList<*>) { @Suppress("UNCHECKED_CAST") - (last as MutableList).add(container) + (last as MutableList).add(container) } else { runs.add(mutableListOf(container)) } @@ -115,32 +115,32 @@ object SettingsWidget { runs.forEach { run -> when (run) { - is Config.SettingContainer.Single -> renderSetting(run.setting) - is Config.SettingContainer.Group -> { - if (hasVisibleSettings(run.settings)) { + is Config.SettingLayer.Single -> renderSetting(run.setting) + is Config.SettingLayer.Group -> { + if (hasVisibleSettings(run.layers)) { treeNode("${run.name}##$idPrefix-group-${run.name}") { - renderContainers(run.settings, "$idPrefix-${run.name}") + renderContainers(run.layers, "$idPrefix-${run.name}") } } } is List<*> -> { @Suppress("UNCHECKED_CAST") - renderTabBar(run as List, idPrefix) + renderTabBar(run as List, idPrefix) } } } } /** - * Renders a group of [Config.SettingContainer.Tab]s as a single ImGui tab bar. + * Renders a group of [Config.SettingLayer.Tab]s as a single ImGui tab bar. */ - private fun ImGuiBuilder.renderTabBar(tabs: List, idPrefix: String) { - val visibleTabs = tabs.filter { hasVisibleSettings(it.settings) } + private fun ImGuiBuilder.renderTabBar(tabs: List, idPrefix: String) { + val visibleTabs = tabs.filter { hasVisibleSettings(it.layers) } if (visibleTabs.isEmpty()) return tabBar("##$idPrefix-tabs", ImGuiTabBarFlags.FittingPolicyResizeDown) { visibleTabs.forEach { tab -> tabItem(tab.name) { - renderContainers(tab.settings, "$idPrefix-${tab.name}") + renderContainers(tab.layers, "$idPrefix-${tab.name}") } } } @@ -157,24 +157,24 @@ object SettingsWidget { } /** - * Checks if any [Config.SettingContainer] in the tree has a visible setting. + * Checks if any [Config.SettingLayer] in the tree has a visible setting. */ - private fun hasVisibleSettings(containers: List): Boolean = + private fun hasVisibleSettings(containers: List): Boolean = containers.any { container -> when (container) { - is Config.SettingContainer.Single -> container.setting.visibility() - is Config.SettingContainer.Multiple -> hasVisibleSettings(container.settings) + is Config.SettingLayer.Single -> container.setting.visibility() + is Config.SettingLayer.Multiple -> hasVisibleSettings(container.layers) } } /** * Recursively resets all settings in the container tree. */ - private fun resetContainers(containers: List) { + private fun resetContainers(containers: List) { containers.forEach { container -> when (container) { - is Config.SettingContainer.Single -> container.setting.reset(silent = true) - is Config.SettingContainer.Multiple -> resetContainers(container.settings) + is Config.SettingLayer.Single -> container.setting.reset(silent = true) + is Config.SettingLayer.Multiple -> resetContainers(container.layers) } } } diff --git a/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt b/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt index 46b8a3986..f795bf2b0 100644 --- a/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt @@ -24,7 +24,7 @@ import baritone.api.pathing.goals.Goal import com.lambda.config.automation.AutomationConfig import com.lambda.config.Config import com.lambda.config.categories.LambdaCategory -import com.lambda.config.groups.RotationSettings +import com.lambda.config.blocks.RotationSettings import com.lambda.context.Automated import com.lambda.util.BlockUtils.blockPos import com.lambda.util.NamedEnum diff --git a/src/main/kotlin/com/lambda/interaction/construction/StructureRegistry.kt b/src/main/kotlin/com/lambda/interaction/construction/StructureRegistry.kt index 77ce6dd8e..7a76210cf 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/StructureRegistry.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/StructureRegistry.kt @@ -17,7 +17,7 @@ package com.lambda.interaction.construction -import com.lambda.Lambda.LOG +import com.lambda.Lambda.Log import com.lambda.core.Loadable import com.lambda.util.FolderRegistry import com.lambda.util.FolderRegistry.structure @@ -189,7 +189,7 @@ object StructureRegistry : ConcurrentHashMap(), Loada .distinctBy { it.nameWithoutExtension } // Pick the first structure in the priority list nbt > litematica > schematica .forEach { struct -> runCatching { loadStructureByRelativePath(structure.relativize(struct)) } - .onFailure { LOG.warn("Unable to load the structure $struct: ${it.message}") } + .onFailure { Log.warn("Unable to load the structure $struct: ${it.message}") } } return "Loaded $size structure templates" diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt index 655a64765..234c6cd5f 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt @@ -24,7 +24,7 @@ import com.lambda.interaction.construction.simulation.SimDsl import com.lambda.interaction.construction.simulation.SimInfo import com.lambda.interaction.construction.simulation.result.results.GenericResult import com.lambda.interaction.construction.simulation.result.results.PreSimResult -import com.lambda.config.groups.BreakConfig.WhitelistMode +import com.lambda.config.blocks.BreakConfig.WhitelistMode import com.lambda.util.player.gamemode import com.lambda.util.world.WorldUtils.isLoaded import net.minecraft.block.OperatorBlock diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/context/BuildContext.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/context/BuildContext.kt index 30b26d55a..676d99b47 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/context/BuildContext.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/context/BuildContext.kt @@ -17,7 +17,7 @@ package com.lambda.interaction.construction.simulation.context -import com.lambda.config.groups.ActionConfig +import com.lambda.config.blocks.ActionConfig import com.lambda.context.Automated import com.lambda.interaction.construction.simulation.result.Drawable import com.lambda.interaction.managers.rotating.RotationRequest diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Contextual.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Contextual.kt index 4d98d6292..9f25ed94f 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Contextual.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Contextual.kt @@ -17,7 +17,7 @@ package com.lambda.interaction.construction.simulation.result -import com.lambda.config.groups.ActionConfig +import com.lambda.config.blocks.ActionConfig import com.lambda.interaction.construction.simulation.context.BreakContext import com.lambda.interaction.construction.simulation.context.BuildContext import com.lambda.interaction.construction.simulation.context.InteractContext diff --git a/src/main/kotlin/com/lambda/interaction/managers/PacketLimitHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/PacketLimitHandler.kt index 40526582e..abb85a09b 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/PacketLimitHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/PacketLimitHandler.kt @@ -17,7 +17,7 @@ package com.lambda.interaction.managers -import com.lambda.config.groups.BuildConfig +import com.lambda.config.blocks.BuildConfig import com.lambda.context.Automated import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakInfo.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakInfo.kt index acf6aaa6b..f9961c681 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakInfo.kt @@ -17,7 +17,7 @@ package com.lambda.interaction.managers.breaking -import com.lambda.config.groups.BreakConfig +import com.lambda.config.blocks.BreakConfig import com.lambda.context.SafeContext import com.lambda.interaction.construction.simulation.context.BreakContext import com.lambda.interaction.managers.ActionInfo diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt index 0ef507446..84e1d681c 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt @@ -17,7 +17,7 @@ package com.lambda.interaction.managers.breaking -import com.lambda.config.groups.BreakConfig +import com.lambda.config.blocks.BreakConfig import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext import com.lambda.event.events.ConnectionEvent @@ -37,8 +37,8 @@ import com.lambda.interaction.managers.ManagerUtils.isPosBlocked import com.lambda.interaction.managers.PacketLimitHandler import com.lambda.interaction.managers.PacketType import com.lambda.interaction.managers.PositionBlocking -import com.lambda.config.groups.BreakConfig.BreakConfirmationMode -import com.lambda.config.groups.BreakConfig.BreakMode +import com.lambda.config.blocks.BreakConfig.BreakConfirmationMode +import com.lambda.config.blocks.BreakConfig.BreakMode import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Primary import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Rebreak import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.RedundantSecondary diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt index 6d0b83a6c..863f88801 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt @@ -24,7 +24,7 @@ import com.lambda.event.events.WorldEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.construction.simulation.processing.ProcessorRegistry import com.lambda.interaction.managers.PostActionHandler -import com.lambda.config.groups.BreakConfig.BreakConfirmationMode +import com.lambda.config.blocks.BreakConfig.BreakConfirmationMode import com.lambda.interaction.managers.breaking.BreakManager.lastPosStarted import com.lambda.interaction.managers.breaking.BreakManager.matchesBlockItem import com.lambda.interaction.managers.breaking.RebreakHandler.rebreak diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakHandler.kt index 42c098ddb..e14d4fccd 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakHandler.kt @@ -17,7 +17,7 @@ package com.lambda.interaction.managers.breaking -import com.lambda.config.groups.BreakConfig +import com.lambda.config.blocks.BreakConfig import com.lambda.context.SafeContext import com.lambda.event.events.ConnectionEvent import com.lambda.event.events.TickEvent diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/SwapInfo.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/SwapInfo.kt index fd2c11b38..936973193 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/SwapInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/SwapInfo.kt @@ -18,7 +18,7 @@ package com.lambda.interaction.managers.breaking import com.lambda.config.automation.AutomationConfig.Companion.DEFAULT -import com.lambda.config.groups.BreakConfig +import com.lambda.config.blocks.BreakConfig import com.lambda.context.Automated import com.lambda.context.SafeContext import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Primary diff --git a/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt index 4dbbf21bd..5b8ed5be2 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt @@ -22,7 +22,7 @@ import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.Manager -import com.lambda.config.groups.HotbarConfig.SwapMode +import com.lambda.config.blocks.HotbarConfig.SwapMode import com.lambda.interaction.managers.hotbar.HotbarManager.activeRequest import com.lambda.interaction.managers.hotbar.HotbarManager.activeSlot import com.lambda.interaction.managers.hotbar.HotbarManager.checkResetSwap @@ -142,7 +142,7 @@ object HotbarManager : Manager( /** * Called after every [tickStage] closes. This method checks if the current [activeRequest] should be stopped. * This action is counted as another swap, so the conditions for a regular swap must be met. If the requests - * [com.lambda.config.groups.HotbarConfig.tickStageMask] does not contain the current tick stage, no actions can be performed. + * [com.lambda.config.blocks.HotbarConfig.tickStageMask] does not contain the current tick stage, no actions can be performed. * * @see net.minecraft.client.network.ClientPlayerInteractionManager.syncSelectedSlot */ diff --git a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractInfo.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractInfo.kt index b05b6c0a8..b4e813267 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractInfo.kt @@ -17,7 +17,7 @@ package com.lambda.interaction.managers.interacting -import com.lambda.config.groups.InteractConfig +import com.lambda.config.blocks.InteractConfig import com.lambda.context.SafeContext import com.lambda.interaction.construction.simulation.context.BuildContext import com.lambda.interaction.construction.simulation.context.InteractContext diff --git a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt index 29f156dc9..8fc257860 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt @@ -17,7 +17,7 @@ package com.lambda.interaction.managers.interacting -import com.lambda.config.groups.InteractConfig +import com.lambda.config.blocks.InteractConfig import com.lambda.context.Automated import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext @@ -35,7 +35,7 @@ import com.lambda.interaction.managers.PacketType import com.lambda.interaction.managers.PositionBlocking import com.lambda.interaction.managers.breaking.BreakManager import com.lambda.interaction.managers.hotbar.HotbarRequest -import com.lambda.config.groups.InteractConfig.AirPlaceMode +import com.lambda.config.blocks.InteractConfig.AirPlaceMode import com.lambda.interaction.managers.interacting.InteractManager.activeRequest import com.lambda.interaction.managers.interacting.InteractManager.maxInteractionsThisTick import com.lambda.interaction.managers.interacting.InteractManager.populateFrom diff --git a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt index 137ea9358..819528088 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt @@ -18,7 +18,7 @@ package com.lambda.interaction.managers.interacting import com.lambda.config.automation.AutomationConfig.Companion.DEFAULT -import com.lambda.config.groups.InteractConfig +import com.lambda.config.blocks.InteractConfig import com.lambda.event.events.WorldEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.PostActionHandler diff --git a/src/main/kotlin/com/lambda/interaction/material/StackSelection.kt b/src/main/kotlin/com/lambda/interaction/material/StackSelection.kt index bea27eca3..5391fb204 100644 --- a/src/main/kotlin/com/lambda/interaction/material/StackSelection.kt +++ b/src/main/kotlin/com/lambda/interaction/material/StackSelection.kt @@ -42,7 +42,7 @@ import kotlin.reflect.KClass class StackSelection { var selector: (ItemStack) -> Boolean = EVERYTHING var comparator: Comparator = NO_COMPARE - var count: Int = DEFAULT_AMOUNT + var count: Int = DefaultAmount var inShulkerBox: Boolean = false var item: Item? = null @@ -276,7 +276,7 @@ class StackSelection { @DslMarker annotation class StackSelectionDsl - const val DEFAULT_AMOUNT = 1 + const val DefaultAmount = 1 val FULL_SHULKERS: (ItemStack) -> Boolean = { stack -> stack.shulkerBoxContents.none { it.isEmpty } } val EMPTY_SHULKERS: (ItemStack) -> Boolean = { stack -> stack.shulkerBoxContents.all { it.isEmpty } } @@ -305,7 +305,7 @@ class StackSelection { @StackSelectionDsl fun selectStack( - count: Int = DEFAULT_AMOUNT, + count: Int = DefaultAmount, inShulkerBox: Boolean = false, sorter: Comparator = NO_COMPARE, block: StackSelection.() -> (ItemStack) -> Boolean = { EVERYTHING }, diff --git a/src/main/kotlin/com/lambda/module/Module.kt b/src/main/kotlin/com/lambda/module/Module.kt index add1cfb97..d402076df 100644 --- a/src/main/kotlin/com/lambda/module/Module.kt +++ b/src/main/kotlin/com/lambda/module/Module.kt @@ -61,7 +61,7 @@ import com.lambda.util.Nameable * If a module does not need to be activated by a key (like [ClickGui]), * the default [keybind] should not be set (using [KeyCode.Unbound]). * - * [Module]s are [Config]s with [settingContainers] (see [SettingCore] for all setting types). + * [Module]s are [Config]s with [settingLayers] (see [SettingCore] for all setting types). * Example: * ``` * private val foo by setting("Foo", true) diff --git a/src/main/kotlin/com/lambda/module/ModuleRegistry.kt b/src/main/kotlin/com/lambda/module/ModuleRegistry.kt index 256557ba7..79e840a52 100644 --- a/src/main/kotlin/com/lambda/module/ModuleRegistry.kt +++ b/src/main/kotlin/com/lambda/module/ModuleRegistry.kt @@ -29,5 +29,5 @@ object ModuleRegistry : Loadable { val moduleNameMap = modules.associateBy { it.name } override fun load() = - "Loaded ${modules.size} modules with ${modules.sumOf { it.settingContainers.size }} settings" + "Loaded ${modules.size} modules with ${modules.sumOf { it.settingLayers.size }} settings" } diff --git a/src/main/kotlin/com/lambda/module/hud/AccountName.kt b/src/main/kotlin/com/lambda/module/hud/AccountName.kt index 7b81bdaa3..8b6e70830 100644 --- a/src/main/kotlin/com/lambda/module/hud/AccountName.kt +++ b/src/main/kotlin/com/lambda/module/hud/AccountName.kt @@ -26,7 +26,7 @@ import com.lambda.threading.runSafe object AccountName : HudModule( name = "AccountName", description = "Displays the current accounts name", - tag = ModuleTag.HUD + tag = ModuleTag.Hud ) { override fun ImGuiBuilder.buildLayout() { runSafe { text(player.name.string) } diff --git a/src/main/kotlin/com/lambda/module/hud/Baritone.kt b/src/main/kotlin/com/lambda/module/hud/Baritone.kt index 2dc0d0771..4935b5579 100644 --- a/src/main/kotlin/com/lambda/module/hud/Baritone.kt +++ b/src/main/kotlin/com/lambda/module/hud/Baritone.kt @@ -27,7 +27,7 @@ import com.lambda.module.tag.ModuleTag object Baritone : HudModule( name = "Baritone", description = "Look inside of Baritones head", - tag = ModuleTag.HUD, + tag = ModuleTag.Hud, ) { override fun ImGuiBuilder.buildLayout() { if (!BaritoneHandler.isBaritoneLoaded) { diff --git a/src/main/kotlin/com/lambda/module/hud/Coordinates.kt b/src/main/kotlin/com/lambda/module/hud/Coordinates.kt index 0458b00aa..200287b86 100644 --- a/src/main/kotlin/com/lambda/module/hud/Coordinates.kt +++ b/src/main/kotlin/com/lambda/module/hud/Coordinates.kt @@ -17,15 +17,14 @@ package com.lambda.module.hud +import com.lambda.config.Tab import com.lambda.config.applyEdits -import com.lambda.config.groups.FormatterSettings +import com.lambda.config.blocks.FormatterSettings import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.module.HudModule -import com.lambda.module.hud.Coordinates.formatter import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe import com.lambda.util.FormattingUtils.format -import com.lambda.util.NamedEnum import com.lambda.util.extension.dimensionName import com.lambda.util.extension.isNether import com.lambda.util.math.Vec2d @@ -36,29 +35,18 @@ import com.lambda.util.math.overworldCoord object Coordinates : HudModule( name = "Coordinates", description = "Show your coordinates", - tag = ModuleTag.HUD, + tag = ModuleTag.Hud, ) { - enum class Group(override val displayName: String) : NamedEnum { - CurrentDimension("Current Dimension"), - OtherDimension("Other Dimension"), - } - private val showDimension by setting("Show Dimension Name", true) private val showBiome by setting("Show Biome Name", true) private val showCurrentDimensionOnly by setting("Show Current Dimension Only", true) - private const val CURRENT_DIMENSION_TAB = "Current Dimension" - @Tab(CURRENT_DIMENSION_TAB) private val formatter = settingBlock(FormatterSettings(this)) { - applyEdits { - ::timeFormat.edit { hide() } + private const val CurrentDimensionTab = "Current Dimension" + @Tab(CurrentDimensionTab) private val formatter = + settingBlock(FormatterSettings(this)) { + applyEdits { ::timeFormat.edit { hide() } } } - } - private val formatter = FormatterSettings(c = this, baseGroup = arrayOf(Group.CurrentDimension)).apply { - applyEdits { - ::timeFormat.edit { hide() } - } - } // private val otherFormatter = FormatterSettings(this, Page.OtherDimension).apply { // ::timeFormat.edit { hide() } // ::group.edit { defaultValue(FormatterConfig.TupleGrouping.SquareBrackets) } diff --git a/src/main/kotlin/com/lambda/module/hud/FPS.kt b/src/main/kotlin/com/lambda/module/hud/FPS.kt index 02a400ef1..075d5d735 100644 --- a/src/main/kotlin/com/lambda/module/hud/FPS.kt +++ b/src/main/kotlin/com/lambda/module/hud/FPS.kt @@ -29,7 +29,7 @@ import kotlin.time.Duration.Companion.seconds object FPS : HudModule( name = "FPS", description = "Displays your games frames per second", - tag = ModuleTag.HUD + tag = ModuleTag.Hud ) { val average by setting("Average", true) val updateDelay by setting("Update Delay", 50, 0..1000, 1, "Time between updating the fps value") diff --git a/src/main/kotlin/com/lambda/module/hud/ModuleList.kt b/src/main/kotlin/com/lambda/module/hud/ModuleList.kt index cd438fbc2..381ab2ab6 100644 --- a/src/main/kotlin/com/lambda/module/hud/ModuleList.kt +++ b/src/main/kotlin/com/lambda/module/hud/ModuleList.kt @@ -27,7 +27,7 @@ import java.awt.Color @Suppress("unused") object ModuleList : HudModule( name = "ModuleList", - tag = ModuleTag.HUD, + tag = ModuleTag.Hud, ) { val onlyBound by setting("Only Bound", false, "Only displays modules with a keybind") val showKeybind by setting("Show Keybind", true, "Display keybind next to a module") diff --git a/src/main/kotlin/com/lambda/module/hud/Rotation.kt b/src/main/kotlin/com/lambda/module/hud/Rotation.kt index fb39ebc05..45d1f972b 100644 --- a/src/main/kotlin/com/lambda/module/hud/Rotation.kt +++ b/src/main/kotlin/com/lambda/module/hud/Rotation.kt @@ -18,7 +18,7 @@ package com.lambda.module.hud import com.lambda.config.applyEdits -import com.lambda.config.groups.FormatterSettings +import com.lambda.config.blocks.FormatterSettings import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag @@ -29,7 +29,7 @@ import com.lambda.util.FormattingUtils.format object Rotation : HudModule( name = "Rotation", description = "Show your rotation", - tag = ModuleTag.HUD, + tag = ModuleTag.Hud, ) { private val formatter = FormatterSettings(c = this,).apply { applyEdits { diff --git a/src/main/kotlin/com/lambda/module/hud/Speedometer.kt b/src/main/kotlin/com/lambda/module/hud/Speedometer.kt index c120a834d..fe20b5f54 100644 --- a/src/main/kotlin/com/lambda/module/hud/Speedometer.kt +++ b/src/main/kotlin/com/lambda/module/hud/Speedometer.kt @@ -30,7 +30,7 @@ import net.minecraft.util.math.Vec3d object Speedometer : HudModule( name = "Speedometer", description = "Displays player speed", - tag = ModuleTag.HUD + tag = ModuleTag.Hud ) { var speedUnit by setting("Speed Unit", SpeedUnit.MetersPerSecond) var onlyHorizontal by setting("Horizontal Speed", false, description = "Only consider horizontal movement for speed calculation") diff --git a/src/main/kotlin/com/lambda/module/hud/TPS.kt b/src/main/kotlin/com/lambda/module/hud/TPS.kt index cd1b3022c..371cac486 100644 --- a/src/main/kotlin/com/lambda/module/hud/TPS.kt +++ b/src/main/kotlin/com/lambda/module/hud/TPS.kt @@ -29,7 +29,7 @@ import com.lambda.util.ServerTPSUtils.recentData object TPS : HudModule( name = "TPS", description = "Display the server's tick rate", - tag = ModuleTag.HUD, + tag = ModuleTag.Hud, ) { private val format by setting("Tick format", ServerTPSUtils.TickFormat.Tps) private val showGraph by setting("Show TPS Graph", false) diff --git a/src/main/kotlin/com/lambda/module/hud/TaskFlowHUD.kt b/src/main/kotlin/com/lambda/module/hud/TaskFlowHUD.kt index eb9b4a789..35ca07d03 100644 --- a/src/main/kotlin/com/lambda/module/hud/TaskFlowHUD.kt +++ b/src/main/kotlin/com/lambda/module/hud/TaskFlowHUD.kt @@ -25,7 +25,7 @@ import com.lambda.task.RootTask @Suppress("unused") object TaskFlowHUD : HudModule( name = "TaskFlowHud", - tag = ModuleTag.HUD, + tag = ModuleTag.Hud, ) { override fun ImGuiBuilder.buildLayout() { text(RootTask.toString()) diff --git a/src/main/kotlin/com/lambda/module/hud/Watermark.kt b/src/main/kotlin/com/lambda/module/hud/Watermark.kt index fa46da254..f58ca99b7 100644 --- a/src/main/kotlin/com/lambda/module/hud/Watermark.kt +++ b/src/main/kotlin/com/lambda/module/hud/Watermark.kt @@ -26,7 +26,7 @@ import com.lambda.module.tag.ModuleTag @Suppress("unused") object Watermark : HudModule( name = "Watermark", - tag = ModuleTag.HUD, + tag = ModuleTag.Hud, enabledByDefault = true, ) { private val texture = upload("textures/lambda.png") diff --git a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt index 91d72943a..4a023f34c 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt @@ -18,8 +18,8 @@ package com.lambda.module.modules.chat import com.lambda.config.Config -import com.lambda.config.groups.ReplaceConfig -import com.lambda.config.groups.ReplaceConfig.ActionStrategy +import com.lambda.config.blocks.ReplaceConfig +import com.lambda.config.blocks.ReplaceConfig.ActionStrategy import com.lambda.event.events.ChatEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.friend.FriendHandler @@ -43,7 +43,7 @@ import com.lambda.config.Group object AntiSpam : Module( name = "AntiSpam", description = "Keeps your chat clean", - tag = ModuleTag.CHAT, + tag = ModuleTag.Chat, ) { private val fancyChats by setting("Replace Fancy Chat", false) diff --git a/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt b/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt index 641d48e0e..88acad6f1 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt @@ -18,8 +18,8 @@ package com.lambda.module.modules.chat import com.lambda.config.applyEdits -import com.lambda.config.groups.FormatterConfig -import com.lambda.config.groups.FormatterSettings +import com.lambda.config.blocks.FormatterConfig +import com.lambda.config.blocks.FormatterSettings import com.lambda.event.events.ChatEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module @@ -40,18 +40,19 @@ import java.time.temporal.ChronoUnit object ChatTimestamp : Module( name = "ChatTimestamp", description = "Displays the time a message was sent next to it", - tag = ModuleTag.CHAT, + tag = ModuleTag.Chat, ) { private var color: Formatting by setting("Color", Formatting.GRAY) .onValueChange { from, to -> if (to.colorIndex !in 0..15) color = from } private val javaColor: Color get() = Color(color.colorValue!! and 16777215) - val formatter = settingBlock(FormatterSettings(this)) { - applyEdits { - hide(::localeEnum, ::sep, ::customSep, ::floatingPrecision) - editTyped(::timeFormat) { defaultValue(FormatterConfig.Time.IsoLocalTime) } + val formatter = + settingBlock(FormatterSettings(this)) { + applyEdits { + hide(::localeEnum, ::sep, ::customSep, ::floatingPrecision) + editTyped(::timeFormat) { defaultValue(FormatterConfig.Time.IsoLocalTime) } + } } - } private val currentTime get() = ZonedDateTime.of(LocalDateTime.now(), ZoneId.systemDefault()) diff --git a/src/main/kotlin/com/lambda/module/modules/chat/CustomChat.kt b/src/main/kotlin/com/lambda/module/modules/chat/CustomChat.kt index b55e6931d..454c8d60b 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/CustomChat.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/CustomChat.kt @@ -30,7 +30,7 @@ import com.lambda.util.NamedEnum object CustomChat : Module( name = "CustomChat", description = "Adds a custom ending to your message", - tag = ModuleTag.CHAT, + tag = ModuleTag.Chat, ) { private val decoration by setting("Decoration", Decoration.Separator) private val text by setting("Text", Text.Lambda) diff --git a/src/main/kotlin/com/lambda/module/modules/chat/FancyChat.kt b/src/main/kotlin/com/lambda/module/modules/chat/FancyChat.kt index 080657967..25dc0dda5 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/FancyChat.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/FancyChat.kt @@ -32,7 +32,7 @@ import com.lambda.util.ChatUtils.toUwu object FancyChat : Module( name = "FancyChat", description = "Makes messages you send - fancy", - tag = ModuleTag.CHAT, + tag = ModuleTag.Chat, ) { private val uwu by setting("uwu", false) private val leet by setting("1337", false) diff --git a/src/main/kotlin/com/lambda/module/modules/chat/FriendHighlight.kt b/src/main/kotlin/com/lambda/module/modules/chat/FriendHighlight.kt index 2065c74eb..748a84c1f 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/FriendHighlight.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/FriendHighlight.kt @@ -36,7 +36,7 @@ import java.awt.Color object FriendHighlight : Module( name = "FriendHighlight", description = "Highlights your friends names in chat", - tag = ModuleTag.CHAT, + tag = ModuleTag.Chat, ) { private var color: Formatting by setting("Color", Formatting.GREEN) .onValueChange { from, to -> if (to.colorIndex !in 0..15) color = from } diff --git a/src/main/kotlin/com/lambda/module/modules/client/AutoUpdater.kt b/src/main/kotlin/com/lambda/module/modules/client/AutoUpdater.kt index 839c2425a..ed465c5ab 100644 --- a/src/main/kotlin/com/lambda/module/modules/client/AutoUpdater.kt +++ b/src/main/kotlin/com/lambda/module/modules/client/AutoUpdater.kt @@ -40,7 +40,7 @@ import javax.xml.parsers.DocumentBuilderFactory object AutoUpdater : Module( name = "AutoUpdater", description = "Installs / uninstalls Lambda loader", - tag = ModuleTag.CLIENT, + tag = ModuleTag.Client, ) { private val debug by setting("Debug", false, "Enable debug logging") private val loaderBranch by setting("Loader Branch", Branch.Stable, "Select loader update branch") @@ -53,18 +53,18 @@ object AutoUpdater : Module( @JvmStatic var showUninstallModal = false private var firstLaunchStateInitialized = false - private const val MAVEN_URL = "https://maven.lambda-client.org" - private const val LOADER_RELEASES_META = "$MAVEN_URL/releases/com/lambda/lambda-loader/maven-metadata.xml" - private const val LOADER_SNAPSHOTS_META = "$MAVEN_URL/snapshots/com/lambda/lambda-loader/maven-metadata.xml" - private const val CLIENT_RELEASES_META = "$MAVEN_URL/releases/com/lambda/lambda/maven-metadata.xml" - private const val CLIENT_SNAPSHOTS_META = "$MAVEN_URL/snapshots/com/lambda/lambda/maven-metadata.xml" + private const val MavenUrl = "https://maven.lambda-client.org" + private const val LoaderReleasesMeta = "$MavenUrl/releases/com/lambda/lambda-loader/maven-metadata.xml" + private const val LoaderSnapshotsMeta = "$MavenUrl/snapshots/com/lambda/lambda-loader/maven-metadata.xml" + private const val ClientReleasesMeta = "$MavenUrl/releases/com/lambda/lambda/maven-metadata.xml" + private const val ClientSnapshotsMeta = "$MavenUrl/snapshots/com/lambda/lambda/maven-metadata.xml" private enum class Branch { Stable, Snapshot } - const val WINDOW_FLAGS = + const val WindowFlags = ImGuiWindowFlags.AlwaysAutoResize or ImGuiWindowFlags.NoMove or ImGuiWindowFlags.NoResize or @@ -91,7 +91,7 @@ object AutoUpdater : Module( if (mc.currentScreen !is LambdaScreen) return@listen ImGui.openPopup("Loader Installation Wizard") - popupModal("Loader Installation Wizard", WINDOW_FLAGS) { + popupModal("Loader Installation Wizard", WindowFlags) { renderLoaderInstallExplanation() val buttonWidth = (ImGui.getContentRegionAvailX() - ImGui.getStyle().itemSpacing.x) / 2f @@ -116,7 +116,7 @@ object AutoUpdater : Module( if (showInstallModal) { ImGui.openPopup("Loader Installation Wizard") - popupModal("Loader Installation Wizard", WINDOW_FLAGS) { + popupModal("Loader Installation Wizard", WindowFlags) { renderLoaderInstallExplanation() val buttonWidth = (ImGui.getContentRegionAvailX() - ImGui.getStyle().itemSpacing.x) / 2f @@ -139,7 +139,7 @@ object AutoUpdater : Module( if (showUninstallModal) { ImGui.openPopup("Uninstall Loader") - popupModal("Uninstall Loader", WINDOW_FLAGS) { + popupModal("Uninstall Loader", WindowFlags) { text("Do you want to uninstall Lambda Loader?") separator() text("This will close the client automatically once the uninstall is finished.") @@ -229,22 +229,22 @@ object AutoUpdater : Module( when (branch) { Branch.Stable -> { - val xml = URI(LOADER_RELEASES_META).toURL().readText() + val xml = URI(LoaderReleasesMeta).toURL().readText() version = parseLatestVersion(xml, null) - baseUrl = "$MAVEN_URL/releases" + baseUrl = "$MavenUrl/releases" } Branch.Snapshot -> { - val xml = URI(LOADER_SNAPSHOTS_META).toURL().readText() + val xml = URI(LoaderSnapshotsMeta).toURL().readText() version = parseLatestVersion(xml, null) - baseUrl = "$MAVEN_URL/snapshots" + baseUrl = "$MavenUrl/snapshots" } } if (version == null && branch == Branch.Stable) { warn("No stable loader found, falling back to snapshot") - val xml = URI(LOADER_SNAPSHOTS_META).toURL().readText() + val xml = URI(LoaderSnapshotsMeta).toURL().readText() version = parseLatestVersion(xml, null) - baseUrl = "$MAVEN_URL/snapshots" + baseUrl = "$MavenUrl/snapshots" } if (version == null) { @@ -281,22 +281,22 @@ object AutoUpdater : Module( when (branch) { Branch.Stable -> { - val xml = URI(CLIENT_RELEASES_META).toURL().readText() + val xml = URI(ClientReleasesMeta).toURL().readText() version = parseLatestVersion(xml, mcVersion) - baseUrl = "$MAVEN_URL/releases" + baseUrl = "$MavenUrl/releases" } Branch.Snapshot -> { - val xml = URI(CLIENT_SNAPSHOTS_META).toURL().readText() + val xml = URI(ClientSnapshotsMeta).toURL().readText() version = parseLatestVersion(xml, mcVersion) - baseUrl = "$MAVEN_URL/snapshots" + baseUrl = "$MavenUrl/snapshots" } } if (version == null && branch == Branch.Stable) { warn("No stable client found for MC $mcVersion, falling back to snapshot") - val xml = URI(CLIENT_SNAPSHOTS_META).toURL().readText() + val xml = URI(ClientSnapshotsMeta).toURL().readText() version = parseLatestVersion(xml, mcVersion) - baseUrl = "$MAVEN_URL/snapshots" + baseUrl = "$MavenUrl/snapshots" } if (version == null) { diff --git a/src/main/kotlin/com/lambda/module/modules/client/Capes.kt b/src/main/kotlin/com/lambda/module/modules/client/Capes.kt index e1e42039f..7cc11902f 100644 --- a/src/main/kotlin/com/lambda/module/modules/client/Capes.kt +++ b/src/main/kotlin/com/lambda/module/modules/client/Capes.kt @@ -23,6 +23,6 @@ import com.lambda.module.tag.ModuleTag object Capes : Module( name = "Capes", description = "Display custom capes", - tag = ModuleTag.CLIENT, + tag = ModuleTag.Client, enabledByDefault = true, ) diff --git a/src/main/kotlin/com/lambda/module/modules/client/Client.kt b/src/main/kotlin/com/lambda/module/modules/client/Client.kt index 10c135b25..c8adb6102 100644 --- a/src/main/kotlin/com/lambda/module/modules/client/Client.kt +++ b/src/main/kotlin/com/lambda/module/modules/client/Client.kt @@ -28,26 +28,26 @@ import java.awt.Color object Client : Module( name = "Client", description = "Global settings for Lambda", - tag = ModuleTag.CLIENT, + tag = ModuleTag.Client, enabledByDefault = true ) { - private const val GENERAL_TAB = "General" - private const val DEBUG_TAB = "Debug" - - private const val RENDERING_GROUP = "Rendering" - - @Tab(GENERAL_TAB) val clientSounds by setting("Client Sounds", true, "Plays sounds when certain actions are performed with lambda. Toggling modules, for example") - @Tab(GENERAL_TAB) val buildTaskRenders by setting("Build Task Renders", false, "Displays renders from some build sim results generated from the build task") - @Tab(GENERAL_TAB) val avoidInventoryDesync by setting("Avoid Inventory Desync", true, "Cancels incoming inventory update packets if they match previous actions") - @Tab(GENERAL_TAB) val desyncTimeout by setting("Desync Timeout", 30, 1..30, 1, unit = " ticks", description = "Time to store previous inventory actions before dropping the cache") { avoidInventoryDesync } - @Tab(GENERAL_TAB) val scanShrinkFactor by setting("Scan Shrink Factor", 0.001, 0.0..1.0, 0.001, "How much to shrink block scans from the edges to avoid flagging anticheats") - @Tab(GENERAL_TAB) @Group(RENDERING_GROUP) val chunkUploadsPerTick by setting("Chunk Uploads", 16, 1..256, 1, unit = " chunks/tick") - @Tab(GENERAL_TAB) @Group(RENDERING_GROUP) val chunkRebuildsPerTick by setting("Chunk Rebuilds", 64, 1..256, 1, unit = " chunks/tick") - @Tab(GENERAL_TAB) val highlightColor by setting("Text Highlight Color", Color(214, 55, 87), "Base text highlight color") - - @Tab(DEBUG_TAB) val showAllEntries by setting("Show All Entries", false, "Show all entries in the task tree") - @Tab(DEBUG_TAB) val ignoreItemDropWarnings by setting("Ignore Drop Warnings", false, "Hides the item drop warnings from the break manager") - @Tab(DEBUG_TAB) val verboseDebug by setting("Verbose Debug", false, "Prints more, and more detailed, debug logs") + private const val GeneralTab = "General" + private const val DebugTab = "Debug" + + private const val RenderingGroup = "Rendering" + + @Tab(GeneralTab) val clientSounds by setting("Client Sounds", true, "Plays sounds when certain actions are performed with lambda. Toggling modules, for example") + @Tab(GeneralTab) val buildTaskRenders by setting("Build Task Renders", false, "Displays renders from some build sim results generated from the build task") + @Tab(GeneralTab) val avoidInventoryDesync by setting("Avoid Inventory Desync", true, "Cancels incoming inventory update packets if they match previous actions") + @Tab(GeneralTab) val desyncTimeout by setting("Desync Timeout", 30, 1..30, 1, unit = " ticks", description = "Time to store previous inventory actions before dropping the cache") { avoidInventoryDesync } + @Tab(GeneralTab) val scanShrinkFactor by setting("Scan Shrink Factor", 0.001, 0.0..1.0, 0.001, "How much to shrink block scans from the edges to avoid flagging anticheats") + @Tab(GeneralTab) @Group(RenderingGroup) val chunkUploadsPerTick by setting("Chunk Uploads", 16, 1..256, 1, unit = " chunks/tick") + @Tab(GeneralTab) @Group(RenderingGroup) val chunkRebuildsPerTick by setting("Chunk Rebuilds", 64, 1..256, 1, unit = " chunks/tick") + @Tab(GeneralTab) val highlightColor by setting("Text Highlight Color", Color(214, 55, 87), "Base text highlight color") + + @Tab(DebugTab) val showAllEntries by setting("Show All Entries", false, "Show all entries in the task tree") + @Tab(DebugTab) val ignoreItemDropWarnings by setting("Ignore Drop Warnings", false, "Hides the item drop warnings from the break manager") + @Tab(DebugTab) val verboseDebug by setting("Verbose Debug", false, "Prints more, and more detailed, debug logs") @Volatile var drawables = listOf() diff --git a/src/main/kotlin/com/lambda/module/modules/client/Discord.kt b/src/main/kotlin/com/lambda/module/modules/client/Discord.kt index 7858e254f..fb74da1e4 100644 --- a/src/main/kotlin/com/lambda/module/modules/client/Discord.kt +++ b/src/main/kotlin/com/lambda/module/modules/client/Discord.kt @@ -18,7 +18,7 @@ package com.lambda.module.modules.client import com.lambda.Lambda -import com.lambda.Lambda.LOG +import com.lambda.Lambda.Log import com.lambda.context.SafeContext import com.lambda.event.EventFlow import com.lambda.event.events.TickEvent @@ -45,7 +45,7 @@ import java.util.concurrent.atomic.AtomicBoolean object Discord : Module( name = "Discord", description = "Discord Rich Presence configuration", - tag = ModuleTag.CLIENT, + tag = ModuleTag.Client, enabledByDefault = true, ) { private val delay by setting("Update Delay", 5000L, 5000L..30000L, 100L, unit = "ms") @@ -56,7 +56,7 @@ object Discord : Module( private val line2Right by setting("Line 2 Right", LineInfo.Fps) val rpc by lazy { - KDiscordIPC(Lambda.APP_ID, scope = EventFlow.lambdaScope) + KDiscordIPC(Lambda.AppId, scope = EventFlow.lambdaScope) } var connecting = AtomicBoolean(false) @@ -95,7 +95,7 @@ object Discord : Module( discordAuth = auth } .onFailure { - LOG.error(it) + Log.error(it) warn("Failed to link your discord account") } return true @@ -118,7 +118,7 @@ object Discord : Module( details = "${line1Left.value(this@update)} | ${line1Right.value(this@update)}".take(128) state = "${line2Left.value(this@update)} | ${line2Right.value(this@update)}".take(128) - largeImage("lambda", Lambda.VERSION) + largeImage("lambda", Lambda.Version) smallImage("https://mc-heads.net/avatar/${mc.gameProfile.id}/nohelm", mc.gameProfile.name) //button("Download", "https://github.com/lambda-client/lambda") @@ -127,7 +127,7 @@ object Discord : Module( } private enum class LineInfo(val value: SafeContext.() -> String) : Nameable { - Version({ Lambda.VERSION }), + Version({ Lambda.Version }), World({ worldName }), Username({ mc.session.username }), Health({ "${player.fullHealth} HP" }), diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt index 9018c60a6..49a5a8e1e 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt @@ -44,7 +44,7 @@ import net.minecraft.screen.slot.Slot object AutoArmor : Module( name = "AutoArmor", description = "Automatically equips armor", - tag = ModuleTag.COMBAT + tag = ModuleTag.Combat ) { private var elytraPriority by setting("Elytra Priority", true, "Prioritizes elytra's over other armor pieces in the chest slot") private val toggleElytraPriority by setting("Toggle Elytra Priority", Bind.EMPTY) diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoDisconnect.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoDisconnect.kt index e20318171..e51c2d15c 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoDisconnect.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoDisconnect.kt @@ -54,7 +54,7 @@ import java.awt.Color object AutoDisconnect : Module( name = "AutoDisconnect", description = "Automatically disconnects when in danger or on low health", - tag = ModuleTag.COMBAT, + tag = ModuleTag.Combat, ) { private val health by setting("Health", true, "Disconnect from the server when health is below the set limit.") private val minimumHealth by setting("Min Health", 10, 1..36, 1, "Set the minimum health threshold for disconnection.", unit = " half-hearts") { health } diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt index f19e6c50b..437d96828 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt @@ -40,7 +40,7 @@ import net.minecraft.item.Items object AutoTotem : Module( name = "AutoTotem", description = "Swaps the your off-hand item to a totem", - tag = ModuleTag.COMBAT, + tag = ModuleTag.Combat, ) { private val always by setting("Always", true, "Always attempt to keep a totem in offhand") private val ignoreWhenHolding by setting("Ignore When Holding", false, "Ignore swapping to offhand when already holding a totem") diff --git a/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt b/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt index a4c848b0d..ef42742c2 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/Criticals.kt @@ -40,7 +40,7 @@ import net.minecraft.util.math.Direction object Criticals : Module( name = "Criticals", description = "Forces your hits to be critical", - tag = ModuleTag.COMBAT, + tag = ModuleTag.Combat, ) { enum class Mode { Grim diff --git a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt index 4b2711f4c..bf481c77e 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt @@ -20,7 +20,7 @@ package com.lambda.module.modules.combat import com.lambda.config.Tab import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig -import com.lambda.config.groups.TargetingSettings +import com.lambda.config.blocks.TargetingSettings import com.lambda.context.SafeContext import com.lambda.event.events.EntityEvent import com.lambda.event.events.TickEvent @@ -76,43 +76,43 @@ import kotlin.time.Duration.Companion.milliseconds object CrystalAura : Module( name = "CrystalAura", description = "Automatically attacks entities with crystals", - tag = ModuleTag.COMBAT, + tag = ModuleTag.Combat, ) { - private const val GENERAL_TAB = "General" - private const val PLACEMENT_TAB = "Placement" - private const val EXPLODING_TAB = "Exploding" - private const val PREDICTION_TAB = "Prediction" - private const val TARGETING_TAB = "Targeting" - - @Tab(GENERAL_TAB) private val rotate by setting("Rotate", true) - @Tab(GENERAL_TAB) private val updateMode by setting("Update Mode", UpdateMode.Async) - @Tab(GENERAL_TAB) private val updateDelaySetting by setting("Update Delay", 25L, 5L..200L, 5L, unit = " ms") { updateMode == UpdateMode.Async } - @Tab(GENERAL_TAB) private val maxUpdatesPerFrame by setting("Max Updates Per Frame", 5, 1..20, 1) { updateMode == UpdateMode.Async } - @Tab(GENERAL_TAB) private val updateDelay get() = if (updateMode == UpdateMode.Async) updateDelaySetting else 0L - @Tab(GENERAL_TAB) private val debug by setting("Debug", false) - - @Tab(PLACEMENT_TAB) private val placeRange by setting("Place Range", 4.6, 1.0..7.0, 0.1, "Range to place crystals", " blocks") - @Tab(PLACEMENT_TAB) private val placeDelay by setting("Place Delay", 50L, 0L..1000L, 1L, "Delay between placement attempts", " ms") - @Tab(PLACEMENT_TAB) private val swap by setting("Swap", true, "Swaps to crystals") - @Tab(PLACEMENT_TAB) private val swapHand by setting("Swap Hand", Hand.MAIN_HAND, "Which hand to swap the crystal to") { swap } - @Tab(PLACEMENT_TAB) private val priorityMode by setting("Crystal Priority", Priority.Damage) - @Tab(PLACEMENT_TAB) private val minDamageAdvantage by setting("Min Damage Advantage", 4.0, 1.0..10.0, 0.5) { priorityMode == Priority.Advantage } - @Tab(PLACEMENT_TAB) private val minTargetDamage by setting("Min Target Damage", 8.0, 0.0..20.0, 0.5, "Minimum target damage to use crystals") - @Tab(PLACEMENT_TAB) private val maxSelfDamage by setting("Max Self Damage", 8.0, 0.0..36.0, 0.5, "Maximum self damage to use crystals") - @Tab(PLACEMENT_TAB) private val minPlaceHealth by setting("Min Place Health", 5.0, 0.0..36.0, 0.5, "Minimum player health to place crystals") - @Tab(PLACEMENT_TAB) private val preventDeath by setting("Prevent Death", true, "Prevent death by crystal") - @Tab(PLACEMENT_TAB) private val oldPlace by setting("1.12 Placement", false) - - @Tab(EXPLODING_TAB) private val explodeRange by setting("Explode Range", 3.0, 1.0..7.0, 0.1, "Range to explode crystals", " blocks") - @Tab(EXPLODING_TAB) private val explodeDelay by setting("Explode Delay", 10L, 0L..1000L, 1L, "Delay between explosion attempts", " ms") - - @Tab(PREDICTION_TAB) private val prediction by setting("Prediction", PredictionMode.None) - @Tab(PREDICTION_TAB) private val packetPredictions by setting("Packet Predictions", 1, 0..20, 1) { prediction.onPacket } - @Tab(PREDICTION_TAB) private val placePostPause by setting("Place Post Pause", true) { prediction.onPacket } - @Tab(PREDICTION_TAB) private val placePredictions by setting("Place Predictions", 4, 1..20, 1) { prediction.onPlace } - @Tab(PREDICTION_TAB) private val packetLifetime by setting("Packet Lifetime", 500L, 50L..1000L) { prediction.onPlace } - - @Tab(PREDICTION_TAB) private val targetingSettings = settingBlock(TargetingSettings.CombatSettings(this, 10.0)) + private const val GeneralTab = "General" + private const val PlacementTab = "Placement" + private const val ExplodingTab = "Exploding" + private const val PredictionTab = "Prediction" + private const val TargetingTab = "Targeting" + + @Tab(GeneralTab) private val rotate by setting("Rotate", true) + @Tab(GeneralTab) private val updateMode by setting("Update Mode", UpdateMode.Async) + @Tab(GeneralTab) private val updateDelaySetting by setting("Update Delay", 25L, 5L..200L, 5L, unit = " ms") { updateMode == UpdateMode.Async } + @Tab(GeneralTab) private val maxUpdatesPerFrame by setting("Max Updates Per Frame", 5, 1..20, 1) { updateMode == UpdateMode.Async } + @Tab(GeneralTab) private val updateDelay get() = if (updateMode == UpdateMode.Async) updateDelaySetting else 0L + @Tab(GeneralTab) private val debug by setting("Debug", false) + + @Tab(PlacementTab) private val placeRange by setting("Place Range", 4.6, 1.0..7.0, 0.1, "Range to place crystals", " blocks") + @Tab(PlacementTab) private val placeDelay by setting("Place Delay", 50L, 0L..1000L, 1L, "Delay between placement attempts", " ms") + @Tab(PlacementTab) private val swap by setting("Swap", true, "Swaps to crystals") + @Tab(PlacementTab) private val swapHand by setting("Swap Hand", Hand.MAIN_HAND, "Which hand to swap the crystal to") { swap } + @Tab(PlacementTab) private val priorityMode by setting("Crystal Priority", Priority.Damage) + @Tab(PlacementTab) private val minDamageAdvantage by setting("Min Damage Advantage", 4.0, 1.0..10.0, 0.5) { priorityMode == Priority.Advantage } + @Tab(PlacementTab) private val minTargetDamage by setting("Min Target Damage", 8.0, 0.0..20.0, 0.5, "Minimum target damage to use crystals") + @Tab(PlacementTab) private val maxSelfDamage by setting("Max Self Damage", 8.0, 0.0..36.0, 0.5, "Maximum self damage to use crystals") + @Tab(PlacementTab) private val minPlaceHealth by setting("Min Place Health", 5.0, 0.0..36.0, 0.5, "Minimum player health to place crystals") + @Tab(PlacementTab) private val preventDeath by setting("Prevent Death", true, "Prevent death by crystal") + @Tab(PlacementTab) private val oldPlace by setting("1.12 Placement", false) + + @Tab(ExplodingTab) private val explodeRange by setting("Explode Range", 3.0, 1.0..7.0, 0.1, "Range to explode crystals", " blocks") + @Tab(ExplodingTab) private val explodeDelay by setting("Explode Delay", 10L, 0L..1000L, 1L, "Delay between explosion attempts", " ms") + + @Tab(PredictionTab) private val prediction by setting("Prediction", PredictionMode.None) + @Tab(PredictionTab) private val packetPredictions by setting("Packet Predictions", 1, 0..20, 1) { prediction.onPacket } + @Tab(PredictionTab) private val placePostPause by setting("Place Post Pause", true) { prediction.onPacket } + @Tab(PredictionTab) private val placePredictions by setting("Place Predictions", 4, 1..20, 1) { prediction.onPlace } + @Tab(PredictionTab) private val packetLifetime by setting("Packet Lifetime", 500L, 50L..1000L) { prediction.onPlace } + + @Tab(PredictionTab) private val targetingSettings = settingBlock(TargetingSettings.CombatSettings(this, 10.0)) private val blueprint = mutableMapOf() private var activeOpportunity: Opportunity? = null diff --git a/src/main/kotlin/com/lambda/module/modules/combat/FakePlayer.kt b/src/main/kotlin/com/lambda/module/modules/combat/FakePlayer.kt index cdfc97aa9..fe88ac343 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/FakePlayer.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/FakePlayer.kt @@ -41,7 +41,7 @@ import kotlin.time.Duration.Companion.seconds object FakePlayer : Module( name = "FakePlayer", description = "Spawns a fake player", - tag = ModuleTag.COMBAT, + tag = ModuleTag.Combat, ) { private val playerName by setting("Name", "Steve") diff --git a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt index 938c729b5..b25d462ff 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt @@ -20,7 +20,7 @@ package com.lambda.module.modules.combat import com.lambda.config.Tab import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig -import com.lambda.config.groups.TargetingSettings +import com.lambda.config.blocks.TargetingSettings import com.lambda.context.SafeContext import com.lambda.event.events.InventoryEvent import com.lambda.event.events.TickEvent @@ -46,21 +46,21 @@ import net.minecraft.world.GameMode object KillAura : Module( name = "KillAura", description = "Attacks entities", - tag = ModuleTag.COMBAT, + tag = ModuleTag.Combat, ) { - private const val GENERAL_TAB = "General" - private const val TARGETING_TAB = "Targeting" - - @Tab(GENERAL_TAB) private val rotate by setting("Rotate", true) - @Tab(GENERAL_TAB) private val swap by setting("Swap", true, "Swap to the item with the highest damage") - @Tab(GENERAL_TAB) private val disableWhileGliding by setting("Disable While Gliding", false, "Disables when gliding with an elytra") - @Tab(GENERAL_TAB) private val damageMode by setting("Damage Mode", DamageMode.DPS) - @Tab(GENERAL_TAB) private val attackMode by setting("Attack Mode", AttackMode.Cooldown) - @Tab(GENERAL_TAB) private val cooldownShrink by setting("Cooldown Offset", 0, 0..5, 1) { attackMode == AttackMode.Cooldown } - @Tab(GENERAL_TAB) private val hitDelay1 by setting("Hit Delay 1", 2.0, 0.0..20.0, 1.0) { attackMode == AttackMode.Delay } - @Tab(GENERAL_TAB) private val hitDelay2 by setting("Hit Delay 2", 6.0, 0.0..20.0, 1.0) { attackMode == AttackMode.Delay } - - @Tab(TARGETING_TAB) private val targetingSettings = settingBlock(TargetingSettings.CombatSettings(this)) + private const val GeneralTab = "General" + private const val TargetingTab = "Targeting" + + @Tab(GeneralTab) private val rotate by setting("Rotate", true) + @Tab(GeneralTab) private val swap by setting("Swap", true, "Swap to the item with the highest damage") + @Tab(GeneralTab) private val disableWhileGliding by setting("Disable While Gliding", false, "Disables when gliding with an elytra") + @Tab(GeneralTab) private val damageMode by setting("Damage Mode", DamageMode.DPS) + @Tab(GeneralTab) private val attackMode by setting("Attack Mode", AttackMode.Cooldown) + @Tab(GeneralTab) private val cooldownShrink by setting("Cooldown Offset", 0, 0..5, 1) { attackMode == AttackMode.Cooldown } + @Tab(GeneralTab) private val hitDelay1 by setting("Hit Delay 1", 2.0, 0.0..20.0, 1.0) { attackMode == AttackMode.Delay } + @Tab(GeneralTab) private val hitDelay2 by setting("Hit Delay 2", 6.0, 0.0..20.0, 1.0) { attackMode == AttackMode.Delay } + + @Tab(TargetingTab) private val targetingSettings = settingBlock(TargetingSettings.CombatSettings(this)) val target: Entity? get() = targetingSettings.target() diff --git a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt index 984e8e35b..74c5cb8b2 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt @@ -44,7 +44,7 @@ import kotlin.jvm.optionals.getOrNull object PlayerTrap : Module( name = "PlayerTrap", description = "Surrounds players with any given block", - tag = ModuleTag.COMBAT + tag = ModuleTag.Combat ) { private val blocks by setting("Blocks", setOf(Blocks.OBSIDIAN, Blocks.ENDER_CHEST, Blocks.CRYING_OBSIDIAN)) private val friends by setting("Friends", false) diff --git a/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt b/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt index 252bd7982..e7ec8d375 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt @@ -36,7 +36,7 @@ import net.minecraft.item.BlockItem object Surround : Module( name = "Surround", description = "Surrounds your players feet with any given block", - tag = ModuleTag.COMBAT + tag = ModuleTag.Combat ) { private val blocks by setting("Blocks", setOf(Blocks.OBSIDIAN, Blocks.ENDER_CHEST, Blocks.CRYING_OBSIDIAN)) diff --git a/src/main/kotlin/com/lambda/module/modules/debug/BaritoneTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/BaritoneTest.kt index b22323764..7237eb029 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/BaritoneTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/BaritoneTest.kt @@ -28,7 +28,7 @@ import com.lambda.module.tag.ModuleTag object BaritoneTest : Module( name = "BaritoneTest", description = "Test Baritone", - tag = ModuleTag.DEBUG, + tag = ModuleTag.Debug, ) { init { listen { diff --git a/src/main/kotlin/com/lambda/module/modules/debug/BlockTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/BlockTest.kt index 125bd5f92..15afac93b 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/BlockTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/BlockTest.kt @@ -29,7 +29,7 @@ import java.awt.Color object BlockTest : Module( name = "BlockTest", description = "BlockTest", - tag = ModuleTag.DEBUG, + tag = ModuleTag.Debug, ) { private val rangeX by setting("Range X", 5, 1..7, 1, "Range X") private val rangeY by setting("Range Y", 5, 1..7, 1, "Range Y") diff --git a/src/main/kotlin/com/lambda/module/modules/debug/ContainerTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/ContainerTest.kt index fc9ceb73a..d5e2e7b1a 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/ContainerTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/ContainerTest.kt @@ -30,7 +30,7 @@ import net.minecraft.item.Items object ContainerTest : Module( name = "ContainerTest", description = "Test container", - tag = ModuleTag.DEBUG, + tag = ModuleTag.Debug, ) { init { listen { diff --git a/src/main/kotlin/com/lambda/module/modules/debug/DebugRendererModule.kt b/src/main/kotlin/com/lambda/module/modules/debug/DebugRendererModule.kt index 3e417f071..c96db2cd4 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/DebugRendererModule.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/DebugRendererModule.kt @@ -24,7 +24,7 @@ import com.lambda.module.tag.ModuleTag object DebugRendererModule: Module( name = "Debug Renderer", description = "Renders debug information of minecraft internals", - tag = ModuleTag.DEBUG, + tag = ModuleTag.Debug, ) { private val waterDebugRenderer by setting("Water Debug Renderer", false) private val chunkBorderDebugRenderer by setting("Chunk Border Debug Renderer", false) diff --git a/src/main/kotlin/com/lambda/module/modules/debug/FallTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/FallTest.kt index d397b76a5..446803891 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/FallTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/FallTest.kt @@ -28,7 +28,7 @@ import com.lambda.util.combat.DamageUtils.isFallDeadly @Suppress("unused") object FallTest : Module( name = "FallTest", - tag = ModuleTag.DEBUG, + tag = ModuleTag.Debug, ) { init { listen { diff --git a/src/main/kotlin/com/lambda/module/modules/debug/InventoryDebug.kt b/src/main/kotlin/com/lambda/module/modules/debug/InventoryDebug.kt index 47ec92134..da058e09e 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/InventoryDebug.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/InventoryDebug.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.debug -import com.lambda.Lambda.LOG +import com.lambda.Lambda.Log import com.lambda.event.events.InventoryEvent import com.lambda.event.events.PacketEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -38,13 +38,13 @@ import net.minecraft.network.packet.s2c.play.UpdateSelectedSlotS2CPacket object InventoryDebug : Module( name = "InventoryDebug", description = "Debugs the inventory", - tag = ModuleTag.DEBUG, + tag = ModuleTag.Debug, ) { init { listen { event -> info("Opened screen handler: ${event.screenHandler::class.simpleName}") - LOG.info("\n" + event.screenHandler.slots.joinToString("\n") { + Log.info("\n" + event.screenHandler.slots.joinToString("\n") { "${it.inventory::class.simpleName} ${it.index} ${it.x} ${it.y}" }) } @@ -62,7 +62,7 @@ object InventoryDebug : Module( is UpdateSelectedSlotS2CPacket, is InventoryS2CPacket, -> { - LOG.info(it.packet.dynamicString()) + Log.info(it.packet.dynamicString()) } } when (val packet = it.packet) { @@ -80,7 +80,7 @@ object InventoryDebug : Module( is CraftRequestC2SPacket, is CreativeInventoryActionC2SPacket, is UpdateSelectedSlotC2SPacket, - -> LOG.info(System.currentTimeMillis().toString() + " " + it.packet.dynamicString()) + -> Log.info(System.currentTimeMillis().toString() + " " + it.packet.dynamicString()) } } } diff --git a/src/main/kotlin/com/lambda/module/modules/debug/PropertyPrinter.kt b/src/main/kotlin/com/lambda/module/modules/debug/PropertyPrinter.kt index 6b5a18da1..fb45830d7 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/PropertyPrinter.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/PropertyPrinter.kt @@ -28,7 +28,7 @@ import net.minecraft.block.Blocks object PropertyPrinter : Module( name = "PropertyPrinter", description = "Prints all properties coupled with all the states that use them into a text file", - tag = ModuleTag.DEBUG, + tag = ModuleTag.Debug, ) { init { onEnable { diff --git a/src/main/kotlin/com/lambda/module/modules/debug/RenderTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/RenderTest.kt index 190a70a84..58a2fb2f2 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/RenderTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/RenderTest.kt @@ -33,7 +33,7 @@ import java.awt.Color object RenderTest : Module( name = "Render:shrimp:Test:canned_food:", description = "RenderTest", - tag = ModuleTag.DEBUG, + tag = ModuleTag.Debug, ) { private val test1 by setting("Toggle visibility", true) private val test21 by setting("Hallo 1", true, visibility = ::test1) diff --git a/src/main/kotlin/com/lambda/module/modules/debug/RendererTestModule.kt b/src/main/kotlin/com/lambda/module/modules/debug/RendererTestModule.kt index 12cb2363b..b04a82b50 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/RendererTestModule.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/RendererTestModule.kt @@ -53,7 +53,7 @@ import java.awt.Color object ChunkedRendererTest : Module( name = "ChunkedRendererTest", description = "Test module for ChunkedRenderer", - tag = ModuleTag.DEBUG, + tag = ModuleTag.Debug, ) { var updated = false @@ -168,7 +168,7 @@ object ChunkedRendererTest : Module( object TickedRendererTest : Module( name = "TickedRendererTest", description = "Test module for TickedRenderer", - tag = ModuleTag.DEBUG, + tag = ModuleTag.Debug, ) { private val throughWalls by setting("Through Walls", true) @@ -275,7 +275,7 @@ object TickedRendererTest : Module( object ImmediateRendererTest : Module( name = "ImmediateRendererTest", description = "Test module for ImmediateRenderer", - tag = ModuleTag.DEBUG, + tag = ModuleTag.Debug, ) { private val throughWalls by setting("Through Walls", true) diff --git a/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt index 6e8a3e4a0..c2ceafb9c 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/RotationTest.kt @@ -28,7 +28,7 @@ import net.minecraft.util.hit.HitResult @Suppress("unused") object RotationTest : Module( name = "RotationTest", - tag = ModuleTag.DEBUG, + tag = ModuleTag.Debug, ) { var hitPos: HitResult? = null diff --git a/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt b/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt index dfd7d7fa8..5d052d7ba 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt @@ -18,10 +18,10 @@ package com.lambda.module.modules.debug import com.lambda.config.Tab -import com.lambda.config.groups.ScreenLineSettings -import com.lambda.config.groups.ScreenTextSettings -import com.lambda.config.groups.WorldLineSettings -import com.lambda.config.groups.WorldTextSettings +import com.lambda.config.blocks.ScreenLineSettings +import com.lambda.config.blocks.ScreenTextSettings +import com.lambda.config.blocks.WorldLineSettings +import com.lambda.config.blocks.WorldTextSettings import com.lambda.module.Module import com.lambda.module.tag.ModuleTag @@ -29,17 +29,17 @@ import com.lambda.module.tag.ModuleTag object SettingsTestModule : Module( name = "SettingsTestModule", description = "Test module for Line and Text Config Settings", - tag = ModuleTag.DEBUG + tag = ModuleTag.Debug ) { - private const val WORLD_LINE_TAB = "World Line" - private const val SCREEN_LINE_TAB = "Screen Line" - private const val WORLD_TEXT_TAB = "World Text" - private const val SCREEN_TEXT_TAB = "Screen Text" + private const val WorldLineTab = "World Line" + private const val ScreenLineTab = "Screen Line" + private const val WorldTextTab = "World Text" + private const val ScreenTextTab = "Screen Text" - @Tab(WORLD_LINE_TAB) private val worldLineConfig = settingBlock(WorldLineSettings(this)) - @Tab(SCREEN_LINE_TAB) private val screenLineConfig = settingBlock(ScreenLineSettings(this)) - @Tab(WORLD_TEXT_TAB) private val worldTextConfig = settingBlock(WorldTextSettings(this)) - @Tab(SCREEN_TEXT_TAB) private val textConfig = settingBlock(ScreenTextSettings(this)) + @Tab(WorldLineTab) private val worldLineConfig = settingBlock(WorldLineSettings(this)) + @Tab(ScreenLineTab) private val screenLineConfig = settingBlock(ScreenLineSettings(this)) + @Tab(WorldTextTab) private val worldTextConfig = settingBlock(WorldTextSettings(this)) + @Tab(ScreenTextTab) private val textConfig = settingBlock(ScreenTextSettings(this)) // private val renderer = ImmediateRenderer("SettingsTestRenderer") diff --git a/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt b/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt index c48c7f704..5f698fc63 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt @@ -17,19 +17,18 @@ package com.lambda.module.modules.debug -import com.lambda.config.groups.HotbarSettings +import com.lambda.config.blocks.HotbarSettings import com.lambda.event.events.PlayerEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.hotbar.HotbarRequest import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.CommunicationUtils.info -import com.lambda.util.NamedEnum object SilentSwap : Module( name = "SilentSwap", description = "SilentSwap", - tag = ModuleTag.DEBUG, + tag = ModuleTag.Debug, ) { override val hotbarConfig = HotbarSettings(this) diff --git a/src/main/kotlin/com/lambda/module/modules/debug/StateInfo.kt b/src/main/kotlin/com/lambda/module/modules/debug/StateInfo.kt index 1cf5a0a47..f073d8c08 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/StateInfo.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/StateInfo.kt @@ -31,7 +31,7 @@ import net.minecraft.util.hit.BlockHitResult object StateInfo : Module( name = "StateInfo", description = "Prints the target block's state into chat", - tag = ModuleTag.DEBUG, + tag = ModuleTag.Debug, ) { @Suppress("unused") private val printBind by setting("Print", KeyCode.Unbound, "The bind used to print the info to chat") diff --git a/src/main/kotlin/com/lambda/module/modules/debug/TimerTest.kt b/src/main/kotlin/com/lambda/module/modules/debug/TimerTest.kt index 25073151a..4a6fb21bb 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/TimerTest.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/TimerTest.kt @@ -27,7 +27,7 @@ import com.lambda.util.CommunicationUtils.info @Suppress("unused") object TimerTest : Module( name = "TimerTest", - tag = ModuleTag.DEBUG, + tag = ModuleTag.Debug, ) { private var last = 0L diff --git a/src/main/kotlin/com/lambda/module/modules/movement/AutoSpiral.kt b/src/main/kotlin/com/lambda/module/modules/movement/AutoSpiral.kt index 67ee5d119..8994e8d9b 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/AutoSpiral.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/AutoSpiral.kt @@ -35,7 +35,7 @@ import kotlin.math.sqrt object AutoSpiral : Module( name = "AutoSpiral", description = "Automatically flies in a spiral pattern. Uses Baritone elytra pathing in the Nether.", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) { var iterator: BlockPosIterators.SpiralIterator2d? = null var currentWaypoint: BlockPos? = null diff --git a/src/main/kotlin/com/lambda/module/modules/movement/AutoWalk.kt b/src/main/kotlin/com/lambda/module/modules/movement/AutoWalk.kt index 8828eaf9f..d53903e96 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/AutoWalk.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/AutoWalk.kt @@ -30,7 +30,7 @@ import net.minecraft.util.math.Vec2f object AutoWalk : Module( name = "AutoWalk", description = "Automatically makes your character walk forward", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) { val limitSpeed by setting("Limit Speed", false) val speed by setting("Speed", 0.5, 0.1..1.0, 0.05) { limitSpeed } diff --git a/src/main/kotlin/com/lambda/module/modules/movement/BackTrack.kt b/src/main/kotlin/com/lambda/module/modules/movement/BackTrack.kt index 281766a82..81062956d 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/BackTrack.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/BackTrack.kt @@ -58,7 +58,7 @@ import java.util.concurrent.ConcurrentLinkedDeque object BackTrack : Module( name = "BackTrack", description = "Gives reach advantage by delaying your packets", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) { private val outbound by setting("Outbound", true) private val mode by setting("Mode", Mode.Fixed) @@ -71,7 +71,7 @@ object BackTrack : Module( private val box = DynamicAABB() - private const val POSITION_PACKET_SCALE = 1 / 4096.0 + private const val PositionPacketScale = 1 / 4096.0 private val currentTime get() = System.currentTimeMillis() private val sendPool = ConcurrentLinkedDeque>() @@ -129,9 +129,9 @@ object BackTrack : Module( if (target.id == packet.id) { targetPos = targetPos?.plus( Vec3d( - packet.deltaX * POSITION_PACKET_SCALE, - packet.deltaY * POSITION_PACKET_SCALE, - packet.deltaZ * POSITION_PACKET_SCALE + packet.deltaX * PositionPacketScale, + packet.deltaY * PositionPacketScale, + packet.deltaZ * PositionPacketScale ) ) } diff --git a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt index b253bba02..e07cb8aa3 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt @@ -49,7 +49,7 @@ import net.minecraft.util.hit.HitResult object BetterFirework : Module( name = "BetterFirework", description = "Automatic takeoff with fireworks", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) { private var activateButton: Bind by setting("Activate Key", Bind(0, 0, Mouse.Middle.ordinal), "Button to activate Firework") .onPress { diff --git a/src/main/kotlin/com/lambda/module/modules/movement/Blink.kt b/src/main/kotlin/com/lambda/module/modules/movement/Blink.kt index 47d8a227f..917e63d6f 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/Blink.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/Blink.kt @@ -44,7 +44,7 @@ import java.util.concurrent.ConcurrentLinkedDeque object Blink : Module( name = "Blink", description = "Holds packets", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) { private var delay by setting("Delay", 500, 50..10000, 10) private val shiftVelocity by setting("Shift velocity", true) diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt index 03266508c..8883077b9 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt @@ -17,6 +17,7 @@ package com.lambda.module.modules.movement +import com.lambda.config.Group import com.lambda.config.Tab import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits @@ -41,16 +42,16 @@ import kotlin.time.TimeSource object ElytraAltitudeControl : Module( name = "ElytraAltitudeControl", description = "Automatically control attitude or speed while elytra flying", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) { enum class Mode { Speed, Altitude } - private const val SPEED_CONTROL_TAB = "Speed Control" - private const val ALTITUDE_CONTROL_TAB = "Altitude Control" - private const val PITCH40_CONTROL_TAB = "Pitch 40 Control" + private const val SpeedControlGroup = "Speed Control" + private const val AltitudeControlGroup = "Altitude Control" + private const val Pitch40ControlGroup = "Pitch 40 Control" val controlValue by setting("Control Value", Mode.Altitude) @@ -58,16 +59,16 @@ object ElytraAltitudeControl : Module( val disableOnFirework by setting("Disable On Firework", false, description = "Disables the module when a firework is used") val targetAltitude by setting("Target Altitude", 120, 0..256, 10, unit = " blocks", description = "Adjusts pitch to control altitude") { controlValue == Mode.Altitude } - @Tab(ALTITUDE_CONTROL_TAB) val altitudeControllerP by setting("Altitude Control P", 1.2, 0.0..2.0, 0.05) - @Tab(ALTITUDE_CONTROL_TAB) val altitudeControllerD by setting("Altitude Control D", 0.85, 0.0..1.0, 0.05) - @Tab(ALTITUDE_CONTROL_TAB) val altitudeControllerI by setting("Altitude Control I", 0.04, 0.0..1.0, 0.05) - @Tab(ALTITUDE_CONTROL_TAB) val altitudeControllerConst by setting("Altitude Control Const", 0.0, 0.0..10.0, 0.1) + @Group(AltitudeControlGroup) val altitudeControllerP by setting("Altitude Control P", 1.2, 0.0..2.0, 0.05) + @Group(AltitudeControlGroup) val altitudeControllerD by setting("Altitude Control D", 0.85, 0.0..1.0, 0.05) + @Group(AltitudeControlGroup) val altitudeControllerI by setting("Altitude Control I", 0.04, 0.0..1.0, 0.05) + @Group(AltitudeControlGroup) val altitudeControllerConst by setting("Altitude Control Const", 0.0, 0.0..10.0, 0.1) val targetSpeed by setting("Target Speed", 20.0, 0.1..50.0, 0.1, unit = " m/s", description = "Adjusts pitch to control speed") { controlValue == Mode.Speed } val horizontalSpeed by setting("Horizontal Speed", false, description = "Uses horizontal speed instead of total speed for speed control") { controlValue == Mode.Speed } - @Tab(SPEED_CONTROL_TAB) val speedControllerP by setting("Speed Control P", 6.75, 0.0..10.0, 0.05) - @Tab(SPEED_CONTROL_TAB) val speedControllerD by setting("Speed Control D", 4.5, 0.0..5.0, 0.05) - @Tab(SPEED_CONTROL_TAB) val speedControllerI by setting("Speed Control I", 0.3, 0.0..1.0, 0.05) + @Group(SpeedControlGroup) val speedControllerP by setting("Speed Control P", 6.75, 0.0..10.0, 0.05) + @Group(SpeedControlGroup) val speedControllerD by setting("Speed Control D", 4.5, 0.0..5.0, 0.05) + @Group(SpeedControlGroup) val speedControllerI by setting("Speed Control I", 0.3, 0.0..1.0, 0.05) val useFireworkOnHeight by setting("Use Firework On Height", false, "Use fireworks when below a certain height") val minHeight by setting("Min Height", 50, 0..256, 10, unit = " blocks", description = "Minimum height to use firework") { useFireworkOnHeight } @@ -80,14 +81,14 @@ object ElytraAltitudeControl : Module( val altitudeController: PIController = PIController({ altitudeControllerP }, { altitudeControllerD }, { altitudeControllerI }, { altitudeControllerConst }) val usePitch40OnHeight by setting("Use Pitch 40 On Height", false, "Use Pitch 40 to gain height and speed") - @Tab(PITCH40_CONTROL_TAB) val logHeightGain by setting("Log Height Gain", false, "Logs the height gained each cycle to the chat") { usePitch40OnHeight } - @Tab(PITCH40_CONTROL_TAB) val minHeightForPitch40 by setting("Min Height For Pitch 40", 120, 0..256, 10, unit = " blocks", description = "Minimum height to use Pitch 40") { usePitch40OnHeight } - @Tab(PITCH40_CONTROL_TAB) val pitch40ExitHeight by setting("Exit height", 190, 0..256, 10, unit = " blocks", description = "Height to exit Pitch 40 mode") { usePitch40OnHeight } - @Tab(PITCH40_CONTROL_TAB) val pitch40UpStartAngle by setting("Up Start Angle", -49f, -90f..0f, .5f, description = "Start angle when going back up. negative pitch = looking up") { usePitch40OnHeight } - @Tab(PITCH40_CONTROL_TAB) val pitch40DownAngle by setting("Down Angle", 33f, 0f..90f, .5f, description = "Angle to dive down at to gain speed") { usePitch40OnHeight } - @Tab(PITCH40_CONTROL_TAB) val pitch40AngleChangeRate by setting("Angle Change Rate", 0.5f, 0.1f..5f, 0.01f, description = "Rate at which to increase pitch while in the fly up curve") { usePitch40OnHeight } - @Tab(PITCH40_CONTROL_TAB) val pitch40SpeedThreshold by setting("Speed Threshold", 41f, 10f..100f, .5f, description = "Speed at which to start pitching up") { usePitch40OnHeight } - @Tab(PITCH40_CONTROL_TAB) val pitch40UseFireworkOnUpTrajectory by setting("Use Firework On Up Trajectory", false, "Use fireworks when converting speed to altitude in the Pitch 40 maneuver") { usePitch40OnHeight } + @Tab(Pitch40ControlGroup) val logHeightGain by setting("Log Height Gain", false, "Logs the height gained each cycle to the chat") { usePitch40OnHeight } + @Tab(Pitch40ControlGroup) val minHeightForPitch40 by setting("Min Height For Pitch 40", 120, 0..256, 10, unit = " blocks", description = "Minimum height to use Pitch 40") { usePitch40OnHeight } + @Tab(Pitch40ControlGroup) val pitch40ExitHeight by setting("Exit height", 190, 0..256, 10, unit = " blocks", description = "Height to exit Pitch 40 mode") { usePitch40OnHeight } + @Tab(Pitch40ControlGroup) val pitch40UpStartAngle by setting("Up Start Angle", -49f, -90f..0f, .5f, description = "Start angle when going back up. negative pitch = looking up") { usePitch40OnHeight } + @Tab(Pitch40ControlGroup) val pitch40DownAngle by setting("Down Angle", 33f, 0f..90f, .5f, description = "Angle to dive down at to gain speed") { usePitch40OnHeight } + @Tab(Pitch40ControlGroup) val pitch40AngleChangeRate by setting("Angle Change Rate", 0.5f, 0.1f..5f, 0.01f, description = "Rate at which to increase pitch while in the fly up curve") { usePitch40OnHeight } + @Tab(Pitch40ControlGroup) val pitch40SpeedThreshold by setting("Speed Threshold", 41f, 10f..100f, .5f, description = "Speed at which to start pitching up") { usePitch40OnHeight } + @Tab(Pitch40ControlGroup) val pitch40UseFireworkOnUpTrajectory by setting("Use Firework On Up Trajectory", false, "Use fireworks when converting speed to altitude in the Pitch 40 maneuver") { usePitch40OnHeight } var controlState = ControlState.AttitudeControl var state = Pitch40State.GainSpeed diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt index 6a4e778b2..f45624593 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt @@ -70,7 +70,7 @@ import kotlin.time.Duration.Companion.seconds object ElytraFly : Module( name = "ElytraFly", description = "Allows you to fly with an elytra", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) { @JvmStatic val mode by setting("Mode", FlyMode.Bounce) diff --git a/src/main/kotlin/com/lambda/module/modules/movement/EntityControl.kt b/src/main/kotlin/com/lambda/module/modules/movement/EntityControl.kt index 03bff2f1d..7aa989730 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/EntityControl.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/EntityControl.kt @@ -30,7 +30,7 @@ import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket object EntityControl : Module( name = "EntityControl", description = "Control mountable entities", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) { private val forceMount by setting("Force Mount", true, description = "Attempts to force mount chested entities.") diff --git a/src/main/kotlin/com/lambda/module/modules/movement/Jesus.kt b/src/main/kotlin/com/lambda/module/modules/movement/Jesus.kt index 7f024e4bb..b31eadcec 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/Jesus.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/Jesus.kt @@ -42,7 +42,7 @@ import net.minecraft.util.shape.VoxelShapes object Jesus : Module( name = "Jesus", description = "Allows to walk on water", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) { private val mode by setting("Mode", Mode.Ncp) @@ -91,7 +91,7 @@ object Jesus : Module( when (mode) { Mode.Ncp -> { if (!collidingWater || !player.isOnGround) return@listen - setSpeed(Speed.NCP_BASE_SPEED * isInputting.toInt()) + setSpeed(Speed.NcpBaseSpeed * isInputting.toInt()) } Mode.NcpDolphin -> { @@ -99,7 +99,7 @@ object Jesus : Module( player.motionY = dolphinStrength if (!waterAt(0.2)) { - setSpeed(Speed.NCP_BASE_SPEED * isInputting.toInt()) + setSpeed(Speed.NcpBaseSpeed * isInputting.toInt()) } else player.motionY = 0.18 } } @@ -112,7 +112,7 @@ object Jesus : Module( if (++swimmingTicks < 15) { if (player.isOnGround) { - setSpeed(Speed.NCP_BASE_SPEED * isInputting.toInt()) + setSpeed(Speed.NcpBaseSpeed * isInputting.toInt()) } return@listen diff --git a/src/main/kotlin/com/lambda/module/modules/movement/NoFall.kt b/src/main/kotlin/com/lambda/module/modules/movement/NoFall.kt index 5275eb08a..60012efe9 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/NoFall.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/NoFall.kt @@ -39,7 +39,7 @@ import net.minecraft.util.math.Vec3d object NoFall : Module( name = "NoFall", description = "Reduces fall damage", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) { private val mode by setting("Mode", Mode.Grim) diff --git a/src/main/kotlin/com/lambda/module/modules/movement/NoJumpCooldown.kt b/src/main/kotlin/com/lambda/module/modules/movement/NoJumpCooldown.kt index 1746e1e95..58ac5f01a 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/NoJumpCooldown.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/NoJumpCooldown.kt @@ -23,5 +23,5 @@ import com.lambda.module.tag.ModuleTag object NoJumpCooldown : Module( name = "NoJumpCooldown", description = "Removes delay between jumps", - tag = ModuleTag.MOVEMENT + tag = ModuleTag.Movement ) \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/module/modules/movement/SafeWalk.kt b/src/main/kotlin/com/lambda/module/modules/movement/SafeWalk.kt index 23e7ae108..e8a2ef8dd 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/SafeWalk.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/SafeWalk.kt @@ -29,7 +29,7 @@ import net.minecraft.entity.LivingEntity object SafeWalk : Module( name = "SafeWalk", description = "Keeps you at the edge", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) { private val sneakOnLedge by setting("Sneak On Ledge", true) private val ledgeDistance by setting("Ledge Distance", 0.2, 0.0..0.5, 0.01, unit = " blocks") diff --git a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt index c2d712fdb..584e3dd63 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt @@ -46,7 +46,7 @@ import net.minecraft.entity.vehicle.BoatEntity object Speed : Module( name = "Speed", description = "Accelerates your walking speed", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) { @JvmStatic val mode by setting("Mode", Mode.GrimStrafe) @@ -63,10 +63,10 @@ object Speed : Module( private val ncpTimerBoost by setting("Timer Boost", 1.08, 1.0..1.1, 0.01) { mode == Mode.NcpStrafe } // NCP state variables - const val NCP_BASE_SPEED = 0.2873 - private const val NCP_AIR_DECAY = 0.9937 + const val NcpBaseSpeed = 0.2873 + private const val NcpAirDecay = 0.9937 private var ncpPhase = NCPPhase.SlowDown - private var ncpSpeed = NCP_BASE_SPEED + private var ncpSpeed = NcpBaseSpeed private var lastDistance = 0.0 enum class Mode(override val displayName: String) : NamedEnum { @@ -157,7 +157,7 @@ object Speed : Module( NCPPhase.Jump -> { if (player.isOnGround) { player.motionY = if (lowerJump) 0.4 else 0.42 - ncpSpeed = NCP_BASE_SPEED + 0.3 + ncpSpeed = NcpBaseSpeed + 0.3 NCPPhase.JumpPost } else NCPPhase.SlowDown } @@ -168,19 +168,19 @@ object Speed : Module( } NCPPhase.SlowDown -> { - ncpSpeed = lastDistance * NCP_AIR_DECAY + ncpSpeed = lastDistance * NcpAirDecay NCPPhase.SlowDown } } if (player.isOnGround && !shouldJump) { - ncpSpeed = NCP_BASE_SPEED + ncpSpeed = NcpBaseSpeed } - ncpSpeed = ncpSpeed.coerceIn(NCP_BASE_SPEED..1.0) + ncpSpeed = ncpSpeed.coerceIn(NcpBaseSpeed..1.0) val moveSpeed = if (isInputting) ncpSpeed else { - ncpSpeed = NCP_BASE_SPEED + ncpSpeed = NcpBaseSpeed 0.0 } @@ -202,6 +202,6 @@ object Speed : Module( private fun reset() { ncpPhase = NCPPhase.SlowDown - ncpSpeed = NCP_BASE_SPEED + ncpSpeed = NcpBaseSpeed } } diff --git a/src/main/kotlin/com/lambda/module/modules/movement/Sprint.kt b/src/main/kotlin/com/lambda/module/modules/movement/Sprint.kt index d31ac27cc..24a54935e 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/Sprint.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/Sprint.kt @@ -23,5 +23,5 @@ import com.lambda.module.tag.ModuleTag object Sprint : Module( name = "Sprint", description = "Sprints automatically", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) diff --git a/src/main/kotlin/com/lambda/module/modules/movement/TargetStrafe.kt b/src/main/kotlin/com/lambda/module/modules/movement/TargetStrafe.kt index 57ece652e..395d9000a 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/TargetStrafe.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/TargetStrafe.kt @@ -31,7 +31,7 @@ import kotlin.math.pow object TargetStrafe : Module( name = "TargetStrafe", description = "Automatically strafes around entities", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) { private val targetDistance by setting("Strafe Distance", 1.0, 0.0..5.0, 0.1) private val jitterCompensation by setting("Jitter Compensation", 0.0, 0.0..1.0, 0.1) diff --git a/src/main/kotlin/com/lambda/module/modules/movement/TickShift.kt b/src/main/kotlin/com/lambda/module/modules/movement/TickShift.kt index 98cf8c9fa..4c84ce175 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/TickShift.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/TickShift.kt @@ -37,7 +37,7 @@ import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket object TickShift : Module( name = "TickShift", description = "Smort tickshift for smort anticheats", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) { val maxBalance by setting("Max Balance", 20, 3..400, 1) private val boostAmount by setting("Boost", 3.0, 1.1..20.0, 0.01) diff --git a/src/main/kotlin/com/lambda/module/modules/movement/Timer.kt b/src/main/kotlin/com/lambda/module/modules/movement/Timer.kt index 359f78bde..a17f24046 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/Timer.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/Timer.kt @@ -26,7 +26,7 @@ import com.lambda.module.tag.ModuleTag object Timer : Module( name = "Timer", description = "Modify client tick speed.", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) { private val timer by setting("Timer", 1.0, 0.0..10.0, 0.01) diff --git a/src/main/kotlin/com/lambda/module/modules/movement/Velocity.kt b/src/main/kotlin/com/lambda/module/modules/movement/Velocity.kt index cd2470c54..71a149aa0 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/Velocity.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/Velocity.kt @@ -26,7 +26,7 @@ import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket object Velocity : Module( name = "Velocity", description = "Modifies your velocity", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) { @JvmStatic val pushed by setting("Pushed", true, "Prevents the player from getting pushed by other entities") private val knockback by setting("Knockback", true, "Prevents the player from taking knockback when being attacked") diff --git a/src/main/kotlin/com/lambda/module/modules/network/PacketDelay.kt b/src/main/kotlin/com/lambda/module/modules/network/PacketDelay.kt index 73deeba44..ce9b49676 100644 --- a/src/main/kotlin/com/lambda/module/modules/network/PacketDelay.kt +++ b/src/main/kotlin/com/lambda/module/modules/network/PacketDelay.kt @@ -40,7 +40,7 @@ import java.util.concurrent.ConcurrentLinkedDeque object PacketDelay : Module( name = "PacketDelay", description = "Delays packets client-bound & server-bound", - tag = ModuleTag.NETWORK, + tag = ModuleTag.Network, ) { private val mode by setting("Mode", Mode.Static, description = "How the delay is applied: Static queues packets until a flush; Pulse delays each packet individually.") private val networkScope by setting("Network Scope", Direction.Both, description = "Which direction(s) to affect: inbound (server → you), outbound (you → server), or both.") diff --git a/src/main/kotlin/com/lambda/module/modules/network/PacketLimiter.kt b/src/main/kotlin/com/lambda/module/modules/network/PacketLimiter.kt index 52e7cb594..8318c6693 100644 --- a/src/main/kotlin/com/lambda/module/modules/network/PacketLimiter.kt +++ b/src/main/kotlin/com/lambda/module/modules/network/PacketLimiter.kt @@ -35,7 +35,7 @@ import net.minecraft.network.packet.c2s.play.TeleportConfirmC2SPacket object PacketLimiter : Module( name = "PacketLimiter", description = "Limits the amount of packets sent to the server", - tag = ModuleTag.NETWORK, + tag = ModuleTag.Network, ) { private var packetQueueMap = mutableMapOf>() private val globalQueue = LimitedDecayQueue(1, 1) diff --git a/src/main/kotlin/com/lambda/module/modules/network/PacketLogger.kt b/src/main/kotlin/com/lambda/module/modules/network/PacketLogger.kt index efcf05299..b36738b41 100644 --- a/src/main/kotlin/com/lambda/module/modules/network/PacketLogger.kt +++ b/src/main/kotlin/com/lambda/module/modules/network/PacketLogger.kt @@ -48,7 +48,7 @@ import kotlin.io.path.pathString object PacketLogger : Module( name = "PacketLogger", description = "Serializes network traffic and persists it for later analysis", - tag = ModuleTag.NETWORK, + tag = ModuleTag.Network, autoDisable = true ) { private val logToChat by setting("Log To Chat", false, "Log packets to chat") @@ -123,7 +123,7 @@ object PacketLogger : Module( }.apply { StringBuilder().apply { appendLine(CommunicationUtils.ascii) - appendLine("${Lambda.SYMBOL} - Lambda ${Lambda.VERSION} - Packet Log") + appendLine("${Lambda.Symbol} - Lambda ${Lambda.Version} - Packet Log") val playerName = mc.player?.name?.string ?: "Unknown" appendLine("Started at ${getTime()} by $playerName") diff --git a/src/main/kotlin/com/lambda/module/modules/network/Rubberband.kt b/src/main/kotlin/com/lambda/module/modules/network/Rubberband.kt index 45fb7f1b7..1bdd94c24 100644 --- a/src/main/kotlin/com/lambda/module/modules/network/Rubberband.kt +++ b/src/main/kotlin/com/lambda/module/modules/network/Rubberband.kt @@ -39,7 +39,7 @@ import java.awt.Color object Rubberband : Module( name = "Rubberband", description = "Info about rubberbands", - tag = ModuleTag.NETWORK, + tag = ModuleTag.Network, ) { private val showLastPacketInfo by setting("Show Last Packet", true) private val showConnectionState by setting("Show Connection State", true) diff --git a/src/main/kotlin/com/lambda/module/modules/network/ServerSpoof.kt b/src/main/kotlin/com/lambda/module/modules/network/ServerSpoof.kt index 39dbcfdd1..709448de7 100644 --- a/src/main/kotlin/com/lambda/module/modules/network/ServerSpoof.kt +++ b/src/main/kotlin/com/lambda/module/modules/network/ServerSpoof.kt @@ -37,7 +37,7 @@ import java.awt.Color object ServerSpoof : Module( name = "ServerSpoof", description = "Decide yourself if you want to accept the server resource pack.", - tag = ModuleTag.NETWORK, + tag = ModuleTag.Network, ) { private val spoofClientBrand by setting("Spoof Client Brand", true) private val spoofName by setting("Spoof Name", "vanilla", visibility = { spoofClientBrand }) diff --git a/src/main/kotlin/com/lambda/module/modules/player/AntiAFK.kt b/src/main/kotlin/com/lambda/module/modules/player/AntiAFK.kt index 25f485e17..168138481 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/AntiAFK.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/AntiAFK.kt @@ -27,7 +27,7 @@ import net.minecraft.util.Hand object AntiAFK : Module( name = "AntiAFK", description = "Keeps you from getting kicked", - tag = ModuleTag.PLAYER, + tag = ModuleTag.Player, ) { private val delay by setting("Delay", 300, 5..600, 1, unit = " s", description = "Delay between swinging the hand.") private val swingHand by setting("Swing Hand", Hand.MAIN_HAND, description = "Hand to swing.") diff --git a/src/main/kotlin/com/lambda/module/modules/player/AntiAim.kt b/src/main/kotlin/com/lambda/module/modules/player/AntiAim.kt index 07cb1c3ce..6cc1e641d 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/AntiAim.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/AntiAim.kt @@ -34,10 +34,10 @@ import kotlin.random.Random object AntiAim : Module( name = "AntiAim", description = "Rotates the player using the given configs", - tag = ModuleTag.MOVEMENT, + tag = ModuleTag.Movement, ) { - private const val GENERAL_TAB = "General" - private const val ROTATION_TAB = "Rotation" + private const val GeneralTab = "General" + private const val RotationTab = "Rotation" private val yaw by setting("Yaw Mode", YawMode.Spin, "The mode used when setting the players yaw") .onValueChange { _, to -> if (to == YawMode.Custom) customYaw = player.yaw } diff --git a/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt b/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt index 13e2db754..3c04c2b52 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt @@ -19,7 +19,7 @@ package com.lambda.module.modules.player import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig -import com.lambda.config.groups.EatConfig.Companion.reasonEating +import com.lambda.config.blocks.EatConfig.Companion.reasonEating import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module @@ -33,7 +33,7 @@ import com.lambda.threading.runSafeAutomated object AutoEat : Module( name = "AutoEat", description = "Eats food when you are hungry", - tag = ModuleTag.PLAYER, + tag = ModuleTag.Player, ) { private var eatTask: EatTask? = null diff --git a/src/main/kotlin/com/lambda/module/modules/player/ClickFriend.kt b/src/main/kotlin/com/lambda/module/modules/player/ClickFriend.kt index b70df459d..51d13e9d0 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/ClickFriend.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/ClickFriend.kt @@ -37,7 +37,7 @@ import org.lwjgl.glfw.GLFW.GLFW_MOD_SHIFT object ClickFriend : Module( name = "ClickFriend", description = "Add or remove friends with a single click", - tag = ModuleTag.PLAYER, + tag = ModuleTag.Player, ) { private val friendBind: Bind by setting("Friend Bind", Bind(0, 0, GLFW.GLFW_MOUSE_BUTTON_MIDDLE), "Bind to press to befriend a player") .onPress { if (!unfriendBind.isSatisfied()) if (checkSetFriend(true)) it.cancel() } diff --git a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt index d9f78c303..8867636a8 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt @@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentLinkedQueue object FastBreak : Module( name = "FastBreak", description = "Break blocks faster.", - tag = ModuleTag.PLAYER, + tag = ModuleTag.Player, ) { private val pendingActions = ConcurrentLinkedQueue() diff --git a/src/main/kotlin/com/lambda/module/modules/player/Interact.kt b/src/main/kotlin/com/lambda/module/modules/player/Interact.kt index 48fec9a24..8f73704ab 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/Interact.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/Interact.kt @@ -23,7 +23,7 @@ import com.lambda.module.tag.ModuleTag object Interact : Module( name = "Interact", description = "Modify players interaction with the world", - tag = ModuleTag.PLAYER, + tag = ModuleTag.Player, ) { @JvmStatic val placeDelay by setting("Item Use / Place Delay", 4, 0..20, 1, "Sets the delay between placing blocks or using items") @JvmStatic val multiAction by setting("Multi Action", false, "Allows to use many items while breaking blocks") diff --git a/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt b/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt index f7df53467..b83d2cf40 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt @@ -18,7 +18,7 @@ package com.lambda.module.modules.player import com.lambda.Lambda.mc -import com.lambda.config.groups.RotationConfig +import com.lambda.config.blocks.RotationConfig import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.gui.LambdaScreen @@ -46,7 +46,7 @@ import org.lwjgl.glfw.GLFW.GLFW_KEY_UP object InventoryMove : Module( name = "InventoryMove", description = "Allows you to move with GUIs opened", - tag = ModuleTag.PLAYER, + tag = ModuleTag.Player, ) { private val clickGui by setting("ClickGui", false) private val disableSneak by setting("Disable Sneak", false) diff --git a/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt b/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt index 17f17a283..f0d77db39 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt @@ -37,7 +37,7 @@ import net.minecraft.util.math.BlockPos object InventoryTweaks : Module( name = "InventoryTweaks", - tag = ModuleTag.PLAYER, + tag = ModuleTag.Player, ) { private val instantShulker by setting("Instant Shulker", true, description = "Right-click shulker boxes in your inventory to instantly place them and open them.") private val instantEChest by setting("Instant Ender-Chest", true, description = "Right-click ender chests in your inventory to instantly place them and open them.") diff --git a/src/main/kotlin/com/lambda/module/modules/player/NoForceRotate.kt b/src/main/kotlin/com/lambda/module/modules/player/NoForceRotate.kt index 29f82c674..3745528b0 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/NoForceRotate.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/NoForceRotate.kt @@ -23,5 +23,5 @@ import com.lambda.module.tag.ModuleTag object NoForceRotate : Module( name = "NoForceRotate", description = "Prevents the server from forcing your players rotation", - tag = ModuleTag.PLAYER + tag = ModuleTag.Player ) \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt index e8e88fab2..41a76e373 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt @@ -20,7 +20,7 @@ package com.lambda.module.modules.player import com.lambda.config.Group import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig -import com.lambda.config.groups.BreakConfig +import com.lambda.config.blocks.BreakConfig import com.lambda.context.SafeContext import com.lambda.event.events.PlayerEvent import com.lambda.event.events.TickEvent @@ -50,28 +50,28 @@ import java.util.concurrent.ConcurrentLinkedQueue object PacketMine : Module( name = "PacketMine", description = "automatically breaks blocks, and does it faster", - tag = ModuleTag.PLAYER + tag = ModuleTag.Player ) { - private const val GENERAL_GROUP = "General" - private const val RENDERS_GROUP = "Renders" + private const val GeneralGroup = "General" + private const val RendersGroup = "Renders" - @Group(GENERAL_GROUP) private val ignoreWhenHolding by setting("Ignore When Holding", emptySet(), description = "These items won't initiate a break if held when attacking a block") - @Group(GENERAL_GROUP) private val rebreakMode by setting("Rebreak Mode", RebreakMode.Manual, "The method used to re-break blocks after they've been broken once").disabled { !breakConfig.rebreak } - @Group(GENERAL_GROUP) private val breakRadius by setting("Break Radius", 0, 0..5, 1, "Selects and breaks all blocks within the break radius of the selected block") - @Group(GENERAL_GROUP) private val flatten by setting("Flatten", true, "Wont allow breaking extra blocks under your players position") { breakRadius > 0 } - @Group(GENERAL_GROUP) private val queue by setting("Queue", false, "Queues blocks to break so you can select multiple at once") + @Group(GeneralGroup) private val ignoreWhenHolding by setting("Ignore When Holding", emptySet(), description = "These items won't initiate a break if held when attacking a block") + @Group(GeneralGroup) private val rebreakMode by setting("Rebreak Mode", RebreakMode.Manual, "The method used to re-break blocks after they've been broken once").disabled { !breakConfig.rebreak } + @Group(GeneralGroup) private val breakRadius by setting("Break Radius", 0, 0..5, 1, "Selects and breaks all blocks within the break radius of the selected block") + @Group(GeneralGroup) private val flatten by setting("Flatten", true, "Wont allow breaking extra blocks under your players position") { breakRadius > 0 } + @Group(GeneralGroup) private val queue by setting("Queue", false, "Queues blocks to break so you can select multiple at once") .onValueChange { _, to -> if (!to) queuePositions.clear() } - @Group(GENERAL_GROUP) private val queueOrder by setting("Queue Order", QueueOrder.Standard, "Which end of the queue to break blocks from") { queue } + @Group(GeneralGroup) private val queueOrder by setting("Queue Order", QueueOrder.Standard, "Which end of the queue to break blocks from") { queue } - @Group(RENDERS_GROUP) private val renderRebreak by setting("Render Rebreak", true, "Displays what block is being checked for rebreak") - @Group(RENDERS_GROUP) private val rebreakColor by setting("Rebreak Color", Color.RED) { renderRebreak } - @Group(RENDERS_GROUP) private val renderQueue by setting("Render Queue", true, "Adds renders to signify what block positions are queued") - @Group(RENDERS_GROUP) private val renderSize by setting("Queue Render Size", 0.3f, 0.01f..1f, 0.01f, "The scale of the queue renders") { renderQueue } - @Group(RENDERS_GROUP) private val renderMode by setting("Queue Render Mode", RenderMode.State, "The style of the queue renders") { renderQueue } - @Group(RENDERS_GROUP) private val dynamicColor by setting("Queue Dynamic Color", true, "Interpolates the color between start and end") { renderQueue } - @Group(RENDERS_GROUP) private val staticColor by setting("Queue Color", Color(255, 0, 0, 60)) { renderQueue && !dynamicColor } - @Group(RENDERS_GROUP) private val startColor by setting("Queue Start Color", Color(255, 255, 0, 60), "The color of the start (closest to breaking) of the queue") { renderQueue && dynamicColor } - @Group(RENDERS_GROUP) private val endColor by setting("Queue End Color", Color(255, 0, 0, 60), "The color of the end (farthest from breaking) of the queue") { renderQueue && dynamicColor } + @Group(RendersGroup) private val renderRebreak by setting("Render Rebreak", true, "Displays what block is being checked for rebreak") + @Group(RendersGroup) private val rebreakColor by setting("Rebreak Color", Color.RED) { renderRebreak } + @Group(RendersGroup) private val renderQueue by setting("Render Queue", true, "Adds renders to signify what block positions are queued") + @Group(RendersGroup) private val renderSize by setting("Queue Render Size", 0.3f, 0.01f..1f, 0.01f, "The scale of the queue renders") { renderQueue } + @Group(RendersGroup) private val renderMode by setting("Queue Render Mode", RenderMode.State, "The style of the queue renders") { renderQueue } + @Group(RendersGroup) private val dynamicColor by setting("Queue Dynamic Color", true, "Interpolates the color between start and end") { renderQueue } + @Group(RendersGroup) private val staticColor by setting("Queue Color", Color(255, 0, 0, 60)) { renderQueue && !dynamicColor } + @Group(RendersGroup) private val startColor by setting("Queue Start Color", Color(255, 255, 0, 60), "The color of the start (closest to breaking) of the queue") { renderQueue && dynamicColor } + @Group(RendersGroup) private val endColor by setting("Queue End Color", Color(255, 0, 0, 60), "The color of the end (farthest from breaking) of the queue") { renderQueue && dynamicColor } private val pendingActions = ConcurrentLinkedQueue() diff --git a/src/main/kotlin/com/lambda/module/modules/player/PortalGui.kt b/src/main/kotlin/com/lambda/module/modules/player/PortalGui.kt index dea4ec2e1..04c10b6b4 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/PortalGui.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/PortalGui.kt @@ -23,5 +23,5 @@ import com.lambda.module.tag.ModuleTag object PortalGui : Module( name = "PortalGui", description = "Allows you to open guis in portals", - tag = ModuleTag.PLAYER, + tag = ModuleTag.Player, ) diff --git a/src/main/kotlin/com/lambda/module/modules/player/Replay.kt b/src/main/kotlin/com/lambda/module/modules/player/Replay.kt index 5c9d84508..70f06a0e4 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/Replay.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/Replay.kt @@ -26,9 +26,7 @@ import com.google.gson.JsonNull import com.google.gson.JsonSerializationContext import com.google.gson.JsonSerializer import com.lambda.brigadier.CommandResult -import com.lambda.config.applyEdits -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig -import com.lambda.config.groups.RotationConfig +import com.lambda.config.blocks.RotationConfig import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.context.SafeContext import com.lambda.core.TimerHandler @@ -87,7 +85,7 @@ import kotlin.time.toDuration object Replay : Module( name = "Replay", description = "Record gameplay actions and replay them like a TAS.", - tag = ModuleTag.PLAYER, + tag = ModuleTag.Player, autoDisable = true ) { private val record by setting("Record", KeyCode.R) diff --git a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt index 7a106b81b..6cbe9f469 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt @@ -31,7 +31,7 @@ import kotlin.math.roundToInt object RotationLock : Module( name = "RotationLock", description = "Locks the player rotation to the given configuration", - tag = ModuleTag.PLAYER, + tag = ModuleTag.Player, ) { @JvmStatic val yawMode by setting("Yaw Mode", Mode.Snap) private val yawStep by setting("Yaw Step", 45.0, 1.0..180.0, 0.1) { yawMode == Mode.Snap } diff --git a/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt b/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt index ecedade9f..02126c1bf 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt @@ -35,7 +35,7 @@ import net.minecraft.item.Items object StackReplenish : Module( name = "StackReplenish", description = "Automatically refills stacks from your inventory", - tag = ModuleTag.PLAYER + tag = ModuleTag.Player ) { private val minStackPercent by setting("Min Stack Percentage", 30, 0..100, 1, "Minimum percentage of a complete stack before refilling", "%") private val offhand by setting("Offhand", false, "Replenishes the players offhand stack") diff --git a/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt b/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt index 4a0e51a2c..a51aecc52 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt @@ -37,7 +37,7 @@ import net.minecraft.screen.slot.Slot object ToolSaver : Module( name = "ToolSaver", description = "Moves tools from your hotbar into your inventory when they get too damaged", - ModuleTag.PLAYER + ModuleTag.Player ) { private val minDurabilityPercentage by setting("Min Durability", 5, 0..100, 1, "Minimum durability percentage before being swapped for a new piece", "%") private val replace by setting("Replace", true, "Replaces the tool with the one of the same kind") diff --git a/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt b/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt index 042f9fb26..aae5d9465 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt @@ -19,8 +19,8 @@ package com.lambda.module.modules.render import com.lambda.config.Group import com.lambda.config.applyEdits -import com.lambda.config.groups.OutlineSettings -import com.lambda.config.groups.WorldLineSettings +import com.lambda.config.settings.blocks.OutlineSettings +import com.lambda.config.settings.blocks.WorldLineSettings import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRenderer @@ -36,7 +36,7 @@ import java.awt.Color object BlockOutline : Module( name = "BlockOutline", description = "Overrides the default block outline rendering", - tag = ModuleTag.RENDER + tag = ModuleTag.Render ) { private enum class Mode { Boxes, @@ -47,22 +47,22 @@ object BlockOutline : Module( private val interpolate by setting("Interpolate", true) { mode == Mode.Boxes } private val depthTest by setting("Depth Test", true) - private const val BOX_FILL_GROUP = "Box Fill" - private const val BOX_OUTLINE_GROUP = "Box Outline" - private const val OUTLINE_GROUP = "Outline" + private const val BoxFillGroup = "Box Fill" + private const val BoxOutlineGroup = "Box Outline" + private const val OutlineGroup = "Outline" - @Group(BOX_FILL_GROUP) private val fill by setting("Fill", true) { mode == Mode.Boxes } - @Group(BOX_FILL_GROUP) private val fillColor by setting("Fill Color", Color(255, 255, 255, 20)) { fill && mode == Mode.Boxes } - @Group(BOX_OUTLINE_GROUP) private val boxOutline by setting("Box Outline", true) { mode == Mode.Boxes } - @Group(BOX_OUTLINE_GROUP) private val boxOutlineColor by setting("Box Outline Color", Color(255, 255, 255, 120)) { boxOutline && mode == Mode.Boxes } - @Group(BOX_OUTLINE_GROUP) private val lineConfig = + @Group(BoxFillGroup) private val fill by setting("Fill", true) { mode == Mode.Boxes } + @Group(BoxFillGroup) private val fillColor by setting("Fill Color", Color(255, 255, 255, 20)) { fill && mode == Mode.Boxes } + @Group(BoxOutlineGroup) private val boxOutline by setting("Box Outline", true) { mode == Mode.Boxes } + @Group(BoxOutlineGroup) private val boxOutlineColor by setting("Box Outline Color", Color(255, 255, 255, 120)) { boxOutline && mode == Mode.Boxes } + @Group(BoxOutlineGroup) private val lineConfig = settingBlock( WorldLineSettings(this), { boxOutline && mode == Mode.Boxes } ) { applyEdits { hide(::startColor, ::endColor) } } - @Group(OUTLINE_GROUP) private val outlineColor by setting("Outline Color", boxOutlineColor) { mode == Mode.Outline } - @Group(OUTLINE_GROUP) private val outlineStyle = settingBlock(OutlineSettings(this), { mode == Mode.Outline }) + @Group(OutlineGroup) private val outlineColor by setting("Outline Color", boxOutlineColor) { mode == Mode.Outline } + @Group(OutlineGroup) private val outlineStyle = settingBlock(OutlineSettings(this), { mode == Mode.Outline }) var previous: List? = null diff --git a/src/main/kotlin/com/lambda/module/modules/render/Bobbing.kt b/src/main/kotlin/com/lambda/module/modules/render/Bobbing.kt index d3d9303d5..1c53876db 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Bobbing.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Bobbing.kt @@ -23,7 +23,7 @@ import com.lambda.module.tag.ModuleTag object Bobbing : Module( name = "Bobbing", description = "Modifies vanilla view bobbing when the player walks or runs", - tag = ModuleTag.RENDER + tag = ModuleTag.Render ) { val magnitude by setting("Magnitude", 1.0, 0.0..2.0, 0.01) val speed by setting("Speed", 1.0, 0.0..2.0, 0.01) diff --git a/src/main/kotlin/com/lambda/module/modules/render/CameraTweaks.kt b/src/main/kotlin/com/lambda/module/modules/render/CameraTweaks.kt index 21c383419..bb43537b8 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/CameraTweaks.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/CameraTweaks.kt @@ -23,7 +23,7 @@ import com.lambda.module.tag.ModuleTag object CameraTweaks : Module( name = "CameraTweaks", description = "Adjusts camera settings", - tag = ModuleTag.RENDER, + tag = ModuleTag.Render, ) { @JvmStatic val camDistance by setting("Camera Distance", 4.0f, 1.0f..20.0f, 0.1f) @JvmStatic val noClipCam by setting("No Clip Camera", true) diff --git a/src/main/kotlin/com/lambda/module/modules/render/ContainerPreview.kt b/src/main/kotlin/com/lambda/module/modules/render/ContainerPreview.kt index ce91e71c8..a342acb6d 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/ContainerPreview.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/ContainerPreview.kt @@ -59,19 +59,19 @@ import kotlin.math.max object ContainerPreview : Module( name = "ContainerPreview", description = "Renders shulker box contents visually in tooltips", - tag = ModuleTag.RENDER, + tag = ModuleTag.Render, ) { - private const val CONTAINER_TOOLTIP_TAB = "Container Tooltip" - private const val CONTENT_PREVIEW_TAB = "Content Preview" + private const val ContainerTooltipTab = "Container Tooltip" + private const val ContentPreviewTab = "Content Preview" - @Tab(CONTAINER_TOOLTIP_TAB) private val lockKey by setting("Lock Key", Bind(KeyCode.LeftShift.code, 0, -1), "Key to lock the tooltip in place for item interaction") - @Tab(CONTAINER_TOOLTIP_TAB) private val colorTint by setting("Color Tint", true, "Tint the background with the shulker box color") + @Tab(ContainerTooltipTab) private val lockKey by setting("Lock Key", Bind(KeyCode.LeftShift.code, 0, -1), "Key to lock the tooltip in place for item interaction") + @Tab(ContainerTooltipTab) private val colorTint by setting("Color Tint", true, "Tint the background with the shulker box color") - @Tab(CONTENT_PREVIEW_TAB) private val contentPreview by setting("Content Preview", true, "Show a preview of the most common item in a container on the container item in inventories") - @Tab(CONTENT_PREVIEW_TAB) private val previewItemScale by setting("Item Scale", 11f, 1f..32f, 0.1f, "Scale of the item icons on a container item") { contentPreview } - @Tab(CONTENT_PREVIEW_TAB) private val previewItemXOffset by setting("Item X Offset", -2f, -32f..32f, 0.1f, "X offset of the item icons on a container item") { contentPreview } - @Tab(CONTENT_PREVIEW_TAB) private val previewItemYOffset by setting("Item Y Offset", 2f, -32f..32f, 0.1f, "Y offset of the item icons on a container item") { contentPreview } - @Tab(CONTENT_PREVIEW_TAB) private val previewItemWeightedCount by setting("Weighted Count", true, description = "Count items for preview in containers relative to max stack size") { contentPreview } + @Tab(ContentPreviewTab) private val contentPreview by setting("Content Preview", true, "Show a preview of the most common item in a container on the container item in inventories") + @Tab(ContentPreviewTab) private val previewItemScale by setting("Item Scale", 11f, 1f..32f, 0.1f, "Scale of the item icons on a container item") { contentPreview } + @Tab(ContentPreviewTab) private val previewItemXOffset by setting("Item X Offset", -2f, -32f..32f, 0.1f, "X offset of the item icons on a container item") { contentPreview } + @Tab(ContentPreviewTab) private val previewItemYOffset by setting("Item Y Offset", 2f, -32f..32f, 0.1f, "Y offset of the item icons on a container item") { contentPreview } + @Tab(ContentPreviewTab) private val previewItemWeightedCount by setting("Weighted Count", true, description = "Count items for preview in containers relative to max stack size") { contentPreview } .onValueChange { _, _ -> containerCache.clear() } private val background = Identifier.ofVanilla("textures/gui/container/shulker_box.png") @@ -96,18 +96,18 @@ object ContainerPreview : Module( } } - private const val ROWS = 3 - private const val COLS = 9 - private const val SLOT_SIZE = 18 - private const val PADDING = 7 - private const val TITLE_HEIGHT = 14 + private const val Rows = 3 + private const val Cols = 9 + private const val SlotSize = 18 + private const val Padding = 7 + private const val TitleHeight = 14 @JvmStatic val isLocked: Boolean get() = lockedSlot != null - private fun getTooltipWidth() = PADDING + COLS * SLOT_SIZE + PADDING - private fun getTooltipHeight() = TITLE_HEIGHT + ROWS * SLOT_SIZE + PADDING + private fun getTooltipWidth() = Padding + Cols * SlotSize + Padding + private fun getTooltipHeight() = TitleHeight + Rows * SlotSize + Padding /** * Check if the mouse is over the locked tooltip area (for click blocking) @@ -194,10 +194,10 @@ object ContainerPreview : Module( drawBackground(context, x, y, width, tintColor) val name = stack.name val textColor = getTextColor(tintColor) - context.drawText(textRenderer, name, x + PADDING, y + 4, textColor, false) + context.drawText(textRenderer, name, x + Padding, y + 4, textColor, false) - val slotsStartX = x + PADDING - val slotsStartY = y + TITLE_HEIGHT + val slotsStartX = x + Padding + val slotsStartY = y + TitleHeight val actualMouseX = (mc.mouse.x * mc.window.scaledWidth / mc.window.width).toInt() val actualMouseY = (mc.mouse.y * mc.window.scaledHeight / mc.window.height).toInt() @@ -207,19 +207,19 @@ object ContainerPreview : Module( var hoveredSlotY = 0 for ((index, item) in contents.withIndex()) { - if (index >= COLS * ROWS) break + if (index >= Cols * Rows) break - val slotCol = index % COLS - val slotRow = index / COLS + val slotCol = index % Cols + val slotRow = index / Cols - val slotX = slotsStartX + slotCol * SLOT_SIZE - val slotY = slotsStartY + slotRow * SLOT_SIZE + val slotX = slotsStartX + slotCol * SlotSize + val slotY = slotsStartY + slotRow * SlotSize val itemX = slotX + 1 val itemY = slotY + 1 if (allowHover) { - val isHovered = actualMouseX >= slotX && actualMouseX < slotX + SLOT_SIZE && - actualMouseY >= slotY && actualMouseY < slotY + SLOT_SIZE + val isHovered = actualMouseX >= slotX && actualMouseX < slotX + SlotSize && + actualMouseY >= slotY && actualMouseY < slotY + SlotSize if (isHovered && !item.isEmpty) { context.fill(itemX, itemY, itemX + 16, itemY + 16, 0x80FFFFFF.toInt()) @@ -311,21 +311,21 @@ object ContainerPreview : Module( background, x, y, 0f, 0f, - width, TITLE_HEIGHT, - width, TITLE_HEIGHT, + width, TitleHeight, + width, TitleHeight, 256, 256, tintColor ) // Middle rows - (0 until ROWS).forEach { row -> + (0 until Rows).forEach { row -> context.drawTexture( RenderPipelines.GUI_TEXTURED, background, - x, y + TITLE_HEIGHT + row * SLOT_SIZE, + x, y + TitleHeight + row * SlotSize, 0f, 17f, - width, SLOT_SIZE, - width, SLOT_SIZE, + width, SlotSize, + width, SlotSize, 256, 256, tintColor ) @@ -335,10 +335,10 @@ object ContainerPreview : Module( context.drawTexture( RenderPipelines.GUI_TEXTURED, background, - x, y + TITLE_HEIGHT + ROWS * SLOT_SIZE, + x, y + TitleHeight + Rows * SlotSize, 0f, 160f, - width, PADDING, - width, PADDING, + width, Padding, + width, Padding, 256, 256, tintColor ) diff --git a/src/main/kotlin/com/lambda/module/modules/render/ESP.kt b/src/main/kotlin/com/lambda/module/modules/render/ESP.kt index 1dab2a16a..4461bcf9a 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/ESP.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/ESP.kt @@ -20,10 +20,10 @@ package com.lambda.module.modules.render import com.lambda.config.Group import com.lambda.config.Tab import com.lambda.config.applyEdits -import com.lambda.config.groups.EntityColorSettings -import com.lambda.config.groups.EntitySelectionSettings -import com.lambda.config.groups.OutlineSettings -import com.lambda.config.groups.WorldLineSettings +import com.lambda.config.blocks.EntityColorSettings +import com.lambda.config.blocks.EntitySelectionSettings +import com.lambda.config.blocks.OutlineSettings +import com.lambda.config.blocks.WorldLineSettings import com.lambda.graphics.mc.RenderBuilder import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRenderer import com.lambda.graphics.util.DynamicAABB.Companion.interpolatedBox @@ -40,7 +40,7 @@ import java.awt.Color object ESP : Module( name = "ESP", description = "Highlight entities with smooth interpolated rendering", - tag = ModuleTag.RENDER + tag = ModuleTag.Render ) { private enum class EspMode { Shader, @@ -49,38 +49,38 @@ object ESP : Module( // Frame } - private const val GENERAL_TAB = "General" - private const val ENTITIES_TAB = "Entities" - private const val COLORS_TAB = "Colors" + private const val GeneralTab = "General" + private const val EntitiesTab = "Entities" + private const val ColorsTab = "Colors" - private const val BOX_OUTLINE_GROUP = "Outline" + private const val BoxOutlineGroup = "Outline" private enum class BoxGroup(override val displayName: String) : NamedEnum { Fill("Fill"), Outline("Outline") } - @Tab(GENERAL_TAB) private val mode by setting("Mode", EspMode.Shader) - @Tab(GENERAL_TAB) private val depthTest by setting("Depth Test", false, "Blend ESP renders into the world") + @Tab(GeneralTab) private val mode by setting("Mode", EspMode.Shader) + @Tab(GeneralTab) private val depthTest by setting("Depth Test", false, "Blend ESP renders into the world") //Shader Outline - @Tab(GENERAL_TAB) private val outlineStyle = settingBlock(OutlineSettings(this), { mode == EspMode.Shader }) + @Tab(GeneralTab) private val outlineStyle = settingBlock(OutlineSettings(this), { mode == EspMode.Shader }) //Box - @Tab(GENERAL_TAB) private var drawFilled: Boolean by setting("Box Fill", true, "Fill entity boxes") { mode == EspMode.Box } + @Tab(GeneralTab) private var drawFilled: Boolean by setting("Box Fill", true, "Fill entity boxes") { mode == EspMode.Box } .onValueChange { _, to -> if (!to && !drawOutline) drawOutline = true } - @Tab(GENERAL_TAB) private val fillAlpha by setting("Filled Alpha", 0.2, 0.0..1.0, 0.05) { mode == EspMode.Box && drawFilled } - @Tab(GENERAL_TAB) @Group(BOX_OUTLINE_GROUP) private var drawOutline: Boolean by setting("Box Outline", true, "Draw box outlines") { mode == EspMode.Box } + @Tab(GeneralTab) private val fillAlpha by setting("Filled Alpha", 0.2, 0.0..1.0, 0.05) { mode == EspMode.Box && drawFilled } + @Tab(GeneralTab) @Group(BoxOutlineGroup) private var drawOutline: Boolean by setting("Box Outline", true, "Draw box outlines") { mode == EspMode.Box } .onValueChange { _, to -> if (!to && !drawFilled) drawFilled = true } - @Tab(GENERAL_TAB) @Group(BOX_OUTLINE_GROUP) private val outlineAlpha by setting("Outline Alpha", 0.8, 0.0..1.0, 0.05) { mode == EspMode.Box && drawOutline } - @Tab(GENERAL_TAB) @Group(BOX_OUTLINE_GROUP) private val boxOutlineSettings = + @Tab(GeneralTab) @Group(BoxOutlineGroup) private val outlineAlpha by setting("Outline Alpha", 0.8, 0.0..1.0, 0.05) { mode == EspMode.Box && drawOutline } + @Tab(GeneralTab) @Group(BoxOutlineGroup) private val boxOutlineSettings = settingBlock( WorldLineSettings(this), { mode == EspMode.Box && drawOutline } ) { applyEdits { hide(::startColor, ::endColor) } } - @Tab(ENTITIES_TAB) private val entitySettings = EntitySelectionSettings(this) - @Tab(COLORS_TAB) private val entityColors = EntityColorSettings(this) + @Tab(EntitiesTab) private val entitySettings = EntitySelectionSettings(this) + @Tab(ColorsTab) private val entityColors = EntityColorSettings(this) init { immediateRenderer("EntityESP Immediate Renderer", depthTest = { depthTest }) { safeContext -> diff --git a/src/main/kotlin/com/lambda/module/modules/render/ExtraTab.kt b/src/main/kotlin/com/lambda/module/modules/render/ExtraTab.kt index d70c37a5a..86382324f 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/ExtraTab.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/ExtraTab.kt @@ -24,7 +24,7 @@ import java.awt.Color object ExtraTab : Module( name = "ExtraTab", description = "Adds more tabs to the main menu", - tag = ModuleTag.RENDER, + tag = ModuleTag.Render, ) { @JvmStatic val tabEntries by setting("Tab Entries", 80L, 1L..500L, 1L) @JvmStatic val rows by setting("Rows", 20, 1..100, 1) diff --git a/src/main/kotlin/com/lambda/module/modules/render/FreeLook.kt b/src/main/kotlin/com/lambda/module/modules/render/FreeLook.kt index a67af3e35..07323061a 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/FreeLook.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/FreeLook.kt @@ -31,7 +31,7 @@ import net.minecraft.client.option.Perspective object FreeLook : Module( name = "FreeLook", description = "Allows you to look around freely while moving", - tag = ModuleTag.PLAYER, + tag = ModuleTag.Player, autoDisable = true ) { @JvmStatic val enableYaw by setting("Enable Yaw", false, "Don't effect pitch if enabled") @@ -44,7 +44,7 @@ object FreeLook : Module( /** * @see net.minecraft.entity.Entity.changeLookDirection */ - private const val SENSITIVITY_FACTOR = 0.15 + private const val SensitivityFactor = 0.15 @JvmStatic fun updateCam() { @@ -69,8 +69,8 @@ object FreeLook : Module( if (!isEnabled) return@listen camera = camera.withDelta( - it.deltaYaw * SENSITIVITY_FACTOR, - it.deltaPitch * SENSITIVITY_FACTOR + it.deltaYaw * SensitivityFactor, + it.deltaPitch * SensitivityFactor ) if (enableYaw) RotationManager.setPlayerYaw(camera.yaw) diff --git a/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt b/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt index 25fe54004..ade2479f9 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt @@ -69,7 +69,7 @@ import kotlin.math.sign object Freecam : Module( name = "Freecam", description = "Move your camera freely", - tag = ModuleTag.RENDER, + tag = ModuleTag.Render, autoDisable = true, ) { private val mode by setting("Mode", Mode.Free, "Freecam movement mode") @@ -84,7 +84,6 @@ object Freecam : Module( private val followMaxDistance by setting("String Length", 10.0, 2.0..50.0, 0.5, "Maximum distance before the string pulls the camera", unit = "m") { mode == Mode.FollowPlayer } private val followTrackPlayer by setting("Track Player", false, "Keeps looking at the followed player") { mode == Mode.FollowPlayer } - private var lastPerspective = Perspective.FIRST_PERSON private var lastPlayerPosition: Vec3d = Vec3d.ZERO private var prevPosition: Vec3d = Vec3d.ZERO @@ -119,7 +118,7 @@ object Freecam : Module( /** * @see net.minecraft.entity.Entity.changeLookDirection */ - private const val SENSITIVITY_FACTOR = 0.15 + private const val SensitivityFactor = 0.15 init { setDefaultAutomationConfig { @@ -152,7 +151,7 @@ object Freecam : Module( } listen { - rotation = rotation.withDelta(it.deltaYaw * SENSITIVITY_FACTOR, it.deltaPitch * SENSITIVITY_FACTOR) + rotation = rotation.withDelta(it.deltaYaw * SensitivityFactor, it.deltaPitch * SensitivityFactor) it.cancel() } diff --git a/src/main/kotlin/com/lambda/module/modules/render/Fullbright.kt b/src/main/kotlin/com/lambda/module/modules/render/Fullbright.kt index 9897e4504..6a1828d52 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Fullbright.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Fullbright.kt @@ -28,7 +28,7 @@ import net.minecraft.entity.effect.StatusEffects object Fullbright : Module( name = "Fullbright", description = "Makes everything brighter", - tag = ModuleTag.RENDER, + tag = ModuleTag.Render, ) { private val nightVision by setting("Night Vision", false, description = "Adds the night vision effect client-side") .onValueChange { _, to -> setNightVision(to) } diff --git a/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt b/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt index 4e61e75cc..c66f1ea99 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt @@ -19,7 +19,7 @@ package com.lambda.module.modules.render import com.lambda.config.Group import com.lambda.config.applyEdits -import com.lambda.config.groups.WorldLineSettings +import com.lambda.config.blocks.WorldLineSettings import com.lambda.context.SafeContext import com.lambda.graphics.mc.LineDashStyle import com.lambda.graphics.mc.RenderBuilder @@ -44,10 +44,10 @@ import java.awt.Color object LightLevels : Module( name = "LightLevels", description = "Shows light level. Helpful for mob-proofing areas", - tag = ModuleTag.RENDER + tag = ModuleTag.Render ) { - private const val FILL_GROUP = "Fill" - private const val LINE_GROUP = "Line" + private const val FillGroup = "Fill" + private const val LineGroup = "Line" private val mode: Mode by setting("Mode", Mode.Chunked) .onValueChange { _, _ -> chunkedRenderer.clear(); refreshChunkedRenderer(this) } @@ -57,10 +57,10 @@ object LightLevels : Module( private val skyLightColor by setting("Sky Light Color", Color.YELLOW).onValueChange(::refreshChunkedRenderer) private val blockLightColor by setting("Block Light Color", Color.RED).onValueChange(::refreshChunkedRenderer) private val size by setting("Size", 14, 1..16).onValueChange(::refreshChunkedRenderer) - @Group(FILL_GROUP) private val fill by setting("Fill", false) { renderMode == RenderMode.Square }.onValueChange(::refreshChunkedRenderer) - @Group(FILL_GROUP) private val fillAlpha by setting("Fill Alpha", 0.2, 0.0..1.0, 0.01) { renderMode == RenderMode.Square && fill }.onValueChange(::refreshChunkedRenderer) - @Group(LINE_GROUP) private val outline by setting("Outline", true) { renderMode == RenderMode.Square }.onValueChange(::refreshChunkedRenderer) - @Group(LINE_GROUP) private val worldLineConfig = + @Group(FillGroup) private val fill by setting("Fill", false) { renderMode == RenderMode.Square }.onValueChange(::refreshChunkedRenderer) + @Group(FillGroup) private val fillAlpha by setting("Fill Alpha", 0.2, 0.0..1.0, 0.01) { renderMode == RenderMode.Square && fill }.onValueChange(::refreshChunkedRenderer) + @Group(LineGroup) private val outline by setting("Outline", true) { renderMode == RenderMode.Square }.onValueChange(::refreshChunkedRenderer) + @Group(LineGroup) private val worldLineConfig = settingBlock(WorldLineSettings(this), { renderMode != RenderMode.Square || outline }) { applyEdits { hide(::startColor, ::endColor) diff --git a/src/main/kotlin/com/lambda/module/modules/render/MapPreview.kt b/src/main/kotlin/com/lambda/module/modules/render/MapPreview.kt index fedeea4cd..16d87f40b 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/MapPreview.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/MapPreview.kt @@ -36,7 +36,7 @@ import net.minecraft.util.Identifier object MapPreview : Module( name = "MapPreview", description = "Preview maps in your inventory", - tag = ModuleTag.RENDER, + tag = ModuleTag.Render, ) { @JvmStatic val showInSlot by setting("Show In Slot", true, "Shows the map in the slot rather than the basic map icon") diff --git a/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt b/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt index 9bd5312a3..99470adee 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt @@ -21,8 +21,8 @@ import com.lambda.Lambda.mc import com.lambda.config.Group import com.lambda.config.Tab import com.lambda.config.applyEdits -import com.lambda.config.groups.EntitySelectionSettings -import com.lambda.config.groups.ScreenTextSettings +import com.lambda.config.blocks.EntitySelectionSettings +import com.lambda.config.blocks.ScreenTextSettings import com.lambda.friend.FriendHandler.isFriend import com.lambda.graphics.mc.RenderBuilder import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRenderer @@ -50,53 +50,52 @@ import kotlin.math.max object Nametags : Module( name = "Nametags", description = "Displays information about entities above them", - tag = ModuleTag.RENDER + tag = ModuleTag.Render ) { - private const val GENERAL_TAB = "General" - private const val ENTITY_TAB = "Entities" - private const val BACKGROUND_TAB = "Background" - private const val TEXT_TAB = "Text" + private const val GeneralTab = "General" + private const val EntityTab = "Entities" + private const val BackgroundTab = "Background" + private const val TextTab = "Text" - @Tab(GENERAL_TAB) private val textSize by setting("Text Size", 18, 1..50, 1) - @Tab(GENERAL_TAB) private val itemScale by setting("Item Scale", 3f, 0.4f..5f, 0.01f) - @Tab(GENERAL_TAB) private val yOffset by setting("Y Offset", 0.2, 0.0..1.0, 0.01) - @Tab(GENERAL_TAB) private val spacing by setting("Spacing", 0, 0..10, 1) - @Tab(GENERAL_TAB) private val health by setting("Health", true) - @Tab(GENERAL_TAB) private val ping by setting("Ping", true) - @Tab(GENERAL_TAB) private val gear by setting("Gear", true) - @Tab(GENERAL_TAB) private val mainItem by setting("Main Item", true) { gear } - @Tab(GENERAL_TAB) private val offhandItem by setting("Offhand Item", true) { gear } - //ToDo: Implement -// private val enchantments by setting("Enchantments", false) { gear } - @Tab(GENERAL_TAB) private val itemName by setting("Item Name", true) - @Tab(GENERAL_TAB) private val itemNameScale by setting("Item Name Scale", 0.7f, 0.1f..1.0f, 0.01f) { itemName } - @Tab(GENERAL_TAB) private val itemCount by setting("Item Count", true) - @Tab(GENERAL_TAB) private val durabilityMode by setting("Durability Mode", DurabilityMode.Text) { gear } + @Tab(GeneralTab) private val textSize by setting("Text Size", 18, 1..50, 1) + @Tab(GeneralTab) private val itemScale by setting("Item Scale", 3f, 0.4f..5f, 0.01f) + @Tab(GeneralTab) private val yOffset by setting("Y Offset", 0.2, 0.0..1.0, 0.01) + @Tab(GeneralTab) private val spacing by setting("Spacing", 0, 0..10, 1) + @Tab(GeneralTab) private val health by setting("Health", true) + @Tab(GeneralTab) private val ping by setting("Ping", true) + @Tab(GeneralTab) private val gear by setting("Gear", true) + @Tab(GeneralTab) private val mainItem by setting("Main Item", true) { gear } + @Tab(GeneralTab) private val offhandItem by setting("Offhand Item", true) { gear } +//ToDo: Implement private val enchantments by setting("Enchantments", false) { gear } + @Tab(GeneralTab) private val itemName by setting("Item Name", true) + @Tab(GeneralTab) private val itemNameScale by setting("Item Name Scale", 0.7f, 0.1f..1.0f, 0.01f) { itemName } + @Tab(GeneralTab) private val itemCount by setting("Item Count", true) + @Tab(GeneralTab) private val durabilityMode by setting("Durability Mode", DurabilityMode.Text) { gear } - @Tab(ENTITY_TAB) private val entitySelectionSettings = + @Tab(EntityTab) private val entitySelectionSettings = settingBlock(EntitySelectionSettings(this)) { applyEdits { hide(::blockEntities) } } - @Tab(BACKGROUND_TAB) private val background by setting("Background", true) - @Tab(BACKGROUND_TAB) private val backgroundColor by setting("Background Color", Color(0, 0, 0, 60)) { background } - @Tab(BACKGROUND_TAB) private val backgroundSize by setting("Background Size", 1.0f, 1.0f..2.0f, 0.01f) { background } + private const val FriendGroup = "Friends" + private const val OtherGroup = "Others" - private const val FRIEND_GROUP = "Friends" - private const val OTHER_GROUP = "Others" - - @Tab(TEXT_TAB) @Group(FRIEND_GROUP) private val friendTextConfig = + @Tab(TextTab) @Group(FriendGroup) private val friendTextConfig = settingBlock(ScreenTextSettings(this)) { applyEdits { hide(::sizeSetting) ::textColor.edit { defaultValue(Color(0, 255, 255, 255)) } } } - @Tab(TEXT_TAB) @Group(OTHER_GROUP) private val otherTextConfig = + @Tab(TextTab) @Group(OtherGroup) private val otherTextConfig = settingBlock(ScreenTextSettings(this)) { applyEdits { hide(::sizeSetting) } } + @Tab(BackgroundTab) private val background by setting("Background", true) + @Tab(BackgroundTab) private val backgroundColor by setting("Background Color", Color(0, 0, 0, 60)) { background } + @Tab(BackgroundTab) private val backgroundSize by setting("Background Size", 1.0f, 1.0f..2.0f, 0.01f) { background } + var heightWidthRatio = 0f var trueItemScaleX = 0f var trueItemScaleY = 0f diff --git a/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt b/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt index dd2f7025e..058c19443 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt @@ -19,7 +19,7 @@ package com.lambda.module.modules.render import com.lambda.config.Tab import com.lambda.config.applyEdits -import com.lambda.config.groups.EntitySelectionSettings +import com.lambda.config.blocks.EntitySelectionSettings import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.EntityUtils.createNameMap @@ -32,60 +32,60 @@ import net.minecraft.entity.Entity object NoRender : Module( name = "NoRender", description = "Disables rendering of certain things", - tag = ModuleTag.RENDER, + tag = ModuleTag.Render, ) { private val particleMap = createParticleNameMap() - private const val EFFECT_TAB = "Effect" - private const val HUD_TAB = "Hud" - private const val ENTITY_TAB = "Entity" - private const val WORLD_TAB = "World" + private const val EffectTab = "Effect" + private const val HudTab = "Hud" + private const val EntityTab = "Entity" + private const val WorldTab = "World" - @Tab(EFFECT_TAB) @JvmStatic val noBlindness by setting("No Blindness", true) - @Tab(EFFECT_TAB) @JvmStatic val noDarkness by setting("No Darkness", true) - @Tab(EFFECT_TAB) @JvmStatic val noNausea by setting("No Nausea", true) + @Tab(EffectTab) @JvmStatic val noBlindness by setting("No Blindness", true) + @Tab(EffectTab) @JvmStatic val noDarkness by setting("No Darkness", true) + @Tab(EffectTab) @JvmStatic val noNausea by setting("No Nausea", true) - @Tab(HUD_TAB) @JvmStatic val noFireOverlay by setting("No Fire Overlay", false) - @Tab(HUD_TAB) @JvmStatic val fireOverlayYOffset by setting("Fire Overlay Y Offset", 0.0, -0.4..0.4, 0.02) { !noFireOverlay } - @Tab(HUD_TAB) @JvmStatic val noPortalOverlay by setting("No Portal Overlay", true) - @Tab(HUD_TAB) @JvmStatic val noFluidOverlay by setting("No Fluid Overlay", true) - @Tab(HUD_TAB) @JvmStatic val noPowderedSnowOverlay by setting("No Powdered Snow Overlay", true) - @Tab(HUD_TAB) @JvmStatic val noInWall by setting("No In Wall Overlay", true) - @Tab(HUD_TAB) @JvmStatic val noPumpkinOverlay by setting("No Pumpkin Overlay", true) - @Tab(HUD_TAB) @JvmStatic val noVignette by setting("No Vignette", true) - @Tab(HUD_TAB) @JvmStatic val noChatVerificationToast by setting("No Chat Verification Toast", true) - @Tab(HUD_TAB) @JvmStatic val noSpyglassOverlay by setting("No Spyglass Overlay", false) - @Tab(HUD_TAB) @JvmStatic val noGuiShadow by setting("No Gui Shadow", false) - @Tab(HUD_TAB) @JvmStatic val noFloatingItemAnimation by setting("No Floating Item Animation", false, "Disables floating item animations, typically used when a totem pops") - @Tab(HUD_TAB) @JvmStatic val noCrosshair by setting("No Crosshair", false) - @Tab(HUD_TAB) @JvmStatic val noBossBar by setting("No Boss Bar", false) - @Tab(HUD_TAB) @JvmStatic val noScoreBoard by setting("No Score Board", false) - @Tab(HUD_TAB) @JvmStatic val noStatusEffects by setting("No Status Effects", false) - @Tab(HUD_TAB) @JvmStatic val no2b2tActionText by setting("No 2b2t Action Text", true, description = "Blocks the '2b2t.org' text from the action bar 2b2t randomly sends") + @Tab(HudTab) @JvmStatic val noFireOverlay by setting("No Fire Overlay", false) + @Tab(HudTab) @JvmStatic val fireOverlayYOffset by setting("Fire Overlay Y Offset", 0.0, -0.4..0.4, 0.02) { !noFireOverlay } + @Tab(HudTab) @JvmStatic val noPortalOverlay by setting("No Portal Overlay", true) + @Tab(HudTab) @JvmStatic val noFluidOverlay by setting("No Fluid Overlay", true) + @Tab(HudTab) @JvmStatic val noPowderedSnowOverlay by setting("No Powdered Snow Overlay", true) + @Tab(HudTab) @JvmStatic val noInWall by setting("No In Wall Overlay", true) + @Tab(HudTab) @JvmStatic val noPumpkinOverlay by setting("No Pumpkin Overlay", true) + @Tab(HudTab) @JvmStatic val noVignette by setting("No Vignette", true) + @Tab(HudTab) @JvmStatic val noChatVerificationToast by setting("No Chat Verification Toast", true) + @Tab(HudTab) @JvmStatic val noSpyglassOverlay by setting("No Spyglass Overlay", false) + @Tab(HudTab) @JvmStatic val noGuiShadow by setting("No Gui Shadow", false) + @Tab(HudTab) @JvmStatic val noFloatingItemAnimation by setting("No Floating Item Animation", false, "Disables floating item animations, typically used when a totem pops") + @Tab(HudTab) @JvmStatic val noCrosshair by setting("No Crosshair", false) + @Tab(HudTab) @JvmStatic val noBossBar by setting("No Boss Bar", false) + @Tab(HudTab) @JvmStatic val noScoreBoard by setting("No Score Board", false) + @Tab(HudTab) @JvmStatic val noStatusEffects by setting("No Status Effects", false) + @Tab(HudTab) @JvmStatic val no2b2tActionText by setting("No 2b2t Action Text", true, description = "Blocks the '2b2t.org' text from the action bar 2b2t randomly sends") - @Tab(ENTITY_TAB) @JvmStatic val noArmor by setting("No Armor", false) - @Tab(ENTITY_TAB) @JvmStatic val includeNoOtherHeadItems by setting("Include No Other Head Items", false) { noArmor } - @Tab(ENTITY_TAB) @JvmStatic val noElytra by setting("No Elytra", false) - @Tab(ENTITY_TAB) @JvmStatic val noInvisibility by setting("No Invisibility", true) - @Tab(ENTITY_TAB) @JvmStatic val noGlow by setting("No Glow", false) - @Tab(ENTITY_TAB) @JvmStatic val noNametags by setting("No Nametags", false) + @Tab(EntityTab) @JvmStatic val noArmor by setting("No Armor", false) + @Tab(EntityTab) @JvmStatic val includeNoOtherHeadItems by setting("Include No Other Head Items", false) { noArmor } + @Tab(EntityTab) @JvmStatic val noElytra by setting("No Elytra", false) + @Tab(EntityTab) @JvmStatic val noInvisibility by setting("No Invisibility", true) + @Tab(EntityTab) @JvmStatic val noGlow by setting("No Glow", false) + @Tab(EntityTab) @JvmStatic val noNametags by setting("No Nametags", false) // RenderLayer.getArmorEntityGlint(), RenderLayer.getGlint(), RenderLayer.getGlintTranslucent(), RenderLayer.getEntityGlint() // @JvmStatic val noEnchantmentGlint by setting("No Enchantment Glint", false).group(Group.Entity) // @JvmStatic val noDeadEntities by setting("No Dead Entities", false).group(Group.Entity) - @Tab(ENTITY_TAB) private val entitySettings = + @Tab(EntityTab) private val entitySettings = settingBlock(EntitySelectionSettings(this)) { applyEdits { editTyped(::playerEntities, ::mobEntities, ::bossEntities) { defaultValue(mutableSetOf()) } } } - @Tab(WORLD_TAB) @JvmStatic val noTerrainFog by setting("No Terrain Fog", false) - @Tab(WORLD_TAB) @JvmStatic val noSignText by setting("No Sign Text", false) - @Tab(WORLD_TAB) @JvmStatic val noWorldBorder by setting("No World Border", false) - @Tab(WORLD_TAB) @JvmStatic val noEnchantingTableBook by setting("No Enchanting Table Book", false) + @Tab(WorldTab) @JvmStatic val noTerrainFog by setting("No Terrain Fog", false) + @Tab(WorldTab) @JvmStatic val noSignText by setting("No Sign Text", false) + @Tab(WorldTab) @JvmStatic val noWorldBorder by setting("No World Border", false) + @Tab(WorldTab) @JvmStatic val noEnchantingTableBook by setting("No Enchanting Table Book", false) // Couldn't get to work with block entities without crashing with sodium on boot // @JvmStatic val noBlockBreakingOverlay by setting("No Block Breaking Overlay", false).group(Group.World) - @Tab(WORLD_TAB) @JvmStatic val noBeaconBeams by setting("No Beacon Beams", false) - @Tab(WORLD_TAB) @JvmStatic val noSpawnerMob by setting("No Spawner Mob", false) - @Tab(WORLD_TAB) private val particles by setting("Particles", emptySet(), particleMap.values.toSet(), "Particles to omit from rendering") + @Tab(WorldTab) @JvmStatic val noBeaconBeams by setting("No Beacon Beams", false) + @Tab(WorldTab) @JvmStatic val noSpawnerMob by setting("No Spawner Mob", false) + @Tab(WorldTab) private val particles by setting("Particles", emptySet(), particleMap.values.toSet(), "Particles to omit from rendering") private fun createParticleNameMap() = scanResult diff --git a/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt b/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt index f964f4bb2..5b2894e20 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt @@ -18,9 +18,8 @@ package com.lambda.module.modules.render import com.lambda.config.Group -import com.lambda.config.Tab import com.lambda.config.applyEdits -import com.lambda.config.groups.WorldLineSettings +import com.lambda.config.blocks.WorldLineSettings import com.lambda.context.SafeContext import com.lambda.graphics.mc.RenderBuilder import com.lambda.graphics.mc.renderer.ChunkedRenderer.Companion.chunkedRenderer @@ -40,22 +39,22 @@ import java.awt.Color object RadiusESP : Module( name = "RadiusESP", description = "Shows the radius for blocks with abnormal functionality", - tag = ModuleTag.RENDER + tag = ModuleTag.Render ) { - private const val RENDER_GROUP = "Render" - private const val OUTLINE_GROUP = "Outline" + private const val RenderGroup = "Render" + private const val OutlineGroup = "Outline" private val beacons by setting("Beacons", true).onValueChange(::rebuildMesh) private val spawners by setting("Spawners", true).onValueChange(::rebuildMesh) - @Group(RENDER_GROUP) private val beaconColor by setting("Beacon Color", Color(0, 255, 255, 255)) { beacons }.onValueChange(::rebuildMesh) - @Group(RENDER_GROUP) private val spawnerColor by setting("Spawner Color", Color(255, 0, 0, 255)) { spawners }.onValueChange(::rebuildMesh) - @Group(RENDER_GROUP) private var fill: Boolean by setting("Fill", true).onValueChange(::rebuildMesh) + @Group(RenderGroup) private val beaconColor by setting("Beacon Color", Color(0, 255, 255, 255)) { beacons }.onValueChange(::rebuildMesh) + @Group(RenderGroup) private val spawnerColor by setting("Spawner Color", Color(255, 0, 0, 255)) { spawners }.onValueChange(::rebuildMesh) + @Group(RenderGroup) private var fill: Boolean by setting("Fill", true).onValueChange(::rebuildMesh) .onValueChange { _, to -> if (!to) outline = true } - @Group(RENDER_GROUP) private var outline: Boolean by setting("Outline", true).onValueChange(::rebuildMesh) + @Group(RenderGroup) private var outline: Boolean by setting("Outline", true).onValueChange(::rebuildMesh) .onValueChange { _, to -> if (!to) fill = true } - @Group(RENDER_GROUP) private val fillAlpha by setting("Fill Alpha", 0.1, 0.0..1.0, 0.01).onValueChange(::rebuildMesh) - @Group(RENDER_GROUP, OUTLINE_GROUP) private val worldLineConfig = + @Group(RenderGroup) private val fillAlpha by setting("Fill Alpha", 0.1, 0.0..1.0, 0.01).onValueChange(::rebuildMesh) + @Group(RenderGroup, OutlineGroup) private val worldLineConfig = settingBlock( WorldLineSettings(this), { outline } diff --git a/src/main/kotlin/com/lambda/module/modules/render/Search.kt b/src/main/kotlin/com/lambda/module/modules/render/Search.kt index 15d6c9c8c..ab25be39d 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Search.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Search.kt @@ -18,10 +18,9 @@ package com.lambda.module.modules.render import com.lambda.config.Group -import com.lambda.config.Tab import com.lambda.config.applyEdits -import com.lambda.config.groups.ScreenLineSettings -import com.lambda.config.groups.WorldLineSettings +import com.lambda.config.blocks.ScreenLineSettings +import com.lambda.config.blocks.WorldLineSettings import com.lambda.config.settings.collections.CollectionSetting.Companion.onDeselect import com.lambda.config.settings.collections.CollectionSetting.Companion.onSelect import com.lambda.context.SafeContext @@ -39,7 +38,6 @@ import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe import com.lambda.util.EntityUtils.decorationEntityMap import com.lambda.util.EntityUtils.entityGroup -import com.lambda.util.NamedEnum import com.lambda.util.extension.blockColor import com.lambda.util.extension.entityColor import com.lambda.util.extension.getBlockState @@ -58,11 +56,11 @@ import java.awt.Color object Search : Module( name = "Search", description = "Highlight blocks within the rendered world", - tag = ModuleTag.RENDER, + tag = ModuleTag.Render, ) { - private const val FILL_GROUP = "Fill" - private const val OUTLINE_GROUP = "Outline" - private const val TRACERS_GROUP = "Tracers" + private const val FillGroup = "Fill" + private const val OutlineGroup = "Outline" + private const val TracersGroup = "Tracers" private val blocks by setting("Blocks", setOf(Blocks.CHEST, Blocks.ENDER_CHEST, Blocks.NETHER_PORTAL, Blocks.END_PORTAL, Blocks.END_PORTAL_FRAME, Blocks.END_GATEWAY), description = "Render blocks") .onSelect { rebuildMesh(this) }.onDeselect { rebuildMesh(this) } @@ -76,18 +74,18 @@ object Search : Module( private val naturalTracerAlpha by setting("Natural Tracer Alpha", 1.0, 0.1..1.0, 0.05) { useNaturalColor }.onValueChange(::rebuildMesh) private val minimumNaturalBrightness by setting("Min Brightness", 150, 0..255, 1) { useNaturalColor }.onValueChange(::rebuildMesh) - @Group(FILL_GROUP) private var fill: Boolean by setting("Fill", true, "Fill the faces of blocks").onValueChange(::rebuildMesh) + @Group(FillGroup) private var fill: Boolean by setting("Fill", true, "Fill the faces of blocks").onValueChange(::rebuildMesh) .onValueChange { _, to -> if (!to) outline = true } - @Group(FILL_GROUP) private val blockFillColor by setting("Block Fill Color", Color(100, 150, 255, 51), "Color of the surfaces") { fill && !useNaturalColor }.onValueChange(::rebuildMesh) - @Group(FILL_GROUP) private val entityFillColor by setting("Entity Fill Color", Color(100, 150, 255, 51)) { fill && !useNaturalColor }.onValueChange(::rebuildMesh) + @Group(FillGroup) private val blockFillColor by setting("Block Fill Color", Color(100, 150, 255, 51), "Color of the surfaces") { fill && !useNaturalColor }.onValueChange(::rebuildMesh) + @Group(FillGroup) private val entityFillColor by setting("Entity Fill Color", Color(100, 150, 255, 51)) { fill && !useNaturalColor }.onValueChange(::rebuildMesh) - @Group(OUTLINE_GROUP) private var outline: Boolean by setting("Outline", true, "Draw the outlines of blocks").onValueChange(::rebuildMesh) + @Group(OutlineGroup) private var outline: Boolean by setting("Outline", true, "Draw the outlines of blocks").onValueChange(::rebuildMesh) .onValueChange { _, to -> if (!to) fill = true } - @Group(OUTLINE_GROUP) private val blockLineColor by setting("Block Line Color", Color(100, 150, 255, 128)) { outline && !useNaturalColor }.onValueChange(::rebuildMesh) - @Group(OUTLINE_GROUP) private val entityOutlineColor by setting("Entity Outline Color", Color(100, 150, 255, 128)) { outline && !useNaturalColor }.onValueChange(::rebuildMesh) + @Group(OutlineGroup) private val blockLineColor by setting("Block Line Color", Color(100, 150, 255, 128)) { outline && !useNaturalColor }.onValueChange(::rebuildMesh) + @Group(OutlineGroup) private val entityOutlineColor by setting("Entity Outline Color", Color(100, 150, 255, 128)) { outline && !useNaturalColor }.onValueChange(::rebuildMesh) - @Group(OUTLINE_GROUP) private val blockOutlineMode by setting("Block Outline Mode", DirectionMask.OutlineMode.And, "Outline mode") { outline }.onValueChange(::rebuildMesh) - @Group(OUTLINE_GROUP) private val outlineConfig = + @Group(OutlineGroup) private val blockOutlineMode by setting("Block Outline Mode", DirectionMask.OutlineMode.And, "Outline mode") { outline }.onValueChange(::rebuildMesh) + @Group(OutlineGroup) private val outlineConfig = settingBlock( WorldLineSettings(this), { outline } @@ -97,8 +95,8 @@ object Search : Module( forEachSetting { it.onValueChange(::rebuildMesh) } } } - @Group(TRACERS_GROUP) private val tracers by setting("Tracers", true, "Draw a line from your cursor to the highlighted position") - @Group(TRACERS_GROUP) private val tracerConfig = + @Group(TracersGroup) private val tracers by setting("Tracers", true, "Draw a line from your cursor to the highlighted position") + @Group(TracersGroup) private val tracerConfig = settingBlock( ScreenLineSettings(this), { tracers } @@ -125,7 +123,7 @@ object Search : Module( buildSideMesh(position) { world.getBlockState(it).block in blocks } - } else DirectionMask.ALL + } else DirectionMask.All val lineColor = getBlockColor(state, position.toBlockPos()) val fillColor = Color(lineColor.red, lineColor.green, lineColor.blue, (naturalColorAlpha * 255).toInt()) @@ -158,7 +156,7 @@ object Search : Module( val entityColor = getEntityColor(entity) box( listOf(entity.interpolatedBox), - DirectionMask.NONE, + DirectionMask.None, if (useNaturalColor) entityColor.setAlpha(naturalColorAlpha) else entityFillColor, if (useNaturalColor) entityColor else entityOutlineColor ) diff --git a/src/main/kotlin/com/lambda/module/modules/render/Time.kt b/src/main/kotlin/com/lambda/module/modules/render/Time.kt index d5e384c68..7688408cc 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Time.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Time.kt @@ -27,7 +27,7 @@ import net.minecraft.network.packet.s2c.play.WorldTimeUpdateS2CPacket object Time : Module( name = "Time", description = "Changes the time of day", - tag = ModuleTag.RENDER + tag = ModuleTag.Render ) { private val time by setting("Time", 12000L, 0L..24000L, 100L) diff --git a/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt b/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt index 641a79136..73cbe28c2 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt @@ -20,9 +20,9 @@ package com.lambda.module.modules.render import com.lambda.config.Group import com.lambda.config.Tab import com.lambda.config.applyEdits -import com.lambda.config.groups.EntityColorSettings -import com.lambda.config.groups.EntitySelectionSettings -import com.lambda.config.groups.ScreenLineSettings +import com.lambda.config.blocks.EntityColorSettings +import com.lambda.config.blocks.EntitySelectionSettings +import com.lambda.config.blocks.ScreenLineSettings import com.lambda.friend.FriendHandler.isFriend import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRenderer import com.lambda.graphics.mc.renderer.RendererUtils.worldToScreenNormalized @@ -41,38 +41,37 @@ import org.joml.component2 object Tracers : Module( name = "Tracers", description = "Draws lines to entities within the world", - tag = ModuleTag.RENDER + tag = ModuleTag.Render ) { private enum class LineGroup(override val displayName: String) : NamedEnum { Other("Other"), Friend("Friend") } - private const val GENERAL_TAB = "General" - private const val ENTITY_TAB = "Entities" - private const val COLOR_TAB = "Colors" - private const val TRACERS_GROUP = "Tracers" + private const val GeneralTab = "General" + private const val EntityTab = "Entities" + private const val ColorsTab = "Colors" - private const val FRIENDS_LINE_GROUP = "Friends" - private const val OTHERS_LINE_GROUP = "Others" + @Tab(GeneralTab) private val target by setting("Target", TracerMode.Feet) + @Tab(GeneralTab) private val stem by setting("Stem", true) - @Tab(GENERAL_TAB) private val target by setting("Target", TracerMode.Feet) - @Tab(GENERAL_TAB) private val stem by setting("Stem", true) + private const val FriendsLineGroup = "Friends" + private const val OthersLineGroup = "Others" - @Tab(GENERAL_TAB) @Group(FRIENDS_LINE_GROUP) private val friendLineConfig = + @Tab(GeneralTab) @Group(FriendsLineGroup) private val friendLineConfig = settingBlock(ScreenLineSettings(this)) { applyEdits { hide(::startColor, ::endColor) } } - @Tab(GENERAL_TAB) @Group(OTHERS_LINE_GROUP) private val otherLineConfig = + @Tab(GeneralTab) @Group(OthersLineGroup) private val otherLineConfig = settingBlock(ScreenLineSettings(this)) { applyEdits { hide(::startColor, ::endColor) } } - @Tab(ENTITY_TAB) private val entitySettings = + @Tab(EntityTab) private val entitySettings = settingBlock(EntitySelectionSettings(this)) { applyEdits { hide(::self, ::blockEntities) } } - @Tab(COLOR_TAB) private val entityColors = settingBlock(EntityColorSettings(this)) + @Tab(ColorsTab) private val entityColors = settingBlock(EntityColorSettings(this)) init { immediateRenderer("Tracers Immediate Renderer") { safeContext -> diff --git a/src/main/kotlin/com/lambda/module/modules/render/ViewModel.kt b/src/main/kotlin/com/lambda/module/modules/render/ViewModel.kt index 599226a19..c89658cc4 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/ViewModel.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/ViewModel.kt @@ -39,78 +39,78 @@ import kotlin.math.tan object ViewModel : Module( name = "ViewModel", description = "Adjusts hand and held item rendering", - tag = ModuleTag.RENDER, + tag = ModuleTag.Render, ) { - private const val GENERAL_TAB = "General" - private const val SCALE_TAB = "Scale" - private const val POSITION_TAB = "Position" - private const val ROTATION_TAB = "Rotation" - private const val FOV_TAB = "FOV" - private const val HAND_TAB = "Hand" - - @Tab(GENERAL_TAB) private val swingMode by setting("Swing Mode", SwingMode.Standard, "Changes which hands swing") - @Tab(GENERAL_TAB)val swingDuration by setting("Swing Duration", 6, 0..20, 1, "Adjusts how fast the player swings", "ticks") - @Tab(GENERAL_TAB)private val noSwingDelay by setting("No Swing Delay", false, "Removes the delay between swings") - @Tab(GENERAL_TAB)val mainSwingProgress by setting("Main Swing Progress", 0.0f, 0.0f..1.0f, 0.025f, "Renders as if the players main hand was this progress through the swing animation") - @Tab(GENERAL_TAB)val offhandSwingProgress by setting("Offhand Swing Progress", 0.0f, 0.0f..1.0f, 0.025f, "Renders as if the players offhand was this progress through the swing animation") - @Tab(GENERAL_TAB)val oldAnimations by setting("Old Animations", false, "Adjusts the animations to look like they did in 1.8") - @Tab(GENERAL_TAB)val swapAnimation by setting("Swap Animation", true, "If disabled, removes the drop down animation when swapping item") { oldAnimations } + private const val GeneralTab = "General" + private const val ScaleTab = "Scale" + private const val PositionTab = "Position" + private const val RotationTab = "Rotation" + private const val FovTab = "FOV" + private const val HandTab = "Hand" + + @Tab(GeneralTab) private val swingMode by setting("Swing Mode", SwingMode.Standard, "Changes which hands swing") + @Tab(GeneralTab)val swingDuration by setting("Swing Duration", 6, 0..20, 1, "Adjusts how fast the player swings", "ticks") + @Tab(GeneralTab)private val noSwingDelay by setting("No Swing Delay", false, "Removes the delay between swings") + @Tab(GeneralTab)val mainSwingProgress by setting("Main Swing Progress", 0.0f, 0.0f..1.0f, 0.025f, "Renders as if the players main hand was this progress through the swing animation") + @Tab(GeneralTab)val offhandSwingProgress by setting("Offhand Swing Progress", 0.0f, 0.0f..1.0f, 0.025f, "Renders as if the players offhand was this progress through the swing animation") + @Tab(GeneralTab)val oldAnimations by setting("Old Animations", false, "Adjusts the animations to look like they did in 1.8") + @Tab(GeneralTab)val swapAnimation by setting("Swap Animation", true, "If disabled, removes the drop down animation when swapping item") { oldAnimations } //ToDo: Implement // val shadow by setting("Shadows", true, "If disabled, removes shadows on the model") { page == Page.General } - @Tab(SCALE_TAB) private val splitScale by setting("Split Scale", false, "Splits left and right hand scale settings") - @Tab(SCALE_TAB) private val xScale by setting("X Scale", 1.0f, 0.0f..2.0f, 0.025f) { !splitScale }.onValueChange { _, to -> leftXScale = to; rightXScale = to } - @Tab(SCALE_TAB) private val yScale by setting("Y Scale", 1.0f, 0.0f..2.0f, 0.025f) { !splitScale }.onValueChange { _, to -> leftYScale = to; rightYScale = to } - @Tab(SCALE_TAB) private val zScale by setting("Z Scale", 1.0f, 0.0f..2.0f, 0.025f) { !splitScale }.onValueChange { _, to -> leftZScale = to; rightZScale = to } - @Tab(SCALE_TAB) private var leftXScale by setting("Left X Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } - @Tab(SCALE_TAB) private var leftYScale by setting("Left Y Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } - @Tab(SCALE_TAB) private var leftZScale by setting("Left Z Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } - @Tab(SCALE_TAB) private var rightXScale by setting("Right X Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } - @Tab(SCALE_TAB) private var rightYScale by setting("Right Y Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } - @Tab(SCALE_TAB) private var rightZScale by setting("Right Z Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } - - @Tab(POSITION_TAB) private val splitPosition by setting("Split Position", false, "Splits left and right position settings") - @Tab(POSITION_TAB) private val xPosition by setting("X Position", 0.0f, -1.0f..1.0f, 0.025f) { !splitPosition }.onValueChange { _, to -> leftXPosition = to; rightXPosition = to } - @Tab(POSITION_TAB) private val yPosition by setting("Y Position", 0.0f, -1.0f..1.0f, 0.025f) { !splitPosition }.onValueChange { _, to -> leftYPosition = to; rightYPosition = to } - @Tab(POSITION_TAB) private val zPosition by setting("Z Position", 0.0f, -1.0f..1.0f, 0.025f) { !splitPosition }.onValueChange { _, to -> leftZPosition = to; rightZPosition = to } - @Tab(POSITION_TAB) private var leftXPosition by setting("Left X Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } - @Tab(POSITION_TAB) private var leftYPosition by setting("Left Y Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } - @Tab(POSITION_TAB) private var leftZPosition by setting("Left Z Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } - @Tab(POSITION_TAB) private var rightXPosition by setting("Right X Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } - @Tab(POSITION_TAB) private var rightYPosition by setting("Right Y Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } - @Tab(POSITION_TAB) private var rightZPosition by setting("Right Z Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } - - @Tab(ROTATION_TAB) private val splitRotation by setting("Split Rotation", false, "Splits left and right rotation settings") - @Tab(ROTATION_TAB) private val xRotation by setting("X Rotation", 0, -180..180, 1) { !splitRotation }.onValueChange { _, to -> leftXRotation = to; rightXRotation = to } - @Tab(ROTATION_TAB) private val yRotation by setting("Y Rotation", 0, -180..180, 1) { !splitRotation }.onValueChange { _, to -> leftYRotation = to; rightYRotation = to } - @Tab(ROTATION_TAB) private val zRotation by setting("Z Rotation", 0, -180..180, 1) { !splitRotation }.onValueChange { _, to -> leftZRotation = to; rightZRotation = to } - @Tab(ROTATION_TAB) private var leftXRotation by setting("Left X Rotation", 0, -180..180, 1) { splitRotation } - @Tab(ROTATION_TAB) private var leftYRotation by setting("Left Y Rotation", 0, -180..180, 1) { splitRotation } - @Tab(ROTATION_TAB) private var leftZRotation by setting("Left Z Rotation", 0, -180..180, 1) { splitRotation } - @Tab(ROTATION_TAB) private var rightXRotation by setting("Right X Rotation", 0, -180..180, 1) { splitRotation } - @Tab(ROTATION_TAB) private var rightYRotation by setting("Right Y Rotation", 0, -180..180, 1) { splitRotation } - @Tab(ROTATION_TAB) private var rightZRotation by setting("Right Z Rotation", 0, -180..180, 1) { splitRotation } - - @Tab(FOV_TAB) private val splitFov by setting("Split FOV", false, "Splits left and right Fov settings") - @Tab(FOV_TAB) private val fov by setting("FOV", 70, 10..180, 1) { !splitFov }.onValueChange { _, to -> leftFov = to; rightFov = to } - @Tab(FOV_TAB) private val fovAnchorDistance by setting("Anchor Distance", 0.5f, 0.0f..1.0f, 0.01f, "The distance to anchor the FOV transformation from") { !splitFov }.onValueChange { _, to -> leftFovAnchorDistance = to; rightFovAnchorDistance = to } - @Tab(FOV_TAB) private var leftFov by setting("Left FOV", 70, 10..180, 1) { splitFov } - @Tab(FOV_TAB) private var leftFovAnchorDistance by setting("Left Anchor Distance", 0.5f, 0.0f..1.0f, 0.01f, "The distance to anchor the left FOV transformation from") { splitFov } - @Tab(FOV_TAB) private var rightFov by setting("Right FOV", 70, 10..180, 1) { splitFov } - @Tab(FOV_TAB) private var rightFovAnchorDistance by setting("Right Anchor Distance", 0.5f, 0.0f..1.0f, 0.01f, "The distance to anchor the right FOV transformation from") { splitFov } - - @Tab(HAND_TAB) private val enableHand by setting("Hand", false, "Enables settings for the players hand") - @Tab(HAND_TAB) private val handXScale by setting("Hand X Scale", 1.0f, 0.0f..2.0f, 0.025f) { enableHand } - @Tab(HAND_TAB) private val handYScale by setting("Hand Y Scale", 1.0f, 0.0f..2.0f, 0.025f) { enableHand } - @Tab(HAND_TAB) private val handZScale by setting("Hand Z Scale", 1.0f, 0.0f..2.0f, 0.025f) { enableHand } - @Tab(HAND_TAB) private val handXPosition by setting("Hand X Position", 0.0f, -1.0f..1.0f, 0.025f) { enableHand } - @Tab(HAND_TAB) private val handYPosition by setting("Hand Y Position", 0.0f, -1.0f..1.0f, 0.025f) { enableHand } - @Tab(HAND_TAB) private val handZPosition by setting("Hand Z Position", 0.0f, -1.0f..1.0f, 0.025f) { enableHand } - @Tab(HAND_TAB) private val handXRotation by setting("Hand X Rotation", 0, -180..180, 1) { enableHand } - @Tab(HAND_TAB) private val handYRotation by setting("Hand Y Rotation", 0, -180..180, 1) { enableHand } - @Tab(HAND_TAB) private val handZRotation by setting("Hand Z Rotation", 0, -180..180, 1) { enableHand } - @Tab(HAND_TAB) private val handFov by setting("Hand FOV", 70, 10..180, 1) { enableHand } - @Tab(HAND_TAB) private val handFovAnchorDistance by setting("Hand FOV Anchor Distance", 0.5f, 0.0f..1.0f, 0.01f, "The distance to anchor the hands FOV transformation from") { enableHand } + @Tab(ScaleTab) private val splitScale by setting("Split Scale", false, "Splits left and right hand scale settings") + @Tab(ScaleTab) private val xScale by setting("X Scale", 1.0f, 0.0f..2.0f, 0.025f) { !splitScale }.onValueChange { _, to -> leftXScale = to; rightXScale = to } + @Tab(ScaleTab) private val yScale by setting("Y Scale", 1.0f, 0.0f..2.0f, 0.025f) { !splitScale }.onValueChange { _, to -> leftYScale = to; rightYScale = to } + @Tab(ScaleTab) private val zScale by setting("Z Scale", 1.0f, 0.0f..2.0f, 0.025f) { !splitScale }.onValueChange { _, to -> leftZScale = to; rightZScale = to } + @Tab(ScaleTab) private var leftXScale by setting("Left X Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } + @Tab(ScaleTab) private var leftYScale by setting("Left Y Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } + @Tab(ScaleTab) private var leftZScale by setting("Left Z Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } + @Tab(ScaleTab) private var rightXScale by setting("Right X Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } + @Tab(ScaleTab) private var rightYScale by setting("Right Y Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } + @Tab(ScaleTab) private var rightZScale by setting("Right Z Scale", 1.0f, 0.0f..2.0f, 0.025f) { splitScale } + + @Tab(PositionTab) private val splitPosition by setting("Split Position", false, "Splits left and right position settings") + @Tab(PositionTab) private val xPosition by setting("X Position", 0.0f, -1.0f..1.0f, 0.025f) { !splitPosition }.onValueChange { _, to -> leftXPosition = to; rightXPosition = to } + @Tab(PositionTab) private val yPosition by setting("Y Position", 0.0f, -1.0f..1.0f, 0.025f) { !splitPosition }.onValueChange { _, to -> leftYPosition = to; rightYPosition = to } + @Tab(PositionTab) private val zPosition by setting("Z Position", 0.0f, -1.0f..1.0f, 0.025f) { !splitPosition }.onValueChange { _, to -> leftZPosition = to; rightZPosition = to } + @Tab(PositionTab) private var leftXPosition by setting("Left X Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } + @Tab(PositionTab) private var leftYPosition by setting("Left Y Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } + @Tab(PositionTab) private var leftZPosition by setting("Left Z Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } + @Tab(PositionTab) private var rightXPosition by setting("Right X Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } + @Tab(PositionTab) private var rightYPosition by setting("Right Y Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } + @Tab(PositionTab) private var rightZPosition by setting("Right Z Position", 0.0f, -1.0f..1.0f, 0.025f) { splitPosition } + + @Tab(RotationTab) private val splitRotation by setting("Split Rotation", false, "Splits left and right rotation settings") + @Tab(RotationTab) private val xRotation by setting("X Rotation", 0, -180..180, 1) { !splitRotation }.onValueChange { _, to -> leftXRotation = to; rightXRotation = to } + @Tab(RotationTab) private val yRotation by setting("Y Rotation", 0, -180..180, 1) { !splitRotation }.onValueChange { _, to -> leftYRotation = to; rightYRotation = to } + @Tab(RotationTab) private val zRotation by setting("Z Rotation", 0, -180..180, 1) { !splitRotation }.onValueChange { _, to -> leftZRotation = to; rightZRotation = to } + @Tab(RotationTab) private var leftXRotation by setting("Left X Rotation", 0, -180..180, 1) { splitRotation } + @Tab(RotationTab) private var leftYRotation by setting("Left Y Rotation", 0, -180..180, 1) { splitRotation } + @Tab(RotationTab) private var leftZRotation by setting("Left Z Rotation", 0, -180..180, 1) { splitRotation } + @Tab(RotationTab) private var rightXRotation by setting("Right X Rotation", 0, -180..180, 1) { splitRotation } + @Tab(RotationTab) private var rightYRotation by setting("Right Y Rotation", 0, -180..180, 1) { splitRotation } + @Tab(RotationTab) private var rightZRotation by setting("Right Z Rotation", 0, -180..180, 1) { splitRotation } + + @Tab(FovTab) private val splitFov by setting("Split FOV", false, "Splits left and right Fov settings") + @Tab(FovTab) private val fov by setting("FOV", 70, 10..180, 1) { !splitFov }.onValueChange { _, to -> leftFov = to; rightFov = to } + @Tab(FovTab) private val fovAnchorDistance by setting("Anchor Distance", 0.5f, 0.0f..1.0f, 0.01f, "The distance to anchor the FOV transformation from") { !splitFov }.onValueChange { _, to -> leftFovAnchorDistance = to; rightFovAnchorDistance = to } + @Tab(FovTab) private var leftFov by setting("Left FOV", 70, 10..180, 1) { splitFov } + @Tab(FovTab) private var leftFovAnchorDistance by setting("Left Anchor Distance", 0.5f, 0.0f..1.0f, 0.01f, "The distance to anchor the left FOV transformation from") { splitFov } + @Tab(FovTab) private var rightFov by setting("Right FOV", 70, 10..180, 1) { splitFov } + @Tab(FovTab) private var rightFovAnchorDistance by setting("Right Anchor Distance", 0.5f, 0.0f..1.0f, 0.01f, "The distance to anchor the right FOV transformation from") { splitFov } + + @Tab(HandTab) private val enableHand by setting("Hand", false, "Enables settings for the players hand") + @Tab(HandTab) private val handXScale by setting("Hand X Scale", 1.0f, 0.0f..2.0f, 0.025f) { enableHand } + @Tab(HandTab) private val handYScale by setting("Hand Y Scale", 1.0f, 0.0f..2.0f, 0.025f) { enableHand } + @Tab(HandTab) private val handZScale by setting("Hand Z Scale", 1.0f, 0.0f..2.0f, 0.025f) { enableHand } + @Tab(HandTab) private val handXPosition by setting("Hand X Position", 0.0f, -1.0f..1.0f, 0.025f) { enableHand } + @Tab(HandTab) private val handYPosition by setting("Hand Y Position", 0.0f, -1.0f..1.0f, 0.025f) { enableHand } + @Tab(HandTab) private val handZPosition by setting("Hand Z Position", 0.0f, -1.0f..1.0f, 0.025f) { enableHand } + @Tab(HandTab) private val handXRotation by setting("Hand X Rotation", 0, -180..180, 1) { enableHand } + @Tab(HandTab) private val handYRotation by setting("Hand Y Rotation", 0, -180..180, 1) { enableHand } + @Tab(HandTab) private val handZRotation by setting("Hand Z Rotation", 0, -180..180, 1) { enableHand } + @Tab(HandTab) private val handFov by setting("Hand FOV", 70, 10..180, 1) { enableHand } + @Tab(HandTab) private val handFovAnchorDistance by setting("Hand FOV Anchor Distance", 0.5f, 0.0f..1.0f, 0.01f, "The distance to anchor the hands FOV transformation from") { enableHand } private var attackKeyTicksPressed = -1 diff --git a/src/main/kotlin/com/lambda/module/modules/render/Weather.kt b/src/main/kotlin/com/lambda/module/modules/render/Weather.kt index 3c540fd51..7f6e9a3c8 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Weather.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Weather.kt @@ -21,22 +21,21 @@ import com.lambda.config.Tab import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe -import com.lambda.util.NamedEnum import net.minecraft.world.World object Weather : Module( name = "Weather", description = "Modifies the client side weather", - tag = ModuleTag.RENDER + tag = ModuleTag.Render ) { - private const val OVERWORLD_TAB = "Overworld" - private const val NETHER_TAB = "Nether" - private const val END_TAB = "End" + private const val OverworldTab = "Overworld" + private const val NetherTab = "Nether" + private const val EndTab = "End" - @Tab(OVERWORLD_TAB) @JvmStatic val overworldMode by setting("Overworld Mode", WeatherMode.Clear) - @Tab(OVERWORLD_TAB) @JvmStatic val overrideSnow by setting("Override Snow", false) { overworldMode == WeatherMode.Rain } - @Tab(NETHER_TAB) @JvmStatic val netherMode by setting("Nether Mode", WeatherMode.Clear) - @Tab(END_TAB) @JvmStatic val endMode by setting("End Mode", WeatherMode.Clear) + @Tab(OverworldTab) @JvmStatic val overworldMode by setting("Overworld Mode", WeatherMode.Clear) + @Tab(OverworldTab) @JvmStatic val overrideSnow by setting("Override Snow", false) { overworldMode == WeatherMode.Rain } + @Tab(NetherTab) @JvmStatic val netherMode by setting("Nether Mode", WeatherMode.Clear) + @Tab(EndTab) @JvmStatic val endMode by setting("End Mode", WeatherMode.Clear) @JvmStatic fun getWeatherMode() = runSafe { diff --git a/src/main/kotlin/com/lambda/module/modules/render/WorldColors.kt b/src/main/kotlin/com/lambda/module/modules/render/WorldColors.kt index 227d0e209..2de24cb4c 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/WorldColors.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/WorldColors.kt @@ -27,7 +27,7 @@ import java.awt.Color object WorldColors : Module( name = "WorldColors", description = "Changes the color of the sky, clouds and fog", - tag = ModuleTag.RENDER, + tag = ModuleTag.Render, ) { @JvmStatic val customSky by setting("Custom Sky", true) @JvmStatic val skyColor by setting("Sky Color", Color(255, 24, 75), "The color of your sky") { customSky } diff --git a/src/main/kotlin/com/lambda/module/modules/render/XRay.kt b/src/main/kotlin/com/lambda/module/modules/render/XRay.kt index 529e41577..1d7634a96 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/XRay.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/XRay.kt @@ -25,7 +25,7 @@ import net.minecraft.block.Blocks object XRay : Module( name = "XRay", description = "Allows you to see ores through walls", - tag = ModuleTag.RENDER, + tag = ModuleTag.Render, ) { val defaultBlocks = setOf( Blocks.COAL_ORE, Blocks.DEEPSLATE_COAL_ORE, diff --git a/src/main/kotlin/com/lambda/module/modules/render/Zoom.kt b/src/main/kotlin/com/lambda/module/modules/render/Zoom.kt index d991feb93..5bf50544f 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Zoom.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Zoom.kt @@ -27,7 +27,7 @@ import java.lang.Math.clamp object Zoom : Module( name = "Zoom", description = "Zooms the current view", - tag = ModuleTag.RENDER, + tag = ModuleTag.Render, ) { private var zoom by setting("Zoom", 2f, 1f..10f, 0.1f) private val style by setting("Style", ZoomStyle.EaseOut) diff --git a/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt b/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt index 8113e9682..24e5c4dd1 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt @@ -39,7 +39,6 @@ import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafeAutomated import com.lambda.util.InputUtils.isSatisfied import com.lambda.util.KeyCode -import com.lambda.util.NamedEnum import com.lambda.util.math.setAlpha import com.lambda.util.math.vec3d import net.minecraft.block.BlockState @@ -61,18 +60,18 @@ import java.util.concurrent.ConcurrentLinkedQueue object AirPlace : Module( name = "AirPlace", description = "Allows placing blocks in air", - tag = ModuleTag.WORLD + tag = ModuleTag.World ) { - private const val RENDER_GROUP = "Renders" + private const val RenderGroup = "Renders" private var distance by setting("Distance", 4.0, 1.0..7.0, 0.01) private val distanceScrollBind by setting("Distance Scroll Bind", Bind(KeyCode.Unbound.code, GLFW.GLFW_MOD_CONTROL), "Allows you to hold the given key and scroll to adjust distance") // Credit to THCFree for the rotation scroll idea private val rotationScrollBind by setting("Rotation Scroll Bind", Bind(KeyCode.Unbound.code, GLFW.GLFW_MOD_ALT), "Allows you to hold the given key and scroll to adjust the rotation of the block you're placing") - @Group(RENDER_GROUP) private val renderState by setting("Render State", true) - @Group(RENDER_GROUP) private val lineColor by setting("Line Color", Color.WHITE) - @Group(RENDER_GROUP) private val stateAlpha by setting("State Alpha", 0.5, 0.01..1.0, 0.01) + @Group(RenderGroup) private val renderState by setting("Render State", true) + @Group(RenderGroup) private val lineColor by setting("Line Color", Color.WHITE) + @Group(RenderGroup) private val stateAlpha by setting("State Alpha", 0.5, 0.01..1.0, 0.01) private var placementPos: BlockPos? = null private var backingState: BlockState? = null diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt index bd3f940fa..fedc490b2 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt @@ -21,7 +21,7 @@ import baritone.api.pathing.goals.GoalBlock import com.lambda.config.Group import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig -import com.lambda.config.groups.WorldLineSettings +import com.lambda.config.blocks.WorldLineSettings import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.config.settings.complex.KeybindSetting.Companion.onRelease @@ -71,11 +71,11 @@ import net.minecraft.util.math.Vec3d object AutoPortal : Module( name = "AutoPortal", description = "Automatically places and lights a nether portal", - tag = ModuleTag.WORLD + tag = ModuleTag.World ) { - private const val RENDER_GROUP = "Renders" - private const val FILL_GROUP = "Fill" - private const val OUTLINE_GROUP = "Outline" + private const val RenderGroup = "Renders" + private const val FillGroup = "Fill" + private const val OutlineGroup = "Outline" private val previewPlace by setting("Preview Place", Bind.EMPTY, "The keybind to preview the portal placement and subsequentially place the portal") .onPress { preview = true } @@ -113,11 +113,11 @@ object AutoPortal : Module( private val lockToGround by setting("Lock To Ground", true) private val allowUpwardShift by setting("Allow Upward Shift", true, "Allows shifting the portal up to find ground when it would be placed inside blocks") { lockToGround } - @Group(RENDER_GROUP) private val renders by setting("Renders", true) - @Group(RENDER_GROUP) private val interpolate by setting("Interpolate", true, "Interpolates the portal renders from position to position") { renders } - @Group(RENDER_GROUP) private val depthTest by setting("Depth Test", false) { renders } - @Group(RENDER_GROUP, FILL_GROUP) private val fillAlpha by setting("Fill Alpha", 0.3, 0.0..1.0, 0.01) { renders } - @Group(RENDER_GROUP, OUTLINE_GROUP) private val outlineConfig = + @Group(RenderGroup) private val renders by setting("Renders", true) + @Group(RenderGroup) private val interpolate by setting("Interpolate", true, "Interpolates the portal renders from position to position") { renders } + @Group(RenderGroup) private val depthTest by setting("Depth Test", false) { renders } + @Group(RenderGroup, FillGroup) private val fillAlpha by setting("Fill Alpha", 0.3, 0.0..1.0, 0.01) { renders } + @Group(RenderGroup, OutlineGroup) private val outlineConfig = settingBlock( WorldLineSettings(this), { renders } diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoSign.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoSign.kt index d2f1e502b..1d10b348e 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoSign.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoSign.kt @@ -49,7 +49,7 @@ object AutoSign : Module( | - Minute (00-59) | - Second (00-59) """.trimMargin(), - tag = ModuleTag.WORLD + tag = ModuleTag.World ) { private var autoWrite by setting("Auto Write", true) private var line1 by setting("Line 1", "Welcome to Lambda!") { autoWrite } diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt index 0b55ff9ca..613619ba2 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt @@ -41,7 +41,6 @@ import com.lambda.util.BlockUtils.blockState import com.lambda.util.BlockUtils.isEmpty import com.lambda.util.CommunicationUtils.info import com.lambda.util.CommunicationUtils.logError -import com.lambda.util.NamedEnum import com.lambda.util.player.RotationUtils.lookAtEntity import com.lambda.util.world.closestEntity import net.minecraft.block.Blocks @@ -61,7 +60,7 @@ import net.minecraft.util.math.BlockPos object AutoVillagerCycle : Module( name = "AutoVillagerCycle", description = "Automatically cycles librarian villagers with lecterns until a desired enchanted book is found", - tag = ModuleTag.WORLD + tag = ModuleTag.World ) { private val allEnchantments = ArrayList() @@ -83,9 +82,9 @@ object AutoVillagerCycle : Module( } } - private const val ENCHANTMENTS_GROUP = "Enchantments" - @Group(ENCHANTMENTS_GROUP) private val desiredEnchantments by setting("Desired Enchantments", emptySet(), allEnchantments) - @Group(ENCHANTMENTS_GROUP) private val minLevel by setting("Min Level", 1, 1..5, 1, "Minimum enchantment level to look for") + private const val EnchantmentsGroup = "Enchantments" + @Group(EnchantmentsGroup) private val desiredEnchantments by setting("Desired Enchantments", emptySet(), allEnchantments) + @Group(EnchantmentsGroup) private val minLevel by setting("Min Level", 1, 1..5, 1, "Minimum enchantment level to look for") private var cycleState = CycleState.Idle private var tickCounter = 0 diff --git a/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt b/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt index 23c106802..ff44720f1 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt @@ -47,7 +47,7 @@ import net.minecraft.util.math.Vec3i object HighwayTools : Module( name = "HighwayTools", description = "Auto highway builder", - tag = ModuleTag.WORLD, + tag = ModuleTag.World, ) { private val height by setting("Height", 4, 2..10, 1) private val width by setting("Width", 6, 1..30, 1) diff --git a/src/main/kotlin/com/lambda/module/modules/world/MapDownloader.kt b/src/main/kotlin/com/lambda/module/modules/world/MapDownloader.kt index b4de4c5e7..359cf1868 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/MapDownloader.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/MapDownloader.kt @@ -37,7 +37,7 @@ import javax.imageio.ImageIO object MapDownloader : Module( name = "MapDownloader", description = "Save map data to your computer", - tag = ModuleTag.WORLD, + tag = ModuleTag.World, ) { init { listen { diff --git a/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt b/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt index 51df8bc89..8fb083e37 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt @@ -38,7 +38,7 @@ import net.minecraft.util.math.BlockPos object Nuker : Module( name = "Nuker", description = "Breaks blocks around you", - tag = ModuleTag.WORLD, + tag = ModuleTag.World, autoDisable = true ) { private val height by setting("Height", 6, 1..8, 1) diff --git a/src/main/kotlin/com/lambda/module/modules/world/Printer.kt b/src/main/kotlin/com/lambda/module/modules/world/Printer.kt index b25337ac0..36f2131fe 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Printer.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Printer.kt @@ -45,7 +45,7 @@ import net.minecraft.util.math.BlockPos object Printer : Module( name = "Printer", description = "Automatically prints schematics", - tag = ModuleTag.WORLD + tag = ModuleTag.World ) { private val range by setting("Range", 5, 1..7, 1, description = "The range around the player to check for blocks to print") private val air by setting("Air", false, description = "Consider breaking blocks in the world that are air in the schematic.\nNote: Breaking can also be disabled in the Automation Config.") diff --git a/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt b/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt index 7cae267c0..bf5801a7f 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt @@ -19,7 +19,7 @@ package com.lambda.module.modules.world import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig -import com.lambda.config.groups.InteractConfig +import com.lambda.config.blocks.InteractConfig import com.lambda.config.settings.complex.Bind import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent @@ -46,7 +46,7 @@ import java.util.concurrent.ConcurrentLinkedQueue object Scaffold : Module( name = "Scaffold", description = "Places blocks under the player", - tag = ModuleTag.WORLD, + tag = ModuleTag.World, ) { private val blacklistedBlocks by setting("Blacklisted Blocks", mutableSetOf()) private val bridgeRange by setting("Bridge Range", 5, 0..5, 1, "The range at which blocks can be placed to help build support for the player", unit = " blocks") diff --git a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt index 7f37a5110..1ad0c67ee 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt @@ -22,7 +22,7 @@ import com.lambda.Lambda.mc import com.lambda.config.Tab import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig -import com.lambda.config.groups.InteractConfig +import com.lambda.config.blocks.InteractConfig import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.context.SafeContext @@ -97,10 +97,10 @@ import kotlin.math.min object StashMover : Module( name = "StashMover", description = "Moves items from one stash location to another", - tag = ModuleTag.WORLD + tag = ModuleTag.World ) { - private const val GENERAL_TAB = "General" - private const val COMMAND_BINDS_TAB = "Command Binds" + private const val GeneralTab = "General" + private const val CommandBindsTab = "Command Binds" enum class Role(val createTask: () -> Task<*>) { MoverBot({ MoverBot() }), @@ -112,44 +112,44 @@ object StashMover : Module( Drop("Drop") } - @Tab(GENERAL_TAB) val role: Role by setting("Role", Role.MoverBot) + @Tab(GeneralTab) val role: Role by setting("Role", Role.MoverBot) .onValueChange { _, _ -> clearModule() } - @Tab(GENERAL_TAB) private val pearlBotName by setting("PearlBot Name", "Steve") { role == Role.MoverBot } - @Tab(GENERAL_TAB) private val moverBotName by setting("MoverBot Name", "Steve") { role == Role.PearlBot } - @Tab(GENERAL_TAB) private val dropOffMode by setting("Drop-Off Mode", DropOffMode.Chests) { role == Role.MoverBot } - @Tab(GENERAL_TAB) private var chestPullSelMode: Boolean by setting("Chest Pull Sel Mode", false, "Enables the mode to select the stash containers you want to move items from") { role == Role.MoverBot } + @Tab(GeneralTab) private val pearlBotName by setting("PearlBot Name", "Steve") { role == Role.MoverBot } + @Tab(GeneralTab) private val moverBotName by setting("MoverBot Name", "Steve") { role == Role.PearlBot } + @Tab(GeneralTab) private val dropOffMode by setting("Drop-Off Mode", DropOffMode.Chests) { role == Role.MoverBot } + @Tab(GeneralTab) private var chestPullSelMode: Boolean by setting("Chest Pull Sel Mode", false, "Enables the mode to select the stash containers you want to move items from") { role == Role.MoverBot } .onValueChange { _, to -> if (to) { chestPutSelMode = false; StashMover.info("Enabled chest pull selection mode!") } } - @Tab(GENERAL_TAB) private var chestPutSelMode: Boolean by setting("Chest Put Sel Mode", false, "Enables the mod to select the stash containers you want to move items into") { role == Role.MoverBot } + @Tab(GeneralTab) private var chestPutSelMode: Boolean by setting("Chest Put Sel Mode", false, "Enables the mod to select the stash containers you want to move items into") { role == Role.MoverBot } .onValueChange { _, to -> if (to) { chestPullSelMode = false; StashMover.info("Enabled chest put selection mode!") } } - @Tab(GENERAL_TAB) private val pearlMsgTimeout by setting("Pearl Msg Timeout", 100, 0..1500, 1, "Ticks before messaging the pearl bot again", "ticks") { role == Role.MoverBot } - @Tab(GENERAL_TAB) private val pearlButtonTimeout by setting("Pearl Button Timeout", 100, 0..1500, 1, "Ticks before pressing the pearl dispenser button again", "ticks") { role == Role.MoverBot } - @Tab(GENERAL_TAB) private val killRespawnTimeout by setting("Kill/Respawn Timeout", 100, 0..1500, 1, "Ticks before sending the kill command or attempting to respawn again", "ticks") { role == Role.MoverBot } - @Tab(GENERAL_TAB) private val actionDelay by setting("Action Delay", 3, 0..20, 1, "The delay after performing one action, before the next") { role == Role.MoverBot } - @Tab(GENERAL_TAB) private val useEnderChest by setting("Use Ender Chest", false, "Uses the ender chest to move more items at once. (Ender chests are included in the pull/put selections)") { role == Role.MoverBot } + @Tab(GeneralTab) private val pearlMsgTimeout by setting("Pearl Msg Timeout", 100, 0..1500, 1, "Ticks before messaging the pearl bot again", "ticks") { role == Role.MoverBot } + @Tab(GeneralTab) private val pearlButtonTimeout by setting("Pearl Button Timeout", 100, 0..1500, 1, "Ticks before pressing the pearl dispenser button again", "ticks") { role == Role.MoverBot } + @Tab(GeneralTab) private val killRespawnTimeout by setting("Kill/Respawn Timeout", 100, 0..1500, 1, "Ticks before sending the kill command or attempting to respawn again", "ticks") { role == Role.MoverBot } + @Tab(GeneralTab) private val actionDelay by setting("Action Delay", 3, 0..20, 1, "The delay after performing one action, before the next") { role == Role.MoverBot } + @Tab(GeneralTab) private val useEnderChest by setting("Use Ender Chest", false, "Uses the ender chest to move more items at once. (Ender chests are included in the pull/put selections)") { role == Role.MoverBot } .onValueChange { _, to -> if (!to) { putEnderChests.clear() pullEnderChests.clear() } } - @Tab(GENERAL_TAB) private val breakEmptyPullContainers by setting("Break Empty Pull Containers", false, "Breaks empty pull containers after taking their items") { role == Role.MoverBot } - @Tab(GENERAL_TAB) private val disconnectOnFinish by setting("Disconnect On Finish", false, "Disconnects the mover bot when it's finished") { role == Role.MoverBot } - @Tab(GENERAL_TAB) private val disconnectOnFail by setting("Disconnect On Fail", false, "Disconnects the mover bot if it fails") { role == Role.MoverBot } - @Tab(GENERAL_TAB) private val startStop by setting("Start/Stop", Bind.EMPTY, "Starts and stops the selected role") + @Tab(GeneralTab) private val breakEmptyPullContainers by setting("Break Empty Pull Containers", false, "Breaks empty pull containers after taking their items") { role == Role.MoverBot } + @Tab(GeneralTab) private val disconnectOnFinish by setting("Disconnect On Finish", false, "Disconnects the mover bot when it's finished") { role == Role.MoverBot } + @Tab(GeneralTab) private val disconnectOnFail by setting("Disconnect On Fail", false, "Disconnects the mover bot if it fails") { role == Role.MoverBot } + @Tab(GeneralTab) private val startStop by setting("Start/Stop", Bind.EMPTY, "Starts and stops the selected role") .onPress { event -> event.cancel(); startStop() } - @Tab(GENERAL_TAB) private val pauseUnpause by setting("Pause/Unpause", Bind.EMPTY, "Pauses and unpauses the selected role") + @Tab(GeneralTab) private val pauseUnpause by setting("Pause/Unpause", Bind.EMPTY, "Pauses and unpauses the selected role") .onPress { event -> event.cancel(); pauseUnpause() } - @Tab(COMMAND_BINDS_TAB) private val indexSelectedContainers by setting("Index Selected Containers", Bind.EMPTY, "Indexes the selected containers to pull/push items from/to") { role == Role.MoverBot } + @Tab(CommandBindsTab) private val indexSelectedContainers by setting("Index Selected Containers", Bind.EMPTY, "Indexes the selected containers to pull/push items from/to") { role == Role.MoverBot } .onPress { event -> event.cancel(); indexSelectedContainers() } - @Tab(COMMAND_BINDS_TAB) private val removeSelectedContainers by setting("Remove Selected Containers", Bind.EMPTY, "Removes the selected containers from being pull/pushed from/to") { role == Role.MoverBot } + @Tab(CommandBindsTab) private val removeSelectedContainers by setting("Remove Selected Containers", Bind.EMPTY, "Removes the selected containers from being pull/pushed from/to") { role == Role.MoverBot } .onPress { event -> event.cancel(); removeSelectedContainers() } - @Tab(COMMAND_BINDS_TAB) private val setItemThrowPosAndRotation by setting("Set Item Throw", Bind.EMPTY, "Sets the item throw position and rotation. (This is usually set to throw into hoppers to pickup the items)") { role == Role.MoverBot } + @Tab(CommandBindsTab) private val setItemThrowPosAndRotation by setting("Set Item Throw", Bind.EMPTY, "Sets the item throw position and rotation. (This is usually set to throw into hoppers to pickup the items)") { role == Role.MoverBot } .onPress { event -> event.cancel(); setItemThrow() } - @Tab(COMMAND_BINDS_TAB) private val setPearlButtonPos by setting("Set Pearl Button Pos", Bind.EMPTY, "Sets the button used to dispense a pearl for the player") { role == Role.MoverBot } + @Tab(CommandBindsTab) private val setPearlButtonPos by setting("Set Pearl Button Pos", Bind.EMPTY, "Sets the button used to dispense a pearl for the player") { role == Role.MoverBot } .onPress { event -> event.cancel(); setPearlButtonPos() } - @Tab(COMMAND_BINDS_TAB) private val setPearlThrowPosAndRotation by setting("Set Pearl Throw", Bind.EMPTY, "Sets the pearl throw position and rotation. (This is best if you throw somewhat sideways into a line of bubble columns)") { role == Role.MoverBot } + @Tab(CommandBindsTab) private val setPearlThrowPosAndRotation by setting("Set Pearl Throw", Bind.EMPTY, "Sets the pearl throw position and rotation. (This is best if you throw somewhat sideways into a line of bubble columns)") { role == Role.MoverBot } .onPress { event -> event.cancel(); setPearlThrow() } - @Tab(COMMAND_BINDS_TAB) private val setPearlBotButton by setting("Set PearlBot Button", Bind.EMPTY, "Sets the button position for the pearl bot to press to load the mover bot") { role == Role.PearlBot } + @Tab(CommandBindsTab) private val setPearlBotButton by setting("Set PearlBot Button", Bind.EMPTY, "Sets the button position for the pearl bot to press to load the mover bot") { role == Role.PearlBot } .onPress { event -> event.cancel(); setPearlBotButton() } private var sel1: BlockPos? = null diff --git a/src/main/kotlin/com/lambda/module/tag/ModuleTag.kt b/src/main/kotlin/com/lambda/module/tag/ModuleTag.kt index caab346cc..e44630f94 100644 --- a/src/main/kotlin/com/lambda/module/tag/ModuleTag.kt +++ b/src/main/kotlin/com/lambda/module/tag/ModuleTag.kt @@ -36,18 +36,18 @@ data class ModuleTag(override val name: String) : Nameable { // Totally needs to be reworked // ToDo: Add registry for tags companion object { - val COMBAT = ModuleTag("Combat") - val MOVEMENT = ModuleTag("Movement") - val RENDER = ModuleTag("Render") - val PLAYER = ModuleTag("Player") - val WORLD = ModuleTag("World") - val CHAT = ModuleTag("Chat") - val CLIENT = ModuleTag("Client") - val NETWORK = ModuleTag("Network") - val DEBUG = ModuleTag("Debug") - val HUD = ModuleTag("Hud") + val Combat = ModuleTag("Combat") + val Movement = ModuleTag("Movement") + val Render = ModuleTag("Render") + val Player = ModuleTag("Player") + val World = ModuleTag("World") + val Chat = ModuleTag("Chat") + val Client = ModuleTag("Client") + val Network = ModuleTag("Network") + val Debug = ModuleTag("Debug") + val Hud = ModuleTag("Hud") - val defaults = setOf(COMBAT, MOVEMENT, RENDER, PLAYER, WORLD, NETWORK, CHAT, CLIENT, HUD) + val defaults = setOf(Combat, Movement, Render, Player, World, Network, Chat, Client, Hud) val shownTags = defaults.toMutableSet() diff --git a/src/main/kotlin/com/lambda/network/CapeHandler.kt b/src/main/kotlin/com/lambda/network/CapeHandler.kt index ea9a33f52..88fb1c5bd 100644 --- a/src/main/kotlin/com/lambda/network/CapeHandler.kt +++ b/src/main/kotlin/com/lambda/network/CapeHandler.kt @@ -17,7 +17,7 @@ package com.lambda.network -import com.lambda.Lambda.LOG +import com.lambda.Lambda.Log import com.lambda.Lambda.mc import com.lambda.config.Config import com.lambda.config.categories.SecretsCategory @@ -62,11 +62,11 @@ object CapeHandler : Config(SecretsCategory), Loadable { capes.resolveFile("capes.txt") .isOlderThan(24.hours) { it.downloadIfNotPresent("${LambdaAPI.capes}.txt") - .onFailure { err -> LOG.error("Could not download the cape list: $err") } + .onFailure { err -> Log.error("Could not download the cape list: $err") } } .ifNotExists { it.downloadCompare("${LambdaAPI.capes}.txt", -1) - .onFailure { err -> LOG.error("Could not download the cape list: $err") } + .onFailure { err -> Log.error("Could not download the cape list: $err") } } .createIfNotExists() .readText() diff --git a/src/main/kotlin/com/lambda/network/LambdaAPI.kt b/src/main/kotlin/com/lambda/network/LambdaAPI.kt index 2d02b4980..228fb4798 100644 --- a/src/main/kotlin/com/lambda/network/LambdaAPI.kt +++ b/src/main/kotlin/com/lambda/network/LambdaAPI.kt @@ -17,7 +17,7 @@ package com.lambda.network -import com.lambda.Lambda.LOG +import com.lambda.Lambda.Log import com.lambda.Lambda.mc import com.lambda.config.Config import com.lambda.config.categories.LambdaCategory @@ -78,7 +78,7 @@ object LambdaAPI : Config(LambdaCategory) { // and posted to the sessionserver api login(mc.session.username, hash ?: return@listenConcurrentlyUnsafe) .onSuccess { updateToken(it) } - .onFailure { LOG.warn(it) } + .onFailure { Log.warn(it) } } } diff --git a/src/main/kotlin/com/lambda/task/Task.kt b/src/main/kotlin/com/lambda/task/Task.kt index 764e13a91..af71d6332 100644 --- a/src/main/kotlin/com/lambda/task/Task.kt +++ b/src/main/kotlin/com/lambda/task/Task.kt @@ -17,7 +17,7 @@ package com.lambda.task -import com.lambda.Lambda.LOG +import com.lambda.Lambda.Log import com.lambda.context.SafeContext import com.lambda.event.EventFlow.unsubscribe import com.lambda.event.Muteable @@ -120,10 +120,10 @@ abstract class Task : Nameable, Muteable { require(owner != this) { "Cannot execute a task as a child of itself" } owner.subTasks.add(this) parent = owner - if (verboseDebug) LOG.info("${owner.name} started $name") + if (verboseDebug) Log.info("${owner.name} started $name") if (pauseParent) { parentPausing = true - if (verboseDebug) LOG.info("$name pausing parent ${owner.name}") + if (verboseDebug) Log.info("$name pausing parent ${owner.name}") if (owner !is RootTask) owner.pause() } state = State.Running @@ -230,7 +230,7 @@ abstract class Task : Nameable, Muteable { } } } - LOG.error(message, e) + Log.error(message, e) logError(message) } } diff --git a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt index 888ca5370..1e6943de2 100644 --- a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt +++ b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt @@ -18,8 +18,8 @@ package com.lambda.task.tasks import baritone.api.pathing.goals.GoalBlock -import com.lambda.Lambda.LOG -import com.lambda.config.groups.EatConfig.Companion.reasonEating +import com.lambda.Lambda.Log +import com.lambda.config.blocks.EatConfig.Companion.reasonEating import com.lambda.context.Automated import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext @@ -304,7 +304,7 @@ class BuildTask private constructor( is Dependent -> handleResult(result.lastDependency, allResults) is Resolvable -> { - LOG.info("Resolving: ${result.name}") + Log.info("Resolving: ${result.name}") result.resolve() } } diff --git a/src/main/kotlin/com/lambda/task/tasks/EatTask.kt b/src/main/kotlin/com/lambda/task/tasks/EatTask.kt index 7927d3660..e67320e33 100644 --- a/src/main/kotlin/com/lambda/task/tasks/EatTask.kt +++ b/src/main/kotlin/com/lambda/task/tasks/EatTask.kt @@ -17,8 +17,8 @@ package com.lambda.task.tasks -import com.lambda.config.groups.EatConfig -import com.lambda.config.groups.EatConfig.Companion.reasonEating +import com.lambda.config.blocks.EatConfig +import com.lambda.config.blocks.EatConfig.Companion.reasonEating import com.lambda.context.Automated import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent diff --git a/src/main/kotlin/com/lambda/util/CommunicationUtils.kt b/src/main/kotlin/com/lambda/util/CommunicationUtils.kt index 7db846cf6..821fbedac 100644 --- a/src/main/kotlin/com/lambda/util/CommunicationUtils.kt +++ b/src/main/kotlin/com/lambda/util/CommunicationUtils.kt @@ -198,16 +198,16 @@ object CommunicationUtils { hoverEvent(HoverEvents.showText(buildText { literal("Lambda ") color(color) { - literal(Lambda.SYMBOL) + literal(Lambda.Symbol) } - literal(" v${Lambda.VERSION}\n") + literal(" v${Lambda.Version}\n") literal("Runtime: ${Loader.runtime}\n") literal("Modules: ${ModuleRegistry.modules.size}\n") literal("Commands: ${CommandRegistry.commands.size}\n") literal( "Settings: ${ ConfigLoader.configCategories.sumOf { config -> - config.configs.sumOf { it.settingContainers.size } + config.configs.sumOf { it.settingLayers.size } } }" ) @@ -217,7 +217,7 @@ object CommunicationUtils { })) { styled(color) { - literal(Lambda.SYMBOL) + literal(Lambda.Symbol) } literal(" ") } diff --git a/src/main/kotlin/com/lambda/util/Diagnostics.kt b/src/main/kotlin/com/lambda/util/Diagnostics.kt index 84ba93dac..fffbdeac5 100644 --- a/src/main/kotlin/com/lambda/util/Diagnostics.kt +++ b/src/main/kotlin/com/lambda/util/Diagnostics.kt @@ -25,7 +25,7 @@ object Diagnostics { modules.filter { it.isEnabled } .forEach { module -> append("\t${module.name}") - module.settingContainers + module.settingLayers .filter { it.isModified } .forEach { setting -> append("\t\t${setting.name} -> ${setting.value}") diff --git a/src/main/kotlin/com/lambda/util/DynamicReflectionSerializer.kt b/src/main/kotlin/com/lambda/util/DynamicReflectionSerializer.kt index 80119e273..2b6b45d45 100644 --- a/src/main/kotlin/com/lambda/util/DynamicReflectionSerializer.kt +++ b/src/main/kotlin/com/lambda/util/DynamicReflectionSerializer.kt @@ -18,7 +18,7 @@ package com.lambda.util import com.lambda.Lambda -import com.lambda.Lambda.LOG +import com.lambda.Lambda.Log import com.lambda.core.Loadable import com.lambda.network.LambdaAPI import com.lambda.util.FileUtils.downloadIfNotPresent @@ -77,20 +77,20 @@ object DynamicReflectionSerializer : Loadable { Codec::class, ) - private const val INDENT = 2 + private const val Indent = 2 private val qualifiedMappings = runBlocking { cache.resolveFile(LambdaAPI.gameVersion) .also { if (it.exists() && !it.readText().contains("net.minecraft.client.MinecraftClient")) { - LOG.debug("Re-downloading yarn mappings as the current cache is improperly generated") + Log.debug("Re-downloading yarn mappings as the current cache is improperly generated") it.delete() } } .downloadIfNotPresent("${LambdaAPI.mappings}/${LambdaAPI.gameVersion}") .map(::buildMappingsMap) .getOrElse { - LOG.error("Unable to download simplified deobfuscated qualifiers", it) + Log.error("Unable to download simplified deobfuscated qualifiers", it) emptyMap() } } @@ -174,7 +174,7 @@ object DynamicReflectionSerializer : Loadable { } val fieldValue = field.javaField?.get(this) - val fieldIndent = "$indent${" ".repeat(INDENT)}" + val fieldIndent = "$indent${" ".repeat(Indent)}" builder.appendLine("$fieldIndent${field.dynamicName(remap)}: ${fieldValue.formatFieldValue(remap)}") if (currentDepth < maxRecursionDepth @@ -187,7 +187,7 @@ object DynamicReflectionSerializer : Loadable { fieldValue.dynamicString( maxRecursionDepth, currentDepth + 1, - "$fieldIndent${" ".repeat(INDENT)}", + "$fieldIndent${" ".repeat(Indent)}", visitedObjects, builder, remap diff --git a/src/main/kotlin/com/lambda/util/FormattingUtils.kt b/src/main/kotlin/com/lambda/util/FormattingUtils.kt index 3088913b9..1533e67a9 100644 --- a/src/main/kotlin/com/lambda/util/FormattingUtils.kt +++ b/src/main/kotlin/com/lambda/util/FormattingUtils.kt @@ -17,7 +17,7 @@ package com.lambda.util -import com.lambda.config.groups.FormatterConfig +import com.lambda.config.blocks.FormatterConfig import com.lambda.util.math.Vec2d import net.minecraft.util.math.Vec2f import net.minecraft.util.math.Vec3d diff --git a/src/main/kotlin/com/lambda/util/KeyCode.kt b/src/main/kotlin/com/lambda/util/KeyCode.kt index 09bda2f42..863b8c3a5 100644 --- a/src/main/kotlin/com/lambda/util/KeyCode.kt +++ b/src/main/kotlin/com/lambda/util/KeyCode.kt @@ -144,7 +144,7 @@ enum class KeyCode(val code: Int) { Last(GLFW.GLFW_KEY_LAST); companion object { - private const val PRINTABLE_POOL = "`-=[]\\,;\'./" + private const val PrintablePool = "`-=[]\\,;\'./" private val glfwPool = intArrayOf( GLFW.GLFW_KEY_GRAVE_ACCENT, GLFW.GLFW_KEY_MINUS, GLFW.GLFW_KEY_EQUAL, GLFW.GLFW_KEY_LEFT_BRACKET, GLFW.GLFW_KEY_RIGHT_BRACKET, GLFW.GLFW_KEY_BACKSLASH, @@ -180,7 +180,7 @@ enum class KeyCode(val code: Int) { in 'A'..'Z' -> GLFW.GLFW_KEY_A + (char - 'A') in 'a'..'z' -> GLFW.GLFW_KEY_A + (char - 'a') else -> { - val i = PRINTABLE_POOL.indexOf(keyName) + val i = PrintablePool.indexOf(keyName) if (i >= 0) glfwPool[i] else keyCode } }) diff --git a/src/main/kotlin/com/lambda/util/StringUtils.kt b/src/main/kotlin/com/lambda/util/StringUtils.kt index c3426b1e5..65660b4d9 100644 --- a/src/main/kotlin/com/lambda/util/StringUtils.kt +++ b/src/main/kotlin/com/lambda/util/StringUtils.kt @@ -33,7 +33,7 @@ object StringUtils { fun String.capitalize() = replaceFirstChar { it.titlecase() } - fun String.toIdentifier(namespace: String = Lambda.MOD_ID): Identifier = + fun String.toIdentifier(namespace: String = Lambda.ModId): Identifier = Identifier.of(namespace, this) val String.asIdentifier: Identifier get() = toIdentifier() diff --git a/src/main/kotlin/com/lambda/util/VarIntIterator.kt b/src/main/kotlin/com/lambda/util/VarIntIterator.kt index ed40f64eb..0fc152aaa 100644 --- a/src/main/kotlin/com/lambda/util/VarIntIterator.kt +++ b/src/main/kotlin/com/lambda/util/VarIntIterator.kt @@ -33,17 +33,17 @@ class VarIntIterator( do { val b = bytes[index++].toInt() - value = value or ((b and SEGMENT_BIT) shl (size++ * 7)) + value = value or ((b and SegmentBit) shl (size++ * 7)) if (size > 5) throw IllegalArgumentException("VarInt size cannot exceed 5 bytes") - } while ((b and CONTINUE_BIT) != 0) + } while ((b and ContinueBit) != 0) return value } companion object { - const val SEGMENT_BIT = 127 - const val CONTINUE_BIT = 128 + const val SegmentBit = 127 + const val ContinueBit = 128 } } diff --git a/src/main/kotlin/com/lambda/util/WindowUtils.kt b/src/main/kotlin/com/lambda/util/WindowUtils.kt index c8e269a88..5be733b24 100644 --- a/src/main/kotlin/com/lambda/util/WindowUtils.kt +++ b/src/main/kotlin/com/lambda/util/WindowUtils.kt @@ -17,9 +17,9 @@ package com.lambda.util -import com.lambda.Lambda.MOD_NAME -import com.lambda.Lambda.SYMBOL -import com.lambda.Lambda.VERSION +import com.lambda.Lambda.ModName +import com.lambda.Lambda.Symbol +import com.lambda.Lambda.Version import com.lambda.Lambda.mc import com.lambda.gui.components.ClickGuiLayout.lambdaTitleAppendixName import net.minecraft.client.util.MacWindowUtil @@ -37,7 +37,7 @@ object WindowUtils { @JvmStatic fun setLambdaTitle() { val name = if (lambdaTitleAppendixName) " - ${mc.session.username}" else "" - mc.window.setTitle("$SYMBOL $MOD_NAME $VERSION - ${mc.windowTitle}$name") + mc.window.setTitle("$Symbol $ModName $Version - ${mc.windowTitle}$name") } fun setLambdaWindowIcon() { diff --git a/src/main/kotlin/com/lambda/util/math/MathUtils.kt b/src/main/kotlin/com/lambda/util/math/MathUtils.kt index 2a3afd405..e043c8c7c 100644 --- a/src/main/kotlin/com/lambda/util/math/MathUtils.kt +++ b/src/main/kotlin/com/lambda/util/math/MathUtils.kt @@ -28,16 +28,16 @@ import kotlin.math.min import kotlin.random.Random.Default.nextDouble object MathUtils { - private const val PI_FLOAT = 3.141593f + private const val PiFloat = 3.141593f inline val Int.sq: Int get() = this * this inline val Float.sq: Float get() = this * this inline val Double.sq: Double get() = this * this - fun Float.toRadian() = this / 180.0f * PI_FLOAT + fun Float.toRadian() = this / 180.0f * PiFloat fun Double.toRadian() = this / 180.0 * PI - fun Float.toDegree() = this * 180.0f / PI_FLOAT + fun Float.toDegree() = this * 180.0f / PiFloat fun Double.toDegree() = this * 180.0 / PI fun Boolean.toInt() = if (this) 1 else 0 diff --git a/src/main/kotlin/com/lambda/util/player/PlayerUtils.kt b/src/main/kotlin/com/lambda/util/player/PlayerUtils.kt index 69c1fb781..1a986ebce 100644 --- a/src/main/kotlin/com/lambda/util/player/PlayerUtils.kt +++ b/src/main/kotlin/com/lambda/util/player/PlayerUtils.kt @@ -17,7 +17,7 @@ package com.lambda.util.player -import com.lambda.config.groups.BuildConfig +import com.lambda.config.blocks.BuildConfig import com.lambda.context.SafeContext import com.lambda.util.world.fastEntitySearch import net.minecraft.client.network.ClientPlayerEntity diff --git a/src/main/kotlin/com/lambda/util/world/Position.kt b/src/main/kotlin/com/lambda/util/world/Position.kt index e6a3ee284..46e3289fc 100644 --- a/src/main/kotlin/com/lambda/util/world/Position.kt +++ b/src/main/kotlin/com/lambda/util/world/Position.kt @@ -34,48 +34,48 @@ import net.minecraft.util.math.Vec3i */ typealias FastVector = Long -internal const val X_BITS = 26 -internal const val Z_BITS = 26 -internal const val Y_BITS = 12 +internal const val XBits = 26 +internal const val ZBits = 26 +internal const val YBits = 12 -internal const val X_SHIFT = Y_BITS + Z_BITS -internal const val Z_SHIFT = Y_BITS +internal const val XShift = YBits + ZBits +internal const val ZShift = YBits -internal const val X_MASK = (1L shl X_BITS) - 1L -internal const val Z_MASK = (1L shl Z_BITS) - 1L -internal const val Y_MASK = (1L shl Y_BITS) - 1L +internal const val XMask = (1L shl XBits) - 1L +internal const val ZMask = (1L shl ZBits) - 1L +internal const val YMask = (1L shl YBits) - 1L -internal const val MIN_X = -(1L shl X_BITS - 1) -internal const val MIN_Z = -(1L shl Z_BITS - 1) -internal const val MAX_X = (1L shl X_BITS - 1) - 1L -internal const val MAX_Z = (1L shl Z_BITS - 1) - 1L +internal const val MinX = -(1L shl XBits - 1) +internal const val MinZ = -(1L shl ZBits - 1) +internal const val MaxX = (1L shl XBits - 1) - 1L +internal const val MaxZ = (1L shl ZBits - 1) - 1L /** * Serialized representation of (1, 1, 1) */ -const val F_ONE = 274945015809L +const val FOne = 274945015809L fun fastVectorOf(x: Long, y: Long, z: Long): FastVector { - require(x in MIN_X..MAX_X) { "X coordinate out of bounds for $X_BITS bits: $x" } - require(z in MIN_Z..MAX_Z) { "Z coordinate out of bounds for $Z_BITS bits: $z" } + require(x in MinX..MaxX) { "X coordinate out of bounds for $XBits bits: $x" } + require(z in MinZ..MaxZ) { "Z coordinate out of bounds for $ZBits bits: $z" } - return ((x and X_MASK) shl X_SHIFT) or ((z and Z_MASK) shl Z_SHIFT) or (y and Y_MASK) + return ((x and XMask) shl XShift) or ((z and ZMask) shl ZShift) or (y and YMask) } fun fastVectorOf(x: Int, y: Int, z: Int): FastVector = fastVectorOf(x.toLong(), y.toLong(), z.toLong()) val FastVector.x: Int - get() = ((this shr X_SHIFT and X_MASK).toInt() shl (32 - X_BITS)) shr (32 - X_BITS) + get() = ((this shr XShift and XMask).toInt() shl (32 - XBits)) shr (32 - XBits) val FastVector.z: Int - get() = ((this shr Z_SHIFT and Z_MASK).toInt() shl (32 - Z_BITS)) shr (32 - Z_BITS) + get() = ((this shr ZShift and ZMask).toInt() shl (32 - ZBits)) shr (32 - ZBits) val FastVector.y: Int - get() = ((this and Y_MASK).toInt() shl (32 - Y_BITS)) shr (32 - Y_BITS) + get() = ((this and YMask).toInt() shl (32 - YBits)) shr (32 - YBits) -infix fun FastVector.setX(x: Int): FastVector = bitSetTo(x.toLong(), X_SHIFT, X_BITS) -infix fun FastVector.setY(y: Int): FastVector = bitSetTo(y.toLong(), 0, Y_BITS) -infix fun FastVector.setZ(z: Int): FastVector = bitSetTo(z.toLong(), Z_SHIFT, Z_BITS) +infix fun FastVector.setX(x: Int): FastVector = bitSetTo(x.toLong(), XShift, XBits) +infix fun FastVector.setY(y: Int): FastVector = bitSetTo(y.toLong(), 0, YBits) +infix fun FastVector.setZ(z: Int): FastVector = bitSetTo(z.toLong(), ZShift, ZBits) infix fun FastVector.addX(value: Int): FastVector = setX(x + value) infix fun FastVector.addY(value: Int): FastVector = setY(y + value) diff --git a/src/main/kotlin/com/lambda/util/world/WorldUtils.kt b/src/main/kotlin/com/lambda/util/world/WorldUtils.kt index 4ca52ec1b..9b0f0d6d8 100644 --- a/src/main/kotlin/com/lambda/util/world/WorldUtils.kt +++ b/src/main/kotlin/com/lambda/util/world/WorldUtils.kt @@ -135,8 +135,8 @@ object WorldUtils { */ inline fun SafeContext.internalSearchBlocks( pos: FastVector, - range: FastVector = F_ONE times 7, - step: FastVector = F_ONE, + range: FastVector = FOne times 7, + step: FastVector = FOne, crossinline filter: (FastVector, BlockState) -> Boolean = { _, _ -> true }, ) = fastSequence(pos, range, step) .filter { @@ -152,8 +152,8 @@ object WorldUtils { */ inline fun SafeContext.internalSearchFluids( pos: FastVector, - range: FastVector = F_ONE times 7, - step: FastVector = F_ONE, + range: FastVector = FOne times 7, + step: FastVector = FOne, crossinline filter: (FastVector, FluidState) -> Boolean = { _, _ -> true }, ) = fastSequence(pos, range, step) .filter { diff --git a/src/test/kotlin/FastVectorTest.kt b/src/test/kotlin/FastVectorTest.kt index ca09e4363..d1888409d 100644 --- a/src/test/kotlin/FastVectorTest.kt +++ b/src/test/kotlin/FastVectorTest.kt @@ -15,8 +15,8 @@ * along with this program. If not, see . */ -import com.lambda.util.world.X_BITS -import com.lambda.util.world.Z_BITS +import com.lambda.util.world.XBits +import com.lambda.util.world.ZBits import com.lambda.util.world.addX import com.lambda.util.world.addY import com.lambda.util.world.addZ @@ -71,7 +71,7 @@ class FastVectorTest { @Test fun `test fast vector with invalid X coordinate`() { - val x = (1L shl X_BITS - 1) + val x = (1L shl XBits - 1) val y = 10L val z = 20L @@ -82,7 +82,7 @@ class FastVectorTest { fun `test fast vector with invalid Z coordinate`() { val x = 10L val y = 20L - val z = (1L shl Z_BITS - 1) + val z = (1L shl ZBits - 1) assertFails { fastVectorOf(x, y, z) } } From 18f11161240eb37ae7854a4369956fa3a5252330 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Fri, 8 May 2026 22:54:45 +0100 Subject: [PATCH 10/40] mostly finished changes in Config.kt and ConfigEditor.kt --- .../lambda/command/commands/ConfigCommand.kt | 129 ------------ src/main/kotlin/com/lambda/config/Config.kt | 194 +++++++++--------- .../kotlin/com/lambda/config/ConfigEditor.kt | 73 +++---- .../settings/blocks/TargetingSettings.kt | 2 +- .../managers/breaking/BreakManager.kt | 6 +- 5 files changed, 143 insertions(+), 261 deletions(-) diff --git a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt index b1d799381..b7d0d7052 100644 --- a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt @@ -81,133 +81,4 @@ object ConfigCommand : LambdaCommand( } } } - - /** - * Recursively registers path arguments for `reset`. - * At each depth, a string argument suggests layer names (settings + groups/tabs). - * If it resolves to a setting, reset it. If it could go deeper, recurse. - */ - private fun CommandBuilder.buildResetPath(depth: Int) { - val argName = "path$depth" - required(string(argName)) { - suggests { ctx, builder -> - val layers = resolveLayersAtDepth(ctx, depth) - layers?.forEach { layer -> - when (layer) { - is SettingLayer.Single -> builder.suggest(layer.setting.commandName) - is SettingLayer.Multiple -> builder.suggest(layer.commandName) - } - } - builder.buildFuture() - } - executeWithResult { - val setting = resolveSettingAtDepth(this, depth + 1) - ?: return@executeWithResult failure("Not a valid setting path.") - setting.reset() - return@executeWithResult success() - } - if (depth < MaxPathDepth) { - buildResetPath(depth + 1) - } - } - } - - /** - * Recursively registers path arguments for `set`. - * Same tree-walking as reset, but at each depth where the path could resolve - * to a setting, registers a value argument using JSON-based parsing. - */ - private fun CommandBuilder.buildSetPath(depth: Int) { - val argName = "path$depth" - required(string(argName)) { - suggests { ctx, builder -> - val layers = resolveLayersAtDepth(ctx, depth) - layers?.forEach { layer -> - when (layer) { - is SettingLayer.Single -> builder.suggest(layer.setting.commandName) - is SettingLayer.Multiple -> builder.suggest(layer.commandName) - } - } - builder.buildFuture() - } - // Register value argument — if the path resolves to a setting, set its value - required(string("value")) { valueArg -> - executeWithResult { - val setting = resolveSettingAtDepth(this, depth + 1) - ?: return@executeWithResult failure("Not a valid setting path.") - val valueString = valueArg(this).value() - val parsed = try { - JsonParser.parseString("\"$valueString\"") - } catch (_: Exception) { - return@executeWithResult failure("$valueString is not a valid value.") - } - val previous = setting.core.value - try { - setting.core.loadFromJson(parsed) - } catch (_: Exception) { - return@executeWithResult failure("Failed to set $valueString for ${setting.name}.") - } - this@ConfigCommand.info("Set ${setting.name} from $previous to ${setting.core.value}") - return@executeWithResult success() - } - } - buildSetPath(depth + 1) - } - } - - /** - * Resolves the [Config] from the "config" argument in the command context. - */ - private fun resolveConfig(ctx: CommandContext): Config? { - val configName = try { - ctx.getArgument("config", String::class.java) - } catch (_: Exception) { return null } - return ConfigLoader.configByCommandName(configName) - } - - /** - * Resolves the [SettingLayer] list at the given depth by reading - * path0..path(depth-1) from the command context and walking the tree. - */ - private fun resolveLayersAtDepth(ctx: CommandContext, depth: Int): List? { - val config = resolveConfig(ctx) ?: return null - var layers: List = config.settingLayers - for (i in 0 until depth) { - val argValue = try { - ctx.getArgument("path$i", String::class.java) - } catch (_: Exception) { return null } - val container = layers - .filterIsInstance() - .find { it.commandName == argValue } - ?: return null - layers = container.layers - } - return layers - } - - /** - * Resolves a [Setting] by reading config + path0..path(depth-1) from context. - * The last path argument is expected to be the setting name. - */ - private fun resolveSettingAtDepth(ctx: CommandContext, depth: Int): Setting<*, *>? { - val config = resolveConfig(ctx) ?: return null - var layers: List = config.settingLayers - for (i in 0 until depth - 1) { - val argValue = try { - ctx.getArgument("path$i", String::class.java) - } catch (_: Exception) { return null } - val container = layers - .filterIsInstance() - .find { it.commandName == argValue } - ?: return null - layers = container.layers - } - val settingName = try { - ctx.getArgument("path${depth - 1}", String::class.java) - } catch (_: Exception) { return null } - return layers - .filterIsInstance() - .find { it.setting.commandName == settingName } - ?.setting - } } diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index ee77de019..8a07a4cbe 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -73,7 +73,7 @@ private annotation class SettingDsl abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { internal val settingLayers = SettingLayer.Root() internal val settingBlockLayers = BlockLayer.Root() - private val registrationQueue = ArrayDeque>() + private val registrationQueue = ArrayDeque() init { if (configs.any { it.name == name }) throw IllegalStateException("Configs with name $name already exists") @@ -86,13 +86,25 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { forEachConfigProperty( klass, onSetting = { setting -> - registrationQueue.addLast(outerPath + buildPathFromAnnotations(setting)) + registrationQueue.addLast( + LayerSpecInfo( + outerPath + buildPathFromAnnotations(setting), + outerBlockPath + ) + ) }, onSettingBlock = { settingBlock, blockClass -> + val fullBlockPath = outerBlockPath + childBlockIndex enqueueProperties( blockClass, outerPath + buildPathFromAnnotations(settingBlock), - outerBlockPath + childBlockIndex + fullBlockPath + ) + registrationQueue.addLast( + LayerSpecInfo( + emptyList(), + fullBlockPath + ) ) childBlockIndex++ } @@ -388,10 +400,9 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { ): SettingBlockWrapper = settingBlock .apply { block?.invoke(this) } - .also { if (visibility != null) forEachSetting(settingBlock) { it.visibility = { it.visibility() && visibility() } } } .let { settingBlock -> val path = try { - settingBlockRegistration.removeFirst() + registrationQueue.removeFirst().settingBlockSpecs } catch(_: NoSuchElementException) { throw IllegalStateException("Setting block registered from an unknown location; layer path was not queued before setting initialization") } @@ -402,26 +413,35 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { val existing = currentLayer.layers.getOrNull(index) if (existing != null) currentLayer = existing else { - val layer = BlockLayer.Block(settingBlock, currentLayer) - currentLayer.layers[index] = layer + val layer = BlockLayer.Block(currentLayer) + currentLayer.layers.add(layer) currentLayer = layer } } - SettingBlockWrapper(settingBlock, currentLayer) + if (visibility != null) { + currentLayer.settingLayers.forEach { settingLayer -> + val setting = settingLayer.setting + setting.visibility = { setting.visibility() && visibility() } + } + } + + SettingBlockWrapper(settingBlock, currentLayer).also { wrapper -> + (currentLayer as? BlockLayer.Block)?.settingBlock = wrapper + } } @PublishedApi internal fun , R : Any> setting(name: String, description: String, settingCore: T, visibility: () -> Boolean): Setting { - val path = try { + val layerSpecInfo = try { registrationQueue.removeFirst() } catch(_: NoSuchElementException) { throw IllegalStateException("Setting registered from an unknown location; layer path was not queued before setting initialization") } - var currentLayer: SettingLayer.Multiple = settingLayers - path.forEach { spec -> - val existing = currentLayer.layers + var currentSettingLayer: SettingLayer.Multiple = settingLayers + layerSpecInfo.settingLayerSpecs.forEach { spec -> + val existing = currentSettingLayer.layers .asSequence() .filterIsInstance() .filter { it.name == spec.name } @@ -433,31 +453,85 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { } .firstOrNull() - if (existing != null) currentLayer = existing + if (existing != null) currentSettingLayer = existing else { - val newContainer = when (spec.type) { - SettingLayerType.Tab -> SettingLayer.Tab(spec.name, mutableListOf(), currentLayer) - SettingLayerType.Group -> SettingLayer.Group(spec.name, mutableListOf(), currentLayer) + val newSettingLayer = when (spec.type) { + SettingLayerType.Tab -> SettingLayer.Tab(spec.name, mutableListOf(), currentSettingLayer) + SettingLayerType.Group -> SettingLayer.Group(spec.name, mutableListOf(), currentSettingLayer) SettingLayerType.Root -> throw IllegalStateException("Multiple root setting layers; only the base class root layer should ever be created") } - currentLayer.layers.add(newContainer) - currentLayer = newContainer + currentSettingLayer.layers.add(newSettingLayer) + currentSettingLayer = newSettingLayer } } - val layer = SettingLayer.Single(currentLayer, name, description, settingCore, this@Config, visibility) - currentLayer.layers.add(layer) + var currentBlockLayer: BlockLayer = settingBlockLayers + layerSpecInfo.settingBlockSpecs.forEach { index -> + val existing = currentBlockLayer.layers.getOrNull(index) + if (existing != null) currentBlockLayer = existing + else { + val newBlockLayer = BlockLayer.Block(currentBlockLayer) + currentBlockLayer.layers.add(newBlockLayer) + currentBlockLayer = newBlockLayer + } + } + + val layer = SettingLayer.Single( + currentSettingLayer, + currentBlockLayer, + name, + description, + settingCore, + this@Config, + visibility + ) + currentSettingLayer.layers.add(layer) + currentBlockLayer.settingLayers.add(layer) return layer.setting } enum class SettingLayerType { Root, Tab, Group } private data class SettingLayerSpec(val type: SettingLayerType, val name: String) + private data class LayerSpecInfo(val settingLayerSpecs: List, val settingBlockSpecs: List) sealed interface SettingLayer { val parent: SettingLayer? + sealed class Multiple( + override val name: String, + val layers: MutableList, + override val parent: Multiple? + ) : SettingLayer, Nameable { + abstract val type: SettingLayerType + } + + class Root : Multiple( + "Root", + mutableListOf(), + null + ) { + override val type = SettingLayerType.Root + } + + class Tab( + name: String, + layers: MutableList, + parent: Multiple + ) : Multiple(name, layers, parent) { + override val type = SettingLayerType.Tab + } + + class Group( + name: String, + layers: MutableList, + parent: Multiple + ) : Multiple(name, layers, parent) { + override val type = SettingLayerType.Group + } + class Single, R : Any>( override val parent: Multiple, + val blockLayer: BlockLayer, name: String, description: String, settingCore: T, @@ -466,89 +540,23 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { ) : SettingLayer { val setting = Setting(name, description, settingCore, config, this, visibility) } - - sealed class Multiple( - override val name: String, - val layers: MutableList, - override val parent: Multiple? - ) : SettingLayer, Nameable { - abstract val type: SettingLayerType - } - - class Root : Multiple( - "Root", - mutableListOf(), - null - ) { - override val type = SettingLayerType.Root - } - - class Tab( - name: String, - layers: MutableList, - parent: Multiple - ) : Multiple(name, layers, parent) { - override val type = SettingLayerType.Tab - } - - class Group( - name: String, - layers: MutableList, - parent: Multiple - ) : Multiple(name, layers, parent) { - override val type = SettingLayerType.Group - } } - sealed interface BlockLayer { - val parent: BlockLayer? - val layers: MutableList + sealed class BlockLayer { + open val parent: BlockLayer? = null + val layers = mutableListOf() + val settingLayers = mutableListOf>() - class Root : BlockLayer { + class Root : BlockLayer() { override val parent = null - override val layers = mutableListOf() } class Block( - val settingBlock: SettingBlock, override val parent: BlockLayer? - ) : BlockLayer { - override val layers = mutableListOf() + ) : BlockLayer() { + var settingBlock: SettingBlockWrapper<*>? = null } } - - companion object { - fun forEachSetting( - instance: Any, - block: (Setting<*, *>) -> Unit - ) { - instance::class.declaredMemberProperties.forEach { property -> - val field = property.javaField ?: return@forEach - field.isAccessible = true - val fieldValue = field.get(instance) ?: return@forEach - when { - Setting::class.java.isAssignableFrom(field.type) -> - block(fieldValue as Setting<*, *>) - SettingBlockWrapper::class.java.isAssignableFrom(field.type) -> - forEachSetting(fieldValue as SettingBlockWrapper<*>, block) - } - } - } - - fun forEachSettingBlockWrapper( - instance: Any, - block: (SettingBlockWrapper) -> Unit - ) { - instance::class.java.declaredFields.forEach { field -> - field.isAccessible = true - val fieldValue = field.get(instance) ?: return@forEach - if (SettingBlockWrapper::class.java.isAssignableFrom(field.type)) { - block(fieldValue as SettingBlockWrapper) - forEachSettingBlockWrapper(fieldValue, block) - } - } - } - } } @Target(AnnotationTarget.PROPERTY) diff --git a/src/main/kotlin/com/lambda/config/ConfigEditor.kt b/src/main/kotlin/com/lambda/config/ConfigEditor.kt index 3dcfb8fc1..bf4a9f00e 100644 --- a/src/main/kotlin/com/lambda/config/ConfigEditor.kt +++ b/src/main/kotlin/com/lambda/config/ConfigEditor.kt @@ -19,22 +19,21 @@ package com.lambda.config -import com.lambda.config.Config.Companion.forEachSetting +import com.lambda.config.Config.BlockLayer import com.lambda.config.Config.SettingLayer +import net.minecraft.client.toast.SystemToast.hide import kotlin.reflect.KProperty0 -import kotlin.reflect.full.declaredMemberProperties import kotlin.reflect.jvm.isAccessible -import kotlin.reflect.jvm.javaField @DslMarker annotation class SettingEditorDsl @SettingEditorDsl -fun T.applyEdits(edits: ConfigEditor.() -> Unit) { +fun Config.applyEdits(edits: ConfigEditor.() -> Unit) { ConfigEditor(this).apply(edits) } -class ConfigEditor(val c: T) { +open class ConfigEditor(val c: Config) { private typealias Property = KProperty0 private typealias SettingProperty = KProperty0 private typealias SettingBlockProperty = KProperty0 @@ -59,59 +58,63 @@ class ConfigEditor(val c: T) { @SettingEditorDsl fun SettingProperty.edit(edits: TypedEditBuilder.(SettingCore) -> Unit) { val delegate = setting - TypedEditBuilder(this@ConfigEditor, listOf(delegate)).edits(delegate.core) + TypedEditBuilder(c, listOf(delegate)).edits(delegate.core) } @SettingEditorDsl fun edit( - vararg settings: SettingProperty<*>, + vararg settings: SettingProperty, edits: BasicEditBuilder.() -> Unit - ) = BasicEditBuilder(this, settings.map { (it as SettingProperty).setting }).apply(edits) + ) = BasicEditBuilder(c, settings.map { it.setting }).apply(edits) @SettingEditorDsl fun editTyped( vararg settings: SettingProperty, edits: TypedEditBuilder.() -> Unit - ) = TypedEditBuilder(this, settings.map { it.setting }).apply(edits) + ) = TypedEditBuilder(c, settings.map { it.setting }).apply(edits) @SettingEditorDsl fun hide(vararg settings: SettingProperty) = - hide(settings.map { it.setting }) + hide(settings.map { it.setting.layer }) @SettingEditorDsl - fun hideBlock(settingGroup: SettingBlockProperty) { - forEachSetting(settingGroup.settingBlock) { setting -> - hide(setting) - } + fun hideBlock(settingBlock: SettingBlockProperty) { + settingBlock.settingBlock.layer.settingLayers.forEach(::hide) } @SettingEditorDsl - fun hideBlocks(vararg settingGroups: SettingBlockProperty) = - settingGroups.forEach { hideBlock(it) } + fun hideBlocks(vararg settingBlocks: SettingBlockProperty) = + settingBlocks.forEach { hideBlock(it) } @SettingEditorDsl - fun hideBlockExcept(settingGroup: SettingBlockProperty, vararg except: SettingProperty) { + fun hideBlockExcept(settingBlock: SettingBlockProperty, vararg except: SettingProperty) { val exceptSettings = except.map { it.setting } - forEachSetting(settingGroup.settingBlock) { setting -> - if (setting !in exceptSettings) hide(setting) + settingBlock.settingBlock.layer.settingLayers.forEach { layer -> + if (layer.setting !in exceptSettings) hide(layer) } } @SettingEditorDsl - fun hideAllBlocksExcept(vararg except: SettingBlockWrapper) { - Config.forEachSettingBlockWrapper(c) { block -> - if (block !in except) hideBlock(block) + fun hideAllBlocksExcept(vararg except: SettingBlockProperty) { + val exceptBlocks = except.map { it.settingBlock.layer } + fun processBlock(blockLayer: BlockLayer.Block) { + blockLayer.layers.forEach(::processBlock) + if (blockLayer !in exceptBlocks) blockLayer.settingLayers.forEach(::hide) } - toHide.forEach { hide(it.collectSettings()) } - } - @SettingEditorDsl - fun SettingBlock.forEachSetting(block: (Setting<*, *>) -> Unit) = - forEachSetting(this, block) + c.settingBlockLayers.layers.forEach(::processBlock) + } - open class BasicEditBuilder(val c: ConfigEditor<*>, open val settings: Collection>) { + open class BasicEditBuilder( + c: Config, + open val settings: Collection> + ) : ConfigEditor(c) { @SettingEditorDsl - fun hide() = c.hide(settings) + fun hide() { + settings.forEach { + hide(it.layer) + } + } @SettingEditorDsl fun visibility(visibility: (() -> Boolean) -> () -> Boolean) { @@ -122,7 +125,7 @@ class ConfigEditor(val c: T) { } class TypedEditBuilder( - c: ConfigEditor<*>, + c: Config, override val settings: Collection, T>> ) : BasicEditBuilder(c, settings) { @SettingEditorDsl @@ -133,13 +136,13 @@ class ConfigEditor(val c: T) { } } - private fun hide(settings: Collection>) { - settings.forEach(::hide) + protected fun hide(layers: Collection>) { + layers.forEach(::hide) } - private fun hide(setting: Setting<*, *>) { - val parentLayer = setting.layer.parent - parentLayer.layers.remove(setting.layer) + protected fun hide(layer: SettingLayer.Single<*, *>) { + val parentLayer = layer.parent + parentLayer.layers.remove(layer) if (parentLayer.layers.isEmpty()) parentLayer.parent?.layers?.remove(parentLayer) } diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt index 3589566ea..d9d7f2edd 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt @@ -58,7 +58,7 @@ abstract class TargetingSettings( * between 1.0 and [maxRange]. */ override val targetingRange by c.setting("Targeting Range", defaultRange, 1.0..maxRange, 0.05) - override val targets = c.settingBlock(EntitySelectionSettings(c)) { + override val targets by c.settingBlock(EntitySelectionSettings(c)) { c.applyEdits { hide(::self, ::blockEntities) } } diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt index 84e1d681c..69a6ad905 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt @@ -17,7 +17,6 @@ package com.lambda.interaction.managers.breaking -import com.lambda.config.blocks.BreakConfig import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext import com.lambda.event.events.ConnectionEvent @@ -37,8 +36,9 @@ import com.lambda.interaction.managers.ManagerUtils.isPosBlocked import com.lambda.interaction.managers.PacketLimitHandler import com.lambda.interaction.managers.PacketType import com.lambda.interaction.managers.PositionBlocking -import com.lambda.config.blocks.BreakConfig.BreakConfirmationMode -import com.lambda.config.blocks.BreakConfig.BreakMode +import com.lambda.config.settings.blocks.BreakConfig +import com.lambda.config.settings.blocks.BreakConfig.BreakConfirmationMode +import com.lambda.config.settings.blocks.BreakConfig.BreakMode import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Primary import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Rebreak import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.RedundantSecondary From 455caa147a7ee16f4c95b93f79a185618f787998 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Mon, 11 May 2026 00:38:05 +0100 Subject: [PATCH 11/40] almost all compilation errors fixed, missing settingBlock group setting changes --- .../lambda/command/commands/BuildCommand.kt | 2 +- .../lambda/command/commands/ConfigCommand.kt | 80 ++- .../lambda/command/commands/PrefixCommand.kt | 3 - .../command/commands/TransferCommand.kt | 6 +- src/main/kotlin/com/lambda/config/Config.kt | 172 +++-- .../kotlin/com/lambda/config/ConfigEditor.kt | 1 - src/main/kotlin/com/lambda/config/Setting.kt | 2 +- .../config/automation/AutomationConfig.kt | 2 +- .../automation/IMutableAutomationConfig.kt | 39 +- .../config/automation/UserAutomationConfig.kt | 2 +- .../config/settings/blocks/BreakSettings.kt | 6 +- .../config/settings/blocks/BuildConfig.kt | 1 - .../config/settings/blocks/EatConfig.kt | 1 - .../settings/blocks/EntityColorsConfig.kt | 1 - .../settings/blocks/EntitySelectionConfig.kt | 2 - .../config/settings/blocks/HotbarConfig.kt | 1 - .../config/settings/blocks/InventoryConfig.kt | 1 - .../config/settings/blocks/ReplaceConfig.kt | 1 - .../config/settings/blocks/RotationConfig.kt | 2 - .../config/settings/blocks/TextConfig.kt | 1 - .../com/lambda/graphics/mc/BoxBuilder.kt | 2 +- .../com/lambda/graphics/mc/RenderBuilder.kt | 2 +- src/main/kotlin/com/lambda/gui/MenuBar.kt | 8 +- .../com/lambda/gui/components/QuickSearch.kt | 31 +- .../lambda/gui/components/SettingsWidget.kt | 109 ++-- .../com/lambda/interaction/BaritoneHandler.kt | 587 +++++++++--------- .../construction/simulation/Sim.kt | 6 +- .../simulation/checks/BasicChecker.kt | 3 +- .../simulation/checks/BreakSim.kt | 2 +- .../simulation/checks/InteractSim.kt | 6 +- .../simulation/context/BuildContext.kt | 2 +- .../simulation/result/Contextual.kt | 2 +- .../interaction/managers/ManagerUtils.kt | 2 +- .../managers/PacketLimitHandler.kt | 2 +- .../managers/breaking/BreakInfo.kt | 2 +- .../managers/breaking/BreakManager.kt | 6 +- .../managers/breaking/BrokenBlockHandler.kt | 6 +- .../managers/breaking/RebreakHandler.kt | 2 +- .../interaction/managers/breaking/SwapInfo.kt | 6 +- .../managers/hotbar/HotbarManager.kt | 3 +- .../managers/interacting/InteractInfo.kt | 2 +- .../managers/interacting/InteractManager.kt | 4 +- .../interacting/InteractedBlockHandler.kt | 8 +- .../interaction/managers/rotating/Rotation.kt | 6 +- .../managers/rotating/RotationManager.kt | 9 +- .../material/container/ContainerHandler.kt | 2 +- src/main/kotlin/com/lambda/module/Module.kt | 2 +- .../com/lambda/module/ModuleRegistry.kt | 9 +- .../com/lambda/module/hud/Coordinates.kt | 4 +- .../kotlin/com/lambda/module/hud/Rotation.kt | 4 +- .../lambda/module/modules/chat/AntiSpam.kt | 29 +- .../module/modules/chat/ChatTimestamp.kt | 15 +- .../lambda/module/modules/combat/AutoArmor.kt | 2 +- .../lambda/module/modules/combat/AutoTotem.kt | 2 +- .../module/modules/combat/CrystalAura.kt | 6 +- .../lambda/module/modules/combat/KillAura.kt | 6 +- .../module/modules/combat/PlayerTrap.kt | 2 +- .../lambda/module/modules/combat/Surround.kt | 2 +- .../modules/debug/SettingsTestModule.kt | 16 +- .../lambda/module/modules/debug/SilentSwap.kt | 11 +- .../module/modules/movement/BetterFirework.kt | 4 +- .../modules/movement/ElytraAltitudeControl.kt | 4 +- .../module/modules/movement/ElytraFly.kt | 4 +- .../lambda/module/modules/movement/Speed.kt | 10 +- .../lambda/module/modules/player/AutoEat.kt | 4 +- .../lambda/module/modules/player/FastBreak.kt | 2 +- .../module/modules/player/InventoryMove.kt | 4 +- .../module/modules/player/InventoryTweaks.kt | 2 +- .../module/modules/player/PacketMine.kt | 4 +- .../lambda/module/modules/player/Replay.kt | 4 +- .../module/modules/player/RotationLock.kt | 2 +- .../module/modules/player/StackReplenish.kt | 2 +- .../lambda/module/modules/player/ToolSaver.kt | 2 +- .../module/modules/render/BlockOutline.kt | 12 +- .../com/lambda/module/modules/render/ESP.kt | 24 +- .../lambda/module/modules/render/FreeLook.kt | 2 +- .../lambda/module/modules/render/Freecam.kt | 4 +- .../module/modules/render/LightLevels.kt | 13 +- .../lambda/module/modules/render/Nametags.kt | 27 +- .../lambda/module/modules/render/NoRender.kt | 9 +- .../lambda/module/modules/render/RadiusESP.kt | 17 +- .../lambda/module/modules/render/Search.kt | 32 +- .../lambda/module/modules/render/Tracers.kt | 29 +- .../lambda/module/modules/world/AirPlace.kt | 2 +- .../lambda/module/modules/world/AutoPortal.kt | 14 +- .../module/modules/world/AutoVillagerCycle.kt | 2 +- .../lambda/module/modules/world/Scaffold.kt | 4 +- .../lambda/module/modules/world/StashMover.kt | 4 +- .../kotlin/com/lambda/task/tasks/BuildTask.kt | 2 +- .../kotlin/com/lambda/task/tasks/EatTask.kt | 4 +- .../lambda/task/tasks/OpenContainerTask.kt | 2 +- .../com/lambda/util/CommunicationUtils.kt | 6 +- .../kotlin/com/lambda/util/Diagnostics.kt | 9 +- .../kotlin/com/lambda/util/FormattingUtils.kt | 2 +- .../com/lambda/util/player/PlayerUtils.kt | 2 +- .../lambda/util/world/raycast/RayCastUtils.kt | 2 +- src/test/kotlin/RotationTest.kt | 12 +- 97 files changed, 793 insertions(+), 747 deletions(-) diff --git a/src/main/kotlin/com/lambda/command/commands/BuildCommand.kt b/src/main/kotlin/com/lambda/command/commands/BuildCommand.kt index 51e93f749..c2db38610 100644 --- a/src/main/kotlin/com/lambda/command/commands/BuildCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/BuildCommand.kt @@ -62,7 +62,7 @@ object BuildCommand : LambdaCommand( .loadStructureByRelativePath(Path.of(pathString)) .let { template -> info("Building structure $pathString with dimensions ${template.size.toShortString()} created by ${template.author}") - lastBuildTask = with(AutomationConfig.Companion.DEFAULT) { + lastBuildTask = with(AutomationConfig.Companion.Default) { template.toStructure() .move(player.blockPos) .toBlueprint() diff --git a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt index b7d0d7052..baadcbdca 100644 --- a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt @@ -17,23 +17,21 @@ package com.lambda.command.commands -import com.google.gson.JsonParser +import com.lambda.brigadier.CommandResult import com.lambda.brigadier.CommandResult.Companion.failure import com.lambda.brigadier.CommandResult.Companion.success +import com.lambda.brigadier.argument.greedyString import com.lambda.brigadier.argument.literal import com.lambda.brigadier.argument.string import com.lambda.brigadier.argument.value import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required import com.lambda.command.LambdaCommand -import com.lambda.config.Config import com.lambda.config.Config.SettingLayer import com.lambda.config.ConfigLoader -import com.lambda.config.Setting import com.lambda.util.CommunicationUtils.info import com.lambda.util.extension.CommandBuilder -import com.mojang.brigadier.context.CommandContext -import net.minecraft.command.CommandSource +import com.mojang.brigadier.builder.ArgumentBuilder import net.minecraft.command.CommandSource.suggestMatching object ConfigCommand : LambdaCommand( @@ -43,8 +41,6 @@ object ConfigCommand : LambdaCommand( description = "Save or load configuration files, or set/reset any settings value", examples = listOf("config save", "config load", "config set HighwayTools Pavement_Material minecraft:obsidian") ) { - private const val MaxPathDepth = 6 - override fun CommandBuilder.create() { required(literal("save")) { executeWithResult { @@ -65,19 +61,71 @@ object ConfigCommand : LambdaCommand( } } required(literal("reset")) { - required(string("config")) { configArg -> - suggests { _, builder -> - suggestMatching(ConfigLoader.configs.map { it.commandName }, builder) - } - buildResetPath(0) + settingArgument { layer -> + layer.setting.reset() + success() } } required(literal("set")) { - required(string("config")) { configArg -> - suggests { _, builder -> - suggestMatching(ConfigLoader.configs.map { it.commandName }, builder) + settingArgument { layer -> + with(layer.setting) { buildCommand(registry) } + success() + } + } + } + + private fun > B.settingArgument(block: B.(SettingLayer.Single<*, *>) -> CommandResult) { + required(string("config")) { configArg -> + suggests { _, builder -> + suggestMatching(ConfigLoader.configs.map { it.commandName }, builder) + } + executeWithResult { + val configString = configArg().value() + val config = ConfigLoader.configByCommandName(configString) ?: return@executeWithResult failure("Config not found") + config.reset() + success() + } + required(greedyString("setting")) { settingArg -> + suggests { context, builder -> + val configString = configArg(context).value() + val config = ConfigLoader.configByCommandName(configString) ?: return@suggests null + val suggestions = mutableListOf() + fun forEach(layer: SettingLayer.Multiple, layerPath: List) { + layer.layers.forEach { layer -> + when (layer) { + is SettingLayer.Single<*, *> -> suggestions.add("${layerPath.joinToString(".")}.${layer.setting.name}") + is SettingLayer.Multiple -> forEach(layer, layerPath + layer.name) + } + } + } + + forEach(config.settingLayers, emptyList()) + suggestMatching(suggestions, builder) + } + executeWithResult { + val configString = configArg().value() + val config = ConfigLoader.configByCommandName(configString) ?: return@executeWithResult failure("Config not found") + val settingString = settingArg().value() + val fullPath = settingString.split(".") + val settingName = fullPath.last() + var currentLayer: SettingLayer.Multiple = config.settingLayers + fullPath.forEachIndexed { index, layerName -> + if (index == fullPath.size - 1) return@forEachIndexed + val layer = currentLayer.layers + .asSequence() + .filterIsInstance() + .find { it.name == layerName } + if (layer == null) return@executeWithResult failure("Config layer not found: $layerName") + currentLayer = layer + } + + val settingLayer = currentLayer.layers + .asSequence() + .filterIsInstance>() + .find { it.setting.name == settingName } + if (settingLayer == null) return@executeWithResult failure("Setting not found: $settingName") + return@executeWithResult block(settingLayer) } - buildSetPath(0) } } } diff --git a/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt b/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt index cf0e04ff1..023fde4c7 100644 --- a/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt @@ -26,10 +26,7 @@ import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required import com.lambda.command.CommandRegistry import com.lambda.command.LambdaCommand -import com.lambda.config.ConfigLoader import com.lambda.config.Setting -import com.lambda.config.SettingCore -import com.lambda.config.settings.CharSetting import com.lambda.util.CommunicationUtils.info import com.lambda.util.extension.CommandBuilder import com.lambda.util.text.buildText diff --git a/src/main/kotlin/com/lambda/command/commands/TransferCommand.kt b/src/main/kotlin/com/lambda/command/commands/TransferCommand.kt index 759a51315..39c55a9da 100644 --- a/src/main/kotlin/com/lambda/command/commands/TransferCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/TransferCommand.kt @@ -54,7 +54,7 @@ object TransferCommand : LambdaCommand( val selection = selectStack(amount(ctx).value()) { isItem(stack(ctx).value().item) } - AutomationConfig.Companion.DEFAULT.runSafeAutomated { + AutomationConfig.Companion.Default.runSafeAutomated { val containers = selection.findContainersWithMaterial() val indexedContainers = containers.withIndex() @@ -75,7 +75,7 @@ object TransferCommand : LambdaCommand( val selection = selectStack(amount(ctx).value()) { isItem(stack(ctx).value().item) } - AutomationConfig.Companion.DEFAULT.runSafeAutomated { + AutomationConfig.Companion.Default.runSafeAutomated { val containers = selection.findContainersWithSpace() val indexedContainers = containers.withIndex() @@ -95,7 +95,7 @@ object TransferCommand : LambdaCommand( val selection = selectStack(amount().value()) { isItem(stack().value().item) } - AutomationConfig.Companion.DEFAULT.runSafeAutomated { + AutomationConfig.Companion.Default.runSafeAutomated { val fromContainer = ContainerHandler.containers().find { it.name == from().value().split(".").last().trim() } ?: return@executeWithResult failure("From container not found") diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index 8a07a4cbe..5d6f70615 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -52,8 +52,6 @@ import net.minecraft.registry.Registries import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Vec3d import java.awt.Color -import kotlin.collections.toMutableList -import kotlin.jvm.java import kotlin.reflect.KClass import kotlin.reflect.KProperty import kotlin.reflect.full.declaredMemberProperties @@ -70,6 +68,7 @@ private annotation class SettingDsl * * @property settingLayers A set of [SettingCore]s that this config manages. */ +@Suppress("unused") abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { internal val settingLayers = SettingLayer.Root() internal val settingBlockLayers = BlockLayer.Root() @@ -136,60 +135,68 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { return path } - final override fun toJson() = - JsonObject().apply { - fun JsonObject.addSettings(settings: Collection) { - settings.forEach { layer -> - when (layer) { - is SettingLayer.Single<*, *> -> - try { - add(layer.setting.name, layer.setting.toJson()) - } catch(e: Throwable) { - logError("Failed to serialize '${layer.setting}' in ${this::class.simpleName}", e) - } - is SettingLayer.Multiple -> { - val grouped = JsonObject() - grouped.addSettings(layer.layers) - try { - add(layer.name, grouped) - } catch(e: Throwable) { - logError("Failed to serialize ${layer.type.toString().lowercase()}: ${layer.name} in ${this::class.simpleName}", e) - } - } - } - } - } - addSettings(settingLayers.layers) - } - - final override fun loadFromJson(serialized: JsonElement) { - val rootObj = serialized.asJsonObject - - fun loadFromObject(obj: JsonObject, layers: Collection) { - layers.forEach { layer -> - when (layer) { - is SettingLayer.Single<*, *> -> { - val jsonValue = obj[layer.setting.name] - if (jsonValue != null) { - try { - layer.setting.loadFromJson(jsonValue) - } catch (e: Throwable) { - logError("Failed to deserialize setting '${layer.setting.name}'", e) - } - } else logError("No saved value for setting '${layer.setting.name}' in ${this::class.simpleName}") - } - is SettingLayer.Multiple -> { - val nestedObj = obj[layer.name]?.asJsonObject - if (nestedObj != null) { - loadFromObject(nestedObj, layer.layers) - } else logError("No data for group/tab '${layer.name}' in ${this::class.simpleName}") - } - } - } - } - - loadFromObject(rootObj, settingLayers.layers) - } + fun reset() { + forEachSettingBlock(settingBlockLayers) { _, single -> + single.setting.reset() + } + } + + final override fun toJson() = + JsonObject().apply { + fun process(multiple: SettingLayer.Multiple, target: JsonObject) { + forEachSetting( + multiple, + false, + { _, multiple -> + val nested = JsonObject() + target.add(multiple.name, nested) + process(multiple, nested) + } + ) { _, single -> + try { + target.add(single.setting.name, single.setting.toJson()) + } catch (e: Throwable) { + logError("Failed to serialize '${single.setting}'", e) + } + } + } + process(settingLayers, this) + } + + final override fun loadFromJson(serialized: JsonElement) { + val rootObj = serialized.asJsonObject + + fun load(multiple: SettingLayer.Multiple, obj: JsonObject) { + forEachSetting( + multiple, + false, + { _, multiple -> + val nestedObj = obj[multiple.name] + if (nestedObj == null || !nestedObj.isJsonObject) { + logError("No data for ${multiple.type.toString().lowercase()} '${multiple.name}' in '$name'}") + } + try { + load(multiple, nestedObj.asJsonObject) + } catch(e: Throwable) { + logError("Failed to deserialize ${multiple.type.toString().lowercase()} '${multiple.name}' in '$name'", e) + } + } + ) { _, single -> + val jsonValue = obj[single.setting.name] + if (jsonValue != null) { + try { + single.setting.loadFromJson(jsonValue) + } catch (e: Throwable) { + logError("Failed to deserialize setting '$name'", e) + } + } else { + logError("No saved value for setting '${single.setting.name}' in '$name'") + } + } + } + + load(settingLayers, rootObj) + } @SettingDsl fun setting( @@ -446,10 +453,11 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { .filterIsInstance() .filter { it.name == spec.name } .also { - if (it.any { layer -> - spec.type == SettingLayerType.Tab && layer is SettingLayer.Group || - spec.type == SettingLayerType.Group && layer is SettingLayer.Tab - }) throw IllegalStateException("Duplicate setting layer names with differing types: ${spec.type}") + it.forEach { layer -> + if (spec.type == SettingLayerType.Tab && layer !is SettingLayer.Tab || + spec.type == SettingLayerType.Group && layer !is SettingLayer.Group + ) throw IllegalStateException("Duplicate setting layers with differing types: ${layer.name} with type ${layer.type.toString().lowercase()} and ${spec.name} with type ${spec.type.toString().lowercase()}") + } } .firstOrNull() @@ -465,6 +473,10 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { } } + if (currentSettingLayer.layers.any { + it is SettingLayer.Single<*, *> && it.setting.name == name + }) throw IllegalStateException("Duplicate setting name ('$name') within ${currentSettingLayer.name}") + var currentBlockLayer: BlockLayer = settingBlockLayers layerSpecInfo.settingBlockSpecs.forEach { index -> val existing = currentBlockLayer.layers.getOrNull(index) @@ -494,7 +506,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { private data class SettingLayerSpec(val type: SettingLayerType, val name: String) private data class LayerSpecInfo(val settingLayerSpecs: List, val settingBlockSpecs: List) - sealed interface SettingLayer { + sealed interface SettingLayer { val parent: SettingLayer? sealed class Multiple( @@ -557,6 +569,44 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { var settingBlock: SettingBlockWrapper<*>? = null } } + + internal fun forEachSetting( + root: SettingLayer.Multiple = settingLayers, + recurse: Boolean = true, + onMultiple: ((path: List, single: SettingLayer.Multiple) -> Unit)? = null, + onSingle: ((path: List, single: SettingLayer.Single<*, *>) -> Unit)? = null + ) { + fun internalForEach(layer: SettingLayer.Multiple, path: List) { + layer.layers.forEach { layer -> + when (layer) { + is SettingLayer.Single<*, *> if onSingle != null -> onSingle(path, layer) + is SettingLayer.Multiple if onMultiple != null -> { + onMultiple(path, layer) + if (recurse) internalForEach(layer, path + layer.name) + } + else -> {} + } + } + } + internalForEach(root, emptyList()) + } + + internal fun forEachSettingBlock( + root: BlockLayer = settingBlockLayers, + recurse: Boolean = true, + onBlockLayer: ((path: List, block: BlockLayer.Block) -> Unit)? = null, + onSetting: ((path: List, single: SettingLayer.Single<*, *>) -> Unit)? = null + ) { + fun internalForEach(layer: BlockLayer, path: List) { + if (onSetting != null) layer.settingLayers.forEach { onSetting(path, it) } + layer.layers.forEachIndexed { index, blockLayer -> + val fullPath = path + index + onBlockLayer?.invoke(fullPath, blockLayer) + if (recurse) internalForEach(blockLayer, fullPath) + } + } + internalForEach(root, emptyList()) + } } @Target(AnnotationTarget.PROPERTY) diff --git a/src/main/kotlin/com/lambda/config/ConfigEditor.kt b/src/main/kotlin/com/lambda/config/ConfigEditor.kt index bf4a9f00e..8e63a8432 100644 --- a/src/main/kotlin/com/lambda/config/ConfigEditor.kt +++ b/src/main/kotlin/com/lambda/config/ConfigEditor.kt @@ -21,7 +21,6 @@ package com.lambda.config import com.lambda.config.Config.BlockLayer import com.lambda.config.Config.SettingLayer -import net.minecraft.client.toast.SystemToast.hide import kotlin.reflect.KProperty0 import kotlin.reflect.jvm.isAccessible diff --git a/src/main/kotlin/com/lambda/config/Setting.kt b/src/main/kotlin/com/lambda/config/Setting.kt index 7969dde9c..0b0b73412 100644 --- a/src/main/kotlin/com/lambda/config/Setting.kt +++ b/src/main/kotlin/com/lambda/config/Setting.kt @@ -136,7 +136,7 @@ class Setting, R>( runCatching { originalCore.loadFromJson(serialized) }.onFailure { - Log.warn("Failed to load setting $name with value $serialized. Resetting to default value ${core.defaultValue}") + Log.warn("Failed to load setting $name with value $serialized") } } diff --git a/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt index b3633746f..aa70fa577 100644 --- a/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt @@ -64,6 +64,6 @@ open class AutomationConfig( edits: (AutomationConfig.() -> Unit)? = null ) { defaultAutomationConfig = AutomationConfig("$name Automation Config").apply { edits?.invoke(this) } } - val DEFAULT = AutomationConfig("Default") + val Default = AutomationConfig("Default") } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt index aea0f1506..06e1a4554 100644 --- a/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt @@ -17,7 +17,7 @@ package com.lambda.config.automation -import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.config.settings.blocks.BreakConfig @@ -34,17 +34,17 @@ interface IMutableAutomationConfig : Automated { var backingAutomationConfig: AutomationConfig var automationConfig: AutomationConfig - override val buildConfig get() = automationConfig.buildConfig - override val breakConfig get() = automationConfig.breakConfig - override val interactConfig get() = automationConfig.interactConfig - override val rotationConfig get() = automationConfig.rotationConfig - override val inventoryConfig get() = automationConfig.inventoryConfig - override val hotbarConfig get() = automationConfig.hotbarConfig - override val eatConfig get() = automationConfig.eatConfig + override val buildConfig: BuildConfig get() = automationConfig.buildConfig + override val breakConfig: BreakConfig get() = automationConfig.breakConfig + override val interactConfig: InteractConfig get() = automationConfig.interactConfig + override val rotationConfig: RotationConfig get() = automationConfig.rotationConfig + override val inventoryConfig: InventoryConfig get() = automationConfig.inventoryConfig + override val hotbarConfig: HotbarConfig get() = automationConfig.hotbarConfig + override val eatConfig: EatConfig get() = automationConfig.eatConfig } class MutableAutomationConfig : IMutableAutomationConfig { - override var defaultAutomationConfig: AutomationConfig = AutomationConfig.DEFAULT + override var defaultAutomationConfig: AutomationConfig = AutomationConfig.Default set(value) { field = value automationConfig = value @@ -54,15 +54,28 @@ class MutableAutomationConfig : IMutableAutomationConfig { set(value) { if (value === defaultAutomationConfig) { if (backingAutomationConfig !== defaultAutomationConfig) { - Config.forEachSetting(field) { it.restoreOriginalCore() } + field.forEachSetting { _, single -> single.setting.restoreOriginalCore() } } field = value } else { - Config.forEachMatchingSetting(field.settingLayers, value.settingLayers) { setting, newSetting -> - if (setting.core.type != newSetting.core.type) + field.forEachSetting { path, single -> + var otherLayer: SettingLayer.Multiple = value.settingLayers + path.forEach { layer -> + val subLayer = otherLayer.layers + .asSequence() + .filterIsInstance() + .find { it.name == layer } ?: return@forEachSetting + otherLayer = subLayer + } + val otherSetting = otherLayer.layers + .asSequence() + .filterIsInstance>() + .find { it.setting.name == single.setting.name } + ?.setting ?: return@forEachSetting + if (single.setting.core.type != otherSetting.core.type) throw IllegalStateException("Settings with the same name do not have the same type.") @Suppress("UNCHECKED_CAST") - (setting as Setting, Any>).core = newSetting.core as SettingCore + (single.setting as Setting, Any>).core = otherSetting.core as SettingCore } } backingAutomationConfig = value diff --git a/src/main/kotlin/com/lambda/config/automation/UserAutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/UserAutomationConfig.kt index 52554f5b0..684f3a224 100644 --- a/src/main/kotlin/com/lambda/config/automation/UserAutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/UserAutomationConfig.kt @@ -24,7 +24,7 @@ import com.lambda.module.Module import com.lambda.module.ModuleRegistry.moduleNameMap class UserAutomationConfig(override val name: String) : AutomationConfig(name, UserAutomationCategory) { - val linkedModules = setting("Linked Modules", emptySet(), moduleNameMap.filter { it.value.defaultAutomationConfig != Companion.DEFAULT }.keys) { false } + val linkedModules = setting("Linked Modules", emptySet(), moduleNameMap.filter { it.value.defaultAutomationConfig != Companion.Default }.keys) { false } .onSelect { name -> moduleNameMap[name]?.let { it.removeLink() diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt index 2ce651ab3..97f60c693 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt @@ -39,7 +39,7 @@ class BreakSettings(override val c: Config) : BreakConfig, SettingBlock { // General @Group(GeneralGroup) override val breakMode by c.setting("Break Mode", BreakMode.Packet) - @Group(GeneralGroup) override val sorter by c.setting("Break Sorter", _root_ide_package_.com.lambda.config.settings.blocks.ActionConfig.SortMode.Tool, "The order in which breaks are performed") + @Group(GeneralGroup) override val sorter by c.setting("Break Sorter", ActionConfig.SortMode.Tool, "The order in which breaks are performed") @Group(GeneralGroup) override val rebreak by c.setting("Rebreak", true, "Re-breaks blocks after they've been broken once") // Double break @Group(GeneralGroup) override val doubleBreak by c.setting("Double Break", true, "Allows breaking two blocks at once") @@ -52,9 +52,9 @@ class BreakSettings(override val c: Config) : BreakConfig, SettingBlock { @Group(GeneralGroup) override val breakDelay by c.setting("Break Delay", 0, 0..6, 1, "The delay between breaking blocks", " tick(s)") // Timing @Group(GeneralGroup) override val tickStageMask by c.setting("Break Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), "The sub-tick timing at which break actions can be performed", displayClassName = true) - @Group(GeneralGroup) override val swapMode by c.setting("Break Swap Mode", _root_ide_package_.com.lambda.config.settings.blocks.BreakConfig.SwapMode.End, "Decides when to swap to the best suited tool when breaking a block") + @Group(GeneralGroup) override val swapMode by c.setting("Break Swap Mode", BreakConfig.SwapMode.End, "Decides when to swap to the best suited tool when breaking a block") @Group(GeneralGroup) override val swing by c.setting("Swing Mode", SwingMode.Constant, "The times at which to swing the players hand") - @Group(GeneralGroup) override val swingType by c.setting("Break Swing Type", _root_ide_package_.com.lambda.config.settings.blocks.BuildConfig.SwingType.Vanilla, "The style of swing") { swing != SwingMode.None } + @Group(GeneralGroup) override val swingType by c.setting("Break Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { swing != SwingMode.None } // Rotate @Group(GeneralGroup) override val rotate by c.setting("Rotate For Break", false, "Rotate towards block while breaking") // Pending / Post diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/BuildConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/BuildConfig.kt index 73b7a81fd..a1d2518a3 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/BuildConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/BuildConfig.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings.blocks -import com.lambda.config.SettingBlock import com.lambda.interaction.managers.rotating.Rotation.Companion.dist import com.lambda.interaction.managers.rotating.RotationManager import com.lambda.util.Describable diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/EatConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/EatConfig.kt index 14b2b9aa7..6975c721f 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/EatConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/EatConfig.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings.blocks -import com.lambda.config.SettingBlock import com.lambda.context.Automated import com.lambda.context.AutomatedSafeContext import com.lambda.interaction.material.StackSelection.Companion.selectStack diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/EntityColorsConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/EntityColorsConfig.kt index fe4f9804f..ef6ac4aec 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/EntityColorsConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/EntityColorsConfig.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings.blocks -import com.lambda.config.SettingBlock import java.awt.Color interface EntityColorsConfig { diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/EntitySelectionConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/EntitySelectionConfig.kt index 87786feff..0916f5108 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/EntitySelectionConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/EntitySelectionConfig.kt @@ -17,8 +17,6 @@ package com.lambda.config.settings.blocks -import com.lambda.config.SettingBlock - interface EntitySelectionConfig { val self: Boolean val enablePlayerEntities: Boolean diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/HotbarConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/HotbarConfig.kt index 656097b16..63f075e02 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/HotbarConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/HotbarConfig.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings.blocks -import com.lambda.config.SettingBlock import com.lambda.event.events.TickEvent /** diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/InventoryConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/InventoryConfig.kt index 21ec4f37f..cfc66af3f 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/InventoryConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/InventoryConfig.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings.blocks -import com.lambda.config.SettingBlock import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.interaction.material.ContainerSelection diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/ReplaceConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/ReplaceConfig.kt index bf2a1451e..3c21ba89f 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/ReplaceConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/ReplaceConfig.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings.blocks -import com.lambda.config.SettingBlock import com.lambda.util.Describable interface ReplaceConfig { diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/RotationConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/RotationConfig.kt index d4e8ab7d6..8ef5b4dc0 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/RotationConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/RotationConfig.kt @@ -17,8 +17,6 @@ package com.lambda.config.settings.blocks -import com.lambda.config.Config -import com.lambda.config.SettingBlock import com.lambda.event.events.TickEvent import com.lambda.interaction.managers.rotating.RotationManager import com.lambda.interaction.managers.rotating.RotationMode diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/TextConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/TextConfig.kt index b7a5dba25..b1dc6c242 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/TextConfig.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/TextConfig.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings.blocks -import com.lambda.config.SettingBlock import com.lambda.graphics.mc.RenderBuilder import java.awt.Color diff --git a/src/main/kotlin/com/lambda/graphics/mc/BoxBuilder.kt b/src/main/kotlin/com/lambda/graphics/mc/BoxBuilder.kt index 8e92f69b0..7ceeed706 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/BoxBuilder.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/BoxBuilder.kt @@ -17,7 +17,7 @@ package com.lambda.graphics.mc -import com.lambda.config.blocks.LineConfig +import com.lambda.config.settings.blocks.LineConfig import com.lambda.graphics.util.DirectionMask import net.minecraft.util.math.Direction import java.awt.Color diff --git a/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt b/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt index 922853664..f0e4f7220 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/RenderBuilder.kt @@ -18,7 +18,7 @@ package com.lambda.graphics.mc import com.lambda.Lambda.mc -import com.lambda.config.blocks.LineConfig +import com.lambda.config.settings.blocks.LineConfig import com.lambda.context.SafeContext import com.lambda.graphics.outline.OutlineHandler import com.lambda.graphics.outline.OutlineStyle diff --git a/src/main/kotlin/com/lambda/gui/MenuBar.kt b/src/main/kotlin/com/lambda/gui/MenuBar.kt index 27d36d4f9..ba7285956 100644 --- a/src/main/kotlin/com/lambda/gui/MenuBar.kt +++ b/src/main/kotlin/com/lambda/gui/MenuBar.kt @@ -307,7 +307,7 @@ object MenuBar { if (config !is UserAutomationConfig) throw java.lang.IllegalStateException("All configs within UserAutomationConfigs must be UserAutomationConfigs!") buildAutomationConfigSelectable(config) } - buildAutomationConfigSelectable(AutomationConfig.Companion.DEFAULT) + buildAutomationConfigSelectable(AutomationConfig.Companion.Default) } private fun ImGuiBuilder.buildAutomationConfigSelectable(config: AutomationConfig) { @@ -470,7 +470,11 @@ object MenuBar { text("Modules: ${ModuleRegistry.modules.size}") text("Commands: ${CommandRegistry.commands.size}") val totalSettings = ConfigLoader.configCategories.sumOf { cfg -> - cfg.configs.sumOf { it.settingLayers.size } + cfg.configs.sumOf { + var count = 0 + it.forEachSetting { _, _ -> count++ } + count + } } text("Settings: $totalSettings") text("Synchronous listeners: ${EventFlow.syncListeners.size}") diff --git a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt index e25752c61..f7634e09a 100644 --- a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt +++ b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt @@ -261,14 +261,17 @@ object QuickSearch { } else null } - val settingResults = ConfigLoader.configCategories.flatMap { - it.configs.flatMap { config -> - config.settingLayers - .filter { setting -> setting.visibility() } - .mapNotNull { setting -> - val score = calculateScore(lowerCaseQuery, setting.name.lowercase(), lenient) - if (score > 0) RankedSearchResult(SettingResult(setting, config), score) else null + val settingResults = buildList { + ConfigLoader.configCategories.forEach { category -> + category.configs.forEach { config -> + config.forEachSetting { _, single -> + val setting = single.setting + if (setting.visibility()) { + val score = calculateScore(lowerCaseQuery, setting.name.lowercase(), lenient) + if (score > 0) add(RankedSearchResult(SettingResult(setting, config), score)) + } } + } } } @@ -298,11 +301,15 @@ object QuickSearch { } private fun buildSettingBreadcrumb(configName: String, setting: Setting<*, *>): String { - val group = setting.groups - .minByOrNull { it.size } - ?.joinToString(" » ") { it.displayName } - ?: return configName - return "$configName » $group" + val path = buildList { + var current: Config.SettingLayer? = setting.layer.parent + while (current is Config.SettingLayer.Multiple && current !is Config.SettingLayer.Root) { + add(current.name) + current = current.parent + } + }.asReversed() + return if (path.isEmpty()) configName + else "$configName » ${path.joinToString(" » ")}" } private fun handleKeyPress(event: ButtonEvent.Keyboard.Press) { diff --git a/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt b/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt index 0221fb3f9..2981a337d 100644 --- a/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt +++ b/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt @@ -18,6 +18,7 @@ package com.lambda.gui.components import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.automation.AutomationConfig import com.lambda.config.automation.IMutableAutomationConfig @@ -51,12 +52,12 @@ object SettingsWidget { with(config.backgroundColor) { buildLayout() } } smallButton("Reset") { - resetContainers(config.settingLayers) + config.reset() } } } lambdaTooltip("Resets all settings for this module to their default values") - if (config is IMutableAutomationConfig && config.automationConfig !== AutomationConfig.DEFAULT) { + if (config is IMutableAutomationConfig && config.automationConfig !== AutomationConfig.Default) { button("Automation Config") { ImGui.openPopup("##automation-config-popup-${config.name}") } @@ -88,94 +89,56 @@ object SettingsWidget { if (!hasVisibleSettings(config.settingLayers)) return separator() - renderContainers(config.settingLayers, config.name) + drawLayers(config.settingLayers, config.name) } - /** - * Recursively renders [Config.SettingLayer]s in order. - * - [Config.SettingLayer.Single]: renders the setting with visibility/disabled checks. - * - [Config.SettingLayer.Tab]: renders as ImGui tab bar with tab items. - * - [Config.SettingLayer.Group]: renders as a collapsible tree node with indent. - */ - private fun ImGuiBuilder.renderContainers(containers: List, idPrefix: String) { - val runs = mutableListOf() - containers.forEach { container -> - if (container is Config.SettingLayer.Tab) { - val last = runs.lastOrNull() - if (last is MutableList<*>) { - @Suppress("UNCHECKED_CAST") - (last as MutableList).add(container) - } else { - runs.add(mutableListOf(container)) - } - } else { - runs.add(container) - } - } + private fun ImGuiBuilder.drawLayers(root: SettingLayer.Multiple, idPrefix: String) { + var tabsDrawn = false - runs.forEach { run -> - when (run) { - is Config.SettingLayer.Single -> renderSetting(run.setting) - is Config.SettingLayer.Group -> { - if (hasVisibleSettings(run.layers)) { - treeNode("${run.name}##$idPrefix-group-${run.name}") { - renderContainers(run.layers, "$idPrefix-${run.name}") + root.layers.forEach { layer -> + when (layer) { + is SettingLayer.Single<*, *> -> drawSetting(layer.setting) + is SettingLayer.Group -> { + if (hasVisibleSettings(layer)) { + treeNode("${layer.name}##$idPrefix-group-${layer.name}") { + drawLayers(layer, "$idPrefix-${layer.name}") } } } - is List<*> -> { - @Suppress("UNCHECKED_CAST") - renderTabBar(run as List, idPrefix) - } - } - } - } - - /** - * Renders a group of [Config.SettingLayer.Tab]s as a single ImGui tab bar. - */ - private fun ImGuiBuilder.renderTabBar(tabs: List, idPrefix: String) { - val visibleTabs = tabs.filter { hasVisibleSettings(it.layers) } - if (visibleTabs.isEmpty()) return - tabBar("##$idPrefix-tabs", ImGuiTabBarFlags.FittingPolicyResizeDown) { - visibleTabs.forEach { tab -> - tabItem(tab.name) { - renderContainers(tab.layers, "$idPrefix-${tab.name}") + is SettingLayer.Tab -> { + if (!tabsDrawn) { + tabsDrawn = true + val allTabs = root.layers + .filterIsInstance() + .filter { hasVisibleSettings(it) } + if (allTabs.isNotEmpty()) { + tabBar("##$idPrefix-tabs", ImGuiTabBarFlags.FittingPolicyResizeDown) { + allTabs.forEach { tab -> + tabItem(tab.name) { + drawLayers(tab, "$idPrefix-${tab.name}") + } + } + } + } + } } + else -> {} } } } - /** - * Renders a single [Setting] with visibility and disabled state checks. - */ - private fun ImGuiBuilder.renderSetting(setting: Setting<*, *>) { + private fun ImGuiBuilder.drawSetting(setting: Setting<*, *>) { if (!setting.visibility()) return if (setting.disabled()) ImGui.beginDisabled() with(setting) { buildLayout() } if (setting.disabled()) ImGui.endDisabled() } - /** - * Checks if any [Config.SettingLayer] in the tree has a visible setting. - */ - private fun hasVisibleSettings(containers: List): Boolean = - containers.any { container -> - when (container) { - is Config.SettingLayer.Single -> container.setting.visibility() - is Config.SettingLayer.Multiple -> hasVisibleSettings(container.layers) - } - } - - /** - * Recursively resets all settings in the container tree. - */ - private fun resetContainers(containers: List) { - containers.forEach { container -> - when (container) { - is Config.SettingLayer.Single -> container.setting.reset(silent = true) - is Config.SettingLayer.Multiple -> resetContainers(container.layers) + private fun hasVisibleSettings(layer: SettingLayer.Multiple): Boolean = + layer.layers.any { layer -> + when (layer) { + is SettingLayer.Single<*, *> -> layer.setting.visibility() + is SettingLayer.Multiple -> hasVisibleSettings(layer) } } - } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt b/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt index f795bf2b0..eebcf60f2 100644 --- a/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt @@ -21,17 +21,21 @@ import baritone.api.BaritoneAPI import baritone.api.IBaritone import baritone.api.Settings import baritone.api.pathing.goals.Goal -import com.lambda.config.automation.AutomationConfig import com.lambda.config.Config +import com.lambda.config.Group +import com.lambda.config.Tab import com.lambda.config.categories.LambdaCategory -import com.lambda.config.blocks.RotationSettings +import net.fabricmc.loader.api.FabricLoader +import com.lambda.config.SettingBlock +import com.lambda.config.automation.AutomationConfig +import com.lambda.config.settings.blocks.RotationSettings import com.lambda.context.Automated import com.lambda.util.BlockUtils.blockPos -import com.lambda.util.NamedEnum -import net.fabricmc.loader.api.FabricLoader +import net.minecraft.util.BlockMirror +import net.minecraft.util.BlockRotation @Suppress("unused") -object BaritoneHandler : Config(LambdaCategory), Automated by AutomationConfig.Companion.DEFAULT { +object BaritoneHandler : Config(LambdaCategory), Automated by AutomationConfig.Default { override val name = "baritone" val isBaritoneLoaded = FabricLoader.getInstance().isModLoaded("baritone") @@ -39,309 +43,13 @@ object BaritoneHandler : Config(LambdaCategory), Automated by AutomationConfig.C private val baritone = if (isBaritoneLoaded) BaritoneAPI.getProvider() else null val baritoneSettings: Settings? = if (isBaritoneLoaded) BaritoneAPI.getSettings() else null + val settings = if (isBaritoneLoaded) baritoneSettings?.let { settingBlock(BaritoneConfigSettings(this, it)) } else null + private const val RotationTab = "Rotation" + @Tab(RotationTab) override val rotationConfig by settingBlock(RotationSettings(this)) + @JvmStatic val primary: IBaritone? = baritone?.primaryBaritone - private enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Rotation("Rotation"), - Pathing("Pathing"), - Behavior("Behavior"), - Building("Building"), - Rendering("Rendering"), - Elytra("Elytra") - } - - private enum class SubGroup(override val displayName: String) : NamedEnum { - ChatAndControl("Chat & Control"), - Waypoints("Waypoints"), - Assumptions("Assumptions"), - Movement("Movement"), - BlockRules("Block Rules"), - MiningAndFarming("Mining & Farming"), - Interaction("Interaction"), - Penalties("Penalties"), - Exploration("Exploration"), - Misc("Misc"), - Rendering("Rendering"), - RenderingColors("Rendering Colors"), - RenderingSelection("Rendering Selection"), - PathingPerformance("Pathing Performance"), - PathingCore("Pathing Core"), - Follow("Follow"), - Schematic("Schematic") - } - - override val rotationConfig = RotationSettings(this, Group.Rotation) - - init { - // ToDo: Dont actually save the settings as its duplicate data - if (isBaritoneLoaded) { - with(baritoneSettings!!) { - // GENERAL - setting("Log As Toast", logAsToast.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> logAsToast.value = it } - setting("Chat Debug", chatDebug.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> chatDebug.value = it } - setting("Chat Control", chatControl.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> chatControl.value = it } - setting("Chat Control Anyway", chatControlAnyway.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> chatControlAnyway.value = it } - setting("Prefix Control", prefixControl.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> prefixControl.value = it } - setting("Prefix", prefix.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> prefix.value = it } - setting("Short Baritone Prefix", shortBaritonePrefix.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> shortBaritonePrefix.value = it } - setting("Use Message Tag", useMessageTag.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> useMessageTag.value = it } - setting("Echo Commands", echoCommands.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> echoCommands.value = it } - setting("Censor Coordinates", censorCoordinates.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> censorCoordinates.value = it } - setting("Censor Ran Commands", censorRanCommands.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> censorRanCommands.value = it } - setting("Desktop Notifications", desktopNotifications.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> desktopNotifications.value = it } - setting("Notification On Path Complete", notificationOnPathComplete.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> notificationOnPathComplete.value = it } - setting("Notification On Farm Fail", notificationOnFarmFail.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> notificationOnFarmFail.value = it } - setting("Notification On Build Finished", notificationOnBuildFinished.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> notificationOnBuildFinished.value = it } - setting("Notification On Explore Finished", notificationOnExploreFinished.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> notificationOnExploreFinished.value = it } - setting("Notification On Mine Fail", notificationOnMineFail.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> notificationOnMineFail.value = it } - setting("Verbose Command Exceptions", verboseCommandExceptions.value).group(Group.General, SubGroup.ChatAndControl).onValueChange { _, it -> verboseCommandExceptions.value = it } - - setting("Do Bed Waypoints", doBedWaypoints.value).group(Group.General, SubGroup.Waypoints).onValueChange { _, it -> doBedWaypoints.value = it } - setting("Do Death Waypoints", doDeathWaypoints.value).group(Group.General, SubGroup.Waypoints).onValueChange { _, it -> doDeathWaypoints.value = it } - - setting("Anti Cheat Compatibility", antiCheatCompatibility.value).group(Group.General, SubGroup.Misc).onValueChange { _, it -> antiCheatCompatibility.value = it } - - // PATHING - setting("Pathing Max Chunk Border Fetch", pathingMaxChunkBorderFetch.value, 0..64).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> pathingMaxChunkBorderFetch.value = it } - setting("Pathing Map Default Size", pathingMapDefaultSize.value, 0..2048).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> pathingMapDefaultSize.value = it } - setting("Pathing Map Load Factor", pathingMapLoadFactor.value, 0f..1f, 0.05f).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> pathingMapLoadFactor.value = it } - setting("Distance Trim", distanceTrim.value).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> distanceTrim.value = it } - setting("Simplify Unloaded Y Coord", simplifyUnloadedYCoord.value).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> simplifyUnloadedYCoord.value = it } - setting("Repack On Any Block Change", repackOnAnyBlockChange.value).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> repackOnAnyBlockChange.value = it } - setting("Avoidance", avoidance.value).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> avoidance.value = it } - setting("Prune Regions From RAM", pruneRegionsFromRAM.value).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> pruneRegionsFromRAM.value = it } - setting("Backfill", backfill.value).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> backfill.value = it } - setting("Max Fall Height No Water", maxFallHeightNoWater.value, 0..256).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> maxFallHeightNoWater.value = it } - setting("Max Fall Height Bucket", maxFallHeightBucket.value, 0..256).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> maxFallHeightBucket.value = it } - setting("Axis Height", axisHeight.value, 0..256).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> axisHeight.value = it } - setting("Disconnect On Arrival", disconnectOnArrival.value).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> disconnectOnArrival.value = it } - setting("Splice Path", splicePath.value).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> splicePath.value = it } - setting("Max Path History Length", maxPathHistoryLength.value, 0..10000).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> maxPathHistoryLength.value = it } - setting("Path History Cutoff Amount", pathHistoryCutoffAmount.value, 0..10000).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> pathHistoryCutoffAmount.value = it } - setting("Mine Goal Update Interval", mineGoalUpdateInterval.value, 0..10000).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> mineGoalUpdateInterval.value = it } - setting("Max Cached World Scan Count", maxCachedWorldScanCount.value, 0..100000).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> maxCachedWorldScanCount.value = it } - setting("Mine Max Ore Locations Count", mineMaxOreLocationsCount.value, 0..100000).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> mineMaxOreLocationsCount.value = it } - setting("Cached Chunks Expiry Seconds", cachedChunksExpirySeconds.value, -1L..86400L).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> cachedChunksExpirySeconds.value = it } - setting("Y Level Box Size", yLevelBoxSize.value, 0.0..256.0).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> yLevelBoxSize.value = it } - setting("Extend Cache On Threshold", extendCacheOnThreshold.value).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> extendCacheOnThreshold.value = it } - setting("Cancel On Goal Invalidation", cancelOnGoalInvalidation.value).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> cancelOnGoalInvalidation.value = it } - setting("Chunk Caching", chunkCaching.value).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> chunkCaching.value = it } - setting("Chunk Packer Queue Max Size", chunkPackerQueueMaxSize.value, 0..10000).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> chunkPackerQueueMaxSize.value = it } - setting("Path Through Cached Only", pathThroughCachedOnly.value).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> pathThroughCachedOnly.value = it } - setting("Blacklist Closest On Failure", blacklistClosestOnFailure.value).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> blacklistClosestOnFailure.value = it } - setting("Path Cutoff Minimum Length", pathCutoffMinimumLength.value, 0..1000).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> pathCutoffMinimumLength.value = it } - setting("Cutoff At Load Boundary", cutoffAtLoadBoundary.value).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> cutoffAtLoadBoundary.value = it } - setting("Minimum Improvement Repropagation", minimumImprovementRepropagation.value).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> minimumImprovementRepropagation.value = it } - setting("Cost Verification Lookahead", costVerificationLookahead.value, 0..1000).group(Group.Pathing, SubGroup.PathingCore).onValueChange { _, it -> costVerificationLookahead.value = it } - - setting("Primary Timeout", primaryTimeoutMS.value, 0L..600000L, unit = " ms").group(Group.Pathing, SubGroup.PathingPerformance).onValueChange { _, it -> primaryTimeoutMS.value = it } - setting("Failure Timeout", failureTimeoutMS.value, 0L..600000L, unit = " ms").group(Group.Pathing, SubGroup.PathingPerformance).onValueChange { _, it -> failureTimeoutMS.value = it } - setting("Plan Ahead Primary Timeout", planAheadPrimaryTimeoutMS.value, 0L..600000L, unit = " ms").group(Group.Pathing, SubGroup.PathingPerformance).onValueChange { _, it -> planAheadPrimaryTimeoutMS.value = it } - setting("Plan Ahead Failure Timeout", planAheadFailureTimeoutMS.value, 0L..600000L, unit = " ms").group(Group.Pathing, SubGroup.PathingPerformance).onValueChange { _, it -> planAheadFailureTimeoutMS.value = it } - setting("Slow Path", slowPath.value).group(Group.Pathing, SubGroup.PathingPerformance).onValueChange { _, it -> slowPath.value = it } - setting("Slow Path Time Delay", slowPathTimeDelayMS.value, 0L..600000L, unit = " ms").group(Group.Pathing, SubGroup.PathingPerformance).onValueChange { _, it -> slowPathTimeDelayMS.value = it } - setting("Slow Path Timeout", slowPathTimeoutMS.value, 0L..600000L, unit = " ms").group(Group.Pathing, SubGroup.PathingPerformance).onValueChange { _, it -> slowPathTimeoutMS.value = it } - setting("Planning Tick Lookahead", planningTickLookahead.value, 0..200).group(Group.Pathing, SubGroup.PathingPerformance).onValueChange { _, it -> planningTickLookahead.value = it } - setting("Movement Timeout Ticks", movementTimeoutTicks.value, 0..2000).group(Group.Pathing, SubGroup.PathingPerformance).onValueChange { _, it -> movementTimeoutTicks.value = it } - - setting("Follow Offset Distance", followOffsetDistance.value, 0.0..256.0).group(Group.Pathing, SubGroup.Follow).onValueChange { _, it -> followOffsetDistance.value = it } - setting("Follow Offset Direction", followOffsetDirection.value, -180f..180f, 1f).group(Group.Pathing, SubGroup.Follow).onValueChange { _, it -> followOffsetDirection.value = it } - setting("Follow Radius", followRadius.value, 0..1000).group(Group.Pathing, SubGroup.Follow).onValueChange { _, it -> followRadius.value = it } - setting("Follow Target Max Distance", followTargetMaxDistance.value, 0..10000).group(Group.Pathing, SubGroup.Follow).onValueChange { _, it -> followTargetMaxDistance.value = it } - setting("Disable Completion Check", disableCompletionCheck.value).group(Group.Pathing, SubGroup.Follow).onValueChange { _, it -> disableCompletionCheck.value = it } - - // BEHAVIOR - setting("Strict Liquid Check", strictLiquidCheck.value).group(Group.Behavior, SubGroup.Assumptions).onValueChange { _, it -> strictLiquidCheck.value = it } - setting("Assume Walk On Water", assumeWalkOnWater.value).group(Group.Behavior, SubGroup.Assumptions).onValueChange { _, it -> assumeWalkOnWater.value = it } - setting("Assume Walk On Lava", assumeWalkOnLava.value).group(Group.Behavior, SubGroup.Assumptions).onValueChange { _, it -> assumeWalkOnLava.value = it } - setting("Assume Step", assumeStep.value).group(Group.Behavior, SubGroup.Assumptions).onValueChange { _, it -> assumeStep.value = it } - setting("Assume Safe Walk", assumeSafeWalk.value).group(Group.Behavior, SubGroup.Assumptions).onValueChange { _, it -> assumeSafeWalk.value = it } - setting("Assume External Auto Tool", assumeExternalAutoTool.value).group(Group.Behavior, SubGroup.Assumptions).onValueChange { _, it -> assumeExternalAutoTool.value = it } - - setting("Allow Parkour Ascend", allowParkourAscend.value).group(Group.Behavior, SubGroup.Movement).onValueChange { _, it -> allowParkourAscend.value = it } - setting("Allow Diagonal Descend", allowDiagonalDescend.value).group(Group.Behavior, SubGroup.Movement).onValueChange { _, it -> allowDiagonalDescend.value = it } - setting("Allow Diagonal Ascend", allowDiagonalAscend.value).group(Group.Behavior, SubGroup.Movement).onValueChange { _, it -> allowDiagonalAscend.value = it } - setting("Allow Downward", allowDownward.value).group(Group.Behavior, SubGroup.Movement).onValueChange { _, it -> allowDownward.value = it } - setting("Allow Vines", allowVines.value).group(Group.Behavior, SubGroup.Movement).onValueChange { _, it -> allowVines.value = it } - setting("Allow Walk On Bottom Slab", allowWalkOnBottomSlab.value).group(Group.Behavior, SubGroup.Movement).onValueChange { _, it -> allowWalkOnBottomSlab.value = it } - setting("Allow Parkour", allowParkour.value).group(Group.Behavior, SubGroup.Movement).onValueChange { _, it -> allowParkour.value = it } - setting("Allow Parkour Place", allowParkourPlace.value).group(Group.Behavior, SubGroup.Movement).onValueChange { _, it -> allowParkourPlace.value = it } - setting("Sprint Ascends", sprintAscends.value).group(Group.Behavior, SubGroup.Movement).onValueChange { _, it -> sprintAscends.value = it } - setting("Overshoot Traverse", overshootTraverse.value).group(Group.Behavior, SubGroup.Movement).onValueChange { _, it -> overshootTraverse.value = it } - setting("Pause Mining For Falling Blocks", pauseMiningForFallingBlocks.value).group(Group.Behavior, SubGroup.Movement).onValueChange { _, it -> pauseMiningForFallingBlocks.value = it } - setting("Allow Overshoot Diagonal Descend", allowOvershootDiagonalDescend.value).group(Group.Behavior, SubGroup.Movement).onValueChange { _, it -> allowOvershootDiagonalDescend.value = it } - setting("Sprint In Water", sprintInWater.value).group(Group.Behavior, SubGroup.Movement).onValueChange { _, it -> sprintInWater.value = it } - - setting("Allow Break", allowBreak.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> allowBreak.value = it } - setting("Allow Break Anyway", allowBreakAnyway.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> allowBreakAnyway.value = it.toList() } - setting("Allow Sprint", allowSprint.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> allowSprint.value = it } - setting("Allow Place", allowPlace.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> allowPlace.value = it } - setting("Allow Place In Fluids Source", allowPlaceInFluidsSource.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> allowPlaceInFluidsSource.value = it } - setting("Allow Place In Fluids Flow", allowPlaceInFluidsFlow.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> allowPlaceInFluidsFlow.value = it } - setting("Allow Inventory", allowInventory.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> allowInventory.value = it } - setting("Ticks Between Inventory Moves", ticksBetweenInventoryMoves.value, 0..20).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> ticksBetweenInventoryMoves.value = it } - setting("Inventory Move Only If Stationary", inventoryMoveOnlyIfStationary.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> inventoryMoveOnlyIfStationary.value = it } - setting("Auto Tool", autoTool.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> autoTool.value = it } - setting("Allow Water Bucket Fall", allowWaterBucketFall.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> allowWaterBucketFall.value = it } - setting("Allow Jump At Build Limit", allowJumpAtBuildLimit.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> allowJumpAtBuildLimit.value = it } - setting("Right Click Container On Arrival", rightClickContainerOnArrival.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> rightClickContainerOnArrival.value = it } - setting("Enter Portal", enterPortal.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> enterPortal.value = it } - setting("Walk While Breaking", walkWhileBreaking.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> walkWhileBreaking.value = it } - setting("Use Sword To Mine", useSwordToMine.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> useSwordToMine.value = it } - setting("Right Click Speed", rightClickSpeed.value, 0..10).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> rightClickSpeed.value = it } - setting("Block Reach Distance", blockReachDistance.value, 0f..10f, 0.1f).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> blockReachDistance.value = it } - setting("Block Break Speed", blockBreakSpeed.value, 0..10).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> blockBreakSpeed.value = it } - setting("Random Looking 1.13", randomLooking113.value, 0.0..5.0, 0.01).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> randomLooking113.value = it } - setting("Random Looking", randomLooking.value, 0.0..1.0, 0.01).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> randomLooking.value = it } - setting("Free Look", freeLook.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> freeLook.value = it } - setting("Block Free Look", blockFreeLook.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> blockFreeLook.value = it } - setting("Elytra Free Look", elytraFreeLook.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> elytraFreeLook.value = it } - setting("Smooth Look", smoothLook.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> smoothLook.value = it } - setting("Elytra Smooth Look", elytraSmoothLook.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> elytraSmoothLook.value = it } - setting("Smooth Look Ticks", smoothLookTicks.value, 0..200).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> smoothLookTicks.value = it } - setting("Remain With Existing Look Direction", remainWithExistingLookDirection.value).group(Group.Behavior, SubGroup.Interaction).onValueChange { _, it -> remainWithExistingLookDirection.value = it } - - setting("Block Placement Penalty", blockPlacementPenalty.value, 0.0..100.0, 0.1).group(Group.Behavior, SubGroup.Penalties).onValueChange { _, it -> blockPlacementPenalty.value = it } - setting("Block Break Additional Penalty", blockBreakAdditionalPenalty.value, 0.0..100.0, 0.1).group(Group.Behavior, SubGroup.Penalties).onValueChange { _, it -> blockBreakAdditionalPenalty.value = it } - setting("Jump Penalty", jumpPenalty.value, 0.0..100.0, 0.1).group(Group.Behavior, SubGroup.Penalties).onValueChange { _, it -> jumpPenalty.value = it } - setting("Walk On Water One Penalty", walkOnWaterOnePenalty.value, 0.0..100.0, 0.1).group(Group.Behavior, SubGroup.Penalties).onValueChange { _, it -> walkOnWaterOnePenalty.value = it } - setting("Avoid Breaking Multiplier", avoidBreakingMultiplier.value, 0.0..100.0, 0.1).group(Group.Behavior, SubGroup.Penalties).onValueChange { _, it -> avoidBreakingMultiplier.value = it } - setting("Max Cost Increase", maxCostIncrease.value, 0.0..100.0).group(Group.Behavior, SubGroup.Penalties).onValueChange { _, it -> maxCostIncrease.value = it } - setting("Backtrack Cost Favoring Coefficient", backtrackCostFavoringCoefficient.value, 0.0..100.0, 0.1).group(Group.Behavior, SubGroup.Penalties).onValueChange { _, it -> backtrackCostFavoringCoefficient.value = it } - setting("Mob Spawner Avoidance Coefficient", mobSpawnerAvoidanceCoefficient.value, 0.0..100.0, 0.1).group(Group.Behavior, SubGroup.Penalties).onValueChange { _, it -> mobSpawnerAvoidanceCoefficient.value = it } - setting("Mob Spawner Avoidance Radius", mobSpawnerAvoidanceRadius.value, 0..1000).group(Group.Behavior, SubGroup.Penalties).onValueChange { _, it -> mobSpawnerAvoidanceRadius.value = it } - setting("Mob Avoidance Coefficient", mobAvoidanceCoefficient.value, 0.0..100.0, 0.1).group(Group.Behavior, SubGroup.Penalties).onValueChange { _, it -> mobAvoidanceCoefficient.value = it } - setting("Mob Avoidance Radius", mobAvoidanceRadius.value, 0..1000).group(Group.Behavior, SubGroup.Penalties).onValueChange { _, it -> mobAvoidanceRadius.value = it } - setting("Path Cutoff Factor", pathCutoffFactor.value, 0.0..100.0, 0.1).group(Group.Behavior, SubGroup.Penalties).onValueChange { _, it -> pathCutoffFactor.value = it } - setting("Break Correct Block Penalty Multiplier", breakCorrectBlockPenaltyMultiplier.value, 0.0..100.0, 0.1).group(Group.Behavior, SubGroup.Penalties).onValueChange { _, it -> breakCorrectBlockPenaltyMultiplier.value = it } - setting("Place Incorrect Block Penalty Multiplier", placeIncorrectBlockPenaltyMultiplier.value, 0.0..100.0, 0.1).group(Group.Behavior, SubGroup.Penalties).onValueChange { _, it -> placeIncorrectBlockPenaltyMultiplier.value = it } - setting("Cost Heuristic", costHeuristic.value, 0.0..10.0, 0.001).group(Group.Behavior, SubGroup.Penalties).onValueChange { _, it -> costHeuristic.value = it } - - setting("Item Saver", itemSaver.value).group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> itemSaver.value = it } - setting("Item Saver Threshold", itemSaverThreshold.value, 0..100).group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> itemSaverThreshold.value = it } - setting("Prefer Silk Touch", preferSilkTouch.value).group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> preferSilkTouch.value = it } - setting("Mine Scan Dropped Items", mineScanDroppedItems.value).group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> mineScanDroppedItems.value = it } - setting("Mine Drop Loiter Duration", mineDropLoiterDurationMSThanksLouca.value, 0L..600000L, unit = " ms").group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> mineDropLoiterDurationMSThanksLouca.value = it } - setting("Legit Mine", legitMine.value).group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> legitMine.value = it } - setting("Legit Mine Y Level", legitMineYLevel.value, 0..256).group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> legitMineYLevel.value = it } - setting("Legit Mine Include Diagonals", legitMineIncludeDiagonals.value).group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> legitMineIncludeDiagonals.value = it } - setting("Force Internal Mining", forceInternalMining.value).group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> forceInternalMining.value = it } - setting("Internal Mining Air Exception", internalMiningAirException.value).group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> internalMiningAirException.value = it } - setting("Min Y Level While Mining", minYLevelWhileMining.value, 0..2048).group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> minYLevelWhileMining.value = it } - setting("Max Y Level While Mining", maxYLevelWhileMining.value, 0..2048).group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> maxYLevelWhileMining.value = it } - setting("Allow Only Exposed Ores", allowOnlyExposedOres.value).group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> allowOnlyExposedOres.value = it } - setting("Allow Only Exposed Ores Distance", allowOnlyExposedOresDistance.value, 0..16).group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> allowOnlyExposedOresDistance.value = it } - setting("Replant Crops", replantCrops.value).group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> replantCrops.value = it } - setting("Replant Nether Wart", replantNetherWart.value).group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> replantNetherWart.value = it } - setting("Farm Max Scan Size", farmMaxScanSize.value, 0..1024).group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> farmMaxScanSize.value = it } - setting("Consider Potion Effects", considerPotionEffects.value).group(Group.Behavior, SubGroup.MiningAndFarming).onValueChange { _, it -> considerPotionEffects.value = it } - - setting("Explore For Blocks", exploreForBlocks.value).group(Group.Behavior, SubGroup.Exploration).onValueChange { _, it -> exploreForBlocks.value = it } - setting("World Exploring Chunk Offset", worldExploringChunkOffset.value, 0..32).group(Group.Behavior, SubGroup.Exploration).onValueChange { _, it -> worldExploringChunkOffset.value = it } - setting("Explore Chunk Set Minimum Size", exploreChunkSetMinimumSize.value, 0..10000).group(Group.Behavior, SubGroup.Exploration).onValueChange { _, it -> exploreChunkSetMinimumSize.value = it } - setting("Explore Maintain Y", exploreMaintainY.value, 0..256).group(Group.Behavior, SubGroup.Exploration).onValueChange { _, it -> exploreMaintainY.value = it } - - // BUILDING - setting("Build In Layers", buildInLayers.value).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> buildInLayers.value = it } - setting("Layer Order", layerOrder.value).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> layerOrder.value = it } - setting("Layer Height", layerHeight.value, 0..256).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> layerHeight.value = it } - setting("Start At Layer", startAtLayer.value, 0..256).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> startAtLayer.value = it } - setting("Skip Failed Layers", skipFailedLayers.value).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> skipFailedLayers.value = it } - setting("Build Only Selection", buildOnlySelection.value).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> buildOnlySelection.value = it } - setting("Build Repeat", buildRepeat.value.blockPos).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> buildRepeat.value = it } - setting("Build Repeat Count", buildRepeatCount.value, 0..1000).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> buildRepeatCount.value = it } - setting("Build Repeat Sneaky", buildRepeatSneaky.value).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> buildRepeatSneaky.value = it } - setting("Break From Above", breakFromAbove.value).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> breakFromAbove.value = it } - setting("Goal Break From Above", goalBreakFromAbove.value).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> goalBreakFromAbove.value = it } - setting("Map Art Mode", mapArtMode.value).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> mapArtMode.value = it } - setting("Ok If Water", okIfWater.value).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> okIfWater.value = it } - setting("Incorrect Size", incorrectSize.value, 0..1000).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> incorrectSize.value = it } - setting("Schematic Orientation X", schematicOrientationX.value).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> schematicOrientationX.value = it } - setting("Schematic Orientation Y", schematicOrientationY.value).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> schematicOrientationY.value = it } - setting("Schematic Orientation Z", schematicOrientationZ.value).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> schematicOrientationZ.value = it } - setting("Build Schematic Rotation", buildSchematicRotation.value).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> buildSchematicRotation.value = it } - setting("Build Schematic Mirror", buildSchematicMirror.value).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> buildSchematicMirror.value = it } - setting("Schematic Fallback Extension", schematicFallbackExtension.value).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> schematicFallbackExtension.value = it } - setting("Builder Tick Scan Radius", builderTickScanRadius.value, 0..64).group(Group.Building, SubGroup.Schematic).onValueChange { _, it -> builderTickScanRadius.value = it } - - setting("Acceptable Throwaway Items", acceptableThrowawayItems.value).group(Group.Building, SubGroup.BlockRules).onValueChange { _, it -> acceptableThrowawayItems.value = it.toList() } - setting("Blocks To Avoid", blocksToAvoid.value).group(Group.Building, SubGroup.BlockRules).onValueChange { _, it -> blocksToAvoid.value = it.toList() } - setting("Blocks To Disallow Breaking", blocksToDisallowBreaking.value).group(Group.Building, SubGroup.BlockRules).onValueChange { _, it -> blocksToDisallowBreaking.value = it.toList() } - setting("Blocks To Avoid Breaking", blocksToAvoidBreaking.value).group(Group.Building, SubGroup.BlockRules).onValueChange { _, it -> blocksToAvoidBreaking.value = it.toList() } - setting("Build Ignore Blocks", buildIgnoreBlocks.value).group(Group.Building, SubGroup.BlockRules).onValueChange { _, it -> buildIgnoreBlocks.value = it.toList() } - setting("Build Skip Blocks", buildSkipBlocks.value).group(Group.Building, SubGroup.BlockRules).onValueChange { _, it -> buildSkipBlocks.value = it.toList() } - // FixMe: lmao fuck this im so done - //setting("Build Valid Substitutes", buildValidSubstitutes.value.flatMap { it.value }).group(Group.Building, SubGroup.BlockRules).onValueChange { _, it -> buildValidSubstitutes.value = it.mapValues { (_, v) -> v.toList() } } - //setting("Build Substitutes", buildSubstitutes.value.flatMap { it.value }).group(Group.Building, SubGroup.BlockRules).onValueChange { _, it -> buildSubstitutes.value = it.mapValues { (_, v) -> v.toList() } } - setting("Ok If Air", okIfAir.value).group(Group.Building, SubGroup.BlockRules).onValueChange { _, it -> okIfAir.value = it.toList() } - setting("Build Ignore Existing", buildIgnoreExisting.value).group(Group.Building, SubGroup.BlockRules).onValueChange { _, it -> buildIgnoreExisting.value = it } - setting("Build Ignore Direction", buildIgnoreDirection.value).group(Group.Building, SubGroup.BlockRules).onValueChange { _, it -> buildIgnoreDirection.value = it } - setting("Build Ignore Properties", buildIgnoreProperties.value).group(Group.Building, SubGroup.BlockRules).onValueChange { _, it -> buildIgnoreProperties.value = it.toList() } - setting("Avoid Updating Falling Blocks", avoidUpdatingFallingBlocks.value).group(Group.Building, SubGroup.BlockRules).onValueChange { _, it -> avoidUpdatingFallingBlocks.value = it } - - // RENDERING - setting("Render Path", renderPath.value).group(Group.Rendering, SubGroup.Rendering).onValueChange { _, it -> renderPath.value = it } - setting("Render Path As Line", renderPathAsLine.value).group(Group.Rendering, SubGroup.Rendering).onValueChange { _, it -> renderPathAsLine.value = it } - setting("Render Goal", renderGoal.value).group(Group.Rendering, SubGroup.Rendering).onValueChange { _, it -> renderGoal.value = it } - setting("Render Goal Animated", renderGoalAnimated.value).group(Group.Rendering, SubGroup.Rendering).onValueChange { _, it -> renderGoalAnimated.value = it } - setting("Render Goal Ignore Depth", renderGoalIgnoreDepth.value).group(Group.Rendering, SubGroup.Rendering).onValueChange { _, it -> renderGoalIgnoreDepth.value = it } - setting("Render Goal XZ Beacon", renderGoalXZBeacon.value).group(Group.Rendering, SubGroup.Rendering).onValueChange { _, it -> renderGoalXZBeacon.value = it } - setting("Path Render Line Width Pixels", pathRenderLineWidthPixels.value, 0f..10f, 0.1f).group(Group.Rendering, SubGroup.Rendering).onValueChange { _, it -> pathRenderLineWidthPixels.value = it } - setting("Goal Render Line Width Pixels", goalRenderLineWidthPixels.value, 0f..10f, 0.1f).group(Group.Rendering, SubGroup.Rendering).onValueChange { _, it -> goalRenderLineWidthPixels.value = it } - setting("Fade Path", fadePath.value).group(Group.Rendering, SubGroup.Rendering).onValueChange { _, it -> fadePath.value = it } - setting("Render Cached Chunks", renderCachedChunks.value).group(Group.Rendering, SubGroup.Rendering).onValueChange { _, it -> renderCachedChunks.value = it } - setting("Cached Chunks Opacity", cachedChunksOpacity.value, 0f..1f, 0.05f).group(Group.Rendering, SubGroup.Rendering).onValueChange { _, it -> cachedChunksOpacity.value = it } - setting("Render Path Ignore Depth", renderPathIgnoreDepth.value).group(Group.Rendering, SubGroup.Rendering).onValueChange { _, it -> renderPathIgnoreDepth.value = it } - setting("Render Selection Boxes", renderSelectionBoxes.value).group(Group.Rendering, SubGroup.Rendering).onValueChange { _, it -> renderSelectionBoxes.value = it } - - setting("Color Current Path", colorCurrentPath.value).group(Group.Rendering, SubGroup.RenderingColors).onValueChange { _, it -> colorCurrentPath.value = it } - setting("Color Next Path", colorNextPath.value).group(Group.Rendering, SubGroup.RenderingColors).onValueChange { _, it -> colorNextPath.value = it } - setting("Color Blocks To Break", colorBlocksToBreak.value).group(Group.Rendering, SubGroup.RenderingColors).onValueChange { _, it -> colorBlocksToBreak.value = it } - setting("Color Blocks To Place", colorBlocksToPlace.value).group(Group.Rendering, SubGroup.RenderingColors).onValueChange { _, it -> colorBlocksToPlace.value = it } - setting("Color Blocks To Walk Into", colorBlocksToWalkInto.value).group(Group.Rendering, SubGroup.RenderingColors).onValueChange { _, it -> colorBlocksToWalkInto.value = it } - setting("Color Best Path So Far", colorBestPathSoFar.value).group(Group.Rendering, SubGroup.RenderingColors).onValueChange { _, it -> colorBestPathSoFar.value = it } - setting("Color Most Recent Considered", colorMostRecentConsidered.value).group(Group.Rendering, SubGroup.RenderingColors).onValueChange { _, it -> colorMostRecentConsidered.value = it } - setting("Color Goal Box", colorGoalBox.value).group(Group.Rendering, SubGroup.RenderingColors).onValueChange { _, it -> colorGoalBox.value = it } - setting("Color Inverted Goal Box", colorInvertedGoalBox.value).group(Group.Rendering, SubGroup.RenderingColors).onValueChange { _, it -> colorInvertedGoalBox.value = it } - - setting("Render Selection", renderSelection.value).group(Group.Rendering, SubGroup.RenderingSelection).onValueChange { _, it -> renderSelection.value = it } - setting("Color Selection", colorSelection.value).group(Group.Rendering, SubGroup.RenderingSelection).onValueChange { _, it -> colorSelection.value = it } - setting("Color Selection Pos1", colorSelectionPos1.value).group(Group.Rendering, SubGroup.RenderingSelection).onValueChange { _, it -> colorSelectionPos1.value = it } - setting("Color Selection Pos2", colorSelectionPos2.value).group(Group.Rendering, SubGroup.RenderingSelection).onValueChange { _, it -> colorSelectionPos2.value = it } - setting("Selection Opacity", selectionOpacity.value, 0f..1f, 0.05f).group(Group.Rendering, SubGroup.RenderingSelection).onValueChange { _, it -> selectionOpacity.value = it } - setting("Selection Line Width", selectionLineWidth.value, 0f..10f, 0.1f).group(Group.Rendering, SubGroup.RenderingSelection).onValueChange { _, it -> selectionLineWidth.value = it } - setting("Render Selection Ignore Depth", renderSelectionIgnoreDepth.value).group(Group.Rendering, SubGroup.RenderingSelection).onValueChange { _, it -> renderSelectionIgnoreDepth.value = it } - setting("Render Selection Corners", renderSelectionCorners.value).group(Group.Rendering, SubGroup.RenderingSelection).onValueChange { _, it -> renderSelectionCorners.value = it } - setting("Render Selection Boxes Ignore Depth", renderSelectionBoxesIgnoreDepth.value).group(Group.Rendering, SubGroup.RenderingSelection).onValueChange { _, it -> renderSelectionBoxesIgnoreDepth.value = it } - - // ELYTRA - setting("Simulation Ticks", elytraSimulationTicks.value, 0..200).group(Group.Elytra).onValueChange { _, it -> elytraSimulationTicks.value = it } - setting("Pitch Range", elytraPitchRange.value, 0..90).group(Group.Elytra).onValueChange { _, it -> elytraPitchRange.value = it } - setting("Firework Speed", elytraFireworkSpeed.value, 0.0..3.0, 0.1).group(Group.Elytra).onValueChange { _, it -> elytraFireworkSpeed.value = it } - setting("Firework Setback Use Delay", elytraFireworkSetbackUseDelay.value, 0..600).group(Group.Elytra).onValueChange { _, it -> elytraFireworkSetbackUseDelay.value = it } - setting("Minimum Avoidance", elytraMinimumAvoidance.value, 0.0..10.0, 0.1).group(Group.Elytra).onValueChange { _, it -> elytraMinimumAvoidance.value = it } - setting("Conserve Fireworks", elytraConserveFireworks.value).group(Group.Elytra).onValueChange { _, it -> elytraConserveFireworks.value = it } - setting("Render Raytraces", elytraRenderRaytraces.value).group(Group.Elytra).onValueChange { _, it -> elytraRenderRaytraces.value = it } - setting("Render Hitbox Raytraces", elytraRenderHitboxRaytraces.value).group(Group.Elytra).onValueChange { _, it -> elytraRenderHitboxRaytraces.value = it } - setting("Render Simulation", elytraRenderSimulation.value).group(Group.Elytra).onValueChange { _, it -> elytraRenderSimulation.value = it } - setting("Auto Jump", elytraAutoJump.value).group(Group.Elytra).onValueChange { _, it -> elytraAutoJump.value = it } - setting("Nether Seed", elytraNetherSeed.value, Long.MIN_VALUE..Long.MAX_VALUE).group(Group.Elytra).onValueChange { _, it -> elytraNetherSeed.value = it } - setting("Predict Terrain", elytraPredictTerrain.value).group(Group.Elytra).onValueChange { _, it -> elytraPredictTerrain.value = it } - setting("Auto Swap", elytraAutoSwap.value).group(Group.Elytra).onValueChange { _, it -> elytraAutoSwap.value = it } - setting("Minimum Durability", elytraMinimumDurability.value, 0..432).group(Group.Elytra).onValueChange { _, it -> elytraMinimumDurability.value = it } - setting("Min Fireworks Before Landing", elytraMinFireworksBeforeLanding.value, 0..64).group(Group.Elytra).onValueChange { _, it -> elytraMinFireworksBeforeLanding.value = it } - setting("Allow Emergency Land", elytraAllowEmergencyLand.value).group(Group.Elytra).onValueChange { _, it -> elytraAllowEmergencyLand.value = it } - setting("Time Between Cache Cull Secs", elytraTimeBetweenCacheCullSecs.value, 0L..86400L).group(Group.Elytra).onValueChange { _, it -> elytraTimeBetweenCacheCullSecs.value = it } - setting("Cache Cull Distance", elytraCacheCullDistance.value, 0..100000).group(Group.Elytra).onValueChange { _, it -> elytraCacheCullDistance.value = it } - setting("Allow Land On Nether Fortress", elytraAllowLandOnNetherFortress.value).group(Group.Elytra).onValueChange { _, it -> elytraAllowLandOnNetherFortress.value = it } - setting("Terms Accepted", elytraTermsAccepted.value).group(Group.Elytra).onValueChange { _, it -> elytraTermsAccepted.value = it } - setting("Chat Spam", elytraChatSpam.value).group(Group.Elytra).onValueChange { _, it -> elytraChatSpam.value = it } - } - } - } - /** * Whether Baritone is currently pathing */ @@ -387,4 +95,273 @@ object BaritoneHandler : Config(LambdaCategory), Automated by AutomationConfig.C primary?.pathingBehavior?.cancelEverything() primary?.elytraProcess?.resetState() } + + class BaritoneConfigSettings( + override val c: Config, + private val bSettings: Settings + ) : SettingBlock { + companion object { + private const val GeneralTab = "General" + private const val PathingTab = "Pathing" + private const val BehaviorTab = "Behavior" + private const val BuildingTab = "Building" + private const val RenderingTab = "Rendering" + private const val ElytraTab = "Elytra" + + private const val ChatAndControlGroup = "Chat & Control" + private const val WaypointsGroup = "Waypoints" + private const val AssumptionsGroup = "Assumptions" + private const val MovementGroup = "Movement" + private const val BlockRulesGroup = "Block Rules" + private const val MiningAndFarmingGroup = "Mining & Farming" + private const val InteractionGroup = "Interaction" + private const val PenaltiesGroup = "Penalties" + private const val ExplorationGroup = "Exploration" + private const val MiscGroup = "Misc" + private const val RenderingGroup = "Rendering" + private const val RenderingColorsGroup = "Rendering Colors" + private const val RenderingSelectionGroup = "Rendering Selection" + private const val PathingPerformanceGroup = "Pathing Performance" + private const val PathingCoreGroup = "Pathing Core" + private const val FollowGroup = "Follow" + private const val SchematicGroup = "Schematic" + } + + @Tab(GeneralTab) @Group(ChatAndControlGroup) val logAsToast by c.setting("Log As Toast", bSettings.logAsToast.value).onValueChange { _, it -> bSettings.logAsToast.value = it } + @Tab(GeneralTab) @Group(ChatAndControlGroup) val chatDebug by c.setting("Chat Debug", bSettings.chatDebug.value).onValueChange { _, it -> bSettings.chatDebug.value = it } + @Tab(GeneralTab) @Group(ChatAndControlGroup) val chatControl by c.setting("Chat Control", bSettings.chatControl.value).onValueChange { _, it -> bSettings.chatControl.value = it } + @Tab(GeneralTab) @Group(ChatAndControlGroup) val chatControlAnyway by c.setting("Chat Control Anyway", bSettings.chatControlAnyway.value).onValueChange { _, it -> bSettings.chatControlAnyway.value = it } + @Tab(GeneralTab) @Group(ChatAndControlGroup) val prefixControl by c.setting("Prefix Control", bSettings.prefixControl.value).onValueChange { _, it -> bSettings.prefixControl.value = it } + @Tab(GeneralTab) @Group(ChatAndControlGroup) val prefix by c.setting("Prefix", bSettings.prefix.value).onValueChange { _, it -> bSettings.prefix.value = it } + @Tab(GeneralTab) @Group(ChatAndControlGroup) val shortBaritonePrefix by c.setting("Short Baritone Prefix", bSettings.shortBaritonePrefix.value).onValueChange { _, it -> bSettings.shortBaritonePrefix.value = it } + @Tab(GeneralTab) @Group(ChatAndControlGroup) val useMessageTag by c.setting("Use Message Tag", bSettings.useMessageTag.value).onValueChange { _, it -> bSettings.useMessageTag.value = it } + @Tab(GeneralTab) @Group(ChatAndControlGroup) val echoCommands by c.setting("Echo Commands", bSettings.echoCommands.value).onValueChange { _, it -> bSettings.echoCommands.value = it } + @Tab(GeneralTab) @Group(ChatAndControlGroup) val censorCoordinates by c.setting("Censor Coordinates", bSettings.censorCoordinates.value).onValueChange { _, it -> bSettings.censorCoordinates.value = it } + @Tab(GeneralTab) @Group(ChatAndControlGroup) val censorRanCommands by c.setting("Censor Ran Commands", bSettings.censorRanCommands.value).onValueChange { _, it -> bSettings.censorRanCommands.value = it } + @Tab(GeneralTab) @Group(ChatAndControlGroup) val desktopNotifications by c.setting("Desktop Notifications", bSettings.desktopNotifications.value).onValueChange { _, it -> bSettings.desktopNotifications.value = it } + @Tab(GeneralTab) @Group(ChatAndControlGroup) val notificationOnPathComplete by c.setting("Notification On Path Complete", bSettings.notificationOnPathComplete.value).onValueChange { _, it -> bSettings.notificationOnPathComplete.value = it } + @Tab(GeneralTab) @Group(ChatAndControlGroup) val notificationOnFarmFail by c.setting("Notification On Farm Fail", bSettings.notificationOnFarmFail.value).onValueChange { _, it -> bSettings.notificationOnFarmFail.value = it } + @Tab(GeneralTab) @Group(ChatAndControlGroup) val notificationOnBuildFinished by c.setting("Notification On Build Finished", bSettings.notificationOnBuildFinished.value).onValueChange { _, it -> bSettings.notificationOnBuildFinished.value = it } + @Tab(GeneralTab) @Group(ChatAndControlGroup) val notificationOnExploreFinished by c.setting("Notification On Explore Finished", bSettings.notificationOnExploreFinished.value).onValueChange { _, it -> bSettings.notificationOnExploreFinished.value = it } + @Tab(GeneralTab) @Group(ChatAndControlGroup) val notificationOnMineFail by c.setting("Notification On Mine Fail", bSettings.notificationOnMineFail.value).onValueChange { _, it -> bSettings.notificationOnMineFail.value = it } + @Tab(GeneralTab) @Group(ChatAndControlGroup) val verboseCommandExceptions by c.setting("Verbose Command Exceptions", bSettings.verboseCommandExceptions.value).onValueChange { _, it -> bSettings.verboseCommandExceptions.value = it } + @Tab(GeneralTab) @Group(WaypointsGroup) val doBedWaypoints by c.setting("Do Bed Waypoints", bSettings.doBedWaypoints.value).onValueChange { _, it -> bSettings.doBedWaypoints.value = it } + @Tab(GeneralTab) @Group(WaypointsGroup) val doDeathWaypoints by c.setting("Do Death Waypoints", bSettings.doDeathWaypoints.value).onValueChange { _, it -> bSettings.doDeathWaypoints.value = it } + @Tab(GeneralTab) @Group(MiscGroup) val antiCheatCompatibility by c.setting("Anti Cheat Compatibility", bSettings.antiCheatCompatibility.value).onValueChange { _, it -> bSettings.antiCheatCompatibility.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val pathingMaxChunkBorderFetch by c.setting("Pathing Max Chunk Border Fetch", bSettings.pathingMaxChunkBorderFetch.value, 0..64).onValueChange { _, it -> bSettings.pathingMaxChunkBorderFetch.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val pathingMapDefaultSize by c.setting("Pathing Map Default Size", bSettings.pathingMapDefaultSize.value, 0..2048).onValueChange { _, it -> bSettings.pathingMapDefaultSize.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val pathingMapLoadFactor by c.setting("Pathing Map Load Factor", bSettings.pathingMapLoadFactor.value, 0f..1f, 0.05f).onValueChange { _, it -> bSettings.pathingMapLoadFactor.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val distanceTrim by c.setting("Distance Trim", bSettings.distanceTrim.value).onValueChange { _, it -> bSettings.distanceTrim.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val simplifyUnloadedYCoord by c.setting("Simplify Unloaded Y Coord", bSettings.simplifyUnloadedYCoord.value).onValueChange { _, it -> bSettings.simplifyUnloadedYCoord.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val repackOnAnyBlockChange by c.setting("Repack On Any Block Change", bSettings.repackOnAnyBlockChange.value).onValueChange { _, it -> bSettings.repackOnAnyBlockChange.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val avoidance by c.setting("Avoidance", bSettings.avoidance.value).onValueChange { _, it -> bSettings.avoidance.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val pruneRegionsFromRAM by c.setting("Prune Regions From RAM", bSettings.pruneRegionsFromRAM.value).onValueChange { _, it -> bSettings.pruneRegionsFromRAM.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val backfill by c.setting("Backfill", bSettings.backfill.value).onValueChange { _, it -> bSettings.backfill.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val maxFallHeightNoWater by c.setting("Max Fall Height No Water", bSettings.maxFallHeightNoWater.value, 0..256).onValueChange { _, it -> bSettings.maxFallHeightNoWater.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val maxFallHeightBucket by c.setting("Max Fall Height Bucket", bSettings.maxFallHeightBucket.value, 0..256).onValueChange { _, it -> bSettings.maxFallHeightBucket.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val axisHeight by c.setting("Axis Height", bSettings.axisHeight.value, 0..256).onValueChange { _, it -> bSettings.axisHeight.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val disconnectOnArrival by c.setting("Disconnect On Arrival", bSettings.disconnectOnArrival.value).onValueChange { _, it -> bSettings.disconnectOnArrival.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val splicePath by c.setting("Splice Path", bSettings.splicePath.value).onValueChange { _, it -> bSettings.splicePath.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val maxPathHistoryLength by c.setting("Max Path History Length", bSettings.maxPathHistoryLength.value, 0..10000).onValueChange { _, it -> bSettings.maxPathHistoryLength.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val pathHistoryCutoffAmount by c.setting("Path History Cutoff Amount", bSettings.pathHistoryCutoffAmount.value, 0..10000).onValueChange { _, it -> bSettings.pathHistoryCutoffAmount.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val mineGoalUpdateInterval by c.setting("Mine Goal Update Interval", bSettings.mineGoalUpdateInterval.value, 0..10000).onValueChange { _, it -> bSettings.mineGoalUpdateInterval.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val maxCachedWorldScanCount by c.setting("Max Cached World Scan Count", bSettings.maxCachedWorldScanCount.value, 0..100000).onValueChange { _, it -> bSettings.maxCachedWorldScanCount.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val mineMaxOreLocationsCount by c.setting("Mine Max Ore Locations Count", bSettings.mineMaxOreLocationsCount.value, 0..100000).onValueChange { _, it -> bSettings.mineMaxOreLocationsCount.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val cachedChunksExpirySeconds by c.setting("Cached Chunks Expiry Seconds", bSettings.cachedChunksExpirySeconds.value, -1L..86400L).onValueChange { _, it -> bSettings.cachedChunksExpirySeconds.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val yLevelBoxSize by c.setting("Y Level Box Size", bSettings.yLevelBoxSize.value, 0.0..256.0).onValueChange { _, it -> bSettings.yLevelBoxSize.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val extendCacheOnThreshold by c.setting("Extend Cache On Threshold", bSettings.extendCacheOnThreshold.value).onValueChange { _, it -> bSettings.extendCacheOnThreshold.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val cancelOnGoalInvalidation by c.setting("Cancel On Goal Invalidation", bSettings.cancelOnGoalInvalidation.value).onValueChange { _, it -> bSettings.cancelOnGoalInvalidation.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val chunkCaching by c.setting("Chunk Caching", bSettings.chunkCaching.value).onValueChange { _, it -> bSettings.chunkCaching.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val chunkPackerQueueMaxSize by c.setting("Chunk Packer Queue Max Size", bSettings.chunkPackerQueueMaxSize.value, 0..10000).onValueChange { _, it -> bSettings.chunkPackerQueueMaxSize.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val pathThroughCachedOnly by c.setting("Path Through Cached Only", bSettings.pathThroughCachedOnly.value).onValueChange { _, it -> bSettings.pathThroughCachedOnly.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val blacklistClosestOnFailure by c.setting("Blacklist Closest On Failure", bSettings.blacklistClosestOnFailure.value).onValueChange { _, it -> bSettings.blacklistClosestOnFailure.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val pathCutoffMinimumLength by c.setting("Path Cutoff Minimum Length", bSettings.pathCutoffMinimumLength.value, 0..1000).onValueChange { _, it -> bSettings.pathCutoffMinimumLength.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val cutoffAtLoadBoundary by c.setting("Cutoff At Load Boundary", bSettings.cutoffAtLoadBoundary.value).onValueChange { _, it -> bSettings.cutoffAtLoadBoundary.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val minimumImprovementRepropagation by c.setting("Minimum Improvement Repropagation", bSettings.minimumImprovementRepropagation.value).onValueChange { _, it -> bSettings.minimumImprovementRepropagation.value = it } + @Tab(PathingTab) @Group(PathingCoreGroup) val costVerificationLookahead by c.setting("Cost Verification Lookahead", bSettings.costVerificationLookahead.value, 0..1000).onValueChange { _, it -> bSettings.costVerificationLookahead.value = it } + @Tab(PathingTab) @Group(PathingPerformanceGroup) val primaryTimeoutMS by c.setting("Primary Timeout", bSettings.primaryTimeoutMS.value, 0L..600000L, unit = " ms").onValueChange { _, it -> bSettings.primaryTimeoutMS.value = it } + @Tab(PathingTab) @Group(PathingPerformanceGroup) val failureTimeoutMS by c.setting("Failure Timeout", bSettings.failureTimeoutMS.value, 0L..600000L, unit = " ms").onValueChange { _, it -> bSettings.failureTimeoutMS.value = it } + @Tab(PathingTab) @Group(PathingPerformanceGroup) val planAheadPrimaryTimeoutMS by c.setting("Plan Ahead Primary Timeout", bSettings.planAheadPrimaryTimeoutMS.value, 0L..600000L, unit = " ms").onValueChange { _, it -> bSettings.planAheadPrimaryTimeoutMS.value = it } + @Tab(PathingTab) @Group(PathingPerformanceGroup) val planAheadFailureTimeoutMS by c.setting("Plan Ahead Failure Timeout", bSettings.planAheadFailureTimeoutMS.value, 0L..600000L, unit = " ms").onValueChange { _, it -> bSettings.planAheadFailureTimeoutMS.value = it } + @Tab(PathingTab) @Group(PathingPerformanceGroup) val slowPath by c.setting("Slow Path", bSettings.slowPath.value).onValueChange { _, it -> bSettings.slowPath.value = it } + @Tab(PathingTab) @Group(PathingPerformanceGroup) val slowPathTimeDelayMS by c.setting("Slow Path Time Delay", bSettings.slowPathTimeDelayMS.value, 0L..600000L, unit = " ms").onValueChange { _, it -> bSettings.slowPathTimeDelayMS.value = it } + @Tab(PathingTab) @Group(PathingPerformanceGroup) val slowPathTimeoutMS by c.setting("Slow Path Timeout", bSettings.slowPathTimeoutMS.value, 0L..600000L, unit = " ms").onValueChange { _, it -> bSettings.slowPathTimeoutMS.value = it } + @Tab(PathingTab) @Group(PathingPerformanceGroup) val planningTickLookahead by c.setting("Planning Tick Lookahead", bSettings.planningTickLookahead.value, 0..200).onValueChange { _, it -> bSettings.planningTickLookahead.value = it } + @Tab(PathingTab) @Group(PathingPerformanceGroup) val movementTimeoutTicks by c.setting("Movement Timeout Ticks", bSettings.movementTimeoutTicks.value, 0..2000).onValueChange { _, it -> bSettings.movementTimeoutTicks.value = it } + @Tab(PathingTab) @Group(FollowGroup) val followOffsetDistance by c.setting("Follow Offset Distance", bSettings.followOffsetDistance.value, 0.0..256.0).onValueChange { _, it -> bSettings.followOffsetDistance.value = it } + @Tab(PathingTab) @Group(FollowGroup) val followOffsetDirection by c.setting("Follow Offset Direction", bSettings.followOffsetDirection.value, -180f..180f, 1f).onValueChange { _, it -> bSettings.followOffsetDirection.value = it } + @Tab(PathingTab) @Group(FollowGroup) val followRadius by c.setting("Follow Radius", bSettings.followRadius.value, 0..1000).onValueChange { _, it -> bSettings.followRadius.value = it } + @Tab(PathingTab) @Group(FollowGroup) val followTargetMaxDistance by c.setting("Follow Target Max Distance", bSettings.followTargetMaxDistance.value, 0..10000).onValueChange { _, it -> bSettings.followTargetMaxDistance.value = it } + @Tab(PathingTab) @Group(FollowGroup) val disableCompletionCheck by c.setting("Disable Completion Check", bSettings.disableCompletionCheck.value).onValueChange { _, it -> bSettings.disableCompletionCheck.value = it } + @Tab(BehaviorTab) @Group(AssumptionsGroup) val strictLiquidCheck by c.setting("Strict Liquid Check", bSettings.strictLiquidCheck.value).onValueChange { _, it -> bSettings.strictLiquidCheck.value = it } + @Tab(BehaviorTab) @Group(AssumptionsGroup) val assumeWalkOnWater by c.setting("Assume Walk On Water", bSettings.assumeWalkOnWater.value).onValueChange { _, it -> bSettings.assumeWalkOnWater.value = it } + @Tab(BehaviorTab) @Group(AssumptionsGroup) val assumeWalkOnLava by c.setting("Assume Walk On Lava", bSettings.assumeWalkOnLava.value).onValueChange { _, it -> bSettings.assumeWalkOnLava.value = it } + @Tab(BehaviorTab) @Group(AssumptionsGroup) val assumeStep by c.setting("Assume Step", bSettings.assumeStep.value).onValueChange { _, it -> bSettings.assumeStep.value = it } + @Tab(BehaviorTab) @Group(AssumptionsGroup) val assumeSafeWalk by c.setting("Assume Safe Walk", bSettings.assumeSafeWalk.value).onValueChange { _, it -> bSettings.assumeSafeWalk.value = it } + @Tab(BehaviorTab) @Group(AssumptionsGroup) val assumeExternalAutoTool by c.setting("Assume External Auto Tool", bSettings.assumeExternalAutoTool.value).onValueChange { _, it -> bSettings.assumeExternalAutoTool.value = it } + @Tab(BehaviorTab) @Group(MovementGroup) val allowParkourAscend by c.setting("Allow Parkour Ascend", bSettings.allowParkourAscend.value).onValueChange { _, it -> bSettings.allowParkourAscend.value = it } + @Tab(BehaviorTab) @Group(MovementGroup) val allowDiagonalDescend by c.setting("Allow Diagonal Descend", bSettings.allowDiagonalDescend.value).onValueChange { _, it -> bSettings.allowDiagonalDescend.value = it } + @Tab(BehaviorTab) @Group(MovementGroup) val allowDiagonalAscend by c.setting("Allow Diagonal Ascend", bSettings.allowDiagonalAscend.value).onValueChange { _, it -> bSettings.allowDiagonalAscend.value = it } + @Tab(BehaviorTab) @Group(MovementGroup) val allowDownward by c.setting("Allow Downward", bSettings.allowDownward.value).onValueChange { _, it -> bSettings.allowDownward.value = it } + @Tab(BehaviorTab) @Group(MovementGroup) val allowVines by c.setting("Allow Vines", bSettings.allowVines.value).onValueChange { _, it -> bSettings.allowVines.value = it } + @Tab(BehaviorTab) @Group(MovementGroup) val allowWalkOnBottomSlab by c.setting("Allow Walk On Bottom Slab", bSettings.allowWalkOnBottomSlab.value).onValueChange { _, it -> bSettings.allowWalkOnBottomSlab.value = it } + @Tab(BehaviorTab) @Group(MovementGroup) val allowParkour by c.setting("Allow Parkour", bSettings.allowParkour.value).onValueChange { _, it -> bSettings.allowParkour.value = it } + @Tab(BehaviorTab) @Group(MovementGroup) val allowParkourPlace by c.setting("Allow Parkour Place", bSettings.allowParkourPlace.value).onValueChange { _, it -> bSettings.allowParkourPlace.value = it } + @Tab(BehaviorTab) @Group(MovementGroup) val sprintAscends by c.setting("Sprint Ascends", bSettings.sprintAscends.value).onValueChange { _, it -> bSettings.sprintAscends.value = it } + @Tab(BehaviorTab) @Group(MovementGroup) val overshootTraverse by c.setting("Overshoot Traverse", bSettings.overshootTraverse.value).onValueChange { _, it -> bSettings.overshootTraverse.value = it } + @Tab(BehaviorTab) @Group(MovementGroup) val pauseMiningForFallingBlocks by c.setting("Pause Mining For Falling Blocks", bSettings.pauseMiningForFallingBlocks.value).onValueChange { _, it -> bSettings.pauseMiningForFallingBlocks.value = it } + @Tab(BehaviorTab) @Group(MovementGroup) val allowOvershootDiagonalDescend by c.setting("Allow Overshoot Diagonal Descend", bSettings.allowOvershootDiagonalDescend.value).onValueChange { _, it -> bSettings.allowOvershootDiagonalDescend.value = it } + @Tab(BehaviorTab) @Group(MovementGroup) val sprintInWater by c.setting("Sprint In Water", bSettings.sprintInWater.value).onValueChange { _, it -> bSettings.sprintInWater.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val allowBreak by c.setting("Allow Break", bSettings.allowBreak.value).onValueChange { _, it -> bSettings.allowBreak.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val allowBreakAnyway by c.setting("Allow Break Anyway", bSettings.allowBreakAnyway.value).onValueChange { _, it -> bSettings.allowBreakAnyway.value = it.toList() } + @Tab(BehaviorTab) @Group(InteractionGroup) val allowSprint by c.setting("Allow Sprint", bSettings.allowSprint.value).onValueChange { _, it -> bSettings.allowSprint.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val allowPlace by c.setting("Allow Place", bSettings.allowPlace.value).onValueChange { _, it -> bSettings.allowPlace.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val allowPlaceInFluidsSource by c.setting("Allow Place In Fluids Source", bSettings.allowPlaceInFluidsSource.value).onValueChange { _, it -> bSettings.allowPlaceInFluidsSource.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val allowPlaceInFluidsFlow by c.setting("Allow Place In Fluids Flow", bSettings.allowPlaceInFluidsFlow.value).onValueChange { _, it -> bSettings.allowPlaceInFluidsFlow.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val allowInventory by c.setting("Allow Inventory", bSettings.allowInventory.value).onValueChange { _, it -> bSettings.allowInventory.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val ticksBetweenInventoryMoves by c.setting("Ticks Between Inventory Moves", bSettings.ticksBetweenInventoryMoves.value, 0..20).onValueChange { _, it -> bSettings.ticksBetweenInventoryMoves.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val inventoryMoveOnlyIfStationary by c.setting("Inventory Move Only If Stationary", bSettings.inventoryMoveOnlyIfStationary.value).onValueChange { _, it -> bSettings.inventoryMoveOnlyIfStationary.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val autoTool by c.setting("Auto Tool", bSettings.autoTool.value).onValueChange { _, it -> bSettings.autoTool.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val allowWaterBucketFall by c.setting("Allow Water Bucket Fall", bSettings.allowWaterBucketFall.value).onValueChange { _, it -> bSettings.allowWaterBucketFall.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val allowJumpAtBuildLimit by c.setting("Allow Jump At Build Limit", bSettings.allowJumpAtBuildLimit.value).onValueChange { _, it -> bSettings.allowJumpAtBuildLimit.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val rightClickContainerOnArrival by c.setting("Right Click Container On Arrival", bSettings.rightClickContainerOnArrival.value).onValueChange { _, it -> bSettings.rightClickContainerOnArrival.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val enterPortal by c.setting("Enter Portal", bSettings.enterPortal.value).onValueChange { _, it -> bSettings.enterPortal.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val walkWhileBreaking by c.setting("Walk While Breaking", bSettings.walkWhileBreaking.value).onValueChange { _, it -> bSettings.walkWhileBreaking.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val useSwordToMine by c.setting("Use Sword To Mine", bSettings.useSwordToMine.value).onValueChange { _, it -> bSettings.useSwordToMine.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val rightClickSpeed by c.setting("Right Click Speed", bSettings.rightClickSpeed.value, 0..10).onValueChange { _, it -> bSettings.rightClickSpeed.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val blockReachDistance by c.setting("Block Reach Distance", bSettings.blockReachDistance.value, 0f..10f, 0.1f).onValueChange { _, it -> bSettings.blockReachDistance.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val blockBreakSpeed by c.setting("Block Break Speed", bSettings.blockBreakSpeed.value, 0..10).onValueChange { _, it -> bSettings.blockBreakSpeed.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val randomLooking113 by c.setting("Random Looking 1.13", bSettings.randomLooking113.value, 0.0..5.0, 0.01).onValueChange { _, it -> bSettings.randomLooking113.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val randomLooking by c.setting("Random Looking", bSettings.randomLooking.value, 0.0..1.0, 0.01).onValueChange { _, it -> bSettings.randomLooking.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val freeLook by c.setting("Free Look", bSettings.freeLook.value).onValueChange { _, it -> bSettings.freeLook.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val blockFreeLook by c.setting("Block Free Look", bSettings.blockFreeLook.value).onValueChange { _, it -> bSettings.blockFreeLook.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val elytraFreeLook by c.setting("Elytra Free Look", bSettings.elytraFreeLook.value).onValueChange { _, it -> bSettings.elytraFreeLook.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val smoothLook by c.setting("Smooth Look", bSettings.smoothLook.value).onValueChange { _, it -> bSettings.smoothLook.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val elytraSmoothLook by c.setting("Elytra Smooth Look", bSettings.elytraSmoothLook.value).onValueChange { _, it -> bSettings.elytraSmoothLook.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val smoothLookTicks by c.setting("Smooth Look Ticks", bSettings.smoothLookTicks.value, 0..200).onValueChange { _, it -> bSettings.smoothLookTicks.value = it } + @Tab(BehaviorTab) @Group(InteractionGroup) val remainWithExistingLookDirection by c.setting("Remain With Existing Look Direction", bSettings.remainWithExistingLookDirection.value).onValueChange { _, it -> bSettings.remainWithExistingLookDirection.value = it } + @Tab(BehaviorTab) @Group(PenaltiesGroup) val blockPlacementPenalty by c.setting("Block Placement Penalty", bSettings.blockPlacementPenalty.value, 0.0..100.0, 0.1).onValueChange { _, it -> bSettings.blockPlacementPenalty.value = it } + @Tab(BehaviorTab) @Group(PenaltiesGroup) val blockBreakAdditionalPenalty by c.setting("Block Break Additional Penalty", bSettings.blockBreakAdditionalPenalty.value, 0.0..100.0, 0.1).onValueChange { _, it -> bSettings.blockBreakAdditionalPenalty.value = it } + @Tab(BehaviorTab) @Group(PenaltiesGroup) val jumpPenalty by c.setting("Jump Penalty", bSettings.jumpPenalty.value, 0.0..100.0, 0.1).onValueChange { _, it -> bSettings.jumpPenalty.value = it } + @Tab(BehaviorTab) @Group(PenaltiesGroup) val walkOnWaterOnePenalty by c.setting("Walk On Water One Penalty", bSettings.walkOnWaterOnePenalty.value, 0.0..100.0, 0.1).onValueChange { _, it -> bSettings.walkOnWaterOnePenalty.value = it } + @Tab(BehaviorTab) @Group(PenaltiesGroup) val avoidBreakingMultiplier by c.setting("Avoid Breaking Multiplier", bSettings.avoidBreakingMultiplier.value, 0.0..100.0, 0.1).onValueChange { _, it -> bSettings.avoidBreakingMultiplier.value = it } + @Tab(BehaviorTab) @Group(PenaltiesGroup) val maxCostIncrease by c.setting("Max Cost Increase", bSettings.maxCostIncrease.value, 0.0..100.0).onValueChange { _, it -> bSettings.maxCostIncrease.value = it } + @Tab(BehaviorTab) @Group(PenaltiesGroup) val backtrackCostFavoringCoefficient by c.setting("Backtrack Cost Favoring Coefficient", bSettings.backtrackCostFavoringCoefficient.value, 0.0..100.0, 0.1).onValueChange { _, it -> bSettings.backtrackCostFavoringCoefficient.value = it } + @Tab(BehaviorTab) @Group(PenaltiesGroup) val mobSpawnerAvoidanceCoefficient by c.setting("Mob Spawner Avoidance Coefficient", bSettings.mobSpawnerAvoidanceCoefficient.value, 0.0..100.0, 0.1).onValueChange { _, it -> bSettings.mobSpawnerAvoidanceCoefficient.value = it } + @Tab(BehaviorTab) @Group(PenaltiesGroup) val mobSpawnerAvoidanceRadius by c.setting("Mob Spawner Avoidance Radius", bSettings.mobSpawnerAvoidanceRadius.value, 0..1000).onValueChange { _, it -> bSettings.mobSpawnerAvoidanceRadius.value = it } + @Tab(BehaviorTab) @Group(PenaltiesGroup) val mobAvoidanceCoefficient by c.setting("Mob Avoidance Coefficient", bSettings.mobAvoidanceCoefficient.value, 0.0..100.0, 0.1).onValueChange { _, it -> bSettings.mobAvoidanceCoefficient.value = it } + @Tab(BehaviorTab) @Group(PenaltiesGroup) val mobAvoidanceRadius by c.setting("Mob Avoidance Radius", bSettings.mobAvoidanceRadius.value, 0..1000).onValueChange { _, it -> bSettings.mobAvoidanceRadius.value = it } + @Tab(BehaviorTab) @Group(PenaltiesGroup) val pathCutoffFactor by c.setting("Path Cutoff Factor", bSettings.pathCutoffFactor.value, 0.0..100.0, 0.1).onValueChange { _, it -> bSettings.pathCutoffFactor.value = it } + @Tab(BehaviorTab) @Group(PenaltiesGroup) val breakCorrectBlockPenaltyMultiplier by c.setting("Break Correct Block Penalty Multiplier", bSettings.breakCorrectBlockPenaltyMultiplier.value, 0.0..100.0, 0.1).onValueChange { _, it -> bSettings.breakCorrectBlockPenaltyMultiplier.value = it } + @Tab(BehaviorTab) @Group(PenaltiesGroup) val placeIncorrectBlockPenaltyMultiplier by c.setting("Place Incorrect Block Penalty Multiplier", bSettings.placeIncorrectBlockPenaltyMultiplier.value, 0.0..100.0, 0.1).onValueChange { _, it -> bSettings.placeIncorrectBlockPenaltyMultiplier.value = it } + @Tab(BehaviorTab) @Group(PenaltiesGroup) val costHeuristic by c.setting("Cost Heuristic", bSettings.costHeuristic.value, 0.0..10.0, 0.001).onValueChange { _, it -> bSettings.costHeuristic.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val itemSaver by c.setting("Item Saver", bSettings.itemSaver.value).onValueChange { _, it -> bSettings.itemSaver.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val itemSaverThreshold by c.setting("Item Saver Threshold", bSettings.itemSaverThreshold.value, 0..100).onValueChange { _, it -> bSettings.itemSaverThreshold.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val preferSilkTouch by c.setting("Prefer Silk Touch", bSettings.preferSilkTouch.value).onValueChange { _, it -> bSettings.preferSilkTouch.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val mineScanDroppedItems by c.setting("Mine Scan Dropped Items", bSettings.mineScanDroppedItems.value).onValueChange { _, it -> bSettings.mineScanDroppedItems.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val mineDropLoiterDurationMSThanksLouca by c.setting("Mine Drop Loiter Duration", bSettings.mineDropLoiterDurationMSThanksLouca.value, 0L..600000L, unit = " ms").onValueChange { _, it -> bSettings.mineDropLoiterDurationMSThanksLouca.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val legitMine by c.setting("Legit Mine", bSettings.legitMine.value).onValueChange { _, it -> bSettings.legitMine.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val legitMineYLevel by c.setting("Legit Mine Y Level", bSettings.legitMineYLevel.value, 0..256).onValueChange { _, it -> bSettings.legitMineYLevel.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val legitMineIncludeDiagonals by c.setting("Legit Mine Include Diagonals", bSettings.legitMineIncludeDiagonals.value).onValueChange { _, it -> bSettings.legitMineIncludeDiagonals.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val forceInternalMining by c.setting("Force Internal Mining", bSettings.forceInternalMining.value).onValueChange { _, it -> bSettings.forceInternalMining.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val internalMiningAirException by c.setting("Internal Mining Air Exception", bSettings.internalMiningAirException.value).onValueChange { _, it -> bSettings.internalMiningAirException.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val minYLevelWhileMining by c.setting("Min Y Level While Mining", bSettings.minYLevelWhileMining.value, 0..2048).onValueChange { _, it -> bSettings.minYLevelWhileMining.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val maxYLevelWhileMining by c.setting("Max Y Level While Mining", bSettings.maxYLevelWhileMining.value, 0..2048).onValueChange { _, it -> bSettings.maxYLevelWhileMining.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val allowOnlyExposedOres by c.setting("Allow Only Exposed Ores", bSettings.allowOnlyExposedOres.value).onValueChange { _, it -> bSettings.allowOnlyExposedOres.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val allowOnlyExposedOresDistance by c.setting("Allow Only Exposed Ores Distance", bSettings.allowOnlyExposedOresDistance.value, 0..16).onValueChange { _, it -> bSettings.allowOnlyExposedOresDistance.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val replantCrops by c.setting("Replant Crops", bSettings.replantCrops.value).onValueChange { _, it -> bSettings.replantCrops.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val replantNetherWart by c.setting("Replant Nether Wart", bSettings.replantNetherWart.value).onValueChange { _, it -> bSettings.replantNetherWart.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val farmMaxScanSize by c.setting("Farm Max Scan Size", bSettings.farmMaxScanSize.value, 0..1024).onValueChange { _, it -> bSettings.farmMaxScanSize.value = it } + @Tab(BehaviorTab) @Group(MiningAndFarmingGroup) val considerPotionEffects by c.setting("Consider Potion Effects", bSettings.considerPotionEffects.value).onValueChange { _, it -> bSettings.considerPotionEffects.value = it } + @Tab(BehaviorTab) @Group(ExplorationGroup) val exploreForBlocks by c.setting("Explore For Blocks", bSettings.exploreForBlocks.value).onValueChange { _, it -> bSettings.exploreForBlocks.value = it } + @Tab(BehaviorTab) @Group(ExplorationGroup) val worldExploringChunkOffset by c.setting("World Exploring Chunk Offset", bSettings.worldExploringChunkOffset.value, 0..32).onValueChange { _, it -> bSettings.worldExploringChunkOffset.value = it } + @Tab(BehaviorTab) @Group(ExplorationGroup) val exploreChunkSetMinimumSize by c.setting("Explore Chunk Set Minimum Size", bSettings.exploreChunkSetMinimumSize.value, 0..10000).onValueChange { _, it -> bSettings.exploreChunkSetMinimumSize.value = it } + @Tab(BehaviorTab) @Group(ExplorationGroup) val exploreMaintainY by c.setting("Explore Maintain Y", bSettings.exploreMaintainY.value, 0..256).onValueChange { _, it -> bSettings.exploreMaintainY.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val buildInLayers by c.setting("Build In Layers", bSettings.buildInLayers.value).onValueChange { _, it -> bSettings.buildInLayers.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val layerOrder by c.setting("Layer Order", bSettings.layerOrder.value).onValueChange { _, it -> bSettings.layerOrder.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val layerHeight by c.setting("Layer Height", bSettings.layerHeight.value, 0..256).onValueChange { _, it -> bSettings.layerHeight.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val startAtLayer by c.setting("Start At Layer", bSettings.startAtLayer.value, 0..256).onValueChange { _, it -> bSettings.startAtLayer.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val skipFailedLayers by c.setting("Skip Failed Layers", bSettings.skipFailedLayers.value).onValueChange { _, it -> bSettings.skipFailedLayers.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val buildOnlySelection by c.setting("Build Only Selection", bSettings.buildOnlySelection.value).onValueChange { _, it -> bSettings.buildOnlySelection.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val buildRepeat by c.setting("Build Repeat", bSettings.buildRepeat.value.blockPos).onValueChange { _, it -> bSettings.buildRepeat.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val buildRepeatCount by c.setting("Build Repeat Count", bSettings.buildRepeatCount.value, 0..1000).onValueChange { _, it -> bSettings.buildRepeatCount.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val buildRepeatSneaky by c.setting("Build Repeat Sneaky", bSettings.buildRepeatSneaky.value).onValueChange { _, it -> bSettings.buildRepeatSneaky.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val breakFromAbove by c.setting("Break From Above", bSettings.breakFromAbove.value).onValueChange { _, it -> bSettings.breakFromAbove.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val goalBreakFromAbove by c.setting("Goal Break From Above", bSettings.goalBreakFromAbove.value).onValueChange { _, it -> bSettings.goalBreakFromAbove.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val mapArtMode by c.setting("Map Art Mode", bSettings.mapArtMode.value).onValueChange { _, it -> bSettings.mapArtMode.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val okIfWater by c.setting("Ok If Water", bSettings.okIfWater.value).onValueChange { _, it -> bSettings.okIfWater.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val incorrectSize by c.setting("Incorrect Size", bSettings.incorrectSize.value, 0..1000).onValueChange { _, it -> bSettings.incorrectSize.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val schematicOrientationX by c.setting("Schematic Orientation X", bSettings.schematicOrientationX.value).onValueChange { _, it -> bSettings.schematicOrientationX.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val schematicOrientationY by c.setting("Schematic Orientation Y", bSettings.schematicOrientationY.value).onValueChange { _, it -> bSettings.schematicOrientationY.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val schematicOrientationZ by c.setting("Schematic Orientation Z", bSettings.schematicOrientationZ.value).onValueChange { _, it -> bSettings.schematicOrientationZ.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val buildSchematicRotation: BlockRotation by c.setting("Build Schematic Rotation", bSettings.buildSchematicRotation.value).onValueChange { _, it -> bSettings.buildSchematicRotation.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val buildSchematicMirror: BlockMirror by c.setting("Build Schematic Mirror", bSettings.buildSchematicMirror.value).onValueChange { _, it -> bSettings.buildSchematicMirror.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val schematicFallbackExtension by c.setting("Schematic Fallback Extension", bSettings.schematicFallbackExtension.value).onValueChange { _, it -> bSettings.schematicFallbackExtension.value = it } + @Tab(BuildingTab) @Group(SchematicGroup) val builderTickScanRadius by c.setting("Builder Tick Scan Radius", bSettings.builderTickScanRadius.value, 0..64).onValueChange { _, it -> bSettings.builderTickScanRadius.value = it } + @Tab(BuildingTab) @Group(BlockRulesGroup) val acceptableThrowawayItems by c.setting("Acceptable Throwaway Items", bSettings.acceptableThrowawayItems.value).onValueChange { _, it -> bSettings.acceptableThrowawayItems.value = it.toList() } + @Tab(BuildingTab) @Group(BlockRulesGroup) val blocksToAvoid by c.setting("Blocks To Avoid", bSettings.blocksToAvoid.value).onValueChange { _, it -> bSettings.blocksToAvoid.value = it.toList() } + @Tab(BuildingTab) @Group(BlockRulesGroup) val blocksToDisallowBreaking by c.setting("Blocks To Disallow Breaking", bSettings.blocksToDisallowBreaking.value).onValueChange { _, it -> bSettings.blocksToDisallowBreaking.value = it.toList() } + @Tab(BuildingTab) @Group(BlockRulesGroup) val blocksToAvoidBreaking by c.setting("Blocks To Avoid Breaking", bSettings.blocksToAvoidBreaking.value).onValueChange { _, it -> bSettings.blocksToAvoidBreaking.value = it.toList() } + @Tab(BuildingTab) @Group(BlockRulesGroup) val buildIgnoreBlocks by c.setting("Build Ignore Blocks", bSettings.buildIgnoreBlocks.value).onValueChange { _, it -> bSettings.buildIgnoreBlocks.value = it.toList() } + @Tab(BuildingTab) @Group(BlockRulesGroup) val buildSkipBlocks by c.setting("Build Skip Blocks", bSettings.buildSkipBlocks.value).onValueChange { _, it -> bSettings.buildSkipBlocks.value = it.toList() } + @Tab(BuildingTab) @Group(BlockRulesGroup) val buildValidSubstitutes by c.setting("Build Valid Substitutes", bSettings.buildValidSubstitutes.value).onValueChange { _, it -> bSettings.buildValidSubstitutes.value = it.mapValues { (_, v) -> v.toList() } } + @Tab(BuildingTab) @Group(BlockRulesGroup) val buildSubstitutes by c.setting("Build Substitutes", bSettings.buildSubstitutes.value).onValueChange { _, it -> bSettings.buildSubstitutes.value = it.mapValues { (_, v) -> v.toList() } } + @Tab(BuildingTab) @Group(BlockRulesGroup) val okIfAir by c.setting("Ok If Air", bSettings.okIfAir.value).onValueChange { _, it -> bSettings.okIfAir.value = it.toList() } + @Tab(BuildingTab) @Group(BlockRulesGroup) val buildIgnoreExisting by c.setting("Build Ignore Existing", bSettings.buildIgnoreExisting.value).onValueChange { _, it -> bSettings.buildIgnoreExisting.value = it } + @Tab(BuildingTab) @Group(BlockRulesGroup) val buildIgnoreDirection by c.setting("Build Ignore Direction", bSettings.buildIgnoreDirection.value).onValueChange { _, it -> bSettings.buildIgnoreDirection.value = it } + @Tab(BuildingTab) @Group(BlockRulesGroup) val buildIgnoreProperties by c.setting("Build Ignore Properties", bSettings.buildIgnoreProperties.value).onValueChange { _, it -> bSettings.buildIgnoreProperties.value = it.toList() } + @Tab(BuildingTab) @Group(BlockRulesGroup) val avoidUpdatingFallingBlocks by c.setting("Avoid Updating Falling Blocks", bSettings.avoidUpdatingFallingBlocks.value).onValueChange { _, it -> bSettings.avoidUpdatingFallingBlocks.value = it } + @Tab(RenderingTab) @Group(RenderingGroup) val renderPath by c.setting("Render Path", bSettings.renderPath.value).onValueChange { _, it -> bSettings.renderPath.value = it } + @Tab(RenderingTab) @Group(RenderingGroup) val renderPathAsLine by c.setting("Render Path As Line", bSettings.renderPathAsLine.value).onValueChange { _, it -> bSettings.renderPathAsLine.value = it } + @Tab(RenderingTab) @Group(RenderingGroup) val renderGoal by c.setting("Render Goal", bSettings.renderGoal.value).onValueChange { _, it -> bSettings.renderGoal.value = it } + @Tab(RenderingTab) @Group(RenderingGroup) val renderGoalAnimated by c.setting("Render Goal Animated", bSettings.renderGoalAnimated.value).onValueChange { _, it -> bSettings.renderGoalAnimated.value = it } + @Tab(RenderingTab) @Group(RenderingGroup) val renderGoalIgnoreDepth by c.setting("Render Goal Ignore Depth", bSettings.renderGoalIgnoreDepth.value).onValueChange { _, it -> bSettings.renderGoalIgnoreDepth.value = it } + @Tab(RenderingTab) @Group(RenderingGroup) val renderGoalXZBeacon by c.setting("Render Goal XZ Beacon", bSettings.renderGoalXZBeacon.value).onValueChange { _, it -> bSettings.renderGoalXZBeacon.value = it } + @Tab(RenderingTab) @Group(RenderingGroup) val pathRenderLineWidthPixels by c.setting("Path Render Line Width Pixels", bSettings.pathRenderLineWidthPixels.value, 0f..10f, 0.1f).onValueChange { _, it -> bSettings.pathRenderLineWidthPixels.value = it } + @Tab(RenderingTab) @Group(RenderingGroup) val goalRenderLineWidthPixels by c.setting("Goal Render Line Width Pixels", bSettings.goalRenderLineWidthPixels.value, 0f..10f, 0.1f).onValueChange { _, it -> bSettings.goalRenderLineWidthPixels.value = it } + @Tab(RenderingTab) @Group(RenderingGroup) val fadePath by c.setting("Fade Path", bSettings.fadePath.value).onValueChange { _, it -> bSettings.fadePath.value = it } + @Tab(RenderingTab) @Group(RenderingGroup) val renderCachedChunks by c.setting("Render Cached Chunks", bSettings.renderCachedChunks.value).onValueChange { _, it -> bSettings.renderCachedChunks.value = it } + @Tab(RenderingTab) @Group(RenderingGroup) val cachedChunksOpacity by c.setting("Cached Chunks Opacity", bSettings.cachedChunksOpacity.value, 0f..1f, 0.05f).onValueChange { _, it -> bSettings.cachedChunksOpacity.value = it } + @Tab(RenderingTab) @Group(RenderingGroup) val renderPathIgnoreDepth by c.setting("Render Path Ignore Depth", bSettings.renderPathIgnoreDepth.value).onValueChange { _, it -> bSettings.renderPathIgnoreDepth.value = it } + @Tab(RenderingTab) @Group(RenderingGroup) val renderSelectionBoxes by c.setting("Render Selection Boxes", bSettings.renderSelectionBoxes.value).onValueChange { _, it -> bSettings.renderSelectionBoxes.value = it } + @Tab(RenderingTab) @Group(RenderingColorsGroup) val colorCurrentPath by c.setting("Color Current Path", bSettings.colorCurrentPath.value).onValueChange { _, it -> bSettings.colorCurrentPath.value = it } + @Tab(RenderingTab) @Group(RenderingColorsGroup) val colorNextPath by c.setting("Color Next Path", bSettings.colorNextPath.value).onValueChange { _, it -> bSettings.colorNextPath.value = it } + @Tab(RenderingTab) @Group(RenderingColorsGroup) val colorBlocksToBreak by c.setting("Color Blocks To Break", bSettings.colorBlocksToBreak.value).onValueChange { _, it -> bSettings.colorBlocksToBreak.value = it } + @Tab(RenderingTab) @Group(RenderingColorsGroup) val colorBlocksToPlace by c.setting("Color Blocks To Place", bSettings.colorBlocksToPlace.value).onValueChange { _, it -> bSettings.colorBlocksToPlace.value = it } + @Tab(RenderingTab) @Group(RenderingColorsGroup) val colorBlocksToWalkInto by c.setting("Color Blocks To Walk Into", bSettings.colorBlocksToWalkInto.value).onValueChange { _, it -> bSettings.colorBlocksToWalkInto.value = it } + @Tab(RenderingTab) @Group(RenderingColorsGroup) val colorBestPathSoFar by c.setting("Color Best Path So Far", bSettings.colorBestPathSoFar.value).onValueChange { _, it -> bSettings.colorBestPathSoFar.value = it } + @Tab(RenderingTab) @Group(RenderingColorsGroup) val colorMostRecentConsidered by c.setting("Color Most Recent Considered", bSettings.colorMostRecentConsidered.value).onValueChange { _, it -> bSettings.colorMostRecentConsidered.value = it } + @Tab(RenderingTab) @Group(RenderingColorsGroup) val colorGoalBox by c.setting("Color Goal Box", bSettings.colorGoalBox.value).onValueChange { _, it -> bSettings.colorGoalBox.value = it } + @Tab(RenderingTab) @Group(RenderingColorsGroup) val colorInvertedGoalBox by c.setting("Color Inverted Goal Box", bSettings.colorInvertedGoalBox.value).onValueChange { _, it -> bSettings.colorInvertedGoalBox.value = it } + @Tab(RenderingTab) @Group(RenderingSelectionGroup) val renderSelection by c.setting("Render Selection", bSettings.renderSelection.value).onValueChange { _, it -> bSettings.renderSelection.value = it } + @Tab(RenderingTab) @Group(RenderingSelectionGroup) val colorSelection by c.setting("Color Selection", bSettings.colorSelection.value).onValueChange { _, it -> bSettings.colorSelection.value = it } + @Tab(RenderingTab) @Group(RenderingSelectionGroup) val colorSelectionPos1 by c.setting("Color Selection Pos1", bSettings.colorSelectionPos1.value).onValueChange { _, it -> bSettings.colorSelectionPos1.value = it } + @Tab(RenderingTab) @Group(RenderingSelectionGroup) val colorSelectionPos2 by c.setting("Color Selection Pos2", bSettings.colorSelectionPos2.value).onValueChange { _, it -> bSettings.colorSelectionPos2.value = it } + @Tab(RenderingTab) @Group(RenderingSelectionGroup) val selectionOpacity by c.setting("Selection Opacity", bSettings.selectionOpacity.value, 0f..1f, 0.05f).onValueChange { _, it -> bSettings.selectionOpacity.value = it } + @Tab(RenderingTab) @Group(RenderingSelectionGroup) val selectionLineWidth by c.setting("Selection Line Width", bSettings.selectionLineWidth.value, 0f..10f, 0.1f).onValueChange { _, it -> bSettings.selectionLineWidth.value = it } + @Tab(RenderingTab) @Group(RenderingSelectionGroup) val renderSelectionIgnoreDepth by c.setting("Render Selection Ignore Depth", bSettings.renderSelectionIgnoreDepth.value).onValueChange { _, it -> bSettings.renderSelectionIgnoreDepth.value = it } + @Tab(RenderingTab) @Group(RenderingSelectionGroup) val renderSelectionCorners by c.setting("Render Selection Corners", bSettings.renderSelectionCorners.value).onValueChange { _, it -> bSettings.renderSelectionCorners.value = it } + @Tab(RenderingTab) @Group(RenderingSelectionGroup) val renderSelectionBoxesIgnoreDepth by c.setting("Render Selection Boxes Ignore Depth", bSettings.renderSelectionBoxesIgnoreDepth.value).onValueChange { _, it -> bSettings.renderSelectionBoxesIgnoreDepth.value = it } + @Tab(ElytraTab) val elytraSimulationTicks by c.setting("Simulation Ticks", bSettings.elytraSimulationTicks.value, 0..200).onValueChange { _, it -> bSettings.elytraSimulationTicks.value = it } + @Tab(ElytraTab) val elytraPitchRange by c.setting("Pitch Range", bSettings.elytraPitchRange.value, 0..90).onValueChange { _, it -> bSettings.elytraPitchRange.value = it } + @Tab(ElytraTab) val elytraFireworkSpeed by c.setting("Firework Speed", bSettings.elytraFireworkSpeed.value, 0.0..3.0, 0.1).onValueChange { _, it -> bSettings.elytraFireworkSpeed.value = it } + @Tab(ElytraTab) val elytraFireworkSetbackUseDelay by c.setting("Firework Setback Use Delay", bSettings.elytraFireworkSetbackUseDelay.value, 0..600).onValueChange { _, it -> bSettings.elytraFireworkSetbackUseDelay.value = it } + @Tab(ElytraTab) val elytraMinimumAvoidance by c.setting("Minimum Avoidance", bSettings.elytraMinimumAvoidance.value, 0.0..10.0, 0.1).onValueChange { _, it -> bSettings.elytraMinimumAvoidance.value = it } + @Tab(ElytraTab) val elytraConserveFireworks by c.setting("Conserve Fireworks", bSettings.elytraConserveFireworks.value).onValueChange { _, it -> bSettings.elytraConserveFireworks.value = it } + @Tab(ElytraTab) val elytraRenderRaytraces by c.setting("Render Raytraces", bSettings.elytraRenderRaytraces.value).onValueChange { _, it -> bSettings.elytraRenderRaytraces.value = it } + @Tab(ElytraTab) val elytraRenderHitboxRaytraces by c.setting("Render Hitbox Raytraces", bSettings.elytraRenderHitboxRaytraces.value).onValueChange { _, it -> bSettings.elytraRenderHitboxRaytraces.value = it } + @Tab(ElytraTab) val elytraRenderSimulation by c.setting("Render Simulation", bSettings.elytraRenderSimulation.value).onValueChange { _, it -> bSettings.elytraRenderSimulation.value = it } + @Tab(ElytraTab) val elytraAutoJump by c.setting("Auto Jump", bSettings.elytraAutoJump.value).onValueChange { _, it -> bSettings.elytraAutoJump.value = it } + @Tab(ElytraTab) val elytraNetherSeed by c.setting("Nether Seed", bSettings.elytraNetherSeed.value, Long.MIN_VALUE..Long.MAX_VALUE).onValueChange { _, it -> bSettings.elytraNetherSeed.value = it } + @Tab(ElytraTab) val elytraPredictTerrain by c.setting("Predict Terrain", bSettings.elytraPredictTerrain.value).onValueChange { _, it -> bSettings.elytraPredictTerrain.value = it } + @Tab(ElytraTab) val elytraAutoSwap by c.setting("Auto Swap", bSettings.elytraAutoSwap.value).onValueChange { _, it -> bSettings.elytraAutoSwap.value = it } + @Tab(ElytraTab) val elytraMinimumDurability by c.setting("Minimum Durability", bSettings.elytraMinimumDurability.value, 0..432).onValueChange { _, it -> bSettings.elytraMinimumDurability.value = it } + @Tab(ElytraTab) val elytraMinFireworksBeforeLanding by c.setting("Min Fireworks Before Landing", bSettings.elytraMinFireworksBeforeLanding.value, 0..64).onValueChange { _, it -> bSettings.elytraMinFireworksBeforeLanding.value = it } + @Tab(ElytraTab) val elytraAllowEmergencyLand by c.setting("Allow Emergency Land", bSettings.elytraAllowEmergencyLand.value).onValueChange { _, it -> bSettings.elytraAllowEmergencyLand.value = it } + @Tab(ElytraTab) val elytraTimeBetweenCacheCullSecs by c.setting("Time Between Cache Cull Secs", bSettings.elytraTimeBetweenCacheCullSecs.value, 0L..86400L).onValueChange { _, it -> bSettings.elytraTimeBetweenCacheCullSecs.value = it } + @Tab(ElytraTab) val elytraCacheCullDistance by c.setting("Cache Cull Distance", bSettings.elytraCacheCullDistance.value, 0..100000).onValueChange { _, it -> bSettings.elytraCacheCullDistance.value = it } + @Tab(ElytraTab) val elytraAllowLandOnNetherFortress by c.setting("Allow Land On Nether Fortress", bSettings.elytraAllowLandOnNetherFortress.value).onValueChange { _, it -> bSettings.elytraAllowLandOnNetherFortress.value = it } + @Tab(ElytraTab) val elytraTermsAccepted by c.setting("Terms Accepted", bSettings.elytraTermsAccepted.value).onValueChange { _, it -> bSettings.elytraTermsAccepted.value = it } + @Tab(ElytraTab) val elytraChatSpam by c.setting("Chat Spam", bSettings.elytraChatSpam.value).onValueChange { _, it -> bSettings.elytraChatSpam.value = it } + } } diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt index 7ce397a90..5c9532b84 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/Sim.kt @@ -21,11 +21,11 @@ import com.lambda.interaction.construction.simulation.processing.PreProcessingDa import com.lambda.interaction.construction.simulation.result.BuildResult import com.lambda.interaction.construction.simulation.result.results.GenericResult import com.lambda.interaction.managers.rotating.Rotation.Companion.rotationTo -import com.lambda.util.player.RotationUtils.CheckedHit -import com.lambda.util.player.RotationUtils.scanClosestPoints -import com.lambda.util.player.RotationUtils.scanSurfaces import com.lambda.util.math.distSq import com.lambda.util.math.vec3d +import com.lambda.util.player.CheckedHit +import com.lambda.util.player.RotationUtils.scanClosestPoints +import com.lambda.util.player.RotationUtils.scanSurfaces import com.lambda.util.world.raycast.RayCastUtils.blockResult import io.ktor.util.collections.* import kotlinx.coroutines.launch diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt index 234c6cd5f..08fe68f5a 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt @@ -17,6 +17,8 @@ package com.lambda.interaction.construction.simulation.checks +import com.lambda.config.settings.blocks.BreakConfig +import com.lambda.config.settings.blocks.BreakConfig.WhitelistMode import com.lambda.context.AutomatedSafeContext import com.lambda.interaction.construction.simulation.BreakSimInfo import com.lambda.interaction.construction.simulation.Results @@ -24,7 +26,6 @@ import com.lambda.interaction.construction.simulation.SimDsl import com.lambda.interaction.construction.simulation.SimInfo import com.lambda.interaction.construction.simulation.result.results.GenericResult import com.lambda.interaction.construction.simulation.result.results.PreSimResult -import com.lambda.config.blocks.BreakConfig.WhitelistMode import com.lambda.util.player.gamemode import com.lambda.util.world.WorldUtils.isLoaded import net.minecraft.block.OperatorBlock diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt index 9645f8e6f..198fd2e7c 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt @@ -31,7 +31,6 @@ import com.lambda.interaction.construction.verify.TargetState import com.lambda.interaction.managers.hotbar.HotbarManager import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest import com.lambda.interaction.managers.rotating.RotationManager -import com.lambda.interaction.managers.rotating.visibilty.lookAtBlock import com.lambda.interaction.material.ContainerSelection.Companion.selectContainer import com.lambda.interaction.material.StackSelection import com.lambda.interaction.material.StackSelection.Companion.EVERYTHING @@ -43,6 +42,7 @@ import com.lambda.util.BlockUtils.calcItemBlockBreakingDelta import com.lambda.util.BlockUtils.instantBreakable import com.lambda.util.item.ItemStackUtils.inventoryIndex import com.lambda.util.item.ItemStackUtils.inventoryIndexOrSelected +import com.lambda.util.player.RotationUtils.lookAtBlock import com.lambda.util.world.raycast.RayCastUtils.blockResult import net.minecraft.block.BlockState import net.minecraft.block.FallingBlock diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt index 43a80cd08..4cfac537d 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt @@ -31,9 +31,6 @@ import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotat import com.lambda.interaction.managers.rotating.Rotation import com.lambda.interaction.managers.rotating.Rotation.Companion.rotation import com.lambda.interaction.managers.rotating.RotationManager -import com.lambda.util.PlaceDirection -import com.lambda.util.player.RotationUtils.CheckedHit -import com.lambda.interaction.managers.rotating.visibilty.lookInDirection import com.lambda.interaction.material.ContainerSelection.Companion.selectContainer import com.lambda.interaction.material.StackSelection import com.lambda.interaction.material.StackSelection.Companion.select @@ -42,11 +39,14 @@ import com.lambda.interaction.material.container.MaterialContainer import com.lambda.util.BlockUtils import com.lambda.util.BlockUtils.blockState import com.lambda.util.EntityUtils.getPositionsWithinHitboxXZ +import com.lambda.util.PlaceDirection import com.lambda.util.item.ItemStackUtils.inventoryIndex import com.lambda.util.item.ItemUtils.blockItem import com.lambda.util.math.MathUtils.floorToInt import com.lambda.util.math.minus +import com.lambda.util.player.CheckedHit import com.lambda.util.player.MovementUtils.sneaking +import com.lambda.util.player.RotationUtils.lookInDirection import com.lambda.util.player.copyPlayer import com.lambda.util.world.raycast.RayCastUtils.blockResult import kotlinx.coroutines.CoroutineScope diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/context/BuildContext.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/context/BuildContext.kt index 676d99b47..572b730ee 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/context/BuildContext.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/context/BuildContext.kt @@ -17,7 +17,7 @@ package com.lambda.interaction.construction.simulation.context -import com.lambda.config.blocks.ActionConfig +import com.lambda.config.settings.blocks.ActionConfig import com.lambda.context.Automated import com.lambda.interaction.construction.simulation.result.Drawable import com.lambda.interaction.managers.rotating.RotationRequest diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Contextual.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Contextual.kt index 9f25ed94f..f996a87a0 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Contextual.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Contextual.kt @@ -17,7 +17,7 @@ package com.lambda.interaction.construction.simulation.result -import com.lambda.config.blocks.ActionConfig +import com.lambda.config.settings.blocks.ActionConfig import com.lambda.interaction.construction.simulation.context.BreakContext import com.lambda.interaction.construction.simulation.context.BuildContext import com.lambda.interaction.construction.simulation.context.InteractContext diff --git a/src/main/kotlin/com/lambda/interaction/managers/ManagerUtils.kt b/src/main/kotlin/com/lambda/interaction/managers/ManagerUtils.kt index 7a26ca836..9a5f193bd 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/ManagerUtils.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/ManagerUtils.kt @@ -17,7 +17,7 @@ package com.lambda.interaction.managers -import com.lambda.util.getInstances +import com.lambda.util.ReflectionUtils.getInstances import net.minecraft.util.math.BlockPos object ManagerUtils { diff --git a/src/main/kotlin/com/lambda/interaction/managers/PacketLimitHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/PacketLimitHandler.kt index abb85a09b..d9d4ba6bb 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/PacketLimitHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/PacketLimitHandler.kt @@ -17,7 +17,7 @@ package com.lambda.interaction.managers -import com.lambda.config.blocks.BuildConfig +import com.lambda.config.settings.blocks.BuildConfig import com.lambda.context.Automated import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakInfo.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakInfo.kt index f9961c681..e36ce31f5 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakInfo.kt @@ -17,7 +17,7 @@ package com.lambda.interaction.managers.breaking -import com.lambda.config.blocks.BreakConfig +import com.lambda.config.settings.blocks.BreakConfig import com.lambda.context.SafeContext import com.lambda.interaction.construction.simulation.context.BreakContext import com.lambda.interaction.managers.ActionInfo diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt index 69a6ad905..cece5f5f6 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt @@ -17,6 +17,9 @@ package com.lambda.interaction.managers.breaking +import com.lambda.config.settings.blocks.BreakConfig +import com.lambda.config.settings.blocks.BreakConfig.BreakConfirmationMode +import com.lambda.config.settings.blocks.BreakConfig.BreakMode import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext import com.lambda.event.events.ConnectionEvent @@ -36,9 +39,6 @@ import com.lambda.interaction.managers.ManagerUtils.isPosBlocked import com.lambda.interaction.managers.PacketLimitHandler import com.lambda.interaction.managers.PacketType import com.lambda.interaction.managers.PositionBlocking -import com.lambda.config.settings.blocks.BreakConfig -import com.lambda.config.settings.blocks.BreakConfig.BreakConfirmationMode -import com.lambda.config.settings.blocks.BreakConfig.BreakMode import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Primary import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Rebreak import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.RedundantSecondary diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt index 863f88801..5bc31bf11 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt @@ -17,14 +17,14 @@ package com.lambda.interaction.managers.breaking -import com.lambda.config.automation.AutomationConfig.Companion.DEFAULT +import com.lambda.config.automation.AutomationConfig.Companion.Default +import com.lambda.config.settings.blocks.BreakConfig.BreakConfirmationMode import com.lambda.context.SafeContext import com.lambda.event.events.EntityEvent import com.lambda.event.events.WorldEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.construction.simulation.processing.ProcessorRegistry import com.lambda.interaction.managers.PostActionHandler -import com.lambda.config.blocks.BreakConfig.BreakConfirmationMode import com.lambda.interaction.managers.breaking.BreakManager.lastPosStarted import com.lambda.interaction.managers.breaking.BreakManager.matchesBlockItem import com.lambda.interaction.managers.breaking.RebreakHandler.rebreak @@ -51,7 +51,7 @@ import net.minecraft.util.math.ChunkSectionPos */ object BrokenBlockHandler : PostActionHandler() { override val pendingActions = LimitedDecayQueue( - DEFAULT.buildConfig.maxPendingActions, DEFAULT.buildConfig.actionTimeout * 50L + Default.buildConfig.maxPendingActions, Default.buildConfig.actionTimeout * 50L ) { info -> runSafe { val pos = info.context.blockPos diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakHandler.kt index e14d4fccd..e80fba20b 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/RebreakHandler.kt @@ -17,7 +17,7 @@ package com.lambda.interaction.managers.breaking -import com.lambda.config.blocks.BreakConfig +import com.lambda.config.settings.blocks.BreakConfig import com.lambda.context.SafeContext import com.lambda.event.events.ConnectionEvent import com.lambda.event.events.TickEvent diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/SwapInfo.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/SwapInfo.kt index 936973193..39850164a 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/SwapInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/SwapInfo.kt @@ -17,8 +17,8 @@ package com.lambda.interaction.managers.breaking -import com.lambda.config.automation.AutomationConfig.Companion.DEFAULT -import com.lambda.config.blocks.BreakConfig +import com.lambda.config.automation.AutomationConfig.Companion.Default +import com.lambda.config.settings.blocks.BreakConfig import com.lambda.context.Automated import com.lambda.context.SafeContext import com.lambda.interaction.managers.breaking.BreakInfo.BreakType.Primary @@ -31,7 +31,7 @@ import com.lambda.threading.runSafeAutomated */ data class SwapInfo( private val type: BreakInfo.BreakType, - private val automated: Automated = DEFAULT, + private val automated: Automated = Default, val swap: Boolean = false, val longSwap: Boolean = false ) : Automated by automated { diff --git a/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt index 5b8ed5be2..ef5b23eb9 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt @@ -17,12 +17,13 @@ package com.lambda.interaction.managers.hotbar +import com.lambda.config.settings.blocks.HotbarConfig +import com.lambda.config.settings.blocks.HotbarConfig.SwapMode import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.Manager -import com.lambda.config.blocks.HotbarConfig.SwapMode import com.lambda.interaction.managers.hotbar.HotbarManager.activeRequest import com.lambda.interaction.managers.hotbar.HotbarManager.activeSlot import com.lambda.interaction.managers.hotbar.HotbarManager.checkResetSwap diff --git a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractInfo.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractInfo.kt index b4e813267..7fbfe671b 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractInfo.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractInfo.kt @@ -17,7 +17,7 @@ package com.lambda.interaction.managers.interacting -import com.lambda.config.blocks.InteractConfig +import com.lambda.config.settings.blocks.InteractConfig import com.lambda.context.SafeContext import com.lambda.interaction.construction.simulation.context.BuildContext import com.lambda.interaction.construction.simulation.context.InteractContext diff --git a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt index 8fc257860..c98fee685 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractManager.kt @@ -17,7 +17,8 @@ package com.lambda.interaction.managers.interacting -import com.lambda.config.blocks.InteractConfig +import com.lambda.config.settings.blocks.InteractConfig +import com.lambda.config.settings.blocks.InteractConfig.AirPlaceMode import com.lambda.context.Automated import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext @@ -35,7 +36,6 @@ import com.lambda.interaction.managers.PacketType import com.lambda.interaction.managers.PositionBlocking import com.lambda.interaction.managers.breaking.BreakManager import com.lambda.interaction.managers.hotbar.HotbarRequest -import com.lambda.config.blocks.InteractConfig.AirPlaceMode import com.lambda.interaction.managers.interacting.InteractManager.activeRequest import com.lambda.interaction.managers.interacting.InteractManager.maxInteractionsThisTick import com.lambda.interaction.managers.interacting.InteractManager.populateFrom diff --git a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt index 819528088..c456b02ed 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt @@ -17,8 +17,8 @@ package com.lambda.interaction.managers.interacting -import com.lambda.config.automation.AutomationConfig.Companion.DEFAULT -import com.lambda.config.blocks.InteractConfig +import com.lambda.config.automation.AutomationConfig.Companion.Default +import com.lambda.config.settings.blocks.InteractConfig import com.lambda.event.events.WorldEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.PostActionHandler @@ -31,8 +31,8 @@ import com.lambda.util.collections.LimitedDecayQueue object InteractedBlockHandler : PostActionHandler() { override val pendingActions = LimitedDecayQueue( - DEFAULT.buildConfig.maxPendingActions, - DEFAULT.buildConfig.actionTimeout * 50L + Default.buildConfig.maxPendingActions, + Default.buildConfig.actionTimeout * 50L ) { if (verboseDebug) warn("${it::class.simpleName} at ${it.context.blockPos.toShortString()} timed out") if (it.interactConfig.interactConfirmationMode != InteractConfig.InteractConfirmationMode.AwaitThenPlace) { diff --git a/src/main/kotlin/com/lambda/interaction/managers/rotating/Rotation.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/Rotation.kt index 18f85a196..3da702a11 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/rotating/Rotation.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/Rotation.kt @@ -88,9 +88,9 @@ data class Rotation(val yaw: Double, val pitch: Double) { else -> 0.0f } - val ZERO = Rotation(0.0, 0.0) - val DOWN = Rotation(0.0, 90.0) - val UP = Rotation(0.0, -90.0) + val Zero = Rotation(0.0, 0.0) + val Down = Rotation(0.0, 90.0) + val Up = Rotation(0.0, -90.0) val Direction.rotation get() = Rotation(yaw.toDouble(), 0.0) var Entity.rotation get() = Rotation(yaw, pitch) diff --git a/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt index 8cdc035b4..a3b6c434a 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt @@ -30,6 +30,7 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.managers.Manager +import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest import com.lambda.interaction.managers.rotating.Rotation.Companion.slerpPitch import com.lambda.interaction.managers.rotating.Rotation.Companion.slerpYaw import com.lambda.interaction.managers.rotating.RotationManager.activeRotation @@ -69,9 +70,9 @@ object RotationManager : Manager( @JvmStatic val requests = mutableListOf(null, null) private var usingBaritoneRotation = false - @JvmStatic var activeRotation = Rotation.ZERO - @JvmStatic var serverRotation = Rotation.ZERO - @JvmStatic var prevServerRotation = Rotation.ZERO + @JvmStatic var activeRotation = Rotation.Zero + @JvmStatic var serverRotation = Rotation.Zero + @JvmStatic var prevServerRotation = Rotation.Zero private var changedThisTick = false @@ -120,7 +121,7 @@ object RotationManager : Manager( } listenUnsafe({ Int.MIN_VALUE }) { - reset(Rotation.ZERO) + reset(Rotation.Zero) } // Override user interactions with max priority diff --git a/src/main/kotlin/com/lambda/interaction/material/container/ContainerHandler.kt b/src/main/kotlin/com/lambda/interaction/material/container/ContainerHandler.kt index f5700ced4..fe48cdb86 100644 --- a/src/main/kotlin/com/lambda/interaction/material/container/ContainerHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/material/container/ContainerHandler.kt @@ -29,8 +29,8 @@ import com.lambda.interaction.material.StackSelection.Companion.select import com.lambda.interaction.material.container.containers.ChestContainer import com.lambda.interaction.material.container.containers.EnderChestContainer import com.lambda.util.BlockUtils.blockEntity +import com.lambda.util.ReflectionUtils.getInstances import com.lambda.util.extension.containerStacks -import com.lambda.util.getInstances import net.minecraft.block.entity.BlockEntity import net.minecraft.block.entity.ChestBlockEntity import net.minecraft.block.entity.EnderChestBlockEntity diff --git a/src/main/kotlin/com/lambda/module/Module.kt b/src/main/kotlin/com/lambda/module/Module.kt index d402076df..6ca912f2c 100644 --- a/src/main/kotlin/com/lambda/module/Module.kt +++ b/src/main/kotlin/com/lambda/module/Module.kt @@ -20,9 +20,9 @@ package com.lambda.module import com.lambda.command.LambdaCommand import com.lambda.config.Config import com.lambda.config.ConfigCategory +import com.lambda.config.SettingCore import com.lambda.config.automation.IMutableAutomationConfig import com.lambda.config.automation.MutableAutomationConfig -import com.lambda.config.SettingCore import com.lambda.config.categories.ModuleCategory import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress diff --git a/src/main/kotlin/com/lambda/module/ModuleRegistry.kt b/src/main/kotlin/com/lambda/module/ModuleRegistry.kt index 79e840a52..a8dc8cda7 100644 --- a/src/main/kotlin/com/lambda/module/ModuleRegistry.kt +++ b/src/main/kotlin/com/lambda/module/ModuleRegistry.kt @@ -28,6 +28,11 @@ object ModuleRegistry : Loadable { val moduleNameMap = modules.associateBy { it.name } - override fun load() = - "Loaded ${modules.size} modules with ${modules.sumOf { it.settingLayers.size }} settings" + override fun load(): String { + var settingCount = 0 + modules.forEach { module -> + module.forEachSetting { _, _ -> settingCount++ } + } + return "Loaded ${modules.size} modules with $settingCount settings" + } } diff --git a/src/main/kotlin/com/lambda/module/hud/Coordinates.kt b/src/main/kotlin/com/lambda/module/hud/Coordinates.kt index 200287b86..40f37ea86 100644 --- a/src/main/kotlin/com/lambda/module/hud/Coordinates.kt +++ b/src/main/kotlin/com/lambda/module/hud/Coordinates.kt @@ -19,7 +19,7 @@ package com.lambda.module.hud import com.lambda.config.Tab import com.lambda.config.applyEdits -import com.lambda.config.blocks.FormatterSettings +import com.lambda.config.settings.blocks.FormatterSettings import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag @@ -42,7 +42,7 @@ object Coordinates : HudModule( private val showCurrentDimensionOnly by setting("Show Current Dimension Only", true) private const val CurrentDimensionTab = "Current Dimension" - @Tab(CurrentDimensionTab) private val formatter = + @Tab(CurrentDimensionTab) private val formatter by settingBlock(FormatterSettings(this)) { applyEdits { ::timeFormat.edit { hide() } } } diff --git a/src/main/kotlin/com/lambda/module/hud/Rotation.kt b/src/main/kotlin/com/lambda/module/hud/Rotation.kt index 45d1f972b..e1cd83310 100644 --- a/src/main/kotlin/com/lambda/module/hud/Rotation.kt +++ b/src/main/kotlin/com/lambda/module/hud/Rotation.kt @@ -18,7 +18,7 @@ package com.lambda.module.hud import com.lambda.config.applyEdits -import com.lambda.config.blocks.FormatterSettings +import com.lambda.config.settings.blocks.FormatterSettings import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag @@ -31,7 +31,7 @@ object Rotation : HudModule( description = "Show your rotation", tag = ModuleTag.Hud, ) { - private val formatter = FormatterSettings(c = this,).apply { + private val formatter by settingBlock(FormatterSettings(this)) { applyEdits { ::timeFormat.edit { hide() } } diff --git a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt index 4a023f34c..1e4bc484d 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt @@ -18,8 +18,10 @@ package com.lambda.module.modules.chat import com.lambda.config.Config -import com.lambda.config.blocks.ReplaceConfig -import com.lambda.config.blocks.ReplaceConfig.ActionStrategy +import com.lambda.config.Group +import com.lambda.config.SettingBlock +import com.lambda.config.settings.blocks.ReplaceConfig +import com.lambda.config.settings.blocks.ReplaceConfig.ActionStrategy import com.lambda.event.events.ChatEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.friend.FriendHandler @@ -37,7 +39,6 @@ import com.lambda.util.text.DirectMessage import com.lambda.util.text.MessageParser import com.lambda.util.text.MessageType import net.minecraft.text.Text -import com.lambda.config.Group @Suppress("unused") object AntiSpam : Module( @@ -55,13 +56,13 @@ object AntiSpam : Module( private val ignoreSystem by setting("Ignore System", false) private val ignoreDms by setting("Ignore DMs", false) - @Group("Slurs") private val detectSlurs = settingBlock(ReplaceSettings("Slurs", this)) - @Group("Swears") private val detectSwears = settingBlock(ReplaceSettings("Swears", this)) - @Group("Sexual") private val detectSexual = settingBlock(ReplaceSettings("Sexual", this)) - @Group("Discord") private val detectDiscord = settingBlock(ReplaceSettings("Discord", this, ActionStrategy.Hide)) - @Group("Addresses") private val detectAddresses = settingBlock(ReplaceSettings("Addresses", this, ActionStrategy.Hide)) - @Group("Hex") private val detectHexBypass = settingBlock(ReplaceSettings("Hex", this, ActionStrategy.Hide)) - @Group("Colors") private val detectColors = settingBlock(ReplaceSettings("Colors", this, ActionStrategy.None)) + @Group("Slurs") private val detectSlurs by settingBlock(ReplaceSettings("Slurs", this)) + @Group("Swears") private val detectSwears by settingBlock(ReplaceSettings("Swears", this)) + @Group("Sexual") private val detectSexual by settingBlock(ReplaceSettings("Sexual", this)) + @Group("Discord") private val detectDiscord by settingBlock(ReplaceSettings("Discord", this, ActionStrategy.Hide)) + @Group("Addresses") private val detectAddresses by settingBlock(ReplaceSettings("Addresses", this, ActionStrategy.Hide)) + @Group("Hex") private val detectHexBypass by settingBlock(ReplaceSettings("Hex", this, ActionStrategy.Hide)) + @Group("Colors") private val detectColors by settingBlock(ReplaceSettings("Colors", this, ActionStrategy.None)) init { setModulePriority(100) @@ -122,9 +123,9 @@ object AntiSpam : Module( class ReplaceSettings( val name: String, override val c: Config, - val actionStrategy: ActionStrategy = ActionStrategy.Replace - ) : ReplaceConfig { - override val action by setting("$name Action Strategy", ActionStrategy.Replace) - override val replace by setting("$name Replace Strategy", ReplaceConfig.ReplaceStrategy.CensorAll) { action == ActionStrategy.Replace } + actionStrategy: ActionStrategy = ActionStrategy.Replace + ) : SettingBlock, ReplaceConfig { + override val action by c.setting("$name Action Strategy", actionStrategy) + override val replace by c.setting("$name Replace Strategy", ReplaceConfig.ReplaceStrategy.CensorAll) { action == ActionStrategy.Replace } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt b/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt index 88acad6f1..58a2974da 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt @@ -18,8 +18,8 @@ package com.lambda.module.modules.chat import com.lambda.config.applyEdits -import com.lambda.config.blocks.FormatterConfig -import com.lambda.config.blocks.FormatterSettings +import com.lambda.config.settings.blocks.FormatterConfig +import com.lambda.config.settings.blocks.FormatterSettings import com.lambda.event.events.ChatEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module @@ -46,13 +46,12 @@ object ChatTimestamp : Module( .onValueChange { from, to -> if (to.colorIndex !in 0..15) color = from } private val javaColor: Color get() = Color(color.colorValue!! and 16777215) - val formatter = - settingBlock(FormatterSettings(this)) { - applyEdits { - hide(::localeEnum, ::sep, ::customSep, ::floatingPrecision) - editTyped(::timeFormat) { defaultValue(FormatterConfig.Time.IsoLocalTime) } - } + val formatter by settingBlock(FormatterSettings(this)) { + applyEdits { + hide(::localeEnum, ::sep, ::customSep, ::floatingPrecision) + editTyped(::timeFormat) { defaultValue(FormatterConfig.Time.IsoLocalTime) } } + } private val currentTime get() = ZonedDateTime.of(LocalDateTime.now(), ZoneId.systemDefault()) diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt index 49a5a8e1e..b36d48018 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt @@ -97,7 +97,7 @@ object AutoArmor : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllBlocksExcept(inventoryConfig) + hideAllBlocksExcept(::inventoryConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt index 437d96828..83511caa1 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt @@ -57,7 +57,7 @@ object AutoTotem : Module( setModulePriority(100) setDefaultAutomationConfig { applyEdits { - hideAllBlocksExcept(inventoryConfig) + hideAllBlocksExcept(::inventoryConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt index bf481c77e..a23398b3d 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt @@ -20,7 +20,7 @@ package com.lambda.module.modules.combat import com.lambda.config.Tab import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig -import com.lambda.config.blocks.TargetingSettings +import com.lambda.config.settings.blocks.TargetingSettings import com.lambda.context.SafeContext import com.lambda.event.events.EntityEvent import com.lambda.event.events.TickEvent @@ -112,7 +112,7 @@ object CrystalAura : Module( @Tab(PredictionTab) private val placePredictions by setting("Place Predictions", 4, 1..20, 1) { prediction.onPlace } @Tab(PredictionTab) private val packetLifetime by setting("Packet Lifetime", 500L, 50L..1000L) { prediction.onPlace } - @Tab(PredictionTab) private val targetingSettings = settingBlock(TargetingSettings.CombatSettings(this, 10.0)) + @Tab(PredictionTab) private val targetingSettings by settingBlock(TargetingSettings.CombatSettings(this, 10.0)) private val blueprint = mutableMapOf() private var activeOpportunity: Opportunity? = null @@ -146,7 +146,7 @@ object CrystalAura : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllBlocksExcept(buildConfig, rotationConfig, hotbarConfig, inventoryConfig) + hideAllBlocksExcept(::buildConfig, ::rotationConfig, ::hotbarConfig, ::inventoryConfig) buildConfig.apply { hide( ::pathing, ::stayInRange, ::collectDrops, ::spleefEntities, diff --git a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt index b25d462ff..d3f59ab54 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt @@ -20,7 +20,7 @@ package com.lambda.module.modules.combat import com.lambda.config.Tab import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig -import com.lambda.config.blocks.TargetingSettings +import com.lambda.config.settings.blocks.TargetingSettings import com.lambda.context.SafeContext import com.lambda.event.events.InventoryEvent import com.lambda.event.events.TickEvent @@ -60,7 +60,7 @@ object KillAura : Module( @Tab(GeneralTab) private val hitDelay1 by setting("Hit Delay 1", 2.0, 0.0..20.0, 1.0) { attackMode == AttackMode.Delay } @Tab(GeneralTab) private val hitDelay2 by setting("Hit Delay 2", 6.0, 0.0..20.0, 1.0) { attackMode == AttackMode.Delay } - @Tab(TargetingTab) private val targetingSettings = settingBlock(TargetingSettings.CombatSettings(this)) + @Tab(TargetingTab) private val targetingSettings by settingBlock(TargetingSettings.CombatSettings(this)) val target: Entity? get() = targetingSettings.target() @@ -92,7 +92,7 @@ object KillAura : Module( setModulePriority(90) setDefaultAutomationConfig { applyEdits { - hideAllBlocksExcept(buildConfig, hotbarConfig, rotationConfig) + hideAllBlocksExcept(::buildConfig, ::hotbarConfig, ::rotationConfig) buildConfig.apply { hide( ::pathing, ::stayInRange, ::collectDrops, diff --git a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt index 74c5cb8b2..06d5bef93 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt @@ -63,7 +63,7 @@ object PlayerTrap : Module( ::collectDrops ) { defaultValue(false); hide() } } - hideBlock(eatConfig) + hideBlock(::eatConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt b/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt index e7ec8d375..fbf8d6099 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt @@ -53,7 +53,7 @@ object Surround : Module( ::collectDrops ) { defaultValue(false); hide() } } - hideBlock(eatConfig) + hideBlock(::eatConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt b/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt index 5d052d7ba..f4b543dac 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt @@ -18,10 +18,10 @@ package com.lambda.module.modules.debug import com.lambda.config.Tab -import com.lambda.config.blocks.ScreenLineSettings -import com.lambda.config.blocks.ScreenTextSettings -import com.lambda.config.blocks.WorldLineSettings -import com.lambda.config.blocks.WorldTextSettings +import com.lambda.config.settings.blocks.ScreenLineSettings +import com.lambda.config.settings.blocks.ScreenTextSettings +import com.lambda.config.settings.blocks.WorldLineSettings +import com.lambda.config.settings.blocks.WorldTextSettings import com.lambda.module.Module import com.lambda.module.tag.ModuleTag @@ -36,10 +36,10 @@ object SettingsTestModule : Module( private const val WorldTextTab = "World Text" private const val ScreenTextTab = "Screen Text" - @Tab(WorldLineTab) private val worldLineConfig = settingBlock(WorldLineSettings(this)) - @Tab(ScreenLineTab) private val screenLineConfig = settingBlock(ScreenLineSettings(this)) - @Tab(WorldTextTab) private val worldTextConfig = settingBlock(WorldTextSettings(this)) - @Tab(ScreenTextTab) private val textConfig = settingBlock(ScreenTextSettings(this)) + @Tab(WorldLineTab) private val worldLineConfig by settingBlock(WorldLineSettings(this)) + @Tab(ScreenLineTab) private val screenLineConfig by settingBlock(ScreenLineSettings(this)) + @Tab(WorldTextTab) private val worldTextConfig by settingBlock(WorldTextSettings(this)) + @Tab(ScreenTextTab) private val textConfig by settingBlock(ScreenTextSettings(this)) // private val renderer = ImmediateRenderer("SettingsTestRenderer") diff --git a/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt b/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt index 5f698fc63..15698f46e 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt @@ -17,7 +17,8 @@ package com.lambda.module.modules.debug -import com.lambda.config.blocks.HotbarSettings +import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.event.events.PlayerEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.hotbar.HotbarRequest @@ -30,9 +31,13 @@ object SilentSwap : Module( description = "SilentSwap", tag = ModuleTag.Debug, ) { - override val hotbarConfig = HotbarSettings(this) - init { + setDefaultAutomationConfig { + applyEdits { + hideAllBlocksExcept(::hotbarConfig) + } + } + listen { if (!HotbarRequest(0, this@SilentSwap).submit().done) { it.cancel() diff --git a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt index e07cb8aa3..ec61e9c43 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt @@ -19,8 +19,8 @@ package com.lambda.module.modules.movement import com.lambda.Lambda import com.lambda.Lambda.mc -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.context.SafeContext @@ -101,7 +101,7 @@ object BetterFirework : Module( setModulePriority(1) setDefaultAutomationConfig { applyEdits { - hideAllBlocksExcept(hotbarConfig, inventoryConfig) + hideAllBlocksExcept(::hotbarConfig, ::inventoryConfig) hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) } inventoryConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) } } diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt index 8883077b9..fc6fa0294 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt @@ -19,8 +19,8 @@ package com.lambda.module.modules.movement import com.lambda.config.Group import com.lambda.config.Tab -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest @@ -101,7 +101,7 @@ object ElytraAltitudeControl : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllBlocksExcept(rotationConfig) + hideAllBlocksExcept(::rotationConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt index f45624593..90c76c81d 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt @@ -18,8 +18,8 @@ package com.lambda.module.modules.movement import baritone.api.pathing.goals.GoalGetToBlock -import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.applyEdits +import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.context.SafeContext import com.lambda.event.events.ClientEvent import com.lambda.event.events.MovementEvent @@ -109,7 +109,7 @@ object ElytraFly : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllBlocksExcept(inventoryConfig, rotationConfig) + hideAllBlocksExcept(::inventoryConfig, ::rotationConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt index 584e3dd63..8dde3e613 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt @@ -50,7 +50,7 @@ object Speed : Module( ) { @JvmStatic val mode by setting("Mode", Mode.GrimStrafe) - .onValueChange { _, _ -> reset() } + .onValueChange { _, _ -> resetNcp() } // Grim private val diagonal by setting("Diagonal", true) { mode == Mode.GrimStrafe } @@ -83,13 +83,13 @@ object Speed : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllBlocksExcept(rotationConfig) + hideAllBlocksExcept(::rotationConfig) } } listen { if (!shouldWork()) { - reset() + resetNcp() return@listen } @@ -128,7 +128,7 @@ object Speed : Module( } onEnable { - reset() + resetNcp() } } @@ -200,7 +200,7 @@ object Speed : Module( } } - private fun reset() { + private fun resetNcp() { ncpPhase = NCPPhase.SlowDown ncpSpeed = NcpBaseSpeed } diff --git a/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt b/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt index 3c04c2b52..d93c482b2 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt @@ -19,7 +19,7 @@ package com.lambda.module.modules.player import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig -import com.lambda.config.blocks.EatConfig.Companion.reasonEating +import com.lambda.config.settings.blocks.EatConfig.Companion.reasonEating import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module @@ -40,7 +40,7 @@ object AutoEat : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllBlocksExcept(eatConfig) + hideAllBlocksExcept(::eatConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt index 8867636a8..c1bcdacff 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt @@ -40,7 +40,7 @@ object FastBreak : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllBlocksExcept(buildConfig, breakConfig, rotationConfig, hotbarConfig) + hideAllBlocksExcept(::buildConfig, ::breakConfig, ::rotationConfig, ::hotbarConfig) buildConfig.apply { hide( ::pathing, diff --git a/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt b/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt index b83d2cf40..00d3bf79b 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/InventoryMove.kt @@ -18,7 +18,7 @@ package com.lambda.module.modules.player import com.lambda.Lambda.mc -import com.lambda.config.blocks.RotationConfig +import com.lambda.config.settings.blocks.RotationConfig import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.gui.LambdaScreen @@ -52,7 +52,7 @@ object InventoryMove : Module( private val disableSneak by setting("Disable Sneak", false) private val arrowKeys by setting("Arrow Keys", false, "Allows rotating the players camera using the arrow keys") private val speed by setting("Rotation Speed", 5, 1..20, 1, unit = "°/tick") { arrowKeys } - override val rotationConfig = settingBlock(RotationConfig.Instant(this, RotationMode.Lock)) + override val rotationConfig = RotationConfig.Instant(RotationMode.Lock) @JvmStatic val shouldMove get() = isEnabled && !mc.currentScreen.hasInputOrNull diff --git a/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt b/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt index f0d77db39..fb50b107b 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt @@ -49,7 +49,7 @@ object InventoryTweaks : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllBlocksExcept(breakConfig, interactConfig, inventoryConfig, hotbarConfig) + hideAllBlocksExcept(::breakConfig, ::interactConfig, ::inventoryConfig, ::hotbarConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt index 41a76e373..c0573f8b8 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt @@ -20,7 +20,7 @@ package com.lambda.module.modules.player import com.lambda.config.Group import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig -import com.lambda.config.blocks.BreakConfig +import com.lambda.config.settings.blocks.BreakConfig import com.lambda.context.SafeContext import com.lambda.event.events.PlayerEvent import com.lambda.event.events.TickEvent @@ -99,7 +99,7 @@ object PacketMine : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllBlocksExcept(buildConfig, breakConfig, breakConfig.outlineConfig, rotationConfig, hotbarConfig) + hideAllBlocksExcept(::buildConfig, ::breakConfig, breakConfig::outlineConfig, ::rotationConfig, ::hotbarConfig) buildConfig.apply { hide( ::pathing, diff --git a/src/main/kotlin/com/lambda/module/modules/player/Replay.kt b/src/main/kotlin/com/lambda/module/modules/player/Replay.kt index 70f06a0e4..6d4c1e50e 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/Replay.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/Replay.kt @@ -26,7 +26,7 @@ import com.google.gson.JsonNull import com.google.gson.JsonSerializationContext import com.google.gson.JsonSerializer import com.lambda.brigadier.CommandResult -import com.lambda.config.blocks.RotationConfig +import com.lambda.config.settings.blocks.RotationConfig import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.context.SafeContext import com.lambda.core.TimerHandler @@ -103,7 +103,7 @@ object Replay : Module( private val deviationThreshold by setting("Deviation threshold", 0.1, 0.1..5.0, 0.1, description = "The threshold for the deviation to cancel the replay.") { cancelOnDeviation } private val lockCamera by setting("Lock Camera", true) - override val rotationConfig = object : RotationConfig.Instant(this, RotationMode.Sync) { + override val rotationConfig = object : RotationConfig.Instant(RotationMode.Sync) { override val rotationMode = if (lockCamera) RotationMode.Lock else RotationMode.Sync } diff --git a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt index 6cbe9f469..f1b87c3fb 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt @@ -45,7 +45,7 @@ object RotationLock : Module( setDefaultAutomationConfig { applyEdits { - hideAllBlocksExcept(rotationConfig) + hideAllBlocksExcept(::rotationConfig) rotationConfig::rotationMode.edit { defaultValue(RotationMode.Lock) } } } diff --git a/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt b/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt index 02126c1bf..7efa60c2f 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt @@ -43,7 +43,7 @@ object StackReplenish : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllBlocksExcept(inventoryConfig) + hideAllBlocksExcept(::inventoryConfig) inventoryConfig.apply { hide(::disposables, ::swapWithDisposables, ::providerPriority, ::storePriority) } diff --git a/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt b/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt index a51aecc52..0a2bee921 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt @@ -45,7 +45,7 @@ object ToolSaver : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllBlocksExcept(inventoryConfig) + hideAllBlocksExcept(::inventoryConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt b/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt index aae5d9465..26562c212 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt @@ -27,6 +27,7 @@ import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRend import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.BlockUtils.blockState +import com.lambda.util.ChatUtils.colors import com.lambda.util.extension.tickDelta import com.lambda.util.math.lerp import com.lambda.util.world.raycast.RayCastUtils.blockResult @@ -55,14 +56,13 @@ object BlockOutline : Module( @Group(BoxFillGroup) private val fillColor by setting("Fill Color", Color(255, 255, 255, 20)) { fill && mode == Mode.Boxes } @Group(BoxOutlineGroup) private val boxOutline by setting("Box Outline", true) { mode == Mode.Boxes } @Group(BoxOutlineGroup) private val boxOutlineColor by setting("Box Outline Color", Color(255, 255, 255, 120)) { boxOutline && mode == Mode.Boxes } - @Group(BoxOutlineGroup) private val lineConfig = - settingBlock( - WorldLineSettings(this), - { boxOutline && mode == Mode.Boxes } - ) { applyEdits { hide(::startColor, ::endColor) } } + @Group(BoxOutlineGroup) private val lineConfig by settingBlock( + WorldLineSettings(this), + { boxOutline && mode == Mode.Boxes } + ) { applyEdits { hide(::startColor, ::endColor) } } @Group(OutlineGroup) private val outlineColor by setting("Outline Color", boxOutlineColor) { mode == Mode.Outline } - @Group(OutlineGroup) private val outlineStyle = settingBlock(OutlineSettings(this), { mode == Mode.Outline }) + @Group(OutlineGroup) private val outlineStyle by settingBlock(OutlineSettings(this), { mode == Mode.Outline }) var previous: List? = null diff --git a/src/main/kotlin/com/lambda/module/modules/render/ESP.kt b/src/main/kotlin/com/lambda/module/modules/render/ESP.kt index 4461bcf9a..ea5a83f7e 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/ESP.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/ESP.kt @@ -20,15 +20,16 @@ package com.lambda.module.modules.render import com.lambda.config.Group import com.lambda.config.Tab import com.lambda.config.applyEdits -import com.lambda.config.blocks.EntityColorSettings -import com.lambda.config.blocks.EntitySelectionSettings -import com.lambda.config.blocks.OutlineSettings -import com.lambda.config.blocks.WorldLineSettings +import com.lambda.config.settings.blocks.EntityColorSettings +import com.lambda.config.settings.blocks.EntitySelectionSettings +import com.lambda.config.settings.blocks.OutlineSettings +import com.lambda.config.settings.blocks.WorldLineSettings import com.lambda.graphics.mc.RenderBuilder import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRenderer import com.lambda.graphics.util.DynamicAABB.Companion.interpolatedBox import com.lambda.module.Module import com.lambda.module.tag.ModuleTag +import com.lambda.util.ChatUtils.colors import com.lambda.util.NamedEnum import com.lambda.util.math.setAlpha import net.minecraft.block.entity.BlockEntity @@ -64,7 +65,7 @@ object ESP : Module( @Tab(GeneralTab) private val depthTest by setting("Depth Test", false, "Blend ESP renders into the world") //Shader Outline - @Tab(GeneralTab) private val outlineStyle = settingBlock(OutlineSettings(this), { mode == EspMode.Shader }) + @Tab(GeneralTab) private val outlineStyle by settingBlock(OutlineSettings(this), { mode == EspMode.Shader }) //Box @Tab(GeneralTab) private var drawFilled: Boolean by setting("Box Fill", true, "Fill entity boxes") { mode == EspMode.Box } @@ -73,14 +74,13 @@ object ESP : Module( @Tab(GeneralTab) @Group(BoxOutlineGroup) private var drawOutline: Boolean by setting("Box Outline", true, "Draw box outlines") { mode == EspMode.Box } .onValueChange { _, to -> if (!to && !drawFilled) drawFilled = true } @Tab(GeneralTab) @Group(BoxOutlineGroup) private val outlineAlpha by setting("Outline Alpha", 0.8, 0.0..1.0, 0.05) { mode == EspMode.Box && drawOutline } - @Tab(GeneralTab) @Group(BoxOutlineGroup) private val boxOutlineSettings = - settingBlock( - WorldLineSettings(this), - { mode == EspMode.Box && drawOutline } - ) { applyEdits { hide(::startColor, ::endColor) } } + @Tab(GeneralTab) @Group(BoxOutlineGroup) private val boxOutlineSettings by settingBlock( + WorldLineSettings(this), + { mode == EspMode.Box && drawOutline } + ) { applyEdits { hide(::startColor, ::endColor) } } - @Tab(EntitiesTab) private val entitySettings = EntitySelectionSettings(this) - @Tab(ColorsTab) private val entityColors = EntityColorSettings(this) + @Tab(EntitiesTab) private val entitySettings by settingBlock(EntitySelectionSettings(this)) + @Tab(ColorsTab) private val entityColors by settingBlock(EntityColorSettings(this)) init { immediateRenderer("EntityESP Immediate Renderer", depthTest = { depthTest }) { safeContext -> diff --git a/src/main/kotlin/com/lambda/module/modules/render/FreeLook.kt b/src/main/kotlin/com/lambda/module/modules/render/FreeLook.kt index 07323061a..b64587d97 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/FreeLook.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/FreeLook.kt @@ -38,7 +38,7 @@ object FreeLook : Module( @JvmStatic val enablePitch by setting("Enable Pitch", false, "Don't effect yaw if enabled") val togglePerspective by setting("Toggle Perspective", true, "Toggle perspective when enabling FreeLook") - var camera: Rotation = Rotation.ZERO + var camera: Rotation = Rotation.Zero var previousPerspective: Perspective = mc.options.perspective /** diff --git a/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt b/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt index ade2479f9..f63d72a36 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt @@ -94,7 +94,7 @@ object Freecam : Module( return prevPosition.interpolate(tickProgress, position) } - private var rotation: Rotation = Rotation.ZERO + private var rotation: Rotation = Rotation.Zero private var velocity: Vec3d = Vec3d.ZERO @JvmStatic @@ -126,7 +126,7 @@ object Freecam : Module( rotationConfig::rotationMode.edit { defaultValue(RotationMode.Lock) } - hideAllBlocksExcept(rotationConfig) + hideAllBlocksExcept(::rotationConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt b/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt index c66f1ea99..d718eb7df 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt @@ -19,7 +19,7 @@ package com.lambda.module.modules.render import com.lambda.config.Group import com.lambda.config.applyEdits -import com.lambda.config.blocks.WorldLineSettings +import com.lambda.config.settings.blocks.WorldLineSettings import com.lambda.context.SafeContext import com.lambda.graphics.mc.LineDashStyle import com.lambda.graphics.mc.RenderBuilder @@ -60,13 +60,12 @@ object LightLevels : Module( @Group(FillGroup) private val fill by setting("Fill", false) { renderMode == RenderMode.Square }.onValueChange(::refreshChunkedRenderer) @Group(FillGroup) private val fillAlpha by setting("Fill Alpha", 0.2, 0.0..1.0, 0.01) { renderMode == RenderMode.Square && fill }.onValueChange(::refreshChunkedRenderer) @Group(LineGroup) private val outline by setting("Outline", true) { renderMode == RenderMode.Square }.onValueChange(::refreshChunkedRenderer) - @Group(LineGroup) private val worldLineConfig = - settingBlock(WorldLineSettings(this), { renderMode != RenderMode.Square || outline }) { - applyEdits { - hide(::startColor, ::endColor) - forEachSetting { it.onValueChange(::refreshChunkedRenderer) } - } + @Group(LineGroup) private val worldLineConfig by settingBlock(WorldLineSettings(this), { renderMode != RenderMode.Square || outline }) { + applyEdits { + hide(::startColor, ::endColor) + forEachSetting { it.onValueChange(::refreshChunkedRenderer) } } + } private val depthTest by setting("Depth Test", false, "Shows renders through terrain") private val horizontalRange by setting("Horizontal Range", 16, 1..32) { mode == Mode.Radius } private val verticalRange by setting("Vertical Range", 8, 1..32) { mode == Mode.Radius } diff --git a/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt b/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt index 99470adee..b576e2c9f 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt @@ -21,8 +21,8 @@ import com.lambda.Lambda.mc import com.lambda.config.Group import com.lambda.config.Tab import com.lambda.config.applyEdits -import com.lambda.config.blocks.EntitySelectionSettings -import com.lambda.config.blocks.ScreenTextSettings +import com.lambda.config.settings.blocks.EntitySelectionSettings +import com.lambda.config.settings.blocks.ScreenTextSettings import com.lambda.friend.FriendHandler.isFriend import com.lambda.graphics.mc.RenderBuilder import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRenderer @@ -72,25 +72,22 @@ object Nametags : Module( @Tab(GeneralTab) private val itemCount by setting("Item Count", true) @Tab(GeneralTab) private val durabilityMode by setting("Durability Mode", DurabilityMode.Text) { gear } - @Tab(EntityTab) private val entitySelectionSettings = - settingBlock(EntitySelectionSettings(this)) { - applyEdits { - hide(::blockEntities) - } + @Tab(EntityTab) private val entitySelectionSettings by settingBlock(EntitySelectionSettings(this)) { + applyEdits { + hide(::blockEntities) } + } private const val FriendGroup = "Friends" private const val OtherGroup = "Others" - @Tab(TextTab) @Group(FriendGroup) private val friendTextConfig = - settingBlock(ScreenTextSettings(this)) { - applyEdits { - hide(::sizeSetting) - ::textColor.edit { defaultValue(Color(0, 255, 255, 255)) } - } + @Tab(TextTab) @Group(FriendGroup) private val friendTextConfig by settingBlock(ScreenTextSettings(this)) { + applyEdits { + hide(::sizeSetting) + ::textColor.edit { defaultValue(Color(0, 255, 255, 255)) } } - @Tab(TextTab) @Group(OtherGroup) private val otherTextConfig = - settingBlock(ScreenTextSettings(this)) { applyEdits { hide(::sizeSetting) } } + } + @Tab(TextTab) @Group(OtherGroup) private val otherTextConfig by settingBlock(ScreenTextSettings(this)) { applyEdits { hide(::sizeSetting) } } @Tab(BackgroundTab) private val background by setting("Background", true) @Tab(BackgroundTab) private val backgroundColor by setting("Background Color", Color(0, 0, 0, 60)) { background } diff --git a/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt b/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt index 058c19443..16310c730 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt @@ -19,7 +19,7 @@ package com.lambda.module.modules.render import com.lambda.config.Tab import com.lambda.config.applyEdits -import com.lambda.config.blocks.EntitySelectionSettings +import com.lambda.config.settings.blocks.EntitySelectionSettings import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.EntityUtils.createNameMap @@ -72,10 +72,9 @@ object NoRender : Module( // RenderLayer.getArmorEntityGlint(), RenderLayer.getGlint(), RenderLayer.getGlintTranslucent(), RenderLayer.getEntityGlint() // @JvmStatic val noEnchantmentGlint by setting("No Enchantment Glint", false).group(Group.Entity) // @JvmStatic val noDeadEntities by setting("No Dead Entities", false).group(Group.Entity) - @Tab(EntityTab) private val entitySettings = - settingBlock(EntitySelectionSettings(this)) { - applyEdits { editTyped(::playerEntities, ::mobEntities, ::bossEntities) { defaultValue(mutableSetOf()) } } - } + @Tab(EntityTab) private val entitySettings by settingBlock(EntitySelectionSettings(this)) { + applyEdits { editTyped(::playerEntities, ::mobEntities, ::bossEntities) { defaultValue(mutableSetOf()) } } + } @Tab(WorldTab) @JvmStatic val noTerrainFog by setting("No Terrain Fog", false) @Tab(WorldTab) @JvmStatic val noSignText by setting("No Sign Text", false) diff --git a/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt b/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt index 5b2894e20..b83ff7bef 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt @@ -19,7 +19,7 @@ package com.lambda.module.modules.render import com.lambda.config.Group import com.lambda.config.applyEdits -import com.lambda.config.blocks.WorldLineSettings +import com.lambda.config.settings.blocks.WorldLineSettings import com.lambda.context.SafeContext import com.lambda.graphics.mc.RenderBuilder import com.lambda.graphics.mc.renderer.ChunkedRenderer.Companion.chunkedRenderer @@ -28,6 +28,7 @@ import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe import com.lambda.util.BlockUtils.blockState +import com.lambda.util.ChatUtils.colors import com.lambda.util.math.setAlpha import com.lambda.util.world.toBlockPos import net.minecraft.block.Blocks @@ -54,16 +55,12 @@ object RadiusESP : Module( @Group(RenderGroup) private var outline: Boolean by setting("Outline", true).onValueChange(::rebuildMesh) .onValueChange { _, to -> if (!to) fill = true } @Group(RenderGroup) private val fillAlpha by setting("Fill Alpha", 0.1, 0.0..1.0, 0.01).onValueChange(::rebuildMesh) - @Group(RenderGroup, OutlineGroup) private val worldLineConfig = - settingBlock( - WorldLineSettings(this), - { outline } - ) { - applyEdits { - hide(::startColor, ::endColor) - forEachSetting { it.onValueChange(::rebuildMesh) } - } + @Group(RenderGroup, OutlineGroup) private val worldLineConfig by settingBlock(WorldLineSettings(this), { outline }) { + applyEdits { + hide(::startColor, ::endColor) + forEachSetting { it.onValueChange(::rebuildMesh) } } + } private val chunkedRenderer = chunkedRenderer("RadiusESP Chunked Renderer") { _, pos -> runSafe { diff --git a/src/main/kotlin/com/lambda/module/modules/render/Search.kt b/src/main/kotlin/com/lambda/module/modules/render/Search.kt index ab25be39d..40ea79baa 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Search.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Search.kt @@ -19,8 +19,8 @@ package com.lambda.module.modules.render import com.lambda.config.Group import com.lambda.config.applyEdits -import com.lambda.config.blocks.ScreenLineSettings -import com.lambda.config.blocks.WorldLineSettings +import com.lambda.config.settings.blocks.ScreenLineSettings +import com.lambda.config.settings.blocks.WorldLineSettings import com.lambda.config.settings.collections.CollectionSetting.Companion.onDeselect import com.lambda.config.settings.collections.CollectionSetting.Companion.onSelect import com.lambda.context.SafeContext @@ -85,28 +85,20 @@ object Search : Module( @Group(OutlineGroup) private val entityOutlineColor by setting("Entity Outline Color", Color(100, 150, 255, 128)) { outline && !useNaturalColor }.onValueChange(::rebuildMesh) @Group(OutlineGroup) private val blockOutlineMode by setting("Block Outline Mode", DirectionMask.OutlineMode.And, "Outline mode") { outline }.onValueChange(::rebuildMesh) - @Group(OutlineGroup) private val outlineConfig = - settingBlock( - WorldLineSettings(this), - { outline } - ) { - applyEdits { - hide(::startColor, ::endColor) - forEachSetting { it.onValueChange(::rebuildMesh) } - } + @Group(OutlineGroup) private val outlineConfig by settingBlock(WorldLineSettings(this), { outline }) { + applyEdits { + hide(::startColor, ::endColor) + forEachSetting { it.onValueChange(::rebuildMesh) } } + } @Group(TracersGroup) private val tracers by setting("Tracers", true, "Draw a line from your cursor to the highlighted position") - @Group(TracersGroup) private val tracerConfig = - settingBlock( - ScreenLineSettings(this), - { tracers } - ) { - applyEdits { - editTyped(::startColor, ::endColor) { - visibility { { !useNaturalColor } } - } + @Group(TracersGroup) private val tracerConfig by settingBlock(ScreenLineSettings(this), { tracers }) { + applyEdits { + editTyped(::startColor, ::endColor) { + visibility { { !useNaturalColor } } } } + } private val tracerBlockPositions = ConcurrentMap>>() diff --git a/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt b/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt index 73cbe28c2..306081ed2 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt @@ -20,9 +20,9 @@ package com.lambda.module.modules.render import com.lambda.config.Group import com.lambda.config.Tab import com.lambda.config.applyEdits -import com.lambda.config.blocks.EntityColorSettings -import com.lambda.config.blocks.EntitySelectionSettings -import com.lambda.config.blocks.ScreenLineSettings +import com.lambda.config.settings.blocks.EntityColorSettings +import com.lambda.config.settings.blocks.EntitySelectionSettings +import com.lambda.config.settings.blocks.ScreenLineSettings import com.lambda.friend.FriendHandler.isFriend import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRenderer import com.lambda.graphics.mc.renderer.RendererUtils.worldToScreenNormalized @@ -58,20 +58,17 @@ object Tracers : Module( private const val FriendsLineGroup = "Friends" private const val OthersLineGroup = "Others" - @Tab(GeneralTab) @Group(FriendsLineGroup) private val friendLineConfig = - settingBlock(ScreenLineSettings(this)) { - applyEdits { hide(::startColor, ::endColor) } - } - @Tab(GeneralTab) @Group(OthersLineGroup) private val otherLineConfig = - settingBlock(ScreenLineSettings(this)) { - applyEdits { hide(::startColor, ::endColor) } - } + @Tab(GeneralTab) @Group(FriendsLineGroup) private val friendLineConfig by settingBlock(ScreenLineSettings(this)) { + applyEdits { hide(::startColor, ::endColor) } + } + @Tab(GeneralTab) @Group(OthersLineGroup) private val otherLineConfig by settingBlock(ScreenLineSettings(this)) { + applyEdits { hide(::startColor, ::endColor) } + } - @Tab(EntityTab) private val entitySettings = - settingBlock(EntitySelectionSettings(this)) { - applyEdits { hide(::self, ::blockEntities) } - } - @Tab(ColorsTab) private val entityColors = settingBlock(EntityColorSettings(this)) + @Tab(EntityTab) private val entitySettings by settingBlock(EntitySelectionSettings(this)) { + applyEdits { hide(::self, ::blockEntities) } + } + @Tab(ColorsTab) private val entityColors by settingBlock(EntityColorSettings(this)) init { immediateRenderer("Tracers Immediate Renderer") { safeContext -> diff --git a/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt b/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt index 24e5c4dd1..e5acf170a 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt @@ -93,7 +93,7 @@ object AirPlace : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllBlocksExcept(interactConfig) + hideAllBlocksExcept(::interactConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt index fedc490b2..a06cf17f7 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt @@ -21,7 +21,7 @@ import baritone.api.pathing.goals.GoalBlock import com.lambda.config.Group import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig -import com.lambda.config.blocks.WorldLineSettings +import com.lambda.config.settings.blocks.WorldLineSettings import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.config.settings.complex.KeybindSetting.Companion.onRelease @@ -47,6 +47,7 @@ import com.lambda.task.tasks.BuildTask.Companion.build import com.lambda.util.BlockUtils.blockState import com.lambda.util.BlockUtils.isEmpty import com.lambda.util.BlockUtils.isNotEmpty +import com.lambda.util.ChatUtils.colors import com.lambda.util.PacketUtils.sendPacket import com.lambda.util.extension.blockColor import com.lambda.util.extension.tickDelta @@ -117,11 +118,10 @@ object AutoPortal : Module( @Group(RenderGroup) private val interpolate by setting("Interpolate", true, "Interpolates the portal renders from position to position") { renders } @Group(RenderGroup) private val depthTest by setting("Depth Test", false) { renders } @Group(RenderGroup, FillGroup) private val fillAlpha by setting("Fill Alpha", 0.3, 0.0..1.0, 0.01) { renders } - @Group(RenderGroup, OutlineGroup) private val outlineConfig = - settingBlock( - WorldLineSettings(this), - { renders } - ) { applyEdits { hide(::startColor, ::endColor) } } + @Group(RenderGroup, OutlineGroup) private val outlineConfig by settingBlock( + WorldLineSettings(this), + { renders } + ) { applyEdits { hide(::startColor, ::endColor) } } private var preview = false private var buildTask: Task<*>? = null @@ -129,7 +129,7 @@ object AutoPortal : Module( init { setDefaultAutomationConfig { applyEdits { - hideBlock(eatConfig) + hideBlock(::eatConfig) hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre, TickEvent.Input.Post)) } diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt index 613619ba2..5ffbfb892 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt @@ -94,7 +94,7 @@ object AutoVillagerCycle : Module( init { setDefaultAutomationConfig { applyEdits { - hideAllBlocksExcept(rotationConfig, inventoryConfig, breakConfig, interactConfig, buildConfig) + hideAllBlocksExcept(::rotationConfig, ::inventoryConfig, ::breakConfig, ::interactConfig, ::buildConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt b/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt index bf5801a7f..ec3e03a04 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt @@ -19,7 +19,7 @@ package com.lambda.module.modules.world import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig -import com.lambda.config.blocks.InteractConfig +import com.lambda.config.settings.blocks.InteractConfig import com.lambda.config.settings.complex.Bind import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent @@ -73,7 +73,7 @@ object Scaffold : Module( ::mean.edit { defaultValue(120.0) } ::spread.edit { defaultValue(0.0) } } - hideAllBlocksExcept(buildConfig, interactConfig, rotationConfig, hotbarConfig) + hideAllBlocksExcept(::buildConfig, ::interactConfig, ::rotationConfig, ::hotbarConfig) } } diff --git a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt index 1ad0c67ee..9c1914225 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt @@ -22,7 +22,7 @@ import com.lambda.Lambda.mc import com.lambda.config.Tab import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig -import com.lambda.config.blocks.InteractConfig +import com.lambda.config.settings.blocks.InteractConfig import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.context.SafeContext @@ -180,7 +180,7 @@ object StashMover : Module( buildConfig.apply { editTyped(::pathing, ::stayInRange, ::checkSideVisibility) { defaultValue(true) } hide(::pathing, ::stayInRange, ::collectDrops, ::spleefEntities, ::entityReach) - hideBlock(eatConfig) + hideBlock(::eatConfig) } interactConfig::airPlace.edit { defaultValue(InteractConfig.AirPlaceMode.None) } breakConfig.apply { diff --git a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt index 1e6943de2..d436a7f37 100644 --- a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt +++ b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt @@ -19,7 +19,7 @@ package com.lambda.task.tasks import baritone.api.pathing.goals.GoalBlock import com.lambda.Lambda.Log -import com.lambda.config.blocks.EatConfig.Companion.reasonEating +import com.lambda.config.settings.blocks.EatConfig.Companion.reasonEating import com.lambda.context.Automated import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext diff --git a/src/main/kotlin/com/lambda/task/tasks/EatTask.kt b/src/main/kotlin/com/lambda/task/tasks/EatTask.kt index e67320e33..6b5051ffb 100644 --- a/src/main/kotlin/com/lambda/task/tasks/EatTask.kt +++ b/src/main/kotlin/com/lambda/task/tasks/EatTask.kt @@ -17,8 +17,8 @@ package com.lambda.task.tasks -import com.lambda.config.blocks.EatConfig -import com.lambda.config.blocks.EatConfig.Companion.reasonEating +import com.lambda.config.settings.blocks.EatConfig +import com.lambda.config.settings.blocks.EatConfig.Companion.reasonEating import com.lambda.context.Automated import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent diff --git a/src/main/kotlin/com/lambda/task/tasks/OpenContainerTask.kt b/src/main/kotlin/com/lambda/task/tasks/OpenContainerTask.kt index b425561e7..48ce8c309 100644 --- a/src/main/kotlin/com/lambda/task/tasks/OpenContainerTask.kt +++ b/src/main/kotlin/com/lambda/task/tasks/OpenContainerTask.kt @@ -24,10 +24,10 @@ import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest -import com.lambda.interaction.managers.rotating.visibilty.lookAtBlock import com.lambda.task.Task import com.lambda.threading.runSafeAutomated import com.lambda.util.TickTimer +import com.lambda.util.player.RotationUtils.lookAtBlock import com.lambda.util.world.raycast.RayCastUtils.blockResult import net.minecraft.screen.ScreenHandler import net.minecraft.util.Hand diff --git a/src/main/kotlin/com/lambda/util/CommunicationUtils.kt b/src/main/kotlin/com/lambda/util/CommunicationUtils.kt index 821fbedac..9c6225756 100644 --- a/src/main/kotlin/com/lambda/util/CommunicationUtils.kt +++ b/src/main/kotlin/com/lambda/util/CommunicationUtils.kt @@ -207,7 +207,11 @@ object CommunicationUtils { literal( "Settings: ${ ConfigLoader.configCategories.sumOf { config -> - config.configs.sumOf { it.settingLayers.size } + config.configs.sumOf { + var count = 0 + it.forEachSetting { _, _ -> count++ } + count + } } }" ) diff --git a/src/main/kotlin/com/lambda/util/Diagnostics.kt b/src/main/kotlin/com/lambda/util/Diagnostics.kt index fffbdeac5..3eb7c9bd4 100644 --- a/src/main/kotlin/com/lambda/util/Diagnostics.kt +++ b/src/main/kotlin/com/lambda/util/Diagnostics.kt @@ -25,11 +25,12 @@ object Diagnostics { modules.filter { it.isEnabled } .forEach { module -> append("\t${module.name}") - module.settingLayers - .filter { it.isModified } - .forEach { setting -> - append("\t\t${setting.name} -> ${setting.value}") + module.forEachSetting { path, single -> + val setting = single.setting + if (setting.isModified) { + append("\t\t${path.joinToString(".", postfix = ".")}${setting.name} -> ${setting.value}") } + } } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/util/FormattingUtils.kt b/src/main/kotlin/com/lambda/util/FormattingUtils.kt index 1533e67a9..f88c9af5b 100644 --- a/src/main/kotlin/com/lambda/util/FormattingUtils.kt +++ b/src/main/kotlin/com/lambda/util/FormattingUtils.kt @@ -17,7 +17,7 @@ package com.lambda.util -import com.lambda.config.blocks.FormatterConfig +import com.lambda.config.settings.blocks.FormatterConfig import com.lambda.util.math.Vec2d import net.minecraft.util.math.Vec2f import net.minecraft.util.math.Vec3d diff --git a/src/main/kotlin/com/lambda/util/player/PlayerUtils.kt b/src/main/kotlin/com/lambda/util/player/PlayerUtils.kt index 1a986ebce..10f15edc5 100644 --- a/src/main/kotlin/com/lambda/util/player/PlayerUtils.kt +++ b/src/main/kotlin/com/lambda/util/player/PlayerUtils.kt @@ -17,7 +17,7 @@ package com.lambda.util.player -import com.lambda.config.blocks.BuildConfig +import com.lambda.config.settings.blocks.BuildConfig import com.lambda.context.SafeContext import com.lambda.util.world.fastEntitySearch import net.minecraft.client.network.ClientPlayerEntity diff --git a/src/main/kotlin/com/lambda/util/world/raycast/RayCastUtils.kt b/src/main/kotlin/com/lambda/util/world/raycast/RayCastUtils.kt index 599186cb9..e126f5689 100644 --- a/src/main/kotlin/com/lambda/util/world/raycast/RayCastUtils.kt +++ b/src/main/kotlin/com/lambda/util/world/raycast/RayCastUtils.kt @@ -72,7 +72,7 @@ object RayCastUtils { // ToDo: Should rather move player hitbox down and check collision fun SafeContext.distanceToGround(maxDist: Double = 100.0): Double { val pos = player.pos.add(0.0, 0.1, 0.0) - val cast = Rotation.DOWN.rayCast(maxDist, pos, false, InteractionMask.Block) ?: return maxDist + val cast = Rotation.Down.rayCast(maxDist, pos, false, InteractionMask.Block) ?: return maxDist return max(0.0, pos.y - cast.pos.y) } diff --git a/src/test/kotlin/RotationTest.kt b/src/test/kotlin/RotationTest.kt index f57a3c33e..6fa33a311 100644 --- a/src/test/kotlin/RotationTest.kt +++ b/src/test/kotlin/RotationTest.kt @@ -130,14 +130,14 @@ class RotationTest { @Test fun `test companion object constants`() { - assertEquals(0.0, Rotation.ZERO.yaw) - assertEquals(0.0, Rotation.ZERO.pitch) + assertEquals(0.0, Rotation.Zero.yaw) + assertEquals(0.0, Rotation.Zero.pitch) - assertEquals(0.0, Rotation.DOWN.yaw) - assertEquals(90.0, Rotation.DOWN.pitch) + assertEquals(0.0, Rotation.Down.yaw) + assertEquals(90.0, Rotation.Down.pitch) - assertEquals(0.0, Rotation.UP.yaw) - assertEquals(-90.0, Rotation.UP.pitch) + assertEquals(0.0, Rotation.Up.yaw) + assertEquals(-90.0, Rotation.Up.pitch) } @Test From f7760d407485949fd26681df64fdb64c744c343c Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Tue, 12 May 2026 21:29:04 +0100 Subject: [PATCH 12/40] compiles but no baritone settings --- .../com/lambda/mixin/CrashReportMixin.java | 18 ++-- .../lambda/command/commands/ConfigCommand.kt | 6 +- .../config/{ConfigEditor.kt => BaseEditor.kt} | 90 +++++++++++++------ src/main/kotlin/com/lambda/config/Config.kt | 56 ++++++++---- .../com/lambda/config/ConfigCategory.kt | 11 +-- .../config/automation/AutomationConfig.kt | 31 ++++--- .../config/categories/AutomationCategory.kt | 7 +- .../lambda/config/categories/FontCategory.kt | 7 +- .../config/categories/FriendCategory.kt | 7 +- .../lambda/config/categories/GuiCategory.kt | 7 +- .../lambda/config/categories/HudCategory.kt | 7 +- .../config/categories/LambdaCategory.kt | 7 +- .../config/categories/ModuleCategory.kt | 7 +- .../config/categories/SecretsCategory.kt | 7 +- .../categories/UserAutomationCategory.kt | 7 +- .../lambda/config/settings/NumericSetting.kt | 8 +- .../lambda/config/settings/StringSetting.kt | 6 +- .../config/settings/blocks/BreakSettings.kt | 7 +- .../config/settings/blocks/EatSettings.kt | 2 +- .../settings/blocks/InventorySettings.kt | 2 +- .../settings/collections/CollectionSetting.kt | 4 +- .../com/lambda/interaction/BaritoneHandler.kt | 2 +- 22 files changed, 211 insertions(+), 95 deletions(-) rename src/main/kotlin/com/lambda/config/{ConfigEditor.kt => BaseEditor.kt} (64%) diff --git a/src/main/java/com/lambda/mixin/CrashReportMixin.java b/src/main/java/com/lambda/mixin/CrashReportMixin.java index 60ef27a3e..e41d2f218 100644 --- a/src/main/java/com/lambda/mixin/CrashReportMixin.java +++ b/src/main/java/com/lambda/mixin/CrashReportMixin.java @@ -18,12 +18,12 @@ package com.lambda.mixin; import com.lambda.Lambda; -import com.lambda.config.Setting; import com.lambda.module.Module; import com.lambda.module.ModuleRegistry; import com.lambda.util.DynamicExceptionKt; import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import kotlin.Unit; import net.minecraft.client.MinecraftClient; import net.minecraft.util.crash.CrashReport; import net.minecraft.util.crash.ReportType; @@ -65,10 +65,18 @@ String injectString(ReportType type, List extraInfo, Operation o .forEach(module -> { list.add(String.format("\t%s", module.getName())); - module.getSettingLayers() - .stream() - .filter(Setting::isModified) - .forEach(setting -> list.add(String.format("\t\t%s -> %s", setting.getName(), setting.getValue()))); + module.forEachSetting$lambda( + module.getSettingLayers$lambda(), + true, + null, + (path, single) -> { + final var setting = single.getSetting(); + if (setting.isModified()) { + list.add("\t\t" + String.join(".", path) + "." + setting.getName() + " -> " + setting.getValue()); + } + return Unit.INSTANCE; + } + ); }); } diff --git a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt index baadcbdca..b8cf6355c 100644 --- a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt @@ -93,7 +93,7 @@ object ConfigCommand : LambdaCommand( fun forEach(layer: SettingLayer.Multiple, layerPath: List) { layer.layers.forEach { layer -> when (layer) { - is SettingLayer.Single<*, *> -> suggestions.add("${layerPath.joinToString(".")}.${layer.setting.name}") + is SettingLayer.Single<*, *> -> suggestions.add("${layerPath.joinToString("->")}->${layer.setting.commandName}") is SettingLayer.Multiple -> forEach(layer, layerPath + layer.name) } } @@ -106,7 +106,7 @@ object ConfigCommand : LambdaCommand( val configString = configArg().value() val config = ConfigLoader.configByCommandName(configString) ?: return@executeWithResult failure("Config not found") val settingString = settingArg().value() - val fullPath = settingString.split(".") + val fullPath = settingString.split("->") val settingName = fullPath.last() var currentLayer: SettingLayer.Multiple = config.settingLayers fullPath.forEachIndexed { index, layerName -> @@ -122,7 +122,7 @@ object ConfigCommand : LambdaCommand( val settingLayer = currentLayer.layers .asSequence() .filterIsInstance>() - .find { it.setting.name == settingName } + .find { it.setting.commandName == settingName } if (settingLayer == null) return@executeWithResult failure("Setting not found: $settingName") return@executeWithResult block(settingLayer) } diff --git a/src/main/kotlin/com/lambda/config/ConfigEditor.kt b/src/main/kotlin/com/lambda/config/BaseEditor.kt similarity index 64% rename from src/main/kotlin/com/lambda/config/ConfigEditor.kt rename to src/main/kotlin/com/lambda/config/BaseEditor.kt index 8e63a8432..c0f7c0212 100644 --- a/src/main/kotlin/com/lambda/config/ConfigEditor.kt +++ b/src/main/kotlin/com/lambda/config/BaseEditor.kt @@ -28,14 +28,63 @@ import kotlin.reflect.jvm.isAccessible annotation class SettingEditorDsl @SettingEditorDsl +context(configEditContext: EditContext.ConfigEditContext) fun Config.applyEdits(edits: ConfigEditor.() -> Unit) { ConfigEditor(this).apply(edits) } -open class ConfigEditor(val c: Config) { - private typealias Property = KProperty0 - private typealias SettingProperty = KProperty0 - private typealias SettingBlockProperty = KProperty0 +@SettingEditorDsl +context(blockEditContext: EditContext.BlockEditContext) +fun Config.applyEdits(edits: BlockEditor.() -> Unit) { + BlockEditor(this, blockEditContext.block).apply(edits) +} + +sealed class EditContext { + class ConfigEditContext internal constructor() : EditContext() + class BlockEditContext internal constructor(internal val block: SettingBlockWrapper<*>) : EditContext() +} + +class ConfigEditor internal constructor(private val c: Config) : BaseEditor() { + @SettingEditorDsl + fun forEachSetting(block: (Setting<*, *>) -> Unit) { + c.forEachSetting { _, single -> block(single.setting) } + } + + @SettingEditorDsl + fun hideAllBlocksExcept(vararg except: SettingBlockProperty) { + val exceptBlocks = except.map { it.settingBlock.layer } + fun processBlock(blockLayer: BlockLayer) { + blockLayer.layers.forEach(::processBlock) + if (blockLayer !in exceptBlocks) blockLayer.settingLayers.forEach(::hide) + } + processBlock(c.settingBlockLayers) + } +} + +class BlockEditor internal constructor( + private val c: Config, + val wrapper: SettingBlockWrapper<*> +) : BaseEditor() { + @SettingEditorDsl + fun forEachSetting(block: (Setting<*, *>) -> Unit) { + c.forEachSettingBlock(wrapper.layer) { _, single -> block(single.setting) } + } + + @SettingEditorDsl + fun hideAllBlocksExcept(vararg except: SettingBlockProperty) { + val exceptBlocks = except.map { it.settingBlock.layer } + fun processBlock(blockLayer: BlockLayer) { + blockLayer.layers.forEach(::processBlock) + if (blockLayer !in exceptBlocks) blockLayer.settingLayers.forEach(::hide) + } + processBlock(wrapper.layer) + } +} + +open class BaseEditor internal constructor() { + protected typealias Property = KProperty0 + protected typealias SettingProperty = KProperty0 + protected typealias SettingBlockProperty = KProperty0 private val Property<*>.delegate get() = try { @@ -44,33 +93,31 @@ open class ConfigEditor(val c: Config) { throw IllegalStateException("Could not access delegate for property $name", e) } - private val SettingProperty.setting + protected val SettingProperty.setting get() = this.delegate as? Setting, T> ?: throw IllegalStateException("Setting delegate did not match the given type") - private val SettingBlockProperty.settingBlock + protected val SettingBlockProperty.settingBlock get() = this.delegate as? SettingBlockWrapper ?: throw IllegalStateException("SettingBlock delegate did not match the given type") - private fun SettingProperty.settingCore() = setting.core - @SettingEditorDsl fun SettingProperty.edit(edits: TypedEditBuilder.(SettingCore) -> Unit) { val delegate = setting - TypedEditBuilder(c, listOf(delegate)).edits(delegate.core) + TypedEditBuilder(listOf(delegate)).edits(delegate.core) } @SettingEditorDsl fun edit( vararg settings: SettingProperty, edits: BasicEditBuilder.() -> Unit - ) = BasicEditBuilder(c, settings.map { it.setting }).apply(edits) + ) = BasicEditBuilder(settings.map { it.setting }).apply(edits) @SettingEditorDsl fun editTyped( vararg settings: SettingProperty, edits: TypedEditBuilder.() -> Unit - ) = TypedEditBuilder(c, settings.map { it.setting }).apply(edits) + ) = TypedEditBuilder(settings.map { it.setting }).apply(edits) @SettingEditorDsl fun hide(vararg settings: SettingProperty) = @@ -93,21 +140,9 @@ open class ConfigEditor(val c: Config) { } } - @SettingEditorDsl - fun hideAllBlocksExcept(vararg except: SettingBlockProperty) { - val exceptBlocks = except.map { it.settingBlock.layer } - fun processBlock(blockLayer: BlockLayer.Block) { - blockLayer.layers.forEach(::processBlock) - if (blockLayer !in exceptBlocks) blockLayer.settingLayers.forEach(::hide) - } - - c.settingBlockLayers.layers.forEach(::processBlock) - } - - open class BasicEditBuilder( - c: Config, + open class BasicEditBuilder internal constructor( open val settings: Collection> - ) : ConfigEditor(c) { + ) : BaseEditor() { @SettingEditorDsl fun hide() { settings.forEach { @@ -123,10 +158,9 @@ open class ConfigEditor(val c: Config) { } } - class TypedEditBuilder( - c: Config, + class TypedEditBuilder internal constructor( override val settings: Collection, T>> - ) : BasicEditBuilder(c, settings) { + ) : BasicEditBuilder(settings) { @SettingEditorDsl fun defaultValue(value: T) = settings.forEach { diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index 5d6f70615..c98176a9a 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -115,12 +115,36 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { onSetting: (property: KProperty<*>) -> Unit = {}, onSettingBlock: (property: KProperty<*>, blockClass: KClass<*>) -> Unit = { _, _ -> } ) { - klass.declaredMemberProperties.forEach { property -> - val fieldType = property.javaField?.type ?: return@forEach - when { - Setting::class.java.isAssignableFrom(fieldType) -> onSetting(property) - SettingBlock::class.java.isAssignableFrom(fieldType) -> onSettingBlock(property, fieldType.kotlin) + val hierarchy = buildList { + var current: KClass<*>? = klass + while (current != null && current != Config::class && current != Any::class) { + add(current) + current = current.supertypes + .mapNotNull { it.classifier as? KClass<*> } + .firstOrNull { !it.java.isInterface } } + }.reversed() + + hierarchy.forEach { level -> + val fieldOrder = level.java.declaredFields + .withIndex() + .associate { (index, field) -> field.name to index } + + level.declaredMemberProperties + .sortedBy { + val javaField = it.javaField ?: return@sortedBy Int.MAX_VALUE + fieldOrder[javaField.name] ?: Int.MAX_VALUE + } + .forEach { property -> + val fieldType = property.javaField?.type ?: return@forEach + when { + Setting::class.java.isAssignableFrom(fieldType) -> onSetting(property) + SettingBlockWrapper::class.java.isAssignableFrom(fieldType) -> { + val blockClass = property.returnType.classifier as? KClass<*> + if (blockClass != null) onSettingBlock(property, blockClass) + } + } + } } } @@ -403,10 +427,9 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { fun settingBlock( settingBlock: T, visibility: (() -> Boolean)? = null, - block: (T.() -> Unit)? = null + block: (context(EditContext.BlockEditContext) T.() -> Unit)? = null ): SettingBlockWrapper = settingBlock - .apply { block?.invoke(this) } .let { settingBlock -> val path = try { registrationQueue.removeFirst().settingBlockSpecs @@ -426,16 +449,17 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { } } - if (visibility != null) { - currentLayer.settingLayers.forEach { settingLayer -> - val setting = settingLayer.setting - setting.visibility = { setting.visibility() && visibility() } + SettingBlockWrapper(settingBlock, currentLayer) + .also { wrapper -> + (currentLayer as? BlockLayer.Block)?.settingBlock = wrapper + } + .also { wrapper -> + if (block != null) { + with (EditContext.BlockEditContext(wrapper)) { + settingBlock.block() + } + } } - } - - SettingBlockWrapper(settingBlock, currentLayer).also { wrapper -> - (currentLayer as? BlockLayer.Block)?.settingBlock = wrapper - } } @PublishedApi diff --git a/src/main/kotlin/com/lambda/config/ConfigCategory.kt b/src/main/kotlin/com/lambda/config/ConfigCategory.kt index 34dc48b90..707906d37 100644 --- a/src/main/kotlin/com/lambda/config/ConfigCategory.kt +++ b/src/main/kotlin/com/lambda/config/ConfigCategory.kt @@ -26,7 +26,6 @@ import com.lambda.Lambda.Log import com.lambda.Lambda.gson import com.lambda.config.ConfigLoader.configByName import com.lambda.config.ConfigLoader.configCategories -import com.lambda.config.categories.AutomationCategory import com.lambda.config.categories.ModuleCategory import com.lambda.config.migration.ConfigMigrations import com.lambda.core.Loadable @@ -39,7 +38,6 @@ import com.lambda.util.CommunicationUtils.logError import com.lambda.util.FileUtils.createIfNotExists import com.lambda.util.FileUtils.ifExists import com.lambda.util.FileUtils.ifNotExists -import com.lambda.util.FolderRegistry import com.lambda.util.StringUtils.capitalize import java.io.File import kotlin.concurrent.fixedRateTimer @@ -59,11 +57,10 @@ import kotlin.time.Duration.Companion.minutes * @property primary The primary file where the configuration is saved. * @property configs A set of [Config] objects that this configuration manages. */ -abstract class ConfigCategory( - val configName: String -) : Jsonable, Loadable { - val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() - private val backup = File("${primaryFile.parent}/${primaryFile.nameWithoutExtension}-backup.${primaryFile.extension}") +abstract class ConfigCategory : Jsonable, Loadable { + abstract val configName: String + abstract val primaryFile: File + private val backup get() = File("${primaryFile.parent}/${primaryFile.nameWithoutExtension}-backup.${primaryFile.extension}") override val priority = 1 val configs = mutableSetOf() diff --git a/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt index aa70fa577..d4d36314e 100644 --- a/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt @@ -19,6 +19,7 @@ package com.lambda.config.automation import com.lambda.config.Config import com.lambda.config.ConfigCategory +import com.lambda.config.EditContext.ConfigEditContext import com.lambda.config.Tab import com.lambda.config.categories.AutomationCategory import com.lambda.config.settings.blocks.BreakSettings @@ -36,13 +37,13 @@ open class AutomationConfig( override val name: String, configCategory: ConfigCategory = AutomationCategory ) : Config(configCategory), Automated { - @Tab(BuildTab) override val buildConfig = BuildSettings(this) - @Tab(BreakTab) override val breakConfig = BreakSettings(this) - @Tab(InteractTab) override val interactConfig = InteractSettings(this) - @Tab(RotationTab) override val rotationConfig = RotationSettings(this) - @Tab(InventoryTab) override val inventoryConfig = InventorySettings(this) - @Tab(HotbarTab) override val hotbarConfig = HotbarSettings(this) - @Tab(EatTab) override val eatConfig = EatSettings(this) + @Tab(BuildTab) override val buildConfig by settingBlock(BuildSettings(this)) + @Tab(BreakTab) override val breakConfig by settingBlock(BreakSettings(this)) + @Tab(InteractTab) override val interactConfig by settingBlock(InteractSettings(this)) + @Tab(RotationTab) override val rotationConfig by settingBlock(RotationSettings(this)) + @Tab(InventoryTab) override val inventoryConfig by settingBlock(InventorySettings(this)) + @Tab(HotbarTab) override val hotbarConfig by settingBlock(HotbarSettings(this)) + @Tab(EatTab) override val eatConfig by settingBlock(EatSettings(this)) companion object { private const val BuildTab = "Build" @@ -56,13 +57,21 @@ open class AutomationConfig( context(module: Module) fun IMutableAutomationConfig.setDefaultAutomationConfig( name: String = module.name, - edits: (AutomationConfig.() -> Unit)? = null - ) { this.defaultAutomationConfig = AutomationConfig("$name Automation Config").apply { edits?.invoke(this) } } + edits: (context (ConfigEditContext) AutomationConfig.() -> Unit)? = null + ) { + this.defaultAutomationConfig = AutomationConfig("$name Automation Config").also { + if (edits != null) with(ConfigEditContext()) { it.edits() } + } + } fun IMutableAutomationConfig.setDefaultAutomationConfig( name: String, - edits: (AutomationConfig.() -> Unit)? = null - ) { defaultAutomationConfig = AutomationConfig("$name Automation Config").apply { edits?.invoke(this) } } + edits: (context(ConfigEditContext) AutomationConfig.() -> Unit)? = null + ) { + defaultAutomationConfig = AutomationConfig("$name Automation Config").also { + if (edits != null) with(ConfigEditContext()) { it.edits() } + } + } val Default = AutomationConfig("Default") } diff --git a/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt b/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt index bc334e2bf..f3b1a0cd3 100644 --- a/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt @@ -18,5 +18,10 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory +import com.lambda.util.FolderRegistry +import java.io.File -object AutomationCategory : ConfigCategory("automation") \ No newline at end of file +object AutomationCategory : ConfigCategory() { + override val configName = "automation" + override val primaryFile: File = FolderRegistry.config.resolve("${configName}.json").toFile() +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/FontCategory.kt b/src/main/kotlin/com/lambda/config/categories/FontCategory.kt index b94643318..3a2e65634 100644 --- a/src/main/kotlin/com/lambda/config/categories/FontCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/FontCategory.kt @@ -18,5 +18,10 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory +import com.lambda.util.FolderRegistry +import java.io.File -object FontCategory : ConfigCategory("font") \ No newline at end of file +object FontCategory : ConfigCategory() { + override val configName get() = "font" + override val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt b/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt index 77de146f7..16f6298ed 100644 --- a/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt @@ -18,5 +18,10 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory +import com.lambda.util.FolderRegistry +import java.io.File -object FriendCategory : ConfigCategory("friends") +object FriendCategory : ConfigCategory() { + override val configName get() = "friends" + override val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() +} diff --git a/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt b/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt index a690752a2..656ad21f7 100644 --- a/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt @@ -18,5 +18,10 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory +import com.lambda.util.FolderRegistry +import java.io.File -object GuiCategory : ConfigCategory("gui") +object GuiCategory : ConfigCategory() { + override val configName get() = "gui" + override val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() +} diff --git a/src/main/kotlin/com/lambda/config/categories/HudCategory.kt b/src/main/kotlin/com/lambda/config/categories/HudCategory.kt index 92f8bd4bd..8b8abdc64 100644 --- a/src/main/kotlin/com/lambda/config/categories/HudCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/HudCategory.kt @@ -18,5 +18,10 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory +import com.lambda.util.FolderRegistry +import java.io.File -object HudCategory : ConfigCategory("hud") \ No newline at end of file +object HudCategory : ConfigCategory() { + override val configName get() = "hud" + override val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt b/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt index 797c80898..10e85eac3 100644 --- a/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt @@ -18,5 +18,10 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory +import com.lambda.util.FolderRegistry +import java.io.File -object LambdaCategory : ConfigCategory("lambda") \ No newline at end of file +object LambdaCategory : ConfigCategory() { + override val configName get() = "lambda" + override val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt b/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt index 1d33f2165..ce2b9bd5b 100644 --- a/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt @@ -18,6 +18,8 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory +import com.lambda.util.FolderRegistry +import java.io.File /** * The [ModuleCategory] object represents the configuration file for the [Module]s. @@ -27,4 +29,7 @@ import com.lambda.config.ConfigCategory * @property configName The name of the configuration. * @property primary The primary file where the configuration is saved. */ -object ModuleCategory : ConfigCategory("modules") \ No newline at end of file +object ModuleCategory : ConfigCategory() { + override val configName get() = "modules" + override val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt b/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt index 20c833bae..4636d2aac 100644 --- a/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt @@ -18,5 +18,10 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory +import com.lambda.util.FolderRegistry +import java.io.File -object SecretsCategory : ConfigCategory("secrets") \ No newline at end of file +object SecretsCategory : ConfigCategory() { + override val configName get() = "secrets" + override val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt b/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt index 532cf0a41..0cfdb6c16 100644 --- a/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt @@ -22,8 +22,13 @@ import com.lambda.config.ConfigCategory import com.lambda.config.automation.UserAutomationConfig import com.lambda.module.ModuleRegistry.moduleNameMap import com.lambda.util.FileUtils.ifExists +import com.lambda.util.FolderRegistry +import java.io.File + +object UserAutomationCategory : ConfigCategory() { + override val configName get() = "custom_automation" + override val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() -object UserAutomationCategory : ConfigCategory("custom-automation") { override fun internalTryLoad() { primaryFile.ifExists { JsonParser.parseReader(it.reader()).asJsonObject.entrySet().forEach { (name, _) -> diff --git a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt index b095cb288..809775a84 100644 --- a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt @@ -18,7 +18,7 @@ package com.lambda.config.settings import com.google.gson.reflect.TypeToken -import com.lambda.config.ConfigEditor +import com.lambda.config.BaseEditor import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.config.SettingEditorDsl @@ -98,19 +98,19 @@ abstract class NumericSetting( companion object { @SettingEditorDsl @Suppress("unchecked_cast") - fun ConfigEditor.TypedEditBuilder.range(range: ClosedRange) where T : Number, T : Comparable { + fun BaseEditor.TypedEditBuilder.range(range: ClosedRange) where T : Number, T : Comparable { (settings as Collection>).forEach { it.range = range } } @SettingEditorDsl @Suppress("unchecked_cast") - fun ConfigEditor.TypedEditBuilder.step(step: T) where T : Number, T : Comparable { + fun BaseEditor.TypedEditBuilder.step(step: T) where T : Number, T : Comparable { (settings as Collection>).forEach { it.step = step } } @SettingEditorDsl @Suppress("unchecked_cast") - fun ConfigEditor.TypedEditBuilder.unit(unit: String) where T : Number, T : Comparable { + fun BaseEditor.TypedEditBuilder.unit(unit: String) where T : Number, T : Comparable { (settings as Collection>).forEach { it.unit = unit} } } diff --git a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt index 079c5084b..e5573b55a 100644 --- a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt @@ -22,7 +22,7 @@ import com.lambda.brigadier.argument.greedyString import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required -import com.lambda.config.ConfigEditor +import com.lambda.config.BaseEditor import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.config.SettingEditorDsl @@ -64,12 +64,12 @@ class StringSetting( @Suppress("unused", "unchecked_cast") companion object { @SettingEditorDsl - fun ConfigEditor.TypedEditBuilder.multiline(multiline: Boolean) { + fun BaseEditor.TypedEditBuilder.multiline(multiline: Boolean) { (settings as Collection).forEach { it.multiline = multiline } } @SettingEditorDsl - fun ConfigEditor.TypedEditBuilder.flags(flags: Int) { + fun BaseEditor.TypedEditBuilder.flags(flags: Int) { (settings as Collection).forEach { it.flags = flags } } } diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt index 97f60c693..b784d1d0c 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt @@ -88,10 +88,9 @@ class BreakSettings(override val c: Config) : BreakConfig, SettingBlock { @Group(CosmeticGroup) override val endFillColor by c.setting("End Fill Color", Color(0, 255, 0, 60), "The color of the fill at the end of breaking") { renders && dynamicFillColor && fill } // Outline @Group(CosmeticGroup) override val outline by c.setting("Outline", true, "Renders the lines of the box to display break progress") { renders } - @Group(CosmeticGroup) override val outlineConfig by - c.settingBlock(WorldLineSettings(c)) { - c.applyEdits { hide(::startColor, ::endColor) } - } + @Group(CosmeticGroup) override val outlineConfig by c.settingBlock(WorldLineSettings(c)) { + c.applyEdits { hide(::startColor, ::endColor) } + } @Group(CosmeticGroup) override val dynamicOutlineColor by c.setting("Dynamic Outline Color", true, "Enables color interpolation from start to finish for the outline when breaking a block") { renders && outline } @Group(CosmeticGroup) override val staticOutlineColor by c.setting("Outline Color", Color.RED, "The Color of the outline at the start of breaking") { renders && !dynamicOutlineColor && outline } @Group(CosmeticGroup) override val startOutlineColor by c.setting("Start Outline Color", Color.RED, "The color of the outline at the start of breaking") { renders && dynamicOutlineColor && outline } diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/EatSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/EatSettings.kt index 3e1533f49..1b85871be 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/EatSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/EatSettings.kt @@ -21,7 +21,7 @@ import com.lambda.config.Config import com.lambda.config.SettingBlock import net.minecraft.item.Items -class EatSettings(override val c: Config) : SettingBlock, EatConfig { +class EatSettings(override val c: Config) : EatConfig, SettingBlock { val nutritiousFoodDefaults = listOf(Items.APPLE, Items.BAKED_POTATO, Items.BEEF, Items.BEETROOT, Items.BEETROOT_SOUP, Items.BREAD, Items.CARROT, Items.CHICKEN, Items.CHORUS_FRUIT, Items.COD, Items.COOKED_BEEF, Items.COOKED_CHICKEN, Items.COOKED_COD, Items.COOKED_MUTTON, Items.COOKED_PORKCHOP, Items.COOKED_RABBIT, Items.COOKED_SALMON, Items.COOKIE, Items.DRIED_KELP, Items.ENCHANTED_GOLDEN_APPLE, Items.GOLDEN_APPLE, Items.GOLDEN_CARROT, Items.HONEY_BOTTLE, Items.MELON_SLICE, Items.MUSHROOM_STEW, Items.MUTTON, Items.POISONOUS_POTATO, Items.PORKCHOP, Items.POTATO, Items.PUFFERFISH, Items.PUMPKIN_PIE, Items.RABBIT, Items.RABBIT_STEW, Items.ROTTEN_FLESH, Items.SALMON, Items.SPIDER_EYE, Items.SUSPICIOUS_STEW, Items.SWEET_BERRIES, Items.GLOW_BERRIES, Items.TROPICAL_FISH) val resistanceFoodDefaults = listOf(Items.ENCHANTED_GOLDEN_APPLE) val regenerationFoodDefaults = listOf(Items.ENCHANTED_GOLDEN_APPLE, Items.GOLDEN_APPLE) diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/InventorySettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/InventorySettings.kt index 01d9ddba9..d83494ab2 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/InventorySettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/InventorySettings.kt @@ -23,7 +23,7 @@ import com.lambda.config.SettingBlock import com.lambda.event.events.TickEvent.Companion.ALL_STAGES import com.lambda.util.item.ItemUtils -class InventorySettings(override val c: Config) : SettingBlock, InventoryConfig { +class InventorySettings(override val c: Config) : InventoryConfig, SettingBlock { companion object { private const val ContainerGroup = "Container" private const val AccessGroup = "Access" diff --git a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt index b5d5cca92..20c840b5e 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt @@ -20,7 +20,7 @@ package com.lambda.config.settings.collections import com.google.gson.JsonElement import com.google.gson.reflect.TypeToken import com.lambda.Lambda.gson -import com.lambda.config.ConfigEditor +import com.lambda.config.BaseEditor import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.config.SettingEditorDsl @@ -192,7 +192,7 @@ open class CollectionSetting( @SettingEditorDsl @Suppress("unchecked_cast") - fun ConfigEditor.TypedEditBuilder>.immutableCollection(collection: Collection) { + fun BaseEditor.TypedEditBuilder>.immutableCollection(collection: Collection) { (settings as Collection>).forEach { it.immutableCollection = collection } } } diff --git a/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt b/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt index eebcf60f2..d98b13094 100644 --- a/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt @@ -43,7 +43,7 @@ object BaritoneHandler : Config(LambdaCategory), Automated by AutomationConfig.D private val baritone = if (isBaritoneLoaded) BaritoneAPI.getProvider() else null val baritoneSettings: Settings? = if (isBaritoneLoaded) BaritoneAPI.getSettings() else null - val settings = if (isBaritoneLoaded) baritoneSettings?.let { settingBlock(BaritoneConfigSettings(this, it)) } else null +// val settings by baritoneSettings?.let { settingBlock(BaritoneConfigSettings(this, it)) } private const val RotationTab = "Rotation" @Tab(RotationTab) override val rotationConfig by settingBlock(RotationSettings(this)) From 2ca10f2418baabb8b929ed7769a7713be132560c Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Wed, 13 May 2026 13:41:33 +0100 Subject: [PATCH 13/40] forEachSetting improvements in config editor and some grouping improvements --- .../kotlin/com/lambda/config/BaseEditor.kt | 40 ++++++++++++------- src/main/kotlin/com/lambda/config/Config.kt | 1 - .../module/modules/movement/ElytraFly.kt | 18 +++++---- .../module/modules/render/BlockOutline.kt | 23 ++++++++--- .../com/lambda/module/modules/render/ESP.kt | 10 +++-- .../module/modules/render/LightLevels.kt | 7 +++- .../lambda/module/modules/render/RadiusESP.kt | 7 +++- .../lambda/module/modules/render/Search.kt | 10 +++-- .../lambda/module/modules/world/AutoPortal.kt | 12 ++++-- 9 files changed, 84 insertions(+), 44 deletions(-) diff --git a/src/main/kotlin/com/lambda/config/BaseEditor.kt b/src/main/kotlin/com/lambda/config/BaseEditor.kt index c0f7c0212..0f7f180fe 100644 --- a/src/main/kotlin/com/lambda/config/BaseEditor.kt +++ b/src/main/kotlin/com/lambda/config/BaseEditor.kt @@ -21,6 +21,9 @@ package com.lambda.config import com.lambda.config.Config.BlockLayer import com.lambda.config.Config.SettingLayer +import com.lambda.context.SafeContext +import net.minecraft.client.toast.SystemToast.hide +import kotlin.apply import kotlin.reflect.KProperty0 import kotlin.reflect.jvm.isAccessible @@ -46,8 +49,10 @@ sealed class EditContext { class ConfigEditor internal constructor(private val c: Config) : BaseEditor() { @SettingEditorDsl - fun forEachSetting(block: (Setting<*, *>) -> Unit) { - c.forEachSetting { _, single -> block(single.setting) } + fun forEachSetting(block: BasicEditBuilder.() -> Unit) { + val settings = mutableListOf>() + c.forEachSetting { _, single -> settings.add(single.setting) } + BasicEditBuilder(settings).apply(block) } @SettingEditorDsl @@ -66,8 +71,10 @@ class BlockEditor internal constructor( val wrapper: SettingBlockWrapper<*> ) : BaseEditor() { @SettingEditorDsl - fun forEachSetting(block: (Setting<*, *>) -> Unit) { - c.forEachSettingBlock(wrapper.layer) { _, single -> block(single.setting) } + fun forEachSetting(block: BasicEditBuilder.() -> Unit) { + val settings = mutableListOf>() + c.forEachSettingBlock(wrapper.layer) { _, single -> settings.add(single.setting) } + BasicEditBuilder(settings).apply(block) } @SettingEditorDsl @@ -142,7 +149,7 @@ open class BaseEditor internal constructor() { open class BasicEditBuilder internal constructor( open val settings: Collection> - ) : BaseEditor() { + ) { @SettingEditorDsl fun hide() { settings.forEach { @@ -156,6 +163,11 @@ open class BaseEditor internal constructor() { it.visibility = visibility(it.visibility) } } + + @SettingEditorDsl + fun onValueChange(block: SafeContext.(from: Any?, to: Any?) -> Unit) { + settings.forEach { it.onValueChange(block) } + } } class TypedEditBuilder internal constructor( @@ -168,15 +180,15 @@ open class BaseEditor internal constructor() { it.core.value = value } } +} - protected fun hide(layers: Collection>) { - layers.forEach(::hide) - } +private fun hide(layers: Collection>) { + layers.forEach(::hide) +} - protected fun hide(layer: SettingLayer.Single<*, *>) { - val parentLayer = layer.parent - parentLayer.layers.remove(layer) - if (parentLayer.layers.isEmpty()) - parentLayer.parent?.layers?.remove(parentLayer) - } +private fun hide(layer: SettingLayer.Single<*, *>) { + val parentLayer = layer.parent + parentLayer.layers.remove(layer) + if (parentLayer.layers.isEmpty()) + parentLayer.parent?.layers?.remove(parentLayer) } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index c98176a9a..e6cbc7a57 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -426,7 +426,6 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { @SettingDsl fun settingBlock( settingBlock: T, - visibility: (() -> Boolean)? = null, block: (context(EditContext.BlockEditContext) T.() -> Unit)? = null ): SettingBlockWrapper = settingBlock diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt index 90c76c81d..149a2e1fa 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt @@ -18,6 +18,7 @@ package com.lambda.module.modules.movement import baritone.api.pathing.goals.GoalGetToBlock +import com.lambda.config.Group import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.context.SafeContext @@ -76,20 +77,21 @@ object ElytraFly : Module( private val inventory by setting("Inventory", true, "Allow using fireworks from the players inventory") { mode == FlyMode.GrimControl } - //ToDo: Implement these commented out settings private val takeoff by setting("Takeoff", true, "Automatically jumps and initiates gliding") { mode == FlyMode.Bounce } private val autoPitch by setting("Auto Pitch", true, "Automatically pitches the players rotation down to bounce at faster speeds") { mode == FlyMode.Bounce } private val pitch by setting("Pitch", 80, 0..90, 1) { mode == FlyMode.Bounce && autoPitch } + private val jump by setting("Jump", true, "Automatically jumps") { mode == FlyMode.Bounce } + private val flagPause by setting("Flag Pause", 5, 0..100, 1, "How long to pause if the server flags you for a movement check", "ticks") { mode == FlyMode.Bounce } private val yMotion by setting("Y Motion", false, "Cancels the players y velocity to aid speed") { mode == FlyMode.Bounce } private val yMotionStartSpeed by setting("Y Motion Start Speed", 30, 5..40, 1, "bps") { mode == FlyMode.Bounce && yMotion } private val speedLimit by setting("Speed Limit", 110, 10..400, 1, "bps") { mode == FlyMode.Bounce && yMotion } - private val jump by setting("Jump", true, "Automatically jumps") { mode == FlyMode.Bounce } - private val flagPause by setting("Flag Pause", 5, 0..100, 1, "How long to pause if the server flags you for a movement check", "ticks") { mode == FlyMode.Bounce } - private val passObstacles by setting("Pass Obstacles", true, "Automatically paths around obstacles using baritone") { mode == FlyMode.Bounce } - private val applyPauseAfterBaritone by setting("Apply Pause After Baritone", false, "Ticks the flag pause after baritone has finished pathing") { mode == FlyMode.Bounce && passObstacles } - private val acceptableOffsetRange by setting("Acceptable Offset Range", 2.0, 0.1..5.0, 0.01, "Acceptable offset from the original flight line to allow when starting to fly again after passing obstacles") { mode == FlyMode.Bounce && passObstacles } - private val obstacleLookAhead by setting("Obstacle Look-Ahead", 15, 0..50, 1, "Looks ahead of the player to see if obstacles are in the way") { mode == FlyMode.Bounce && passObstacles } - private val directionStep by setting("Direction Step", 45.0, 0.0..180.0, 0.1, "The step size to use when locking the flight direction") { mode == FlyMode.Bounce && passObstacles } + + private const val ObstaclePasserGroup = "Obstacle Passer" + @Group(ObstaclePasserGroup) private val passObstacles by setting("Pass Obstacles", true, "Automatically paths around obstacles using baritone") { mode == FlyMode.Bounce } + @Group(ObstaclePasserGroup) private val applyPauseAfterBaritone by setting("Apply Pause After Baritone", false, "Ticks the flag pause after baritone has finished pathing") { mode == FlyMode.Bounce && passObstacles } + @Group(ObstaclePasserGroup) private val acceptableOffsetRange by setting("Acceptable Offset Range", 2.0, 0.1..5.0, 0.01, "Acceptable offset from the original flight line to allow when starting to fly again after passing obstacles") { mode == FlyMode.Bounce && passObstacles } + @Group(ObstaclePasserGroup) private val obstacleLookAhead by setting("Obstacle Look-Ahead", 15, 0..50, 1, "Looks ahead of the player to see if obstacles are in the way") { mode == FlyMode.Bounce && passObstacles } + @Group(ObstaclePasserGroup) private val directionStep by setting("Direction Step", 45.0, 0.0..180.0, 0.1, "The step size to use when locking the flight direction") { mode == FlyMode.Bounce && passObstacles } private val boostSpeed by setting("Boost", 0.00, 0.0..0.5, 0.005, description = "Speed to add when flying") private val rocketSpeed by setting("Rocket Speed", 0.0, 0.0..2.0, description = "Speed multiplier that the rocket gives you") { mode == FlyMode.Enhanced } diff --git a/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt b/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt index 26562c212..6d741309e 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt @@ -31,6 +31,7 @@ import com.lambda.util.ChatUtils.colors import com.lambda.util.extension.tickDelta import com.lambda.util.math.lerp import com.lambda.util.world.raycast.RayCastUtils.blockResult +import net.minecraft.client.toast.SystemToast.hide import net.minecraft.util.math.Box import java.awt.Color @@ -55,14 +56,24 @@ object BlockOutline : Module( @Group(BoxFillGroup) private val fill by setting("Fill", true) { mode == Mode.Boxes } @Group(BoxFillGroup) private val fillColor by setting("Fill Color", Color(255, 255, 255, 20)) { fill && mode == Mode.Boxes } @Group(BoxOutlineGroup) private val boxOutline by setting("Box Outline", true) { mode == Mode.Boxes } - @Group(BoxOutlineGroup) private val boxOutlineColor by setting("Box Outline Color", Color(255, 255, 255, 120)) { boxOutline && mode == Mode.Boxes } - @Group(BoxOutlineGroup) private val lineConfig by settingBlock( - WorldLineSettings(this), - { boxOutline && mode == Mode.Boxes } - ) { applyEdits { hide(::startColor, ::endColor) } } + @Group(BoxOutlineGroup) private val boxOutlineColor by setting("Box Outline Color", Color(255, 255, 255, 120)) { mode == Mode.Boxes && boxOutline } + @Group(BoxOutlineGroup) private val lineConfig by settingBlock(WorldLineSettings(this)) { + applyEdits { + hide(::startColor, ::endColor) + forEachSetting { + visibility { old -> { old() && mode == Mode.Boxes } } + } + } + } @Group(OutlineGroup) private val outlineColor by setting("Outline Color", boxOutlineColor) { mode == Mode.Outline } - @Group(OutlineGroup) private val outlineStyle by settingBlock(OutlineSettings(this), { mode == Mode.Outline }) + @Group(OutlineGroup) private val outlineStyle by settingBlock(OutlineSettings(this)) { + applyEdits { + forEachSetting { + visibility { old -> { old() && mode == Mode.Outline } } + } + } + } var previous: List? = null diff --git a/src/main/kotlin/com/lambda/module/modules/render/ESP.kt b/src/main/kotlin/com/lambda/module/modules/render/ESP.kt index ea5a83f7e..962309cc5 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/ESP.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/ESP.kt @@ -74,10 +74,12 @@ object ESP : Module( @Tab(GeneralTab) @Group(BoxOutlineGroup) private var drawOutline: Boolean by setting("Box Outline", true, "Draw box outlines") { mode == EspMode.Box } .onValueChange { _, to -> if (!to && !drawFilled) drawFilled = true } @Tab(GeneralTab) @Group(BoxOutlineGroup) private val outlineAlpha by setting("Outline Alpha", 0.8, 0.0..1.0, 0.05) { mode == EspMode.Box && drawOutline } - @Tab(GeneralTab) @Group(BoxOutlineGroup) private val boxOutlineSettings by settingBlock( - WorldLineSettings(this), - { mode == EspMode.Box && drawOutline } - ) { applyEdits { hide(::startColor, ::endColor) } } + @Tab(GeneralTab) @Group(BoxOutlineGroup) private val boxOutlineSettings by settingBlock(WorldLineSettings(this)) { + applyEdits { + forEachSetting { visibility { old -> { old() && mode == EspMode.Box && drawOutline } } } + hide(::startColor, ::endColor) + } + } @Tab(EntitiesTab) private val entitySettings by settingBlock(EntitySelectionSettings(this)) @Tab(ColorsTab) private val entityColors by settingBlock(EntityColorSettings(this)) diff --git a/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt b/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt index d718eb7df..078a559ef 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt @@ -60,10 +60,13 @@ object LightLevels : Module( @Group(FillGroup) private val fill by setting("Fill", false) { renderMode == RenderMode.Square }.onValueChange(::refreshChunkedRenderer) @Group(FillGroup) private val fillAlpha by setting("Fill Alpha", 0.2, 0.0..1.0, 0.01) { renderMode == RenderMode.Square && fill }.onValueChange(::refreshChunkedRenderer) @Group(LineGroup) private val outline by setting("Outline", true) { renderMode == RenderMode.Square }.onValueChange(::refreshChunkedRenderer) - @Group(LineGroup) private val worldLineConfig by settingBlock(WorldLineSettings(this), { renderMode != RenderMode.Square || outline }) { + @Group(LineGroup) private val worldLineConfig by settingBlock(WorldLineSettings(this)) { applyEdits { hide(::startColor, ::endColor) - forEachSetting { it.onValueChange(::refreshChunkedRenderer) } + forEachSetting { + visibility { old -> { old() && renderMode != RenderMode.Square || outline } } + onValueChange(::refreshChunkedRenderer) + } } } private val depthTest by setting("Depth Test", false, "Shows renders through terrain") diff --git a/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt b/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt index b83ff7bef..faab883ce 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt @@ -55,10 +55,13 @@ object RadiusESP : Module( @Group(RenderGroup) private var outline: Boolean by setting("Outline", true).onValueChange(::rebuildMesh) .onValueChange { _, to -> if (!to) fill = true } @Group(RenderGroup) private val fillAlpha by setting("Fill Alpha", 0.1, 0.0..1.0, 0.01).onValueChange(::rebuildMesh) - @Group(RenderGroup, OutlineGroup) private val worldLineConfig by settingBlock(WorldLineSettings(this), { outline }) { + @Group(RenderGroup, OutlineGroup) private val worldLineConfig by settingBlock(WorldLineSettings(this)) { applyEdits { hide(::startColor, ::endColor) - forEachSetting { it.onValueChange(::rebuildMesh) } + forEachSetting { + visibility { old -> { old() && outline } } + onValueChange(::rebuildMesh) + } } } diff --git a/src/main/kotlin/com/lambda/module/modules/render/Search.kt b/src/main/kotlin/com/lambda/module/modules/render/Search.kt index 40ea79baa..685b83abf 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Search.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Search.kt @@ -85,15 +85,19 @@ object Search : Module( @Group(OutlineGroup) private val entityOutlineColor by setting("Entity Outline Color", Color(100, 150, 255, 128)) { outline && !useNaturalColor }.onValueChange(::rebuildMesh) @Group(OutlineGroup) private val blockOutlineMode by setting("Block Outline Mode", DirectionMask.OutlineMode.And, "Outline mode") { outline }.onValueChange(::rebuildMesh) - @Group(OutlineGroup) private val outlineConfig by settingBlock(WorldLineSettings(this), { outline }) { + @Group(OutlineGroup) private val outlineConfig by settingBlock(WorldLineSettings(this)) { applyEdits { hide(::startColor, ::endColor) - forEachSetting { it.onValueChange(::rebuildMesh) } + forEachSetting { + visibility { old -> { old() && outline } } + onValueChange(::rebuildMesh) + } } } @Group(TracersGroup) private val tracers by setting("Tracers", true, "Draw a line from your cursor to the highlighted position") - @Group(TracersGroup) private val tracerConfig by settingBlock(ScreenLineSettings(this), { tracers }) { + @Group(TracersGroup) private val tracerConfig by settingBlock(ScreenLineSettings(this)) { applyEdits { + forEachSetting { visibility { old -> { old() && tracers } } } editTyped(::startColor, ::endColor) { visibility { { !useNaturalColor } } } diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt index a06cf17f7..0bbb2fee5 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt @@ -118,10 +118,14 @@ object AutoPortal : Module( @Group(RenderGroup) private val interpolate by setting("Interpolate", true, "Interpolates the portal renders from position to position") { renders } @Group(RenderGroup) private val depthTest by setting("Depth Test", false) { renders } @Group(RenderGroup, FillGroup) private val fillAlpha by setting("Fill Alpha", 0.3, 0.0..1.0, 0.01) { renders } - @Group(RenderGroup, OutlineGroup) private val outlineConfig by settingBlock( - WorldLineSettings(this), - { renders } - ) { applyEdits { hide(::startColor, ::endColor) } } + @Group(RenderGroup, OutlineGroup) private val outlineConfig by settingBlock(WorldLineSettings(this)) { + applyEdits { + hide(::startColor, ::endColor) + forEachSetting { + visibility { old -> { old() && renders } } + } + } + } private var preview = false private var buildTask: Task<*>? = null From 1198b07eca5004dad20a81b0c0a7db0c7dd75820 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Thu, 14 May 2026 22:00:34 +0100 Subject: [PATCH 14/40] improved config editing --- .../com/lambda/command/CommandRegistry.kt | 6 +- .../lambda/command/commands/ConfigCommand.kt | 3 +- .../kotlin/com/lambda/config/BaseEditor.kt | 113 ++++++++++-------- src/main/kotlin/com/lambda/config/Config.kt | 36 +++--- .../config/automation/AutomationConfig.kt | 17 +-- .../config/automation/UserAutomationConfig.kt | 4 +- .../config/categories/AutomationCategory.kt | 2 +- .../lambda/config/categories/FontCategory.kt | 2 +- .../config/categories/FriendCategory.kt | 2 +- .../lambda/config/categories/GuiCategory.kt | 2 +- .../lambda/config/categories/HudCategory.kt | 2 +- .../config/categories/LambdaCategory.kt | 2 +- .../config/categories/ModuleCategory.kt | 3 +- .../config/categories/SecretsCategory.kt | 2 +- .../categories/UserAutomationCategory.kt | 2 +- .../lambda/config/settings/NumericSetting.kt | 8 +- .../lambda/config/settings/StringSetting.kt | 6 +- .../config/settings/blocks/BreakSettings.kt | 10 +- .../config/settings/blocks/ReplaceConfig.kt | 41 ------- .../settings/blocks/TargetingSettings.kt | 8 +- .../settings/collections/CollectionSetting.kt | 4 +- .../kotlin/com/lambda/friend/FriendHandler.kt | 6 +- .../com/lambda/graphics/text/FontHandler.kt | 7 +- src/main/kotlin/com/lambda/gui/MenuBar.kt | 4 +- .../lambda/gui/components/ClickGuiLayout.kt | 6 +- .../com/lambda/gui/components/HudGuiLayout.kt | 7 +- .../com/lambda/interaction/BaritoneHandler.kt | 13 +- .../simulation/checks/BasicChecker.kt | 1 - .../simulation/result/Navigable.kt | 2 +- .../simulation/result/results/BreakResult.kt | 3 +- .../result/results/GenericResult.kt | 3 +- .../result/results/InteractResult.kt | 3 +- .../simulation/result/results/PreSimResult.kt | 3 +- .../managers/hotbar/HotbarManager.kt | 1 - .../managers/rotating/RotationManager.kt | 1 - src/main/kotlin/com/lambda/module/Module.kt | 4 +- .../com/lambda/module/hud/Coordinates.kt | 9 +- .../kotlin/com/lambda/module/hud/Rotation.kt | 8 +- .../lambda/module/modules/chat/AntiSpam.kt | 50 +++++--- .../module/modules/chat/ChatTimestamp.kt | 9 +- .../lambda/module/modules/combat/AutoArmor.kt | 6 +- .../lambda/module/modules/combat/AutoTotem.kt | 6 +- .../module/modules/combat/CrystalAura.kt | 19 ++- .../lambda/module/modules/combat/KillAura.kt | 31 ++--- .../module/modules/combat/PlayerTrap.kt | 21 ++-- .../lambda/module/modules/combat/Surround.kt | 21 ++-- .../lambda/module/modules/debug/SilentSwap.kt | 6 +- .../module/modules/movement/BetterFirework.kt | 11 +- .../modules/movement/ElytraAltitudeControl.kt | 6 +- .../module/modules/movement/ElytraFly.kt | 6 +- .../lambda/module/modules/movement/Speed.kt | 6 +- .../lambda/module/modules/player/AutoEat.kt | 6 +- .../lambda/module/modules/player/FastBreak.kt | 79 ++++++------ .../module/modules/player/InventoryTweaks.kt | 7 +- .../module/modules/player/PacketMine.kt | 55 ++++----- .../module/modules/player/RotationLock.kt | 9 +- .../module/modules/player/StackReplenish.kt | 11 +- .../lambda/module/modules/player/ToolSaver.kt | 6 +- .../module/modules/render/BlockOutline.kt | 16 ++- .../com/lambda/module/modules/render/ESP.kt | 13 +- .../lambda/module/modules/render/Freecam.kt | 11 +- .../module/modules/render/LightLevels.kt | 9 +- .../lambda/module/modules/render/Nametags.kt | 19 ++- .../lambda/module/modules/render/NoRender.kt | 10 +- .../lambda/module/modules/render/RadiusESP.kt | 10 +- .../lambda/module/modules/render/Search.kt | 15 +-- .../lambda/module/modules/render/Tracers.kt | 24 ++-- .../lambda/module/modules/world/AirPlace.kt | 6 +- .../lambda/module/modules/world/AutoPortal.kt | 20 ++-- .../module/modules/world/AutoVillagerCycle.kt | 6 +- .../module/modules/world/HighwayTools.kt | 10 +- .../com/lambda/module/modules/world/Nuker.kt | 8 +- .../lambda/module/modules/world/Scaffold.kt | 33 ++--- .../lambda/module/modules/world/StashMover.kt | 23 ++-- .../kotlin/com/lambda/network/CapeHandler.kt | 7 +- .../kotlin/com/lambda/network/LambdaAPI.kt | 7 +- .../com/lambda/network/NetworkHandler.kt | 7 +- .../kotlin/com/lambda/task/tasks/BuildTask.kt | 2 +- 78 files changed, 476 insertions(+), 507 deletions(-) delete mode 100644 src/main/kotlin/com/lambda/config/settings/blocks/ReplaceConfig.kt diff --git a/src/main/kotlin/com/lambda/command/CommandRegistry.kt b/src/main/kotlin/com/lambda/command/CommandRegistry.kt index a784a0e33..fbad9f4a1 100644 --- a/src/main/kotlin/com/lambda/command/CommandRegistry.kt +++ b/src/main/kotlin/com/lambda/command/CommandRegistry.kt @@ -27,9 +27,11 @@ import com.mojang.brigadier.tree.CommandNode /** * The [CommandRegistry] object is responsible for managing all [LambdaCommand] instances in the system. */ -object CommandRegistry : Config(LambdaCategory), Loadable { +object CommandRegistry : Config( + "command", + LambdaCategory +), Loadable { override val priority get() = -2 - override val name = "command" val prefix by setting("prefix", ';') val commands = getInstances().toMutableList() diff --git a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt index b8cf6355c..c40558916 100644 --- a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt @@ -20,7 +20,6 @@ package com.lambda.command.commands import com.lambda.brigadier.CommandResult import com.lambda.brigadier.CommandResult.Companion.failure import com.lambda.brigadier.CommandResult.Companion.success -import com.lambda.brigadier.argument.greedyString import com.lambda.brigadier.argument.literal import com.lambda.brigadier.argument.string import com.lambda.brigadier.argument.value @@ -85,7 +84,7 @@ object ConfigCommand : LambdaCommand( config.reset() success() } - required(greedyString("setting")) { settingArg -> + required(string("setting")) { settingArg -> suggests { context, builder -> val configString = configArg(context).value() val config = ConfigLoader.configByCommandName(configString) ?: return@suggests null diff --git a/src/main/kotlin/com/lambda/config/BaseEditor.kt b/src/main/kotlin/com/lambda/config/BaseEditor.kt index 0f7f180fe..d25126c0a 100644 --- a/src/main/kotlin/com/lambda/config/BaseEditor.kt +++ b/src/main/kotlin/com/lambda/config/BaseEditor.kt @@ -22,8 +22,6 @@ package com.lambda.config import com.lambda.config.Config.BlockLayer import com.lambda.config.Config.SettingLayer import com.lambda.context.SafeContext -import net.minecraft.client.toast.SystemToast.hide -import kotlin.apply import kotlin.reflect.KProperty0 import kotlin.reflect.jvm.isAccessible @@ -31,115 +29,107 @@ import kotlin.reflect.jvm.isAccessible annotation class SettingEditorDsl @SettingEditorDsl -context(configEditContext: EditContext.ConfigEditContext) -fun Config.applyEdits(edits: ConfigEditor.() -> Unit) { - ConfigEditor(this).apply(edits) +fun T.withEdits(edits: context(EditContext.ConfigEditContext) T.() -> Unit): T { + with(EditContext.ConfigEditContext(this)) { edits() } + return this } @SettingEditorDsl -context(blockEditContext: EditContext.BlockEditContext) -fun Config.applyEdits(edits: BlockEditor.() -> Unit) { - BlockEditor(this, blockEditContext.block).apply(edits) +context(c: Config) +fun SettingBlockWrapper.withEdits(edits: context(EditContext.BlockEditContext) T.() -> Unit): SettingBlockWrapper { + with(EditContext.BlockEditContext(c, this)) { this@withEdits.settingBlock.edits() } + return this } -sealed class EditContext { - class ConfigEditContext internal constructor() : EditContext() - class BlockEditContext internal constructor(internal val block: SettingBlockWrapper<*>) : EditContext() +@SettingEditorDsl +fun SettingBlockWrapper.withEdits(c: Config, edits: context(EditContext.BlockEditContext) T.() -> Unit): SettingBlockWrapper { + with(EditContext.BlockEditContext(c, this)) { this@withEdits.settingBlock.edits() } + return this +} + +sealed class EditContext(internal val c: Config) { + class ConfigEditContext internal constructor(c: Config) : EditContext(c) + class BlockEditContext internal constructor(c: Config, internal val block: SettingBlockWrapper<*>) : EditContext(c) } -class ConfigEditor internal constructor(private val c: Config) : BaseEditor() { +object ConfigEditor { @SettingEditorDsl + context(editContext: EditContext.ConfigEditContext) fun forEachSetting(block: BasicEditBuilder.() -> Unit) { val settings = mutableListOf>() - c.forEachSetting { _, single -> settings.add(single.setting) } + editContext.c.forEachSetting { _, single -> settings.add(single.setting) } BasicEditBuilder(settings).apply(block) } @SettingEditorDsl + context(editContext: EditContext.ConfigEditContext) fun hideAllBlocksExcept(vararg except: SettingBlockProperty) { val exceptBlocks = except.map { it.settingBlock.layer } fun processBlock(blockLayer: BlockLayer) { blockLayer.layers.forEach(::processBlock) if (blockLayer !in exceptBlocks) blockLayer.settingLayers.forEach(::hide) } - processBlock(c.settingBlockLayers) + processBlock(editContext.c.settingBlockLayers) } -} -class BlockEditor internal constructor( - private val c: Config, - val wrapper: SettingBlockWrapper<*> -) : BaseEditor() { @SettingEditorDsl + context(editContext: EditContext.BlockEditContext) fun forEachSetting(block: BasicEditBuilder.() -> Unit) { val settings = mutableListOf>() - c.forEachSettingBlock(wrapper.layer) { _, single -> settings.add(single.setting) } + editContext.c.forEachSettingBlock(editContext.block.layer) { _, single -> settings.add(single.setting) } BasicEditBuilder(settings).apply(block) } @SettingEditorDsl + context(editContext: EditContext.BlockEditContext) fun hideAllBlocksExcept(vararg except: SettingBlockProperty) { val exceptBlocks = except.map { it.settingBlock.layer } fun processBlock(blockLayer: BlockLayer) { blockLayer.layers.forEach(::processBlock) if (blockLayer !in exceptBlocks) blockLayer.settingLayers.forEach(::hide) } - processBlock(wrapper.layer) + processBlock(editContext.block.layer) } -} - -open class BaseEditor internal constructor() { - protected typealias Property = KProperty0 - protected typealias SettingProperty = KProperty0 - protected typealias SettingBlockProperty = KProperty0 - - private val Property<*>.delegate - get() = try { - apply { isAccessible = true }.getDelegate() - } catch (e: Exception) { - throw IllegalStateException("Could not access delegate for property $name", e) - } - - protected val SettingProperty.setting - get() = this.delegate as? Setting, T> - ?: throw IllegalStateException("Setting delegate did not match the given type") - - protected val SettingBlockProperty.settingBlock - get() = this.delegate as? SettingBlockWrapper - ?: throw IllegalStateException("SettingBlock delegate did not match the given type") @SettingEditorDsl + context(_: EditContext) fun SettingProperty.edit(edits: TypedEditBuilder.(SettingCore) -> Unit) { val delegate = setting TypedEditBuilder(listOf(delegate)).edits(delegate.core) } @SettingEditorDsl + context(_: EditContext) fun edit( vararg settings: SettingProperty, edits: BasicEditBuilder.() -> Unit ) = BasicEditBuilder(settings.map { it.setting }).apply(edits) @SettingEditorDsl + context(_: EditContext) fun editTyped( vararg settings: SettingProperty, edits: TypedEditBuilder.() -> Unit ) = TypedEditBuilder(settings.map { it.setting }).apply(edits) @SettingEditorDsl + context(_: EditContext) fun hide(vararg settings: SettingProperty) = hide(settings.map { it.setting.layer }) @SettingEditorDsl + context(_: EditContext) fun hideBlock(settingBlock: SettingBlockProperty) { settingBlock.settingBlock.layer.settingLayers.forEach(::hide) } @SettingEditorDsl + context(_: EditContext) fun hideBlocks(vararg settingBlocks: SettingBlockProperty) = settingBlocks.forEach { hideBlock(it) } @SettingEditorDsl + context(_: EditContext) fun hideBlockExcept(settingBlock: SettingBlockProperty, vararg except: SettingProperty) { val exceptSettings = except.map { it.setting } settingBlock.settingBlock.layer.settingLayers.forEach { layer -> @@ -180,15 +170,34 @@ open class BaseEditor internal constructor() { it.core.value = value } } -} -private fun hide(layers: Collection>) { - layers.forEach(::hide) -} + private fun hide(layers: Collection>) { + layers.forEach(::hide) + } + + private fun hide(layer: SettingLayer.Single<*, *>) { + val parentLayer = layer.parent + parentLayer.layers.remove(layer) + if (parentLayer.layers.isEmpty()) + parentLayer.parent?.layers?.remove(parentLayer) + } -private fun hide(layer: SettingLayer.Single<*, *>) { - val parentLayer = layer.parent - parentLayer.layers.remove(layer) - if (parentLayer.layers.isEmpty()) - parentLayer.parent?.layers?.remove(parentLayer) -} \ No newline at end of file + private typealias Property = KProperty0 + private typealias SettingProperty = KProperty0 + private typealias SettingBlockProperty = KProperty0 + + private val Property<*>.delegate + get() = try { + apply { isAccessible = true }.getDelegate() + } catch (e: Exception) { + throw IllegalStateException("Could not access delegate for property $name", e) + } + + private val SettingProperty.setting + get() = this.delegate as? Setting, T> + ?: throw IllegalStateException("Setting delegate did not match the given type") + + private val SettingBlockProperty.settingBlock + get() = this.delegate as? SettingBlockWrapper + ?: throw IllegalStateException("SettingBlock delegate did not match the given type") +} diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index e6cbc7a57..550e97acb 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -69,7 +69,10 @@ private annotation class SettingDsl * @property settingLayers A set of [SettingCore]s that this config manages. */ @Suppress("unused") -abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { +abstract class Config( + final override val name: String, + configCategory: ConfigCategory +) : Jsonable, Nameable { internal val settingLayers = SettingLayer.Root() internal val settingBlockLayers = BlockLayer.Root() private val registrationQueue = ArrayDeque() @@ -424,16 +427,13 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { ) = setting(name, description, FunctionSetting(defaultValue), visibility) @SettingDsl - fun settingBlock( - settingBlock: T, - block: (context(EditContext.BlockEditContext) T.() -> Unit)? = null - ): SettingBlockWrapper = + fun settingBlock(settingBlock: T): SettingBlockWrapper = settingBlock .let { settingBlock -> val path = try { registrationQueue.removeFirst().settingBlockSpecs } catch(_: NoSuchElementException) { - throw IllegalStateException("Setting block registered from an unknown location; layer path was not queued before setting initialization") + throw IllegalStateException("Setting block registered from an unknown location for config '$name'; layer path was not queued before setting block initialization") } var currentLayer: BlockLayer = settingBlockLayers @@ -452,13 +452,6 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { .also { wrapper -> (currentLayer as? BlockLayer.Block)?.settingBlock = wrapper } - .also { wrapper -> - if (block != null) { - with (EditContext.BlockEditContext(wrapper)) { - settingBlock.block() - } - } - } } @PublishedApi @@ -466,7 +459,7 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { val layerSpecInfo = try { registrationQueue.removeFirst() } catch(_: NoSuchElementException) { - throw IllegalStateException("Setting registered from an unknown location; layer path was not queued before setting initialization") + throw IllegalStateException("Setting registered from an unknown location for config '$name'; layer path was not queued before setting initialization") } var currentSettingLayer: SettingLayer.Multiple = settingLayers @@ -630,6 +623,21 @@ abstract class Config(configCategory: ConfigCategory) : Jsonable, Nameable { } internalForEach(root, emptyList()) } + + internal fun getSettingByPathedName(path: Collection, setting: String): Setting<*, *>? { + var currentLayer: SettingLayer.Multiple = settingLayers + path.forEach { layer -> + currentLayer = currentLayer.layers + .asSequence() + .filterIsInstance() + .find { it.name == layer } ?: return null + } + return currentLayer.layers + .asSequence() + .filterIsInstance>() + .find { it.setting.name == setting } + ?.setting + } } @Target(AnnotationTarget.PROPERTY) diff --git a/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt index d4d36314e..2df77bd2d 100644 --- a/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt @@ -34,9 +34,12 @@ import com.lambda.module.Module open class AutomationConfig( - override val name: String, + name: String, configCategory: ConfigCategory = AutomationCategory -) : Config(configCategory), Automated { +) : Config( + name, + configCategory +), Automated { @Tab(BuildTab) override val buildConfig by settingBlock(BuildSettings(this)) @Tab(BreakTab) override val breakConfig by settingBlock(BreakSettings(this)) @Tab(InteractTab) override val interactConfig by settingBlock(InteractSettings(this)) @@ -57,10 +60,10 @@ open class AutomationConfig( context(module: Module) fun IMutableAutomationConfig.setDefaultAutomationConfig( name: String = module.name, - edits: (context (ConfigEditContext) AutomationConfig.() -> Unit)? = null + edits: (context(ConfigEditContext) AutomationConfig.() -> Unit)? = null ) { - this.defaultAutomationConfig = AutomationConfig("$name Automation Config").also { - if (edits != null) with(ConfigEditContext()) { it.edits() } + this.defaultAutomationConfig = AutomationConfig("$name Automation Config").also { config -> + if (edits != null) with(ConfigEditContext(config)) { config.edits() } } } @@ -68,8 +71,8 @@ open class AutomationConfig( name: String, edits: (context(ConfigEditContext) AutomationConfig.() -> Unit)? = null ) { - defaultAutomationConfig = AutomationConfig("$name Automation Config").also { - if (edits != null) with(ConfigEditContext()) { it.edits() } + defaultAutomationConfig = AutomationConfig("$name Automation Config").also { config -> + if (edits != null) with(ConfigEditContext(config)) { config.edits() } } } diff --git a/src/main/kotlin/com/lambda/config/automation/UserAutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/UserAutomationConfig.kt index 684f3a224..e88bafc52 100644 --- a/src/main/kotlin/com/lambda/config/automation/UserAutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/UserAutomationConfig.kt @@ -23,8 +23,8 @@ import com.lambda.config.settings.collections.CollectionSetting.Companion.onSele import com.lambda.module.Module import com.lambda.module.ModuleRegistry.moduleNameMap -class UserAutomationConfig(override val name: String) : AutomationConfig(name, UserAutomationCategory) { - val linkedModules = setting("Linked Modules", emptySet(), moduleNameMap.filter { it.value.defaultAutomationConfig != Companion.Default }.keys) { false } +class UserAutomationConfig(name: String) : AutomationConfig(name, UserAutomationCategory) { + val linkedModules = setting("Linked Modules", emptySet(), moduleNameMap.filter { it.value.defaultAutomationConfig != Default }.keys) { false } .onSelect { name -> moduleNameMap[name]?.let { it.removeLink() diff --git a/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt b/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt index f3b1a0cd3..b7419dbaa 100644 --- a/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt @@ -23,5 +23,5 @@ import java.io.File object AutomationCategory : ConfigCategory() { override val configName = "automation" - override val primaryFile: File = FolderRegistry.config.resolve("${configName}.json").toFile() + override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/FontCategory.kt b/src/main/kotlin/com/lambda/config/categories/FontCategory.kt index 3a2e65634..c863835cb 100644 --- a/src/main/kotlin/com/lambda/config/categories/FontCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/FontCategory.kt @@ -23,5 +23,5 @@ import java.io.File object FontCategory : ConfigCategory() { override val configName get() = "font" - override val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() + override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt b/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt index 16f6298ed..884641e90 100644 --- a/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt @@ -23,5 +23,5 @@ import java.io.File object FriendCategory : ConfigCategory() { override val configName get() = "friends" - override val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() + override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() } diff --git a/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt b/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt index 656ad21f7..db0537133 100644 --- a/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt @@ -23,5 +23,5 @@ import java.io.File object GuiCategory : ConfigCategory() { override val configName get() = "gui" - override val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() + override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() } diff --git a/src/main/kotlin/com/lambda/config/categories/HudCategory.kt b/src/main/kotlin/com/lambda/config/categories/HudCategory.kt index 8b8abdc64..e5e08e7d7 100644 --- a/src/main/kotlin/com/lambda/config/categories/HudCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/HudCategory.kt @@ -23,5 +23,5 @@ import java.io.File object HudCategory : ConfigCategory() { override val configName get() = "hud" - override val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() + override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt b/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt index 10e85eac3..9bb534df3 100644 --- a/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt @@ -23,5 +23,5 @@ import java.io.File object LambdaCategory : ConfigCategory() { override val configName get() = "lambda" - override val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() + override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt b/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt index ce2b9bd5b..f6dfc88ce 100644 --- a/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt @@ -18,6 +18,7 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory +import com.lambda.config.categories.ModuleCategory.configName import com.lambda.util.FolderRegistry import java.io.File @@ -31,5 +32,5 @@ import java.io.File */ object ModuleCategory : ConfigCategory() { override val configName get() = "modules" - override val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() + override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt b/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt index 4636d2aac..c5b8d4e1a 100644 --- a/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt @@ -23,5 +23,5 @@ import java.io.File object SecretsCategory : ConfigCategory() { override val configName get() = "secrets" - override val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() + override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt b/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt index 0cfdb6c16..ece048ebe 100644 --- a/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt @@ -27,7 +27,7 @@ import java.io.File object UserAutomationCategory : ConfigCategory() { override val configName get() = "custom_automation" - override val primaryFile: File = FolderRegistry.config.resolve("${AutomationCategory.configName}.json").toFile() + override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() override fun internalTryLoad() { primaryFile.ifExists { diff --git a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt index 809775a84..b095cb288 100644 --- a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt @@ -18,7 +18,7 @@ package com.lambda.config.settings import com.google.gson.reflect.TypeToken -import com.lambda.config.BaseEditor +import com.lambda.config.ConfigEditor import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.config.SettingEditorDsl @@ -98,19 +98,19 @@ abstract class NumericSetting( companion object { @SettingEditorDsl @Suppress("unchecked_cast") - fun BaseEditor.TypedEditBuilder.range(range: ClosedRange) where T : Number, T : Comparable { + fun ConfigEditor.TypedEditBuilder.range(range: ClosedRange) where T : Number, T : Comparable { (settings as Collection>).forEach { it.range = range } } @SettingEditorDsl @Suppress("unchecked_cast") - fun BaseEditor.TypedEditBuilder.step(step: T) where T : Number, T : Comparable { + fun ConfigEditor.TypedEditBuilder.step(step: T) where T : Number, T : Comparable { (settings as Collection>).forEach { it.step = step } } @SettingEditorDsl @Suppress("unchecked_cast") - fun BaseEditor.TypedEditBuilder.unit(unit: String) where T : Number, T : Comparable { + fun ConfigEditor.TypedEditBuilder.unit(unit: String) where T : Number, T : Comparable { (settings as Collection>).forEach { it.unit = unit} } } diff --git a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt index e5573b55a..079c5084b 100644 --- a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt @@ -22,7 +22,7 @@ import com.lambda.brigadier.argument.greedyString import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required -import com.lambda.config.BaseEditor +import com.lambda.config.ConfigEditor import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.config.SettingEditorDsl @@ -64,12 +64,12 @@ class StringSetting( @Suppress("unused", "unchecked_cast") companion object { @SettingEditorDsl - fun BaseEditor.TypedEditBuilder.multiline(multiline: Boolean) { + fun ConfigEditor.TypedEditBuilder.multiline(multiline: Boolean) { (settings as Collection).forEach { it.multiline = multiline } } @SettingEditorDsl - fun BaseEditor.TypedEditBuilder.flags(flags: Int) { + fun ConfigEditor.TypedEditBuilder.flags(flags: Int) { (settings as Collection).forEach { it.flags = flags } } } diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt index b784d1d0c..08e304dc1 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt @@ -18,14 +18,15 @@ package com.lambda.config.settings.blocks import com.lambda.config.Config +import com.lambda.config.ConfigEditor.hide import com.lambda.config.Group import com.lambda.config.SettingBlock -import com.lambda.config.applyEdits import com.lambda.config.settings.blocks.BreakConfig.AnimationMode import com.lambda.config.settings.blocks.BreakConfig.BreakConfirmationMode import com.lambda.config.settings.blocks.BreakConfig.BreakMode import com.lambda.config.settings.blocks.BreakConfig.SwingMode import com.lambda.config.settings.blocks.BreakConfig.WhitelistMode +import com.lambda.config.withEdits import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES import net.minecraft.registry.Registries @@ -88,9 +89,10 @@ class BreakSettings(override val c: Config) : BreakConfig, SettingBlock { @Group(CosmeticGroup) override val endFillColor by c.setting("End Fill Color", Color(0, 255, 0, 60), "The color of the fill at the end of breaking") { renders && dynamicFillColor && fill } // Outline @Group(CosmeticGroup) override val outline by c.setting("Outline", true, "Renders the lines of the box to display break progress") { renders } - @Group(CosmeticGroup) override val outlineConfig by c.settingBlock(WorldLineSettings(c)) { - c.applyEdits { hide(::startColor, ::endColor) } - } + @Group(CosmeticGroup) override val outlineConfig by c.settingBlock(WorldLineSettings(c)) + .withEdits(c) { + hide(::startColor, ::endColor) + } @Group(CosmeticGroup) override val dynamicOutlineColor by c.setting("Dynamic Outline Color", true, "Enables color interpolation from start to finish for the outline when breaking a block") { renders && outline } @Group(CosmeticGroup) override val staticOutlineColor by c.setting("Outline Color", Color.RED, "The Color of the outline at the start of breaking") { renders && !dynamicOutlineColor && outline } @Group(CosmeticGroup) override val startOutlineColor by c.setting("Start Outline Color", Color.RED, "The color of the outline at the start of breaking") { renders && dynamicOutlineColor && outline } diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/ReplaceConfig.kt b/src/main/kotlin/com/lambda/config/settings/blocks/ReplaceConfig.kt deleted file mode 100644 index 3c21ba89f..000000000 --- a/src/main/kotlin/com/lambda/config/settings/blocks/ReplaceConfig.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.settings.blocks - -import com.lambda.util.Describable - -interface ReplaceConfig { - val action: ActionStrategy - val replace: ReplaceStrategy - - val enabled: Boolean get() = action != ActionStrategy.None - - enum class ActionStrategy(override val description: String) : Describable { - Hide("Hides the message. Will override other strategies."), - Delete("Deletes the matching part off the message."), - Replace("Replace the matching string in the message with one of the following replace strategy."), - None("Don't do anything."), - } - - @Suppress("unused") - enum class ReplaceStrategy(val block: (String) -> String) { - CensorAll({ it.replaceRange(0.. if (i % 2 == 0) acc + char else "$acc*" } }), - KeepFirst({ if (it.length <= 1) it else it.replaceRange(1, it.length, "*".repeat(it.length - 1)) }), - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt index d9d7f2edd..fb61fcf0a 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt @@ -18,8 +18,9 @@ package com.lambda.config.settings.blocks import com.lambda.config.Config +import com.lambda.config.ConfigEditor.hide import com.lambda.config.SettingBlock -import com.lambda.config.applyEdits +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.friend.FriendHandler.isFriend import com.lambda.interaction.managers.rotating.Rotation.Companion.dist @@ -58,9 +59,8 @@ abstract class TargetingSettings( * between 1.0 and [maxRange]. */ override val targetingRange by c.setting("Targeting Range", defaultRange, 1.0..maxRange, 0.05) - override val targets by c.settingBlock(EntitySelectionSettings(c)) { - c.applyEdits { hide(::self, ::blockEntities) } - } + override val targets by c.settingBlock(EntitySelectionSettings(c)) + .withEdits(c) { hide(::self, ::blockEntities) } /** * Validates whether a given entity is targetable by the player based on current settings. diff --git a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt index 20c840b5e..b5d5cca92 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt @@ -20,7 +20,7 @@ package com.lambda.config.settings.collections import com.google.gson.JsonElement import com.google.gson.reflect.TypeToken import com.lambda.Lambda.gson -import com.lambda.config.BaseEditor +import com.lambda.config.ConfigEditor import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.config.SettingEditorDsl @@ -192,7 +192,7 @@ open class CollectionSetting( @SettingEditorDsl @Suppress("unchecked_cast") - fun BaseEditor.TypedEditBuilder>.immutableCollection(collection: Collection) { + fun ConfigEditor.TypedEditBuilder>.immutableCollection(collection: Collection) { (settings as Collection>).forEach { it.immutableCollection = collection } } } diff --git a/src/main/kotlin/com/lambda/friend/FriendHandler.kt b/src/main/kotlin/com/lambda/friend/FriendHandler.kt index 43195e83c..e6e9e521c 100644 --- a/src/main/kotlin/com/lambda/friend/FriendHandler.kt +++ b/src/main/kotlin/com/lambda/friend/FriendHandler.kt @@ -34,8 +34,10 @@ import net.minecraft.text.Text import java.awt.Color import java.util.* -object FriendHandler : Config(FriendCategory), Loadable { - override val name = "friends" +object FriendHandler : Config( + "friends", + FriendCategory +), Loadable { val friends by setting("friends", emptySet(), serialize = true) private val cachedProfiles = mutableMapOf() diff --git a/src/main/kotlin/com/lambda/graphics/text/FontHandler.kt b/src/main/kotlin/com/lambda/graphics/text/FontHandler.kt index 0c963c9d1..133848156 100644 --- a/src/main/kotlin/com/lambda/graphics/text/FontHandler.kt +++ b/src/main/kotlin/com/lambda/graphics/text/FontHandler.kt @@ -33,8 +33,11 @@ import kotlin.io.path.notExists * Manages SDF font atlases with automatic caching by path and size. * Fonts are discovered at startup but only loaded when actually used. */ -object FontHandler : Loadable, Config(FontCategory) { - override val name = "Font" +@Suppress("unused") +object FontHandler : Loadable, Config( + "Font", + FontCategory +) { override val priority = -1 private val loadedAtlases = ConcurrentHashMap() diff --git a/src/main/kotlin/com/lambda/gui/MenuBar.kt b/src/main/kotlin/com/lambda/gui/MenuBar.kt index ba7285956..d6636bf3d 100644 --- a/src/main/kotlin/com/lambda/gui/MenuBar.kt +++ b/src/main/kotlin/com/lambda/gui/MenuBar.kt @@ -304,10 +304,10 @@ object MenuBar { } UserAutomationCategory.configs.forEach { config -> - if (config !is UserAutomationConfig) throw java.lang.IllegalStateException("All configs within UserAutomationConfigs must be UserAutomationConfigs!") + if (config !is UserAutomationConfig) throw IllegalStateException("All configs within UserAutomationConfigs must be UserAutomationConfigs!") buildAutomationConfigSelectable(config) } - buildAutomationConfigSelectable(AutomationConfig.Companion.Default) + buildAutomationConfigSelectable(AutomationConfig.Default) } private fun ImGuiBuilder.buildAutomationConfigSelectable(config: AutomationConfig) { diff --git a/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt b/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt index 589296dc1..33831aae8 100644 --- a/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt +++ b/src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt @@ -62,8 +62,10 @@ import net.minecraft.client.util.Icons import java.awt.Color @Suppress("unused") -object ClickGuiLayout : Loadable, Config(GuiCategory) { - override val name = "GUI" +object ClickGuiLayout : Loadable, Config( + "GUI", + GuiCategory +) { var open = false var developerMode = false val keybind by setting("Keybind", KeyCode.Y, screenCheck = false) diff --git a/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt b/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt index 1afdaa825..257053243 100644 --- a/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt +++ b/src/main/kotlin/com/lambda/gui/components/HudGuiLayout.kt @@ -42,9 +42,10 @@ import com.lambda.module.ModuleRegistry import java.awt.Color import kotlin.math.PI -object HudGuiLayout : Loadable, Config(HudCategory) { - override val name = "HUD" - +object HudGuiLayout : Loadable, Config( + "HUD", + HudCategory +) { // HUD Outline val hudOutlineCornerRadius by setting("HUD Corner Radius", 6.0f, 0.5f..24.0f, 0.5f) val hudOutlineHaloColor by setting("HUD Corner Halo Color", Color(140, 140, 140, 90)) diff --git a/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt b/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt index d98b13094..37ea6a9d8 100644 --- a/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt @@ -23,21 +23,22 @@ import baritone.api.Settings import baritone.api.pathing.goals.Goal import com.lambda.config.Config import com.lambda.config.Group -import com.lambda.config.Tab -import com.lambda.config.categories.LambdaCategory -import net.fabricmc.loader.api.FabricLoader import com.lambda.config.SettingBlock +import com.lambda.config.Tab import com.lambda.config.automation.AutomationConfig +import com.lambda.config.categories.LambdaCategory import com.lambda.config.settings.blocks.RotationSettings import com.lambda.context.Automated import com.lambda.util.BlockUtils.blockPos +import net.fabricmc.loader.api.FabricLoader import net.minecraft.util.BlockMirror import net.minecraft.util.BlockRotation @Suppress("unused") -object BaritoneHandler : Config(LambdaCategory), Automated by AutomationConfig.Default { - override val name = "baritone" - +object BaritoneHandler : Config( + "baritone", + LambdaCategory +), Automated by AutomationConfig.Default { val isBaritoneLoaded = FabricLoader.getInstance().isModLoaded("baritone") private val baritone = if (isBaritoneLoaded) BaritoneAPI.getProvider() else null diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt index 08fe68f5a..8c4c996af 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BasicChecker.kt @@ -17,7 +17,6 @@ package com.lambda.interaction.construction.simulation.checks -import com.lambda.config.settings.blocks.BreakConfig import com.lambda.config.settings.blocks.BreakConfig.WhitelistMode import com.lambda.context.AutomatedSafeContext import com.lambda.interaction.construction.simulation.BreakSimInfo diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Navigable.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Navigable.kt index 47611f36d..dcbd702da 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Navigable.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/Navigable.kt @@ -23,5 +23,5 @@ import baritone.api.pathing.goals.Goal * Represents a [BuildResult] with a pathing goal. */ interface Navigable { - val goal: Goal + val goal: Goal? } diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/BreakResult.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/BreakResult.kt index 0c8632122..54cb085e1 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/BreakResult.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/BreakResult.kt @@ -22,6 +22,7 @@ import baritone.api.pathing.goals.GoalInverted import com.lambda.context.AutomatedSafeContext import com.lambda.graphics.mc.RenderBuilder import com.lambda.graphics.util.DirectionMask.mask +import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.construction.simulation.context.BreakContext import com.lambda.interaction.construction.simulation.result.BuildResult import com.lambda.interaction.construction.simulation.result.ComparableResult @@ -181,7 +182,7 @@ sealed class BreakResult : BuildResult() { override val rank = Rank.BreakPlayerOnTop private val color = Color(252, 3, 207, 100) - override val goal = GoalInverted(GoalBlock(pos)) + override val goal = if (BaritoneHandler.isBaritoneLoaded) GoalInverted(GoalBlock(pos)) else null override fun RenderBuilder.render() { box(pos) { diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/GenericResult.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/GenericResult.kt index 73a77da9e..404f61963 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/GenericResult.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/GenericResult.kt @@ -20,6 +20,7 @@ package com.lambda.interaction.construction.simulation.result.results import baritone.api.pathing.goals.GoalNear import com.lambda.context.AutomatedSafeContext import com.lambda.graphics.mc.RenderBuilder +import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.construction.simulation.result.BuildResult import com.lambda.interaction.construction.simulation.result.ComparableResult import com.lambda.interaction.construction.simulation.result.Drawable @@ -133,7 +134,7 @@ sealed class GenericResult : BuildResult() { misses.minOfOrNull { pov.distanceTo(it.first) } ?: 0.0 } - override val goal = GoalNear(pos, 3) + override val goal = if (BaritoneHandler.isBaritoneLoaded) GoalNear(pos, 3) else null override fun RenderBuilder.render() { val center = pos.toCenterPos() diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/InteractResult.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/InteractResult.kt index f399b7c45..86c7fe4fd 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/InteractResult.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/InteractResult.kt @@ -20,6 +20,7 @@ package com.lambda.interaction.construction.simulation.result.results import baritone.api.pathing.goals.GoalBlock import baritone.api.pathing.goals.GoalInverted import com.lambda.graphics.mc.RenderBuilder +import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.construction.simulation.context.InteractContext import com.lambda.interaction.construction.simulation.result.BuildResult import com.lambda.interaction.construction.simulation.result.Contextual @@ -104,7 +105,7 @@ sealed class InteractResult : BuildResult() { override val pos: BlockPos ) : Navigable, InteractResult() { override val rank = Rank.PlaceBlockedByPlayer - override val goal = GoalInverted(GoalBlock(pos)) + override val goal = if (BaritoneHandler.isBaritoneLoaded) GoalInverted(GoalBlock(pos)) else null } /** diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/PreSimResult.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/PreSimResult.kt index 496552fc0..8369a0b27 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/PreSimResult.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/result/results/PreSimResult.kt @@ -19,6 +19,7 @@ package com.lambda.interaction.construction.simulation.result.results import baritone.api.pathing.goals.GoalBlock import com.lambda.graphics.mc.RenderBuilder +import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.construction.simulation.result.BuildResult import com.lambda.interaction.construction.simulation.result.ComparableResult import com.lambda.interaction.construction.simulation.result.Drawable @@ -53,7 +54,7 @@ sealed class PreSimResult : BuildResult() { override val rank = Rank.ChunkNotLoaded private val color = Color(252, 165, 3, 100) - override val goal = GoalBlock(pos) + override val goal = if (BaritoneHandler.isBaritoneLoaded) GoalBlock(pos) else null override fun RenderBuilder.render() { box(pos) { diff --git a/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt index ef5b23eb9..a4b19c48c 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/hotbar/HotbarManager.kt @@ -17,7 +17,6 @@ package com.lambda.interaction.managers.hotbar -import com.lambda.config.settings.blocks.HotbarConfig import com.lambda.config.settings.blocks.HotbarConfig.SwapMode import com.lambda.context.AutomatedSafeContext import com.lambda.context.SafeContext diff --git a/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt b/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt index a3b6c434a..343a95a8d 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/rotating/RotationManager.kt @@ -30,7 +30,6 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.managers.Manager -import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest import com.lambda.interaction.managers.rotating.Rotation.Companion.slerpPitch import com.lambda.interaction.managers.rotating.Rotation.Companion.slerpYaw import com.lambda.interaction.managers.rotating.RotationManager.activeRotation diff --git a/src/main/kotlin/com/lambda/module/Module.kt b/src/main/kotlin/com/lambda/module/Module.kt index 6ca912f2c..4909367d1 100644 --- a/src/main/kotlin/com/lambda/module/Module.kt +++ b/src/main/kotlin/com/lambda/module/Module.kt @@ -116,14 +116,14 @@ import com.lambda.util.Nameable */ @Suppress("unused") abstract class Module( - override val name: String, + name: String, val description: String = "", val tag: ModuleTag, private val alwaysListening: Boolean = false, enabledByDefault: Boolean = false, defaultKeybind: Bind = Bind.EMPTY, autoDisable: Boolean = false -) : Nameable, Muteable, OwnerPriority, Config(ModuleCategory), +) : Nameable, Muteable, OwnerPriority, Config(name, ModuleCategory), IMutableAutomationConfig by MutableAutomationConfig() { private val isEnabledSetting = setting("Enabled", enabledByDefault) { false } diff --git a/src/main/kotlin/com/lambda/module/hud/Coordinates.kt b/src/main/kotlin/com/lambda/module/hud/Coordinates.kt index 40f37ea86..91aba6e57 100644 --- a/src/main/kotlin/com/lambda/module/hud/Coordinates.kt +++ b/src/main/kotlin/com/lambda/module/hud/Coordinates.kt @@ -17,9 +17,10 @@ package com.lambda.module.hud +import com.lambda.config.ConfigEditor.edit import com.lambda.config.Tab -import com.lambda.config.applyEdits import com.lambda.config.settings.blocks.FormatterSettings +import com.lambda.config.withEdits import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag @@ -42,10 +43,8 @@ object Coordinates : HudModule( private val showCurrentDimensionOnly by setting("Show Current Dimension Only", true) private const val CurrentDimensionTab = "Current Dimension" - @Tab(CurrentDimensionTab) private val formatter by - settingBlock(FormatterSettings(this)) { - applyEdits { ::timeFormat.edit { hide() } } - } + @Tab(CurrentDimensionTab) private val formatter by settingBlock(FormatterSettings(this)) + .withEdits { ::timeFormat.edit { hide() } } // private val otherFormatter = FormatterSettings(this, Page.OtherDimension).apply { // ::timeFormat.edit { hide() } diff --git a/src/main/kotlin/com/lambda/module/hud/Rotation.kt b/src/main/kotlin/com/lambda/module/hud/Rotation.kt index e1cd83310..f527c21e0 100644 --- a/src/main/kotlin/com/lambda/module/hud/Rotation.kt +++ b/src/main/kotlin/com/lambda/module/hud/Rotation.kt @@ -17,8 +17,9 @@ package com.lambda.module.hud -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.edit import com.lambda.config.settings.blocks.FormatterSettings +import com.lambda.config.withEdits import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag @@ -31,11 +32,10 @@ object Rotation : HudModule( description = "Show your rotation", tag = ModuleTag.Hud, ) { - private val formatter by settingBlock(FormatterSettings(this)) { - applyEdits { + private val formatter by settingBlock(FormatterSettings(this)) + .withEdits { ::timeFormat.edit { hide() } } - } override fun ImGuiBuilder.buildLayout() { runSafe { diff --git a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt index 1e4bc484d..1876d935c 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt @@ -20,8 +20,6 @@ package com.lambda.module.modules.chat import com.lambda.config.Config import com.lambda.config.Group import com.lambda.config.SettingBlock -import com.lambda.config.settings.blocks.ReplaceConfig -import com.lambda.config.settings.blocks.ReplaceConfig.ActionStrategy import com.lambda.event.events.ChatEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.friend.FriendHandler @@ -35,6 +33,7 @@ import com.lambda.util.ChatUtils.sexual import com.lambda.util.ChatUtils.slurs import com.lambda.util.ChatUtils.swears import com.lambda.util.ChatUtils.toAscii +import com.lambda.util.Describable import com.lambda.util.text.DirectMessage import com.lambda.util.text.MessageParser import com.lambda.util.text.MessageType @@ -70,10 +69,9 @@ object AntiSpam : Module( var raw = event.message.string val author = MessageParser.playerName(raw) - if ( - ignoreSystem && !MessageType.Both.matches(raw) && !DirectMessage.Both.matches(raw) || - ignoreDms && DirectMessage.Receive.matches(raw) - ) return@listen + if ((ignoreSystem && !MessageType.Both.matches(raw) && !DirectMessage.Both.matches(raw)) || + (ignoreDms && DirectMessage.Receive.matches(raw)) + ) return@listen val slurMatches = slurs.takeIf { detectSlurs.enabled }.orEmpty().flatMap { it.findAll(raw).toList().reversed() } val swearMatches = swears.takeIf { detectSwears.enabled }.orEmpty().flatMap { it.findAll(raw).toList().reversed() } @@ -86,14 +84,13 @@ object AntiSpam : Module( var cancelled = false var hasMatches = false - fun doMatch(replace: ReplaceConfig, matches: Sequence) { - if ( - cancelled || - filterSystem && !MessageType.Both.matches(raw) && !DirectMessage.Both.matches(raw) || - filterDms && DirectMessage.Receive.matches(raw) || - filterFriends && author?.let { FriendHandler.isFriend(it) } == true || - filterSelf && MessageType.Self.matches(raw) - ) return + fun doMatch(replace: ReplaceSettings, matches: Sequence) { + if (cancelled || + (filterSystem && !MessageType.Both.matches(raw) && !DirectMessage.Both.matches(raw)) || + (filterDms && DirectMessage.Receive.matches(raw)) || + (filterFriends && author?.let { FriendHandler.isFriend(it) } == true) || + (filterSelf && MessageType.Self.matches(raw)) + ) return when (replace.action) { ActionStrategy.Hide -> matches.firstOrNull()?.let { event.cancel(); cancelled = true } // If there's one detection, nuke the whole damn thang @@ -115,8 +112,7 @@ object AntiSpam : Module( if (cancelled) return@listen event.cancel() - if (hasMatches) - event.message = Text.of(if (fancyChats) raw.toAscii else raw) + if (hasMatches) event.message = Text.of(if (fancyChats) raw.toAscii else raw) } } @@ -124,8 +120,24 @@ object AntiSpam : Module( val name: String, override val c: Config, actionStrategy: ActionStrategy = ActionStrategy.Replace - ) : SettingBlock, ReplaceConfig { - override val action by c.setting("$name Action Strategy", actionStrategy) - override val replace by c.setting("$name Replace Strategy", ReplaceConfig.ReplaceStrategy.CensorAll) { action == ActionStrategy.Replace } + ) : SettingBlock { + val action by c.setting("$name Action Strategy", actionStrategy) + val replace by c.setting("$name Replace Strategy", ReplaceStrategy.CensorAll) { action == ActionStrategy.Replace } + + val enabled: Boolean get() = action != ActionStrategy.None + } + + enum class ActionStrategy(override val description: String) : Describable { + Hide("Hides the message. Will override other strategies."), + Delete("Deletes the matching part off the message."), + Replace("Replace the matching string in the message with one of the following replace strategy."), + None("Don't do anything."), + } + + @Suppress("unused") + enum class ReplaceStrategy(val block: (String) -> String) { + CensorAll({ it.replaceRange(0.. if (i % 2 == 0) acc + char else "$acc*" } }), + KeepFirst({ if (it.length <= 1) it else it.replaceRange(1, it.length, "*".repeat(it.length - 1)) }), } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt b/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt index 58a2974da..9725e46dc 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt @@ -17,9 +17,11 @@ package com.lambda.module.modules.chat -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.editTyped +import com.lambda.config.ConfigEditor.hide import com.lambda.config.settings.blocks.FormatterConfig import com.lambda.config.settings.blocks.FormatterSettings +import com.lambda.config.withEdits import com.lambda.event.events.ChatEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module @@ -46,12 +48,11 @@ object ChatTimestamp : Module( .onValueChange { from, to -> if (to.colorIndex !in 0..15) color = from } private val javaColor: Color get() = Color(color.colorValue!! and 16777215) - val formatter by settingBlock(FormatterSettings(this)) { - applyEdits { + val formatter by settingBlock(FormatterSettings(this)) + .withEdits { hide(::localeEnum, ::sep, ::customSep, ::floatingPrecision) editTyped(::timeFormat) { defaultValue(FormatterConfig.Time.IsoLocalTime) } } - } private val currentTime get() = ZonedDateTime.of(LocalDateTime.now(), ZoneId.systemDefault()) diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt index b36d48018..8cc8af750 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.combat -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress @@ -96,9 +96,7 @@ object AutoArmor : Module( init { setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::inventoryConfig) - } + hideAllBlocksExcept(::inventoryConfig) } listen { diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt index 83511caa1..d571eaadf 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.combat -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent @@ -56,9 +56,7 @@ object AutoTotem : Module( init { setModulePriority(100) setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::inventoryConfig) - } + hideAllBlocksExcept(::inventoryConfig) } listen { diff --git a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt index a23398b3d..0fc8bd2be 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt @@ -17,8 +17,9 @@ package com.lambda.module.modules.combat +import com.lambda.config.ConfigEditor.hide +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.Tab -import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.TargetingSettings import com.lambda.context.SafeContext @@ -145,15 +146,13 @@ object CrystalAura : Module( init { setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::buildConfig, ::rotationConfig, ::hotbarConfig, ::inventoryConfig) - buildConfig.apply { - hide( - ::pathing, ::stayInRange, ::collectDrops, ::spleefEntities, - ::maxPendingActions, ::actionTimeout, ::maxBuildDependencies, ::breakBlocks, ::interactBlocks, ::placeBlocks - ) - } - } + hideAllBlocksExcept(::buildConfig, ::rotationConfig, ::hotbarConfig, ::inventoryConfig) + buildConfig.apply { + hide( + ::pathing, ::stayInRange, ::collectDrops, ::spleefEntities, + ::maxPendingActions, ::actionTimeout, ::maxBuildDependencies, ::breakBlocks, ::interactBlocks, ::placeBlocks + ) + } } // Async ticking diff --git a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt index d3f59ab54..18878e57b 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt @@ -17,8 +17,10 @@ package com.lambda.module.modules.combat +import com.lambda.config.ConfigEditor.edit +import com.lambda.config.ConfigEditor.hide +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.Tab -import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.TargetingSettings import com.lambda.context.SafeContext @@ -72,11 +74,6 @@ object KillAura : Module( private var hitDelay = 100.0 private var cooldownFromSwap = false - enum class Group(override val displayName: String) : NamedEnum { - General("General"), - Targeting("Targeting"), - } - enum class AttackMode { Cooldown, Delay @@ -91,18 +88,16 @@ object KillAura : Module( init { setModulePriority(90) setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::buildConfig, ::hotbarConfig, ::rotationConfig) - buildConfig.apply { - hide( - ::pathing, ::stayInRange, ::collectDrops, - ::spleefEntities, ::maxPendingActions, ::actionTimeout, - ::maxBuildDependencies, ::blockReach - ) - } - hotbarConfig.apply { - ::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) } - } + hideAllBlocksExcept(::buildConfig, ::hotbarConfig, ::rotationConfig) + buildConfig.apply { + hide( + ::pathing, ::stayInRange, ::collectDrops, + ::spleefEntities, ::maxPendingActions, ::actionTimeout, + ::maxBuildDependencies, ::blockReach + ) + } + hotbarConfig.apply { + ::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) } } } diff --git a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt index 06d5bef93..d66255bcd 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt @@ -17,7 +17,8 @@ package com.lambda.module.modules.combat -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.editTyped +import com.lambda.config.ConfigEditor.hideBlock import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.context.SafeContext import com.lambda.friend.FriendHandler.isFriend @@ -54,17 +55,15 @@ object PlayerTrap : Module( init { setDefaultAutomationConfig { - applyEdits { - buildConfig.apply { - editTyped( - ::pathing, - ::stayInRange, - ::spleefEntities, - ::collectDrops - ) { defaultValue(false); hide() } - } - hideBlock(::eatConfig) + buildConfig.apply { + editTyped( + ::pathing, + ::stayInRange, + ::spleefEntities, + ::collectDrops + ) { defaultValue(false); hide() } } + hideBlock(::eatConfig) } onEnable { diff --git a/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt b/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt index fbf8d6099..cd5f5f1c5 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt @@ -17,7 +17,8 @@ package com.lambda.module.modules.combat -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.editTyped +import com.lambda.config.ConfigEditor.hideBlock import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint import com.lambda.interaction.construction.verify.TargetState @@ -44,17 +45,15 @@ object Surround : Module( init { setDefaultAutomationConfig { - applyEdits { - buildConfig.apply { - editTyped( - ::pathing, - ::stayInRange, - ::spleefEntities, - ::collectDrops - ) { defaultValue(false); hide() } - } - hideBlock(::eatConfig) + buildConfig.apply { + editTyped( + ::pathing, + ::stayInRange, + ::spleefEntities, + ::collectDrops + ) { defaultValue(false); hide() } } + hideBlock(::eatConfig) } onEnable { diff --git a/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt b/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt index 15698f46e..f44dec380 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.debug -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.event.events.PlayerEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -33,9 +33,7 @@ object SilentSwap : Module( ) { init { setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::hotbarConfig) - } + hideAllBlocksExcept(::hotbarConfig) } listen { diff --git a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt index ec61e9c43..647fd7cdf 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt @@ -19,7 +19,8 @@ package com.lambda.module.modules.movement import com.lambda.Lambda import com.lambda.Lambda.mc -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.edit +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress @@ -100,11 +101,9 @@ object BetterFirework : Module( init { setModulePriority(1) setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::hotbarConfig, ::inventoryConfig) - hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) } - inventoryConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) } - } + hideAllBlocksExcept(::hotbarConfig, ::inventoryConfig) + hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) } + inventoryConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) } } listen { diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt index fc6fa0294..157e24ad2 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt @@ -17,9 +17,9 @@ package com.lambda.module.modules.movement +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.Group import com.lambda.config.Tab -import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -100,9 +100,7 @@ object ElytraAltitudeControl : Module( init { setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::rotationConfig) - } + hideAllBlocksExcept(::rotationConfig) } listen { diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt index 149a2e1fa..8ce8d6737 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt @@ -18,8 +18,8 @@ package com.lambda.module.modules.movement import baritone.api.pathing.goals.GoalGetToBlock +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.Group -import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.context.SafeContext import com.lambda.event.events.ClientEvent @@ -110,9 +110,7 @@ object ElytraFly : Module( init { setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::inventoryConfig, ::rotationConfig) - } + hideAllBlocksExcept(::inventoryConfig, ::rotationConfig) } listen { diff --git a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt index 8dde3e613..1e3e81c0f 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.movement -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.context.SafeContext import com.lambda.event.events.ClientEvent @@ -82,9 +82,7 @@ object Speed : Module( init { setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::rotationConfig) - } + hideAllBlocksExcept(::rotationConfig) } listen { diff --git a/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt b/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt index d93c482b2..64899e0e7 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.player -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.EatConfig.Companion.reasonEating import com.lambda.event.events.TickEvent @@ -39,9 +39,7 @@ object AutoEat : Module( init { setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::eatConfig) - } + hideAllBlocksExcept(::eatConfig) } listen { diff --git a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt index c1bcdacff..c166018af 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt @@ -17,7 +17,10 @@ package com.lambda.module.modules.player -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.edit +import com.lambda.config.ConfigEditor.editTyped +import com.lambda.config.ConfigEditor.hide +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.event.events.PlayerEvent import com.lambda.event.events.TickEvent @@ -39,45 +42,43 @@ object FastBreak : Module( init { setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::buildConfig, ::breakConfig, ::rotationConfig, ::hotbarConfig) - buildConfig.apply { - hide( - ::pathing, - ::stayInRange, - ::spleefEntities, - ::maxBuildDependencies, - ::collectDrops, - ::blockReach, - ::entityReach, - ::breakBlocks, - ::interactBlocks, - ::placeBlocks - ) - ::maxBuildDependencies.edit { defaultValue(0) } - editTyped( - ::strictRayCast - ) { defaultValue(false); } - hide(::strictRayCast, ::checkSideVisibility) - ::blockReach.edit { defaultValue(Double.MAX_VALUE) } - } - breakConfig.apply { - editTyped( - ::avoidFluids, - ::avoidSupporting, - ::efficientOnly, - ::suitableToolsOnly - ) { defaultValue(false) } - editTyped( - ::rotate, - ::doubleBreak - ) { defaultValue(false); hide() } - ::breaksPerTick.edit { defaultValue(1); hide() } - ::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Input.Post)); hide() } - hide(::sorter, ::unsafeCancels) - } - hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Input.Post)); hide() } + hideAllBlocksExcept(::buildConfig, ::breakConfig, ::rotationConfig, ::hotbarConfig) + buildConfig.apply { + hide( + ::pathing, + ::stayInRange, + ::spleefEntities, + ::maxBuildDependencies, + ::collectDrops, + ::blockReach, + ::entityReach, + ::breakBlocks, + ::interactBlocks, + ::placeBlocks + ) + ::maxBuildDependencies.edit { defaultValue(0) } + editTyped( + ::strictRayCast + ) { defaultValue(false); } + hide(::strictRayCast, ::checkSideVisibility) + ::blockReach.edit { defaultValue(Double.MAX_VALUE) } } + breakConfig.apply { + editTyped( + ::avoidFluids, + ::avoidSupporting, + ::efficientOnly, + ::suitableToolsOnly + ) { defaultValue(false) } + editTyped( + ::rotate, + ::doubleBreak + ) { defaultValue(false); hide() } + ::breaksPerTick.edit { defaultValue(1); hide() } + ::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Input.Post)); hide() } + hide(::sorter, ::unsafeCancels) + } + hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Input.Post)); hide() } } listen { it.cancel() } diff --git a/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt b/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt index fb50b107b..a4aeeb7af 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.player -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.event.events.InventoryEvent import com.lambda.event.events.PlayerEvent @@ -41,6 +41,7 @@ object InventoryTweaks : Module( ) { private val instantShulker by setting("Instant Shulker", true, description = "Right-click shulker boxes in your inventory to instantly place them and open them.") private val instantEChest by setting("Instant Ender-Chest", true, description = "Right-click ender chests in your inventory to instantly place them and open them.") + private var placedPos: BlockPos? = null private var placeAndOpen: Task<*>? = null private var lastBreak: Task<*>? = null @@ -48,9 +49,7 @@ object InventoryTweaks : Module( init { setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::breakConfig, ::interactConfig, ::inventoryConfig, ::hotbarConfig) - } + hideAllBlocksExcept(::breakConfig, ::interactConfig, ::inventoryConfig, ::hotbarConfig) } listen { diff --git a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt index c0573f8b8..2a79f4511 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt @@ -17,8 +17,11 @@ package com.lambda.module.modules.player +import com.lambda.config.ConfigEditor.edit +import com.lambda.config.ConfigEditor.editTyped +import com.lambda.config.ConfigEditor.hide +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.Group -import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.BreakConfig import com.lambda.context.SafeContext @@ -98,33 +101,31 @@ object PacketMine : Module( init { setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::buildConfig, ::breakConfig, breakConfig::outlineConfig, ::rotationConfig, ::hotbarConfig) - buildConfig.apply { - hide( - ::pathing, - ::stayInRange, - ::spleefEntities, - ::maxBuildDependencies, - ::collectDrops, - ::entityReach, - ::breakBlocks, - ::interactBlocks, - ::placeBlocks - ) - ::maxBuildDependencies.edit { defaultValue(0) } - } - breakConfig.apply { - editTyped( - ::avoidFluids, - ::avoidSupporting, - ::efficientOnly, - ::suitableToolsOnly - ) { defaultValue(false) } - ::swing.edit { defaultValue(BreakConfig.SwingMode.Start) } - } - hotbarConfig::keepTicks.edit { defaultValue(0) } + hideAllBlocksExcept(::buildConfig, ::breakConfig, breakConfig::outlineConfig, ::rotationConfig, ::hotbarConfig) + buildConfig.apply { + hide( + ::pathing, + ::stayInRange, + ::spleefEntities, + ::maxBuildDependencies, + ::collectDrops, + ::entityReach, + ::breakBlocks, + ::interactBlocks, + ::placeBlocks + ) + ::maxBuildDependencies.edit { defaultValue(0) } + } + breakConfig.apply { + editTyped( + ::avoidFluids, + ::avoidSupporting, + ::efficientOnly, + ::suitableToolsOnly + ) { defaultValue(false) } + ::swing.edit { defaultValue(BreakConfig.SwingMode.Start) } } + hotbarConfig::keepTicks.edit { defaultValue(0) } } listen { diff --git a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt index f1b87c3fb..e41ea5839 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt @@ -17,7 +17,8 @@ package com.lambda.module.modules.player -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.edit +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -44,10 +45,8 @@ object RotationLock : Module( setModulePriority(100) setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::rotationConfig) - rotationConfig::rotationMode.edit { defaultValue(RotationMode.Lock) } - } + hideAllBlocksExcept(::rotationConfig) + rotationConfig::rotationMode.edit { defaultValue(RotationMode.Lock) } } listen { diff --git a/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt b/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt index 7efa60c2f..a6c49321e 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt @@ -17,7 +17,8 @@ package com.lambda.module.modules.player -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.hide +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent @@ -42,11 +43,9 @@ object StackReplenish : Module( init { setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::inventoryConfig) - inventoryConfig.apply { - hide(::disposables, ::swapWithDisposables, ::providerPriority, ::storePriority) - } + hideAllBlocksExcept(::inventoryConfig) + inventoryConfig.apply { + hide(::disposables, ::swapWithDisposables, ::providerPriority, ::storePriority) } } diff --git a/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt b/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt index 0a2bee921..0505763f1 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.player -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.event.events.ContainerEvent import com.lambda.event.events.TickEvent @@ -44,9 +44,7 @@ object ToolSaver : Module( init { setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::inventoryConfig) - } + hideAllBlocksExcept(::inventoryConfig) } listen { diff --git a/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt b/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt index 6d741309e..2b1b5992c 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt @@ -17,21 +17,21 @@ package com.lambda.module.modules.render +import com.lambda.config.ConfigEditor.forEachSetting +import com.lambda.config.ConfigEditor.hide import com.lambda.config.Group -import com.lambda.config.applyEdits import com.lambda.config.settings.blocks.OutlineSettings import com.lambda.config.settings.blocks.WorldLineSettings +import com.lambda.config.withEdits import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRenderer import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.BlockUtils.blockState -import com.lambda.util.ChatUtils.colors import com.lambda.util.extension.tickDelta import com.lambda.util.math.lerp import com.lambda.util.world.raycast.RayCastUtils.blockResult -import net.minecraft.client.toast.SystemToast.hide import net.minecraft.util.math.Box import java.awt.Color @@ -57,23 +57,21 @@ object BlockOutline : Module( @Group(BoxFillGroup) private val fillColor by setting("Fill Color", Color(255, 255, 255, 20)) { fill && mode == Mode.Boxes } @Group(BoxOutlineGroup) private val boxOutline by setting("Box Outline", true) { mode == Mode.Boxes } @Group(BoxOutlineGroup) private val boxOutlineColor by setting("Box Outline Color", Color(255, 255, 255, 120)) { mode == Mode.Boxes && boxOutline } - @Group(BoxOutlineGroup) private val lineConfig by settingBlock(WorldLineSettings(this)) { - applyEdits { + @Group(BoxOutlineGroup) private val lineConfig by settingBlock(WorldLineSettings(this)) + .withEdits { hide(::startColor, ::endColor) forEachSetting { visibility { old -> { old() && mode == Mode.Boxes } } } } - } @Group(OutlineGroup) private val outlineColor by setting("Outline Color", boxOutlineColor) { mode == Mode.Outline } - @Group(OutlineGroup) private val outlineStyle by settingBlock(OutlineSettings(this)) { - applyEdits { + @Group(OutlineGroup) private val outlineStyle by settingBlock(OutlineSettings(this)) + .withEdits { forEachSetting { visibility { old -> { old() && mode == Mode.Outline } } } } - } var previous: List? = null diff --git a/src/main/kotlin/com/lambda/module/modules/render/ESP.kt b/src/main/kotlin/com/lambda/module/modules/render/ESP.kt index 962309cc5..def52b618 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/ESP.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/ESP.kt @@ -17,19 +17,20 @@ package com.lambda.module.modules.render +import com.lambda.config.ConfigEditor.forEachSetting +import com.lambda.config.ConfigEditor.hide import com.lambda.config.Group import com.lambda.config.Tab -import com.lambda.config.applyEdits import com.lambda.config.settings.blocks.EntityColorSettings import com.lambda.config.settings.blocks.EntitySelectionSettings import com.lambda.config.settings.blocks.OutlineSettings import com.lambda.config.settings.blocks.WorldLineSettings +import com.lambda.config.withEdits import com.lambda.graphics.mc.RenderBuilder import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRenderer import com.lambda.graphics.util.DynamicAABB.Companion.interpolatedBox import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.ChatUtils.colors import com.lambda.util.NamedEnum import com.lambda.util.math.setAlpha import net.minecraft.block.entity.BlockEntity @@ -65,7 +66,8 @@ object ESP : Module( @Tab(GeneralTab) private val depthTest by setting("Depth Test", false, "Blend ESP renders into the world") //Shader Outline - @Tab(GeneralTab) private val outlineStyle by settingBlock(OutlineSettings(this), { mode == EspMode.Shader }) + @Tab(GeneralTab) private val outlineStyle by settingBlock(OutlineSettings(this)) + .withEdits { forEachSetting { visibility { old -> { old() && mode == EspMode.Shader } } } } //Box @Tab(GeneralTab) private var drawFilled: Boolean by setting("Box Fill", true, "Fill entity boxes") { mode == EspMode.Box } @@ -74,12 +76,11 @@ object ESP : Module( @Tab(GeneralTab) @Group(BoxOutlineGroup) private var drawOutline: Boolean by setting("Box Outline", true, "Draw box outlines") { mode == EspMode.Box } .onValueChange { _, to -> if (!to && !drawFilled) drawFilled = true } @Tab(GeneralTab) @Group(BoxOutlineGroup) private val outlineAlpha by setting("Outline Alpha", 0.8, 0.0..1.0, 0.05) { mode == EspMode.Box && drawOutline } - @Tab(GeneralTab) @Group(BoxOutlineGroup) private val boxOutlineSettings by settingBlock(WorldLineSettings(this)) { - applyEdits { + @Tab(GeneralTab) @Group(BoxOutlineGroup) private val boxOutlineSettings by settingBlock(WorldLineSettings(this)) + .withEdits { forEachSetting { visibility { old -> { old() && mode == EspMode.Box && drawOutline } } } hide(::startColor, ::endColor) } - } @Tab(EntitiesTab) private val entitySettings by settingBlock(EntitySelectionSettings(this)) @Tab(ColorsTab) private val entityColors by settingBlock(EntityColorSettings(this)) diff --git a/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt b/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt index f63d72a36..201f95dfa 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt @@ -18,7 +18,8 @@ package com.lambda.module.modules.render import com.lambda.Lambda.mc -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.edit +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.context.SafeContext import com.lambda.event.events.MovementEvent @@ -122,12 +123,10 @@ object Freecam : Module( init { setDefaultAutomationConfig { - applyEdits { - rotationConfig::rotationMode.edit { - defaultValue(RotationMode.Lock) - } - hideAllBlocksExcept(::rotationConfig) + rotationConfig::rotationMode.edit { + defaultValue(RotationMode.Lock) } + hideAllBlocksExcept(::rotationConfig) } onEnable { diff --git a/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt b/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt index 078a559ef..c91c1dc8e 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt @@ -17,9 +17,11 @@ package com.lambda.module.modules.render +import com.lambda.config.ConfigEditor.forEachSetting +import com.lambda.config.ConfigEditor.hide import com.lambda.config.Group -import com.lambda.config.applyEdits import com.lambda.config.settings.blocks.WorldLineSettings +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.graphics.mc.LineDashStyle import com.lambda.graphics.mc.RenderBuilder @@ -60,15 +62,14 @@ object LightLevels : Module( @Group(FillGroup) private val fill by setting("Fill", false) { renderMode == RenderMode.Square }.onValueChange(::refreshChunkedRenderer) @Group(FillGroup) private val fillAlpha by setting("Fill Alpha", 0.2, 0.0..1.0, 0.01) { renderMode == RenderMode.Square && fill }.onValueChange(::refreshChunkedRenderer) @Group(LineGroup) private val outline by setting("Outline", true) { renderMode == RenderMode.Square }.onValueChange(::refreshChunkedRenderer) - @Group(LineGroup) private val worldLineConfig by settingBlock(WorldLineSettings(this)) { - applyEdits { + @Group(LineGroup) private val worldLineConfig by settingBlock(WorldLineSettings(this)) + .withEdits { hide(::startColor, ::endColor) forEachSetting { visibility { old -> { old() && renderMode != RenderMode.Square || outline } } onValueChange(::refreshChunkedRenderer) } } - } private val depthTest by setting("Depth Test", false, "Shows renders through terrain") private val horizontalRange by setting("Horizontal Range", 16, 1..32) { mode == Mode.Radius } private val verticalRange by setting("Vertical Range", 8, 1..32) { mode == Mode.Radius } diff --git a/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt b/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt index b576e2c9f..ba497188c 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt @@ -18,11 +18,13 @@ package com.lambda.module.modules.render import com.lambda.Lambda.mc +import com.lambda.config.ConfigEditor.edit +import com.lambda.config.ConfigEditor.hide import com.lambda.config.Group import com.lambda.config.Tab -import com.lambda.config.applyEdits import com.lambda.config.settings.blocks.EntitySelectionSettings import com.lambda.config.settings.blocks.ScreenTextSettings +import com.lambda.config.withEdits import com.lambda.friend.FriendHandler.isFriend import com.lambda.graphics.mc.RenderBuilder import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRenderer @@ -72,22 +74,19 @@ object Nametags : Module( @Tab(GeneralTab) private val itemCount by setting("Item Count", true) @Tab(GeneralTab) private val durabilityMode by setting("Durability Mode", DurabilityMode.Text) { gear } - @Tab(EntityTab) private val entitySelectionSettings by settingBlock(EntitySelectionSettings(this)) { - applyEdits { - hide(::blockEntities) - } - } + @Tab(EntityTab) private val entitySelectionSettings by settingBlock(EntitySelectionSettings(this)) + .withEdits { hide(::blockEntities) } private const val FriendGroup = "Friends" private const val OtherGroup = "Others" - @Tab(TextTab) @Group(FriendGroup) private val friendTextConfig by settingBlock(ScreenTextSettings(this)) { - applyEdits { + @Tab(TextTab) @Group(FriendGroup) private val friendTextConfig by settingBlock(ScreenTextSettings(this)) + .withEdits { hide(::sizeSetting) ::textColor.edit { defaultValue(Color(0, 255, 255, 255)) } } - } - @Tab(TextTab) @Group(OtherGroup) private val otherTextConfig by settingBlock(ScreenTextSettings(this)) { applyEdits { hide(::sizeSetting) } } + @Tab(TextTab) @Group(OtherGroup) private val otherTextConfig by settingBlock(ScreenTextSettings(this)) + .withEdits { hide(::sizeSetting) } @Tab(BackgroundTab) private val background by setting("Background", true) @Tab(BackgroundTab) private val backgroundColor by setting("Background Color", Color(0, 0, 0, 60)) { background } diff --git a/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt b/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt index 16310c730..0211aaede 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt @@ -17,9 +17,10 @@ package com.lambda.module.modules.render +import com.lambda.config.ConfigEditor.editTyped import com.lambda.config.Tab -import com.lambda.config.applyEdits import com.lambda.config.settings.blocks.EntitySelectionSettings +import com.lambda.config.withEdits import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.util.EntityUtils.createNameMap @@ -72,9 +73,10 @@ object NoRender : Module( // RenderLayer.getArmorEntityGlint(), RenderLayer.getGlint(), RenderLayer.getGlintTranslucent(), RenderLayer.getEntityGlint() // @JvmStatic val noEnchantmentGlint by setting("No Enchantment Glint", false).group(Group.Entity) // @JvmStatic val noDeadEntities by setting("No Dead Entities", false).group(Group.Entity) - @Tab(EntityTab) private val entitySettings by settingBlock(EntitySelectionSettings(this)) { - applyEdits { editTyped(::playerEntities, ::mobEntities, ::bossEntities) { defaultValue(mutableSetOf()) } } - } + @Tab(EntityTab) private val entitySettings by settingBlock(EntitySelectionSettings(this)) + .withEdits { + editTyped(::playerEntities, ::mobEntities, ::bossEntities) { defaultValue(mutableSetOf()) } + } @Tab(WorldTab) @JvmStatic val noTerrainFog by setting("No Terrain Fog", false) @Tab(WorldTab) @JvmStatic val noSignText by setting("No Sign Text", false) diff --git a/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt b/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt index faab883ce..d6ce66c19 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt @@ -17,9 +17,11 @@ package com.lambda.module.modules.render +import com.lambda.config.ConfigEditor.forEachSetting +import com.lambda.config.ConfigEditor.hide import com.lambda.config.Group -import com.lambda.config.applyEdits import com.lambda.config.settings.blocks.WorldLineSettings +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.graphics.mc.RenderBuilder import com.lambda.graphics.mc.renderer.ChunkedRenderer.Companion.chunkedRenderer @@ -28,7 +30,6 @@ import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe import com.lambda.util.BlockUtils.blockState -import com.lambda.util.ChatUtils.colors import com.lambda.util.math.setAlpha import com.lambda.util.world.toBlockPos import net.minecraft.block.Blocks @@ -55,15 +56,14 @@ object RadiusESP : Module( @Group(RenderGroup) private var outline: Boolean by setting("Outline", true).onValueChange(::rebuildMesh) .onValueChange { _, to -> if (!to) fill = true } @Group(RenderGroup) private val fillAlpha by setting("Fill Alpha", 0.1, 0.0..1.0, 0.01).onValueChange(::rebuildMesh) - @Group(RenderGroup, OutlineGroup) private val worldLineConfig by settingBlock(WorldLineSettings(this)) { - applyEdits { + @Group(RenderGroup, OutlineGroup) private val worldLineConfig by settingBlock(WorldLineSettings(this)) + .withEdits { hide(::startColor, ::endColor) forEachSetting { visibility { old -> { old() && outline } } onValueChange(::rebuildMesh) } } - } private val chunkedRenderer = chunkedRenderer("RadiusESP Chunked Renderer") { _, pos -> runSafe { diff --git a/src/main/kotlin/com/lambda/module/modules/render/Search.kt b/src/main/kotlin/com/lambda/module/modules/render/Search.kt index 685b83abf..9597f2b6f 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Search.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Search.kt @@ -17,12 +17,15 @@ package com.lambda.module.modules.render +import com.lambda.config.ConfigEditor.editTyped +import com.lambda.config.ConfigEditor.forEachSetting +import com.lambda.config.ConfigEditor.hide import com.lambda.config.Group -import com.lambda.config.applyEdits import com.lambda.config.settings.blocks.ScreenLineSettings import com.lambda.config.settings.blocks.WorldLineSettings import com.lambda.config.settings.collections.CollectionSetting.Companion.onDeselect import com.lambda.config.settings.collections.CollectionSetting.Companion.onSelect +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.event.events.WorldEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -85,24 +88,22 @@ object Search : Module( @Group(OutlineGroup) private val entityOutlineColor by setting("Entity Outline Color", Color(100, 150, 255, 128)) { outline && !useNaturalColor }.onValueChange(::rebuildMesh) @Group(OutlineGroup) private val blockOutlineMode by setting("Block Outline Mode", DirectionMask.OutlineMode.And, "Outline mode") { outline }.onValueChange(::rebuildMesh) - @Group(OutlineGroup) private val outlineConfig by settingBlock(WorldLineSettings(this)) { - applyEdits { + @Group(OutlineGroup) private val outlineConfig by settingBlock(WorldLineSettings(this)) + .withEdits { hide(::startColor, ::endColor) forEachSetting { visibility { old -> { old() && outline } } onValueChange(::rebuildMesh) } } - } @Group(TracersGroup) private val tracers by setting("Tracers", true, "Draw a line from your cursor to the highlighted position") - @Group(TracersGroup) private val tracerConfig by settingBlock(ScreenLineSettings(this)) { - applyEdits { + @Group(TracersGroup) private val tracerConfig by settingBlock(ScreenLineSettings(this)) + .withEdits { forEachSetting { visibility { old -> { old() && tracers } } } editTyped(::startColor, ::endColor) { visibility { { !useNaturalColor } } } } - } private val tracerBlockPositions = ConcurrentMap>>() diff --git a/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt b/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt index 306081ed2..0f36a93b2 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt @@ -17,18 +17,18 @@ package com.lambda.module.modules.render +import com.lambda.config.ConfigEditor.hide import com.lambda.config.Group import com.lambda.config.Tab -import com.lambda.config.applyEdits import com.lambda.config.settings.blocks.EntityColorSettings import com.lambda.config.settings.blocks.EntitySelectionSettings import com.lambda.config.settings.blocks.ScreenLineSettings +import com.lambda.config.withEdits import com.lambda.friend.FriendHandler.isFriend import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRenderer import com.lambda.graphics.mc.renderer.RendererUtils.worldToScreenNormalized import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.NamedEnum import com.lambda.util.extension.prevPos import com.lambda.util.extension.tickDelta import com.lambda.util.math.lerp @@ -43,11 +43,6 @@ object Tracers : Module( description = "Draws lines to entities within the world", tag = ModuleTag.Render ) { - private enum class LineGroup(override val displayName: String) : NamedEnum { - Other("Other"), - Friend("Friend") - } - private const val GeneralTab = "General" private const val EntityTab = "Entities" private const val ColorsTab = "Colors" @@ -58,16 +53,13 @@ object Tracers : Module( private const val FriendsLineGroup = "Friends" private const val OthersLineGroup = "Others" - @Tab(GeneralTab) @Group(FriendsLineGroup) private val friendLineConfig by settingBlock(ScreenLineSettings(this)) { - applyEdits { hide(::startColor, ::endColor) } - } - @Tab(GeneralTab) @Group(OthersLineGroup) private val otherLineConfig by settingBlock(ScreenLineSettings(this)) { - applyEdits { hide(::startColor, ::endColor) } - } + @Tab(GeneralTab) @Group(FriendsLineGroup) private val friendLineConfig by settingBlock(ScreenLineSettings(this)) + .withEdits { hide(::startColor, ::endColor) } + @Tab(GeneralTab) @Group(OthersLineGroup) private val otherLineConfig by settingBlock(ScreenLineSettings(this)) + .withEdits { hide(::startColor, ::endColor) } - @Tab(EntityTab) private val entitySettings by settingBlock(EntitySelectionSettings(this)) { - applyEdits { hide(::self, ::blockEntities) } - } + @Tab(EntityTab) private val entitySettings by settingBlock(EntitySelectionSettings(this)) + .withEdits { hide(::self, ::blockEntities) } @Tab(ColorsTab) private val entityColors by settingBlock(EntityColorSettings(this)) init { diff --git a/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt b/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt index e5acf170a..9fc79ed14 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt @@ -18,8 +18,8 @@ package com.lambda.module.modules.world import com.lambda.Lambda.mc +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.Group -import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.complex.Bind import com.lambda.context.SafeContext @@ -92,9 +92,7 @@ object AirPlace : Module( init { setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::interactConfig) - } + hideAllBlocksExcept(::interactConfig) } listen { diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt index 0bbb2fee5..5be3817b0 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt @@ -18,13 +18,17 @@ package com.lambda.module.modules.world import baritone.api.pathing.goals.GoalBlock +import com.lambda.config.ConfigEditor.edit +import com.lambda.config.ConfigEditor.forEachSetting +import com.lambda.config.ConfigEditor.hide +import com.lambda.config.ConfigEditor.hideBlock import com.lambda.config.Group -import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.WorldLineSettings import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress import com.lambda.config.settings.complex.KeybindSetting.Companion.onRelease +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -47,7 +51,6 @@ import com.lambda.task.tasks.BuildTask.Companion.build import com.lambda.util.BlockUtils.blockState import com.lambda.util.BlockUtils.isEmpty import com.lambda.util.BlockUtils.isNotEmpty -import com.lambda.util.ChatUtils.colors import com.lambda.util.PacketUtils.sendPacket import com.lambda.util.extension.blockColor import com.lambda.util.extension.tickDelta @@ -118,25 +121,22 @@ object AutoPortal : Module( @Group(RenderGroup) private val interpolate by setting("Interpolate", true, "Interpolates the portal renders from position to position") { renders } @Group(RenderGroup) private val depthTest by setting("Depth Test", false) { renders } @Group(RenderGroup, FillGroup) private val fillAlpha by setting("Fill Alpha", 0.3, 0.0..1.0, 0.01) { renders } - @Group(RenderGroup, OutlineGroup) private val outlineConfig by settingBlock(WorldLineSettings(this)) { - applyEdits { + @Group(RenderGroup, OutlineGroup) private val outlineConfig by settingBlock(WorldLineSettings(this)) + .withEdits { hide(::startColor, ::endColor) forEachSetting { visibility { old -> { old() && renders } } } } - } private var preview = false private var buildTask: Task<*>? = null init { setDefaultAutomationConfig { - applyEdits { - hideBlock(::eatConfig) - hotbarConfig::tickStageMask.edit { - defaultValue(mutableSetOf(TickEvent.Pre, TickEvent.Input.Post)) - } + hideBlock(::eatConfig) + hotbarConfig::tickStageMask.edit { + defaultValue(mutableSetOf(TickEvent.Pre, TickEvent.Input.Post)) } } diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt index 5ffbfb892..2719fc404 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.world +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.Group -import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress @@ -93,9 +93,7 @@ object AutoVillagerCycle : Module( init { setDefaultAutomationConfig { - applyEdits { - hideAllBlocksExcept(::rotationConfig, ::inventoryConfig, ::breakConfig, ::interactConfig, ::buildConfig) - } + hideAllBlocksExcept(::rotationConfig, ::inventoryConfig, ::breakConfig, ::interactConfig, ::buildConfig) } onEnable { diff --git a/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt b/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt index ff44720f1..8cd17e255 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.world -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.editTyped import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.construction.blueprint.Blueprint.Companion.emptyStructure @@ -92,11 +92,9 @@ object HighwayTools : Module( init { setDefaultAutomationConfig { - applyEdits { - buildConfig.apply { - editTyped(::pathing, ::stayInRange) { defaultValue(true) } - } - } + buildConfig.apply { + editTyped(::pathing, ::stayInRange) { defaultValue(true) } + } } onEnable { diff --git a/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt b/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt index 8fb083e37..e6eff41ac 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.world -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.editTyped import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.context.SafeContext import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint @@ -57,10 +57,8 @@ object Nuker : Module( init { setDefaultAutomationConfig { - applyEdits { - buildConfig.apply { - editTyped(::pathing, ::stayInRange) { defaultValue(false) } - } + buildConfig.apply { + editTyped(::pathing, ::stayInRange) { defaultValue(false) } } } diff --git a/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt b/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt index ec3e03a04..3093ff204 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt @@ -17,7 +17,10 @@ package com.lambda.module.modules.world -import com.lambda.config.applyEdits +import com.lambda.config.ConfigEditor.edit +import com.lambda.config.ConfigEditor.editTyped +import com.lambda.config.ConfigEditor.hide +import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.InteractConfig import com.lambda.config.settings.complex.Bind @@ -58,23 +61,21 @@ object Scaffold : Module( init { setDefaultAutomationConfig { - applyEdits { - buildConfig.apply { - editTyped(::pathing, ::stayInRange, ::collectDrops, ::spleefEntities) { - defaultValue(false) - hide() - } - ::checkSideVisibility.edit { defaultValue(true) } - hide(::breakBlocks) + buildConfig.apply { + editTyped(::pathing, ::stayInRange, ::collectDrops, ::spleefEntities) { + defaultValue(false) + hide() } - interactConfig::airPlace.edit { defaultValue(InteractConfig.AirPlaceMode.None) } - rotationConfig.apply { - ::instant.edit { defaultValue(false) } - ::mean.edit { defaultValue(120.0) } - ::spread.edit { defaultValue(0.0) } - } - hideAllBlocksExcept(::buildConfig, ::interactConfig, ::rotationConfig, ::hotbarConfig) + ::checkSideVisibility.edit { defaultValue(true) } + hide(::breakBlocks) + } + interactConfig::airPlace.edit { defaultValue(InteractConfig.AirPlaceMode.None) } + rotationConfig.apply { + ::instant.edit { defaultValue(false) } + ::mean.edit { defaultValue(120.0) } + ::spread.edit { defaultValue(0.0) } } + hideAllBlocksExcept(::buildConfig, ::interactConfig, ::rotationConfig, ::hotbarConfig) } listen { diff --git a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt index 9c1914225..3b019e2df 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt @@ -19,8 +19,11 @@ package com.lambda.module.modules.world import baritone.api.pathing.goals.GoalBlock import com.lambda.Lambda.mc +import com.lambda.config.ConfigEditor.edit +import com.lambda.config.ConfigEditor.editTyped +import com.lambda.config.ConfigEditor.hide +import com.lambda.config.ConfigEditor.hideBlock import com.lambda.config.Tab -import com.lambda.config.applyEdits import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.InteractConfig import com.lambda.config.settings.complex.Bind @@ -176,16 +179,14 @@ object StashMover : Module( init { setModulePriority(100) setDefaultAutomationConfig { - applyEdits { - buildConfig.apply { - editTyped(::pathing, ::stayInRange, ::checkSideVisibility) { defaultValue(true) } - hide(::pathing, ::stayInRange, ::collectDrops, ::spleefEntities, ::entityReach) - hideBlock(::eatConfig) - } - interactConfig::airPlace.edit { defaultValue(InteractConfig.AirPlaceMode.None) } - breakConfig.apply { - editTyped(::suitableToolsOnly, ::efficientOnly) { defaultValue(false) } - } + buildConfig.apply { + editTyped(::pathing, ::stayInRange, ::checkSideVisibility) { defaultValue(true) } + hide(::pathing, ::stayInRange, ::collectDrops, ::spleefEntities, ::entityReach) + hideBlock(::eatConfig) + } + interactConfig::airPlace.edit { defaultValue(InteractConfig.AirPlaceMode.None) } + breakConfig.apply { + editTyped(::suitableToolsOnly, ::efficientOnly) { defaultValue(false) } } } diff --git a/src/main/kotlin/com/lambda/network/CapeHandler.kt b/src/main/kotlin/com/lambda/network/CapeHandler.kt index 88fb1c5bd..ab89539f9 100644 --- a/src/main/kotlin/com/lambda/network/CapeHandler.kt +++ b/src/main/kotlin/com/lambda/network/CapeHandler.kt @@ -49,9 +49,10 @@ import kotlin.time.Duration.Companion.hours import kotlin.time.Duration.Companion.seconds @Suppress("unused") -object CapeHandler : Config(SecretsCategory), Loadable { - override val name: String = "capes" - +object CapeHandler : Config( + "capes", + SecretsCategory +), Loadable { var currentCape by setting("cape", "") .onValueChangeUnsafe { _, to -> updateCape(to) } diff --git a/src/main/kotlin/com/lambda/network/LambdaAPI.kt b/src/main/kotlin/com/lambda/network/LambdaAPI.kt index 228fb4798..62e99443b 100644 --- a/src/main/kotlin/com/lambda/network/LambdaAPI.kt +++ b/src/main/kotlin/com/lambda/network/LambdaAPI.kt @@ -42,9 +42,10 @@ import net.minecraft.text.Text import java.math.BigInteger import kotlin.jvm.optionals.getOrElse -object LambdaAPI : Config(LambdaCategory) { - override val name = "api" - +object LambdaAPI : Config( + "api", + LambdaCategory +) { val authServer by setting("Auth Server", "auth.lambda-client.org") val apiUrl by setting("API Server", "https://api.lambda-client.org") val apiVersion by setting("API Version", ApiVersion.V1) diff --git a/src/main/kotlin/com/lambda/network/NetworkHandler.kt b/src/main/kotlin/com/lambda/network/NetworkHandler.kt index d42a4096f..065ddeb78 100644 --- a/src/main/kotlin/com/lambda/network/NetworkHandler.kt +++ b/src/main/kotlin/com/lambda/network/NetworkHandler.kt @@ -27,9 +27,10 @@ import com.lambda.util.StringUtils.base64UrlDecode import com.lambda.util.StringUtils.json import com.lambda.util.collections.updatableLazy -object NetworkHandler : Config(SecretsCategory), Loadable { - override val name = "network" - +object NetworkHandler : Config( + "network", + SecretsCategory +), Loadable { var accessToken by setting("access_token", "") { false }; private set val isValid: Boolean diff --git a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt index d436a7f37..c97fce65e 100644 --- a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt +++ b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt @@ -279,7 +279,7 @@ class BuildTask private constructor( } is Navigable -> { - if (buildConfig.pathing) BaritoneHandler.setGoalAndPath(result.goal) + if (buildConfig.pathing) BaritoneHandler.setGoalAndPath(result.goal ?: return) } is Contextual -> { From 5d5d2cce27a1c3cf95ae3c7dfd157f9930db288a Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Thu, 14 May 2026 22:52:38 +0100 Subject: [PATCH 15/40] better ElytraAltitudeControl setting layout --- .../modules/movement/ElytraAltitudeControl.kt | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt index 157e24ad2..249ce6c21 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt @@ -18,7 +18,6 @@ package com.lambda.module.modules.movement import com.lambda.config.ConfigEditor.hideAllBlocksExcept -import com.lambda.config.Group import com.lambda.config.Tab import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.event.events.TickEvent @@ -49,38 +48,36 @@ object ElytraAltitudeControl : Module( Altitude } - private const val SpeedControlGroup = "Speed Control" - private const val AltitudeControlGroup = "Altitude Control" - private const val Pitch40ControlGroup = "Pitch 40 Control" - val controlValue by setting("Control Value", Mode.Altitude) - - val maxPitchAngle by setting("Max Pitch Angle", 45.0, 0.0..90.0, 1.0, unit = "°", description = "Maximum pitch angle") - val disableOnFirework by setting("Disable On Firework", false, description = "Disables the module when a firework is used") - val targetAltitude by setting("Target Altitude", 120, 0..256, 10, unit = " blocks", description = "Adjusts pitch to control altitude") { controlValue == Mode.Altitude } - @Group(AltitudeControlGroup) val altitudeControllerP by setting("Altitude Control P", 1.2, 0.0..2.0, 0.05) - @Group(AltitudeControlGroup) val altitudeControllerD by setting("Altitude Control D", 0.85, 0.0..1.0, 0.05) - @Group(AltitudeControlGroup) val altitudeControllerI by setting("Altitude Control I", 0.04, 0.0..1.0, 0.05) - @Group(AltitudeControlGroup) val altitudeControllerConst by setting("Altitude Control Const", 0.0, 0.0..10.0, 0.1) - val targetSpeed by setting("Target Speed", 20.0, 0.1..50.0, 0.1, unit = " m/s", description = "Adjusts pitch to control speed") { controlValue == Mode.Speed } + val horizontalSpeed by setting("Horizontal Speed", false, description = "Uses horizontal speed instead of total speed for speed control") { controlValue == Mode.Speed } - @Group(SpeedControlGroup) val speedControllerP by setting("Speed Control P", 6.75, 0.0..10.0, 0.05) - @Group(SpeedControlGroup) val speedControllerD by setting("Speed Control D", 4.5, 0.0..5.0, 0.05) - @Group(SpeedControlGroup) val speedControllerI by setting("Speed Control I", 0.3, 0.0..1.0, 0.05) + + val maxPitchAngle by setting("Max Pitch Angle", 45.0, 0.0..90.0, 1.0, unit = "°", description = "Maximum pitch angle") + val disableOnFirework by setting("Disable On Firework", false, description = "Disables the module when a firework is used") val useFireworkOnHeight by setting("Use Firework On Height", false, "Use fireworks when below a certain height") - val minHeight by setting("Min Height", 50, 0..256, 10, unit = " blocks", description = "Minimum height to use firework") { useFireworkOnHeight } + val minHeight by setting("Min Height", 150, 0..256, 10, unit = " blocks", description = "Minimum height to use firework") { useFireworkOnHeight } val useFireworkOnSpeed by setting("Use Firework On Speed", false, "Use fireworks based on speed") val minSpeed by setting("Min Speed", 20.0, 0.1..50.0, 0.1, unit = " m/s", description = "Minimum speed to use fireworks") { useFireworkOnSpeed } - var lastPos: Vec3d = Vec3d.ZERO - val speedController: PIController = PIController({ speedControllerP }, { speedControllerD }, { speedControllerI }, { 0.0 }) - val altitudeController: PIController = PIController({ altitudeControllerP }, { altitudeControllerD }, { altitudeControllerI }, { altitudeControllerConst }) - val usePitch40OnHeight by setting("Use Pitch 40 On Height", false, "Use Pitch 40 to gain height and speed") + + private const val AltitudeControlGroup = "Altitude Control" + private const val SpeedControlGroup = "Speed Control" + private const val Pitch40ControlGroup = "Pitch 40 Control" + + @Tab(AltitudeControlGroup) val altitudeControllerP by setting("PID P", 1.2, 0.0..2.0, 0.05) + @Tab(AltitudeControlGroup) val altitudeControllerD by setting("PID D", 0.85, 0.0..1.0, 0.05) + @Tab(AltitudeControlGroup) val altitudeControllerI by setting("PID I", 0.04, 0.0..1.0, 0.05) + @Tab(AltitudeControlGroup) val altitudeControllerConst by setting("PID const", 0.0, 0.0..10.0, 0.1) + + @Tab(SpeedControlGroup) val speedControllerP by setting("PID P", 6.75, 0.0..10.0, 0.05) + @Tab(SpeedControlGroup) val speedControllerD by setting("PID D", 4.5, 0.0..5.0, 0.05) + @Tab(SpeedControlGroup) val speedControllerI by setting("PID I", 0.3, 0.0..1.0, 0.05) + @Tab(Pitch40ControlGroup) val logHeightGain by setting("Log Height Gain", false, "Logs the height gained each cycle to the chat") { usePitch40OnHeight } @Tab(Pitch40ControlGroup) val minHeightForPitch40 by setting("Min Height For Pitch 40", 120, 0..256, 10, unit = " blocks", description = "Minimum height to use Pitch 40") { usePitch40OnHeight } @Tab(Pitch40ControlGroup) val pitch40ExitHeight by setting("Exit height", 190, 0..256, 10, unit = " blocks", description = "Height to exit Pitch 40 mode") { usePitch40OnHeight } @@ -90,6 +87,10 @@ object ElytraAltitudeControl : Module( @Tab(Pitch40ControlGroup) val pitch40SpeedThreshold by setting("Speed Threshold", 41f, 10f..100f, .5f, description = "Speed at which to start pitching up") { usePitch40OnHeight } @Tab(Pitch40ControlGroup) val pitch40UseFireworkOnUpTrajectory by setting("Use Firework On Up Trajectory", false, "Use fireworks when converting speed to altitude in the Pitch 40 maneuver") { usePitch40OnHeight } + var lastPos: Vec3d = Vec3d.ZERO + val speedController: PIController = PIController({ speedControllerP }, { speedControllerD }, { speedControllerI }, { 0.0 }) + val altitudeController: PIController = PIController({ altitudeControllerP }, { altitudeControllerD }, { altitudeControllerI }, { altitudeControllerConst }) + var controlState = ControlState.AttitudeControl var state = Pitch40State.GainSpeed var lastAngle = pitch40UpStartAngle From a45c4fb328391ac23b3e8dc9fe8f6ecb5c639619 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Sat, 16 May 2026 00:47:59 +0100 Subject: [PATCH 16/40] mostly fixed config command and added module a module dsl marker --- .../lambda/command/commands/ConfigCommand.kt | 111 ++++++++---------- .../command/commands/TransferCommand.kt | 6 +- src/main/kotlin/com/lambda/module/Module.kt | 13 ++ 3 files changed, 63 insertions(+), 67 deletions(-) diff --git a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt index c40558916..a7c710e93 100644 --- a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt @@ -17,7 +17,6 @@ package com.lambda.command.commands -import com.lambda.brigadier.CommandResult import com.lambda.brigadier.CommandResult.Companion.failure import com.lambda.brigadier.CommandResult.Companion.success import com.lambda.brigadier.argument.literal @@ -30,13 +29,14 @@ import com.lambda.config.Config.SettingLayer import com.lambda.config.ConfigLoader import com.lambda.util.CommunicationUtils.info import com.lambda.util.extension.CommandBuilder -import com.mojang.brigadier.builder.ArgumentBuilder import net.minecraft.command.CommandSource.suggestMatching +//ToDo: Make this command add and remove paths when configs are created or removed. +// Brigadier doesn't allow for removing paths by default, so that's something we might have to look into creating our own small system for. object ConfigCommand : LambdaCommand( name = "config", aliases = setOf("cfg", "settings", "setting"), - usage = "config [group/tab...] [value]", + usage = "config [value]", description = "Save or load configuration files, or set/reset any settings value", examples = listOf("config save", "config load", "config set HighwayTools Pavement_Material minecraft:obsidian") ) { @@ -46,7 +46,7 @@ object ConfigCommand : LambdaCommand( ConfigLoader.configCategories.forEach { config -> config.trySaveToFile(true) } - this@ConfigCommand.info("Saved ${ConfigLoader.configCategories.size} configuration files.") + this@ConfigCommand.info("Saved ${ConfigLoader.configCategories.size} config files.") return@executeWithResult success() } } @@ -55,75 +55,58 @@ object ConfigCommand : LambdaCommand( ConfigLoader.configCategories.forEach { config -> config.tryLoadFromFile() } - this@ConfigCommand.info("Loaded ${ConfigLoader.configCategories.size} configuration files.") + this@ConfigCommand.info("Loaded ${ConfigLoader.configCategories.size} config files.") return@executeWithResult success() } } required(literal("reset")) { - settingArgument { layer -> - layer.setting.reset() - success() + required(string("config")) { configArg -> + suggests { _, builder -> + suggestMatching(ConfigLoader.configs.map { it.commandName }, builder) + } + required(string("setting")) { settingArg -> + suggests { context, builder -> + val config = ConfigLoader.configByCommandName(configArg(context).value()) ?: return@suggests null + val suggestions = mutableListOf() + config.forEachSetting { path, single -> + val settingLit = + if (path.isEmpty()) single.setting.name + else "${path.joinToString("->")}->${single.setting.commandName}" + suggestions.add(settingLit) + } + suggestMatching(suggestions, builder) + } + executeWithResult { + val config = ConfigLoader.configByCommandName(configArg().value()) ?: return@executeWithResult failure("Config not found.") + var currentMultiple: SettingLayer.Multiple = config.settingLayers + val fullSettingPath = settingArg().value().split("->") + fullSettingPath.dropLast(1).forEach { path -> + currentMultiple = currentMultiple.layers + .asSequence() + .filterIsInstance() + .find { it.name == path } ?: return@executeWithResult failure("Setting not found.") + } + val settingLayer = currentMultiple.layers + .asSequence() + .filterIsInstance>() + .find { it.setting.commandName == fullSettingPath.last() } ?: return@executeWithResult failure("Setting not found.") + settingLayer.setting.reset() + success() + } + } } } required(literal("set")) { - settingArgument { layer -> - with(layer.setting) { buildCommand(registry) } - success() - } - } - } - - private fun > B.settingArgument(block: B.(SettingLayer.Single<*, *>) -> CommandResult) { - required(string("config")) { configArg -> - suggests { _, builder -> - suggestMatching(ConfigLoader.configs.map { it.commandName }, builder) - } - executeWithResult { - val configString = configArg().value() - val config = ConfigLoader.configByCommandName(configString) ?: return@executeWithResult failure("Config not found") - config.reset() - success() - } - required(string("setting")) { settingArg -> - suggests { context, builder -> - val configString = configArg(context).value() - val config = ConfigLoader.configByCommandName(configString) ?: return@suggests null - val suggestions = mutableListOf() - fun forEach(layer: SettingLayer.Multiple, layerPath: List) { - layer.layers.forEach { layer -> - when (layer) { - is SettingLayer.Single<*, *> -> suggestions.add("${layerPath.joinToString("->")}->${layer.setting.commandName}") - is SettingLayer.Multiple -> forEach(layer, layerPath + layer.name) - } + ConfigLoader.configs.forEach { config -> + required(literal(config.commandName)) { + config.forEachSetting { path, single -> + val settingLit = + if (path.isEmpty()) single.setting.commandName + else "${path.joinToString("->")}->${single.setting.commandName}" + required(literal(settingLit)) { + with(single.setting) { buildCommand(registry) } } } - - forEach(config.settingLayers, emptyList()) - suggestMatching(suggestions, builder) - } - executeWithResult { - val configString = configArg().value() - val config = ConfigLoader.configByCommandName(configString) ?: return@executeWithResult failure("Config not found") - val settingString = settingArg().value() - val fullPath = settingString.split("->") - val settingName = fullPath.last() - var currentLayer: SettingLayer.Multiple = config.settingLayers - fullPath.forEachIndexed { index, layerName -> - if (index == fullPath.size - 1) return@forEachIndexed - val layer = currentLayer.layers - .asSequence() - .filterIsInstance() - .find { it.name == layerName } - if (layer == null) return@executeWithResult failure("Config layer not found: $layerName") - currentLayer = layer - } - - val settingLayer = currentLayer.layers - .asSequence() - .filterIsInstance>() - .find { it.setting.commandName == settingName } - if (settingLayer == null) return@executeWithResult failure("Setting not found: $settingName") - return@executeWithResult block(settingLayer) } } } diff --git a/src/main/kotlin/com/lambda/command/commands/TransferCommand.kt b/src/main/kotlin/com/lambda/command/commands/TransferCommand.kt index 39c55a9da..37a6c46ed 100644 --- a/src/main/kotlin/com/lambda/command/commands/TransferCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/TransferCommand.kt @@ -54,7 +54,7 @@ object TransferCommand : LambdaCommand( val selection = selectStack(amount(ctx).value()) { isItem(stack(ctx).value().item) } - AutomationConfig.Companion.Default.runSafeAutomated { + AutomationConfig.Default.runSafeAutomated { val containers = selection.findContainersWithMaterial() val indexedContainers = containers.withIndex() @@ -75,7 +75,7 @@ object TransferCommand : LambdaCommand( val selection = selectStack(amount(ctx).value()) { isItem(stack(ctx).value().item) } - AutomationConfig.Companion.Default.runSafeAutomated { + AutomationConfig.Default.runSafeAutomated { val containers = selection.findContainersWithSpace() val indexedContainers = containers.withIndex() @@ -95,7 +95,7 @@ object TransferCommand : LambdaCommand( val selection = selectStack(amount().value()) { isItem(stack().value().item) } - AutomationConfig.Companion.Default.runSafeAutomated { + AutomationConfig.Default.runSafeAutomated { val fromContainer = ContainerHandler.containers().find { it.name == from().value().split(".").last().trim() } ?: return@executeWithResult failure("From container not found") diff --git a/src/main/kotlin/com/lambda/module/Module.kt b/src/main/kotlin/com/lambda/module/Module.kt index b04c1ae62..588f7a9b6 100644 --- a/src/main/kotlin/com/lambda/module/Module.kt +++ b/src/main/kotlin/com/lambda/module/Module.kt @@ -164,57 +164,70 @@ abstract class Module( listen { if (autoDisable) disable() } } + @DslMarker + private annotation class ModuleDsl + + @ModuleDsl fun enable() { ModuleEvent.Enabled(this@Module).post() isEnabled = true } + @ModuleDsl fun disable() { ModuleEvent.Disabled(this@Module).post() isEnabled = false } + @ModuleDsl fun toggle() { ModuleEvent.Toggle(this@Module, !isEnabled).post() if (isEnabled) disable() else enable() } + @ModuleDsl fun onEnable(block: SafeContext.() -> Unit) { isEnabledSetting.onValueChange { from, to -> if (!from && to) block() } } + @ModuleDsl fun onDisable(block: SafeContext.() -> Unit) { isEnabledSetting.onValueChange { from, to -> if (from && !to) block() } } + @ModuleDsl fun onToggle(block: SafeContext.(to: Boolean) -> Unit) { isEnabledSetting.onValueChange { from, to -> if (from != to) block(to) } } + @ModuleDsl fun onEnableUnsafe(block: () -> Unit) { isEnabledSetting.onValueChangeUnsafe { from, to -> if (!from && to) block() } } + @ModuleDsl fun onDisableUnsafe(block: () -> Unit) { isEnabledSetting.onValueChangeUnsafe { from, to -> if (from && !to) block() } } + @ModuleDsl fun onToggleUnsafe(block: (to: Boolean) -> Unit) { isEnabledSetting.onValueChangeUnsafe { from, to -> if (from != to) block(to) } } + @ModuleDsl protected fun setModulePriority(priority: Int) { prioritySetting.value = priority prioritySetting.core.defaultValue = priority From 37882ed89f292150ef99b985c53d460d0130ec6b Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Sat, 16 May 2026 00:56:33 +0100 Subject: [PATCH 17/40] fix compilation errors --- src/main/kotlin/com/lambda/Lambda.kt | 12 ------------ .../kotlin/com/lambda/config/codecs/BindCodec.kt | 5 ++++- .../lambda/module/modules/client/ModuleNotifier.kt | 8 +++----- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/com/lambda/Lambda.kt b/src/main/kotlin/com/lambda/Lambda.kt index 4cfbde19d..6dcb49f85 100644 --- a/src/main/kotlin/com/lambda/Lambda.kt +++ b/src/main/kotlin/com/lambda/Lambda.kt @@ -19,18 +19,6 @@ package com.lambda import com.google.gson.Gson import com.google.gson.GsonBuilder -import com.lambda.config.serializer.BindCodec -import com.lambda.config.serializer.BlockCodec -import com.lambda.config.serializer.BlockPosCodec -import com.lambda.config.serializer.ColorSerializer -import com.lambda.config.serializer.GameProfileCodec -import com.lambda.config.serializer.ItemCodec -import com.lambda.config.serializer.ItemStackCodec -import com.lambda.config.serializer.KeyCodeCodec -import com.lambda.config.serializer.OptionalCodec -import com.lambda.config.serializer.TextCodec -import com.lambda.config.serializer.UUIDCodec -import com.lambda.config.settings.complex.Bind import com.lambda.config.Codec import com.lambda.core.Loader import com.lambda.event.events.ClientEvent diff --git a/src/main/kotlin/com/lambda/config/codecs/BindCodec.kt b/src/main/kotlin/com/lambda/config/codecs/BindCodec.kt index ba9de5608..d6915d913 100644 --- a/src/main/kotlin/com/lambda/config/codecs/BindCodec.kt +++ b/src/main/kotlin/com/lambda/config/codecs/BindCodec.kt @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -package com.lambda.config.serializer +package com.lambda.config.codecs import com.google.gson.JsonDeserializationContext import com.google.gson.JsonElement @@ -25,7 +25,10 @@ import com.lambda.config.Codec import com.lambda.config.settings.complex.Bind import java.lang.reflect.Type +@Suppress("unused") object BindCodec : Codec { + override val type = Bind::class.java + override fun serialize(src: Bind, typeOfSrc: Type, context: JsonSerializationContext): JsonElement = JsonObject().apply { addProperty("key", src.key) diff --git a/src/main/kotlin/com/lambda/module/modules/client/ModuleNotifier.kt b/src/main/kotlin/com/lambda/module/modules/client/ModuleNotifier.kt index a7861b00e..0b055fbdb 100644 --- a/src/main/kotlin/com/lambda/module/modules/client/ModuleNotifier.kt +++ b/src/main/kotlin/com/lambda/module/modules/client/ModuleNotifier.kt @@ -21,22 +21,20 @@ import com.lambda.event.events.ModuleEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.threading.runSafe -import com.lambda.util.Communication.log +import com.lambda.util.CommunicationUtils.log import com.lambda.util.Describable import com.lambda.util.NamedEnum import com.lambda.util.text.TextBuilder -import com.lambda.util.text.buildText import com.lambda.util.text.color import com.lambda.util.text.literal -import net.minecraft.text.Text import net.minecraft.util.Colors import java.awt.Color +@Suppress("unused") object ModuleNotifier : Module( name = "ModuleNotifier", description = "Notifies you when a module is enabled or disabled", - tag = ModuleTag.CLIENT + tag = ModuleTag.Client ) { var notifyTarget by setting("Notify Target", setOf(NotifyTarget.ActionBar), NotifyTarget.entries.toSet(), description = "Where to send notifications when modules are toggled") From 44004cd44dda6afe8bda46ec0b1636c35ae87634 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Sat, 16 May 2026 00:59:36 +0100 Subject: [PATCH 18/40] more comp errors --- .../kotlin/com/lambda/module/modules/client/ModuleNotifier.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/module/modules/client/ModuleNotifier.kt b/src/main/kotlin/com/lambda/module/modules/client/ModuleNotifier.kt index 7106b9114..7b5b7ad1c 100644 --- a/src/main/kotlin/com/lambda/module/modules/client/ModuleNotifier.kt +++ b/src/main/kotlin/com/lambda/module/modules/client/ModuleNotifier.kt @@ -21,11 +21,11 @@ import com.lambda.event.events.ModuleEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module import com.lambda.module.tag.ModuleTag -import com.lambda.util.Communication.log import com.lambda.util.CommunicationUtils.log import com.lambda.util.Describable import com.lambda.util.NamedEnum import com.lambda.util.text.TextBuilder +import com.lambda.util.text.buildText import com.lambda.util.text.color import com.lambda.util.text.literal import net.minecraft.util.Colors From 4e3b60b0a42fda9ad6264c481c0157a8ae344b21 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Sat, 16 May 2026 13:45:05 +0100 Subject: [PATCH 19/40] fix ConfigCommand and remove setModulePriority in favor of a param in the Module constructor --- .../com/lambda/mixin/CrashReportMixin.java | 3 +- .../lambda/command/commands/ConfigCommand.kt | 4 +- .../lambda/command/commands/ModuleCommand.kt | 7 +--- src/main/kotlin/com/lambda/config/Config.kt | 12 +++--- .../automation/IMutableAutomationConfig.kt | 2 +- .../kotlin/com/lambda/module/HudModule.kt | 2 +- src/main/kotlin/com/lambda/module/Module.kt | 29 ++++++-------- .../lambda/module/modules/chat/AntiSpam.kt | 2 +- .../module/modules/combat/AutoDisconnect.kt | 2 +- .../lambda/module/modules/combat/AutoTotem.kt | 2 +- .../lambda/module/modules/combat/KillAura.kt | 2 +- .../module/modules/movement/BetterFirework.kt | 2 +- .../module/modules/player/ClickFriend.kt | 5 +-- .../module/modules/player/PacketMine.kt | 40 +++++++++---------- .../module/modules/player/RotationLock.kt | 3 +- .../lambda/module/modules/world/StashMover.kt | 4 +- .../kotlin/com/lambda/util/Diagnostics.kt | 2 +- 17 files changed, 56 insertions(+), 67 deletions(-) diff --git a/src/main/java/com/lambda/mixin/CrashReportMixin.java b/src/main/java/com/lambda/mixin/CrashReportMixin.java index e41d2f218..86700228d 100644 --- a/src/main/java/com/lambda/mixin/CrashReportMixin.java +++ b/src/main/java/com/lambda/mixin/CrashReportMixin.java @@ -18,6 +18,7 @@ package com.lambda.mixin; import com.lambda.Lambda; +import com.lambda.config.Config.SettingLayer; import com.lambda.module.Module; import com.lambda.module.ModuleRegistry; import com.lambda.util.DynamicExceptionKt; @@ -72,7 +73,7 @@ String injectString(ReportType type, List extraInfo, Operation o (path, single) -> { final var setting = single.getSetting(); if (setting.isModified()) { - list.add("\t\t" + String.join(".", path) + "." + setting.getName() + " -> " + setting.getValue()); + list.add("\t\t" + String.join(".", path.stream().map(SettingLayer.Multiple::getName).toList()) + "." + setting.getName() + " -> " + setting.getValue()); } return Unit.INSTANCE; } diff --git a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt index a7c710e93..8416f379d 100644 --- a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt @@ -71,7 +71,7 @@ object ConfigCommand : LambdaCommand( config.forEachSetting { path, single -> val settingLit = if (path.isEmpty()) single.setting.name - else "${path.joinToString("->")}->${single.setting.commandName}" + else "${path.joinToString("->") { it.commandName }}->${single.setting.commandName}" suggestions.add(settingLit) } suggestMatching(suggestions, builder) @@ -102,7 +102,7 @@ object ConfigCommand : LambdaCommand( config.forEachSetting { path, single -> val settingLit = if (path.isEmpty()) single.setting.commandName - else "${path.joinToString("->")}->${single.setting.commandName}" + else "${path.joinToString("->") { it.commandName }}->${single.setting.commandName}" required(literal(settingLit)) { with(single.setting) { buildCommand(registry) } } diff --git a/src/main/kotlin/com/lambda/command/commands/ModuleCommand.kt b/src/main/kotlin/com/lambda/command/commands/ModuleCommand.kt index a4dfd4a6d..d4f21fd25 100644 --- a/src/main/kotlin/com/lambda/command/commands/ModuleCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/ModuleCommand.kt @@ -125,11 +125,8 @@ object ModuleCommand : LambdaCommand( return@runSafe success() } - if (enable().value()) { - module.enable() - } else { - module.disable() - } + if (enable().value()) module.enable() + else module.disable() } this@ModuleCommand.info(buildText { styled(Color.GRAY) { diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index 550e97acb..cb336a70b 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -589,16 +589,16 @@ abstract class Config( internal fun forEachSetting( root: SettingLayer.Multiple = settingLayers, recurse: Boolean = true, - onMultiple: ((path: List, single: SettingLayer.Multiple) -> Unit)? = null, - onSingle: ((path: List, single: SettingLayer.Single<*, *>) -> Unit)? = null + onMultiple: ((path: List, single: SettingLayer.Multiple) -> Unit)? = null, + onSingle: ((path: List, single: SettingLayer.Single<*, *>) -> Unit)? = null ) { - fun internalForEach(layer: SettingLayer.Multiple, path: List) { + fun internalForEach(layer: SettingLayer.Multiple, path: List) { layer.layers.forEach { layer -> when (layer) { is SettingLayer.Single<*, *> if onSingle != null -> onSingle(path, layer) - is SettingLayer.Multiple if onMultiple != null -> { - onMultiple(path, layer) - if (recurse) internalForEach(layer, path + layer.name) + is SettingLayer.Multiple -> { + if (onMultiple != null) onMultiple(path, layer) + if (recurse) internalForEach(layer, path + layer) } else -> {} } diff --git a/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt index 06e1a4554..2b88d81e3 100644 --- a/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt @@ -64,7 +64,7 @@ class MutableAutomationConfig : IMutableAutomationConfig { val subLayer = otherLayer.layers .asSequence() .filterIsInstance() - .find { it.name == layer } ?: return@forEachSetting + .find { it.name == layer.name } ?: return@forEachSetting otherLayer = subLayer } val otherSetting = otherLayer.layers diff --git a/src/main/kotlin/com/lambda/module/HudModule.kt b/src/main/kotlin/com/lambda/module/HudModule.kt index e084165f1..9b3d571e4 100644 --- a/src/main/kotlin/com/lambda/module/HudModule.kt +++ b/src/main/kotlin/com/lambda/module/HudModule.kt @@ -29,6 +29,6 @@ abstract class HudModule( alwaysListening: Boolean = false, enabledByDefault: Boolean = false, defaultKeybind: Bind = Bind.EMPTY, -) : Module(name, description, tag, alwaysListening, enabledByDefault, defaultKeybind), Layout { +) : Module(name, description, tag, alwaysListening, enabledByDefault, defaultKeybind = defaultKeybind), Layout { val backgroundColor = setting("Background Color", Color(0, 0, 0, 0)) } diff --git a/src/main/kotlin/com/lambda/module/Module.kt b/src/main/kotlin/com/lambda/module/Module.kt index 588f7a9b6..e1bdecd87 100644 --- a/src/main/kotlin/com/lambda/module/Module.kt +++ b/src/main/kotlin/com/lambda/module/Module.kt @@ -125,13 +125,14 @@ abstract class Module( val tag: ModuleTag, private val alwaysListening: Boolean = false, enabledByDefault: Boolean = false, + modulePriority: Int = 0, defaultKeybind: Bind = Bind.EMPTY, autoDisable: Boolean = false ) : Nameable, Muteable, OwnerPriority, Config(name, ModuleCategory), IMutableAutomationConfig by MutableAutomationConfig() { private val isEnabledSetting = setting("Enabled", enabledByDefault) { false } - val prioritySetting = setting("Module Priority", 0, -100..100, 1, "Priority over other modules") { false } + val prioritySetting = setting("Module Priority", modulePriority, -100..100, 1, "Priority over other modules") { false } .onValueChangeUnsafe { _, to -> ownerPriority = to } override var ownerPriority = 0 set(value) { @@ -165,71 +166,65 @@ abstract class Module( } @DslMarker - private annotation class ModuleDsl + private annotation class ModuleMarker - @ModuleDsl + @ModuleMarker fun enable() { ModuleEvent.Enabled(this@Module).post() isEnabled = true } - @ModuleDsl + @ModuleMarker fun disable() { ModuleEvent.Disabled(this@Module).post() isEnabled = false } - @ModuleDsl + @ModuleMarker fun toggle() { ModuleEvent.Toggle(this@Module, !isEnabled).post() if (isEnabled) disable() else enable() } - @ModuleDsl + @ModuleMarker fun onEnable(block: SafeContext.() -> Unit) { isEnabledSetting.onValueChange { from, to -> if (!from && to) block() } } - @ModuleDsl + @ModuleMarker fun onDisable(block: SafeContext.() -> Unit) { isEnabledSetting.onValueChange { from, to -> if (from && !to) block() } } - @ModuleDsl + @ModuleMarker fun onToggle(block: SafeContext.(to: Boolean) -> Unit) { isEnabledSetting.onValueChange { from, to -> if (from != to) block(to) } } - @ModuleDsl + @ModuleMarker fun onEnableUnsafe(block: () -> Unit) { isEnabledSetting.onValueChangeUnsafe { from, to -> if (!from && to) block() } } - @ModuleDsl + @ModuleMarker fun onDisableUnsafe(block: () -> Unit) { isEnabledSetting.onValueChangeUnsafe { from, to -> if (from && !to) block() } } - @ModuleDsl + @ModuleMarker fun onToggleUnsafe(block: (to: Boolean) -> Unit) { isEnabledSetting.onValueChangeUnsafe { from, to -> if (from != to) block(to) } } - - @ModuleDsl - protected fun setModulePriority(priority: Int) { - prioritySetting.value = priority - prioritySetting.core.defaultValue = priority - } } diff --git a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt index 1876d935c..b2076bcac 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt @@ -44,6 +44,7 @@ object AntiSpam : Module( name = "AntiSpam", description = "Keeps your chat clean", tag = ModuleTag.Chat, + modulePriority = 100 ) { private val fancyChats by setting("Replace Fancy Chat", false) @@ -64,7 +65,6 @@ object AntiSpam : Module( @Group("Colors") private val detectColors by settingBlock(ReplaceSettings("Colors", this, ActionStrategy.None)) init { - setModulePriority(100) listen { event -> var raw = event.message.string val author = MessageParser.playerName(raw) diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoDisconnect.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoDisconnect.kt index e51c2d15c..34ebc152f 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoDisconnect.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoDisconnect.kt @@ -55,6 +55,7 @@ object AutoDisconnect : Module( name = "AutoDisconnect", description = "Automatically disconnects when in danger or on low health", tag = ModuleTag.Combat, + modulePriority = -100 ) { private val health by setting("Health", true, "Disconnect from the server when health is below the set limit.") private val minimumHealth by setting("Min Health", 10, 1..36, 1, "Set the minimum health threshold for disconnection.", unit = " half-hearts") { health } @@ -87,7 +88,6 @@ object AutoDisconnect : Module( private val trident by setting("Trident", false, "Disconnect from the server when you get trident damage.") { onDamage } init { - setModulePriority(-100) listen { Reason.entries.filter { it.check() diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt index d571eaadf..7074f46c4 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt @@ -41,6 +41,7 @@ object AutoTotem : Module( name = "AutoTotem", description = "Swaps the your off-hand item to a totem", tag = ModuleTag.Combat, + modulePriority = 100 ) { private val always by setting("Always", true, "Always attempt to keep a totem in offhand") private val ignoreWhenHolding by setting("Ignore When Holding", false, "Ignore swapping to offhand when already holding a totem") @@ -54,7 +55,6 @@ object AutoTotem : Module( private val friends by setting("Friends", false, "Exclude friends from triggering player-based swaps") { !always && players } init { - setModulePriority(100) setDefaultAutomationConfig { hideAllBlocksExcept(::inventoryConfig) } diff --git a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt index 18878e57b..cdd21799b 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt @@ -49,6 +49,7 @@ object KillAura : Module( name = "KillAura", description = "Attacks entities", tag = ModuleTag.Combat, + modulePriority = 90 ) { private const val GeneralTab = "General" private const val TargetingTab = "Targeting" @@ -86,7 +87,6 @@ object KillAura : Module( } init { - setModulePriority(90) setDefaultAutomationConfig { hideAllBlocksExcept(::buildConfig, ::hotbarConfig, ::rotationConfig) buildConfig.apply { diff --git a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt index 647fd7cdf..f3e4b21e6 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt @@ -51,6 +51,7 @@ object BetterFirework : Module( name = "BetterFirework", description = "Automatic takeoff with fireworks", tag = ModuleTag.Movement, + modulePriority = 1 ) { private var activateButton: Bind by setting("Activate Key", Bind(0, 0, Mouse.Middle.ordinal), "Button to activate Firework") .onPress { @@ -99,7 +100,6 @@ object BetterFirework : Module( get() = !abilities.flying && !isClimbing && !isGliding && !isTouchingWater && !isOnGround && !hasVehicle() && !hasStatusEffect(StatusEffects.LEVITATION) init { - setModulePriority(1) setDefaultAutomationConfig { hideAllBlocksExcept(::hotbarConfig, ::inventoryConfig) hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) } diff --git a/src/main/kotlin/com/lambda/module/modules/player/ClickFriend.kt b/src/main/kotlin/com/lambda/module/modules/player/ClickFriend.kt index 51d13e9d0..8f225970b 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/ClickFriend.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/ClickFriend.kt @@ -38,6 +38,7 @@ object ClickFriend : Module( name = "ClickFriend", description = "Add or remove friends with a single click", tag = ModuleTag.Player, + modulePriority = 100 ) { private val friendBind: Bind by setting("Friend Bind", Bind(0, 0, GLFW.GLFW_MOUSE_BUTTON_MIDDLE), "Bind to press to befriend a player") .onPress { if (!unfriendBind.isSatisfied()) if (checkSetFriend(true)) it.cancel() } @@ -45,10 +46,6 @@ object ClickFriend : Module( private val unfriendBind: Bind by setting("Unfriend Bind", Bind(0, GLFW_MOD_SHIFT, GLFW.GLFW_MOUSE_BUTTON_MIDDLE), "Bind to press to unfriend a player") .onPress { if (!friendBind.isSatisfied()) if (checkSetFriend(false)) it.cancel() } - init { - setModulePriority(100) - } - private fun SafeContext.checkSetFriend(friend: Boolean): Boolean { val target = mc.crosshairTarget?.entityResult?.entity as? OtherClientPlayerEntity ?: return false diff --git a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt index 2a79f4511..4ac8928bc 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt @@ -55,26 +55,26 @@ object PacketMine : Module( description = "automatically breaks blocks, and does it faster", tag = ModuleTag.Player ) { - private const val GeneralGroup = "General" - private const val RendersGroup = "Renders" - - @Group(GeneralGroup) private val ignoreWhenHolding by setting("Ignore When Holding", emptySet(), description = "These items won't initiate a break if held when attacking a block") - @Group(GeneralGroup) private val rebreakMode by setting("Rebreak Mode", RebreakMode.Manual, "The method used to re-break blocks after they've been broken once").disabled { !breakConfig.rebreak } - @Group(GeneralGroup) private val breakRadius by setting("Break Radius", 0, 0..5, 1, "Selects and breaks all blocks within the break radius of the selected block") - @Group(GeneralGroup) private val flatten by setting("Flatten", true, "Wont allow breaking extra blocks under your players position") { breakRadius > 0 } - @Group(GeneralGroup) private val queue by setting("Queue", false, "Queues blocks to break so you can select multiple at once") + private val ignoreWhenHolding by setting("Ignore When Holding", emptySet(), description = "These items won't initiate a break if held when attacking a block") + private val rebreakMode by setting("Rebreak Mode", RebreakMode.Manual, "The method used to re-break blocks after they've been broken once").disabled { !breakConfig.rebreak } + private val breakRadius by setting("Break Radius", 0, 0..5, 1, "Selects and breaks all blocks within the break radius of the selected block") + private val flatten by setting("Flatten", true, "Wont allow breaking extra blocks under your players position") { breakRadius > 0 } + private val queue by setting("Queue", false, "Queues blocks to break so you can select multiple at once") .onValueChange { _, to -> if (!to) queuePositions.clear() } - @Group(GeneralGroup) private val queueOrder by setting("Queue Order", QueueOrder.Standard, "Which end of the queue to break blocks from") { queue } + private val queueOrder by setting("Queue Order", QueueOrder.Standard, "Which end of the queue to break blocks from") { queue } + + private const val ReBreakRendersGroup = "Queue Renders" + private const val QueueRendersGroup = "Queue Renders" - @Group(RendersGroup) private val renderRebreak by setting("Render Rebreak", true, "Displays what block is being checked for rebreak") - @Group(RendersGroup) private val rebreakColor by setting("Rebreak Color", Color.RED) { renderRebreak } - @Group(RendersGroup) private val renderQueue by setting("Render Queue", true, "Adds renders to signify what block positions are queued") - @Group(RendersGroup) private val renderSize by setting("Queue Render Size", 0.3f, 0.01f..1f, 0.01f, "The scale of the queue renders") { renderQueue } - @Group(RendersGroup) private val renderMode by setting("Queue Render Mode", RenderMode.State, "The style of the queue renders") { renderQueue } - @Group(RendersGroup) private val dynamicColor by setting("Queue Dynamic Color", true, "Interpolates the color between start and end") { renderQueue } - @Group(RendersGroup) private val staticColor by setting("Queue Color", Color(255, 0, 0, 60)) { renderQueue && !dynamicColor } - @Group(RendersGroup) private val startColor by setting("Queue Start Color", Color(255, 255, 0, 60), "The color of the start (closest to breaking) of the queue") { renderQueue && dynamicColor } - @Group(RendersGroup) private val endColor by setting("Queue End Color", Color(255, 0, 0, 60), "The color of the end (farthest from breaking) of the queue") { renderQueue && dynamicColor } + @Group(ReBreakRendersGroup) private val renderRebreak by setting("Render Rebreak", true, "Displays what block is being checked for rebreak") + @Group(ReBreakRendersGroup) private val rebreakColor by setting("Rebreak Color", Color.RED) { renderRebreak } + @Group(QueueRendersGroup) private val renderQueue by setting("Render Queue", true, "Adds renders to signify what block positions are queued") + @Group(QueueRendersGroup) private val renderSize by setting("Render Size", 0.3f, 0.01f..1f, 0.01f, "The scale of the queue renders") { renderQueue } + @Group(QueueRendersGroup) private val renderMode by setting("Render Mode", RenderMode.State, "The style of the queue renders") { renderQueue } + @Group(QueueRendersGroup) private val dynamicColor by setting("Dynamic Color", true, "Interpolates the color between start and end") { renderQueue } + @Group(QueueRendersGroup) private val staticColor by setting("Color", Color(255, 0, 0, 60)) { renderQueue && !dynamicColor } + @Group(QueueRendersGroup) private val startColor by setting("Start Color", Color(255, 255, 0, 60), "The color of the start (closest to breaking) of the queue") { renderQueue && dynamicColor } + @Group(QueueRendersGroup) private val endColor by setting("End Color", Color(255, 0, 0, 60), "The color of the end (farthest from breaking) of the queue") { renderQueue && dynamicColor } private val pendingActions = ConcurrentLinkedQueue() @@ -296,7 +296,7 @@ object PacketMine : Module( return false } - enum class RebreakMode( + private enum class RebreakMode( override val displayName: String, override val description: String ) : NamedEnum, Describable { @@ -306,7 +306,7 @@ object PacketMine : Module( // AutoConstant("Auto (Constant)", "Continuously re-break as soon as conditions allow; most aggressive.") } - enum class QueueOrder( + private enum class QueueOrder( override val displayName: String, override val description: String ) : NamedEnum, Describable { diff --git a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt index e41ea5839..07fbde6f8 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt @@ -33,6 +33,7 @@ object RotationLock : Module( name = "RotationLock", description = "Locks the player rotation to the given configuration", tag = ModuleTag.Player, + modulePriority = 100 ) { @JvmStatic val yawMode by setting("Yaw Mode", Mode.Snap) private val yawStep by setting("Yaw Step", 45.0, 1.0..180.0, 0.1) { yawMode == Mode.Snap } @@ -42,8 +43,6 @@ object RotationLock : Module( private val customPitch by setting("Custom Pitch", 0.0, -90.0..90.0, 0.1) { pitchMode == Mode.Custom } init { - setModulePriority(100) - setDefaultAutomationConfig { hideAllBlocksExcept(::rotationConfig) rotationConfig::rotationMode.edit { defaultValue(RotationMode.Lock) } diff --git a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt index 3b019e2df..acef06d92 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt @@ -100,7 +100,8 @@ import kotlin.math.min object StashMover : Module( name = "StashMover", description = "Moves items from one stash location to another", - tag = ModuleTag.World + tag = ModuleTag.World, + modulePriority = 100 ) { private const val GeneralTab = "General" private const val CommandBindsTab = "Command Binds" @@ -177,7 +178,6 @@ object StashMover : Module( private var task: Task<*>? = null init { - setModulePriority(100) setDefaultAutomationConfig { buildConfig.apply { editTyped(::pathing, ::stayInRange, ::checkSideVisibility) { defaultValue(true) } diff --git a/src/main/kotlin/com/lambda/util/Diagnostics.kt b/src/main/kotlin/com/lambda/util/Diagnostics.kt index 3eb7c9bd4..c1cdb51f7 100644 --- a/src/main/kotlin/com/lambda/util/Diagnostics.kt +++ b/src/main/kotlin/com/lambda/util/Diagnostics.kt @@ -28,7 +28,7 @@ object Diagnostics { module.forEachSetting { path, single -> val setting = single.setting if (setting.isModified) { - append("\t\t${path.joinToString(".", postfix = ".")}${setting.name} -> ${setting.value}") + append("\t\t${path.joinToString(".", postfix = ".") { it.name }}${setting.name} -> ${setting.value}") } } } From 2b825b3de1cf6028787d6475cae0d460291bd1bf Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Sat, 16 May 2026 14:04:58 +0100 Subject: [PATCH 20/40] use modulePriority param for default ownerPriority value --- src/main/kotlin/com/lambda/module/Module.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/lambda/module/Module.kt b/src/main/kotlin/com/lambda/module/Module.kt index e1bdecd87..6630cbbb9 100644 --- a/src/main/kotlin/com/lambda/module/Module.kt +++ b/src/main/kotlin/com/lambda/module/Module.kt @@ -134,7 +134,7 @@ abstract class Module( private val isEnabledSetting = setting("Enabled", enabledByDefault) { false } val prioritySetting = setting("Module Priority", modulePriority, -100..100, 1, "Priority over other modules") { false } .onValueChangeUnsafe { _, to -> ownerPriority = to } - override var ownerPriority = 0 + override var ownerPriority = modulePriority set(value) { val oldVal = field field = value From f0fad2a2b179ffbede27139cb1e33e860ec35a58 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Mon, 18 May 2026 21:20:04 +0100 Subject: [PATCH 21/40] withEdits for setDefaultAutomationConfig and fix config commands not giving the right reset / undo commands when clicked --- .../lambda/command/commands/ConfigCommand.kt | 3 +- src/main/kotlin/com/lambda/config/Config.kt | 18 ----- src/main/kotlin/com/lambda/config/Setting.kt | 38 ++++++--- .../config/automation/AutomationConfig.kt | 24 +++--- .../com/lambda/event/events/ModuleEvent.kt | 2 - .../com/lambda/event/listener/Listener.kt | 3 + .../com/lambda/event/listener/SafeListener.kt | 4 + .../lambda/event/listener/UnsafeListener.kt | 4 + .../kotlin/com/lambda/friend/FriendHandler.kt | 6 +- .../com/lambda/gui/components/QuickSearch.kt | 7 +- .../simulation/checks/BreakSim.kt | 4 +- .../managers/breaking/BreakManager.kt | 2 +- .../interaction/material/StackSelection.kt | 33 ++++---- src/main/kotlin/com/lambda/module/Module.kt | 20 ++--- .../lambda/module/modules/combat/AutoArmor.kt | 8 +- .../lambda/module/modules/combat/AutoTotem.kt | 8 +- .../module/modules/combat/CrystalAura.kt | 18 +++-- .../lambda/module/modules/combat/KillAura.kt | 26 ++++--- .../module/modules/combat/PlayerTrap.kt | 22 +++--- .../lambda/module/modules/combat/Surround.kt | 22 +++--- .../lambda/module/modules/debug/SilentSwap.kt | 8 +- .../module/modules/movement/BetterFirework.kt | 12 +-- .../modules/movement/ElytraAltitudeControl.kt | 8 +- .../module/modules/movement/ElytraFly.kt | 8 +- .../lambda/module/modules/movement/Speed.kt | 8 +- .../lambda/module/modules/player/AutoEat.kt | 8 +- .../lambda/module/modules/player/FastBreak.kt | 78 ++++++++++--------- .../module/modules/player/InventoryTweaks.kt | 8 +- .../module/modules/player/PacketMine.kt | 54 ++++++------- .../module/modules/player/RotationLock.kt | 10 ++- .../module/modules/player/StackReplenish.kt | 12 +-- .../lambda/module/modules/player/ToolSaver.kt | 8 +- .../lambda/module/modules/render/Freecam.kt | 10 +-- .../com/lambda/module/modules/render/XRay.kt | 1 + .../lambda/module/modules/world/AirPlace.kt | 8 +- .../lambda/module/modules/world/AutoPortal.kt | 11 +-- .../module/modules/world/AutoVillagerCycle.kt | 8 +- .../module/modules/world/HighwayTools.kt | 12 +-- .../com/lambda/module/modules/world/Nuker.kt | 10 ++- .../lambda/module/modules/world/Scaffold.kt | 32 ++++---- .../lambda/module/modules/world/StashMover.kt | 26 ++++--- .../kotlin/com/lambda/task/tasks/BuildTask.kt | 2 +- 42 files changed, 334 insertions(+), 280 deletions(-) diff --git a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt index 8416f379d..c92337abe 100644 --- a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt @@ -19,6 +19,7 @@ package com.lambda.command.commands import com.lambda.brigadier.CommandResult.Companion.failure import com.lambda.brigadier.CommandResult.Companion.success +import com.lambda.brigadier.argument.greedyString import com.lambda.brigadier.argument.literal import com.lambda.brigadier.argument.string import com.lambda.brigadier.argument.value @@ -64,7 +65,7 @@ object ConfigCommand : LambdaCommand( suggests { _, builder -> suggestMatching(ConfigLoader.configs.map { it.commandName }, builder) } - required(string("setting")) { settingArg -> + required(greedyString("setting")) { settingArg -> suggests { context, builder -> val config = ConfigLoader.configByCommandName(configArg(context).value()) ?: return@suggests null val suggestions = mutableListOf() diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index cb336a70b..63fbb2b77 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -57,9 +57,6 @@ import kotlin.reflect.KProperty import kotlin.reflect.full.declaredMemberProperties import kotlin.reflect.jvm.javaField -@DslMarker -private annotation class SettingDsl - /** * Represents a set of [SettingCore]s that are associated with the [name] of the [Config]. * The settings are managed by this [Config] and are saved and loaded as part of the [ConfigCategory]. @@ -623,21 +620,6 @@ abstract class Config( } internalForEach(root, emptyList()) } - - internal fun getSettingByPathedName(path: Collection, setting: String): Setting<*, *>? { - var currentLayer: SettingLayer.Multiple = settingLayers - path.forEach { layer -> - currentLayer = currentLayer.layers - .asSequence() - .filterIsInstance() - .find { it.name == layer } ?: return null - } - return currentLayer.layers - .asSequence() - .filterIsInstance>() - .find { it.setting.name == setting } - ?.setting - } } @Target(AnnotationTarget.PROPERTY) diff --git a/src/main/kotlin/com/lambda/config/Setting.kt b/src/main/kotlin/com/lambda/config/Setting.kt index 0b0b73412..44225fc40 100644 --- a/src/main/kotlin/com/lambda/config/Setting.kt +++ b/src/main/kotlin/com/lambda/config/Setting.kt @@ -30,6 +30,7 @@ import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required import com.lambda.command.CommandRegistry import com.lambda.command.commands.ConfigCommand +import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting.ValueListener import com.lambda.context.SafeContext import com.lambda.gui.dsl.ImGuiBuilder @@ -37,7 +38,6 @@ import com.lambda.threading.runSafe import com.lambda.util.CommunicationUtils.info import com.lambda.util.Describable import com.lambda.util.Nameable -import com.lambda.util.NamedEnum import com.lambda.util.extension.CommandBuilder import com.lambda.util.text.ClickEvents import com.lambda.util.text.HoverEvents @@ -99,12 +99,11 @@ class Setting, R>( override val description: String, var core: T, val config: Config, - val layer: Config.SettingLayer.Single<*, *>, + val layer: SettingLayer.Single<*, *>, var visibility: () -> Boolean ) : Nameable, Describable, Jsonable { val originalCore = core var disabled = { false } - var buttonMenu: NamedEnum? = null var value by this @@ -146,6 +145,7 @@ class Setting, R>( * Will only register changes of the variable, not the content of the variable! * E.g., if the variable is a list, it will only register if the list reference changes, not if the content of the list changes. */ + @SettingDsl fun onValueChange(block: SafeContext.(from: R, to: R) -> Unit) = apply { core.listeners.add(ValueListener(true) { from, to -> runSafe { @@ -154,22 +154,21 @@ class Setting, R>( }) } + @SettingDsl fun onValueChangeUnsafe(block: (from: R, to: R) -> Unit) = apply { core.listeners.add(ValueListener(true, block)) } + @SettingDsl fun onValueSet(block: (from: R, to: R) -> Unit) = apply { core.listeners.add(ValueListener(false, block)) } + @SettingDsl fun disabled(predicate: () -> Boolean) = apply { disabled = predicate } - fun buttonMenu(menu: NamedEnum) = apply { - buttonMenu = menu - } - fun trySetValue(newValue: R) { if (newValue == value) { ConfigCommand.info(notChangedMessage()) @@ -183,7 +182,8 @@ class Setting, R>( fun setMessage(previousValue: R, newValue: R) = buildText { literal("Set ") changedMessage(previousValue, newValue) - clickEvent(ClickEvents.suggestCommand("${CommandRegistry.prefix}${ConfigCommand.name} reset ${config.commandName} $commandName")) { + val commandPath = getConfigCommandPath().joinToString("->", postfix = "->").takeIf { it != "->" } ?: "" + clickEvent(ClickEvents.suggestCommand("${CommandRegistry.prefix}${ConfigCommand.commandName} reset ${config.commandName} $commandPath$commandName")) { hoverEvent(HoverEvents.showText(buildText { literal("Click to reset to default value ") highlighted(core.defaultValue.toString()) @@ -215,7 +215,8 @@ class Setting, R>( literal(" to ") highlighted(newValue.toString()) literal(".") - clickEvent(ClickEvents.suggestCommand("${CommandRegistry.prefix}${ConfigCommand.name} set ${config.commandName} $commandName $previousValue")) { + val commandPath = getConfigCommandPath().joinToString("->", postfix = "->").takeIf { it != "->" } ?: "" + clickEvent(ClickEvents.suggestCommand("${CommandRegistry.prefix}${ConfigCommand.name} set ${config.commandName} $commandPath$commandName $previousValue")) { hoverEvent(HoverEvents.showText(buildText { literal("Click to undo to previous value ") highlighted(previousValue.toString()) @@ -225,6 +226,17 @@ class Setting, R>( } } + private fun getConfigCommandPath(): Collection { + var current: SettingLayer.Multiple = layer.parent + val layers = mutableListOf(current.commandName) + while (true) { + current = current.parent ?: break + if (current is SettingLayer.Root) break + layers.add(current.commandName) + } + return layers.asReversed() + } + override fun toString() = "Setting $name: $value of type ${core.type.typeName}" } @@ -255,8 +267,7 @@ abstract class SettingCore( JsonParser.parseString("\"$valueString\"") } catch (_: Exception) { return@executeWithResult failure("$valueString is not a valid JSON string.") - } - ?: return@executeWithResult failure("No config found for $name.") + } ?: return@executeWithResult failure("No config found for $name.") val previous = this@SettingCore.value try { loadFromJson(parsed) @@ -275,4 +286,7 @@ abstract class SettingCore( override fun loadFromJson(serialized: JsonElement) { value = gson.fromJson(serialized, type) } -} \ No newline at end of file +} + +@DslMarker +internal annotation class SettingDsl \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt index 2df77bd2d..41f2b2687 100644 --- a/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt @@ -19,7 +19,6 @@ package com.lambda.config.automation import com.lambda.config.Config import com.lambda.config.ConfigCategory -import com.lambda.config.EditContext.ConfigEditContext import com.lambda.config.Tab import com.lambda.config.categories.AutomationCategory import com.lambda.config.settings.blocks.BreakSettings @@ -57,24 +56,19 @@ open class AutomationConfig( private const val HotbarTab = "Hotbar" private const val EatTab = "Eat" + @DslMarker + private annotation class AutomationConfigMarker + + @AutomationConfigMarker context(module: Module) fun IMutableAutomationConfig.setDefaultAutomationConfig( - name: String = module.name, - edits: (context(ConfigEditContext) AutomationConfig.() -> Unit)? = null - ) { - this.defaultAutomationConfig = AutomationConfig("$name Automation Config").also { config -> - if (edits != null) with(ConfigEditContext(config)) { config.edits() } - } - } + name: String = module.name + ) = AutomationConfig("$name Automation Config").also { this.defaultAutomationConfig = it } + @AutomationConfigMarker fun IMutableAutomationConfig.setDefaultAutomationConfig( - name: String, - edits: (context(ConfigEditContext) AutomationConfig.() -> Unit)? = null - ) { - defaultAutomationConfig = AutomationConfig("$name Automation Config").also { config -> - if (edits != null) with(ConfigEditContext(config)) { config.edits() } - } - } + name: String + ) = AutomationConfig("$name Automation Config").also { this.defaultAutomationConfig = it } val Default = AutomationConfig("Default") } diff --git a/src/main/kotlin/com/lambda/event/events/ModuleEvent.kt b/src/main/kotlin/com/lambda/event/events/ModuleEvent.kt index 5eba52e79..531cee463 100644 --- a/src/main/kotlin/com/lambda/event/events/ModuleEvent.kt +++ b/src/main/kotlin/com/lambda/event/events/ModuleEvent.kt @@ -18,8 +18,6 @@ package com.lambda.event.events import com.lambda.event.Event -import com.lambda.event.callback.Cancellable -import com.lambda.event.callback.ICancellable import com.lambda.module.Module /** diff --git a/src/main/kotlin/com/lambda/event/listener/Listener.kt b/src/main/kotlin/com/lambda/event/listener/Listener.kt index e45dc9c0e..8a59ba1ea 100644 --- a/src/main/kotlin/com/lambda/event/listener/Listener.kt +++ b/src/main/kotlin/com/lambda/event/listener/Listener.kt @@ -73,3 +73,6 @@ abstract class Listener : Comparable> { get() = (this as? OwnerPriority)?.let { { ownerPriority } } ?: { 0 } } } + +@DslMarker +annotation class ListenMarker diff --git a/src/main/kotlin/com/lambda/event/listener/SafeListener.kt b/src/main/kotlin/com/lambda/event/listener/SafeListener.kt index f29dd6811..4071fba71 100644 --- a/src/main/kotlin/com/lambda/event/listener/SafeListener.kt +++ b/src/main/kotlin/com/lambda/event/listener/SafeListener.kt @@ -119,6 +119,7 @@ class SafeListener( * @param function The function to be executed when the event is posted. This function should take a SafeContext and an event of type T as parameters. * @return The newly created and registered [SafeListener]. */ + @ListenMarker inline fun Any.listen( noinline priority: () -> Int = ownerPriorityOr0Getter, alwaysListen: Boolean = false, @@ -161,6 +162,7 @@ class SafeListener( * @param function The function to be executed when the event is posted. This function should take a SafeContext and an event of type T as parameters. * @return The newly created and registered [SafeListener]. */ + @ListenMarker fun Any.listen( kClass: KClass, priority: () -> Int = ownerPriorityOr0Getter, @@ -202,6 +204,7 @@ class SafeListener( * @param alwaysListen If true, the listener will be executed even if it is muted. The Default value is false. * @return The newly created and registered [SafeListener]. */ + @ListenMarker inline fun Any.listenOnce( noinline priority: () -> Int = ownerPriorityOr0Getter, alwaysListen: Boolean = false, @@ -250,6 +253,7 @@ class SafeListener( * @param function The function to be executed when the event is posted. This function should take a SafeContext and an event of type T as parameters. * @return The newly created and registered [SafeListener]. */ + @ListenMarker inline fun Any.listenConcurrently( noinline priority: () -> Int = ownerPriorityOr0Getter, alwaysListen: Boolean = false, diff --git a/src/main/kotlin/com/lambda/event/listener/UnsafeListener.kt b/src/main/kotlin/com/lambda/event/listener/UnsafeListener.kt index 58347660d..c6c126daf 100644 --- a/src/main/kotlin/com/lambda/event/listener/UnsafeListener.kt +++ b/src/main/kotlin/com/lambda/event/listener/UnsafeListener.kt @@ -111,6 +111,7 @@ class UnsafeListener( * @param function The function to be executed when the event is posted. This function should take an event of type T as a parameter. * @return The newly created and registered [UnsafeListener]. */ + @ListenMarker inline fun Any.listenUnsafe( noinline priority: () -> Int = ownerPriorityOr0Getter, alwaysListen: Boolean = false, @@ -149,6 +150,7 @@ class UnsafeListener( * @param function The function to be executed when the event is posted. This function should take an event of type T as a parameter. * @return The newly created and registered [UnsafeListener]. */ + @ListenMarker fun Any.listenUnsafe( kClass: KClass, priority: () -> Int = ownerPriorityOr0Getter, @@ -185,6 +187,7 @@ class UnsafeListener( * @param alwaysListen If true, the listener will be executed even if it is muted. * @return The newly created and registered [UnsafeListener]. */ + @ListenMarker inline fun Any.listenOnceUnsafe( noinline priority: () -> Int = ownerPriorityOr0Getter, alwaysListen: Boolean = false, @@ -234,6 +237,7 @@ class UnsafeListener( * @param function The function to be executed when the event is posted. This function should take a SafeContext and an event of type T as parameters. * @return The newly created and registered [UnsafeListener]. */ + @ListenMarker inline fun Any.listenConcurrentlyUnsafe( noinline priority: () -> Int = ownerPriorityOr0Getter, alwaysListen: Boolean = false, diff --git a/src/main/kotlin/com/lambda/friend/FriendHandler.kt b/src/main/kotlin/com/lambda/friend/FriendHandler.kt index e6e9e521c..3edf6c20a 100644 --- a/src/main/kotlin/com/lambda/friend/FriendHandler.kt +++ b/src/main/kotlin/com/lambda/friend/FriendHandler.kt @@ -18,6 +18,8 @@ package com.lambda.friend import com.lambda.Lambda.mc +import com.lambda.command.CommandRegistry.prefix +import com.lambda.command.commands.FriendCommand import com.lambda.config.Config import com.lambda.config.categories.FriendCategory import com.lambda.core.Loadable @@ -114,7 +116,7 @@ object FriendHandler : Config( literal(Color.GREEN, "Added ") text(name) literal(" to your friend list ") - clickEvent(ClickEvents.suggestCommand(";friends remove ${name.string}")) { + clickEvent(ClickEvents.suggestCommand("${prefix}${FriendCommand.name} remove ${name.string}")) { styled(underlined = true, color = Color.LIGHT_GRAY) { literal("[Undo]") } @@ -126,7 +128,7 @@ object FriendHandler : Config( literal(Color.RED, "Removed ") text(name) literal(" from your friend list ") - clickEvent(ClickEvents.suggestCommand(";friends add ${name.string}")) { + clickEvent(ClickEvents.suggestCommand("${prefix}${FriendCommand.name} add ${name.string}")) { styled(underlined = true, color = Color.LIGHT_GRAY) { literal("[Undo]") } diff --git a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt index f7634e09a..ba92ffc14 100644 --- a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt +++ b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt @@ -21,6 +21,7 @@ import com.lambda.Lambda.mc import com.lambda.command.CommandRegistry import com.lambda.command.LambdaCommand import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.ConfigLoader import com.lambda.config.Setting import com.lambda.event.events.ButtonEvent @@ -302,10 +303,10 @@ object QuickSearch { private fun buildSettingBreadcrumb(configName: String, setting: Setting<*, *>): String { val path = buildList { - var current: Config.SettingLayer? = setting.layer.parent - while (current is Config.SettingLayer.Multiple && current !is Config.SettingLayer.Root) { + var current: SettingLayer.Multiple? = setting.layer.parent + while (current !is SettingLayer.Root) { + current = current?.parent ?: return@buildList add(current.name) - current = current.parent } }.asReversed() return if (path.isEmpty()) configName diff --git a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt index 198fd2e7c..cf6048e21 100644 --- a/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt +++ b/src/main/kotlin/com/lambda/interaction/construction/simulation/checks/BreakSim.kt @@ -33,7 +33,7 @@ import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotat import com.lambda.interaction.managers.rotating.RotationManager import com.lambda.interaction.material.ContainerSelection.Companion.selectContainer import com.lambda.interaction.material.StackSelection -import com.lambda.interaction.material.StackSelection.Companion.EVERYTHING +import com.lambda.interaction.material.StackSelection.Companion.Everything import com.lambda.interaction.material.StackSelection.Companion.selectStack import com.lambda.interaction.material.container.ContainerHandler.findContainersWithMaterial import com.lambda.interaction.material.container.MaterialContainer @@ -155,7 +155,7 @@ class BreakSim private constructor(simInfo: SimInfo) it.inventoryIndex == HotbarManager.serverSlot } ) { - EVERYTHING + Everything .andIf(breakConfig.efficientOnly) { isEfficientForBreaking(state) }.andIf(breakConfig.suitableToolsOnly) { diff --git a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt index cece5f5f6..f6f2eb282 100644 --- a/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt +++ b/src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt @@ -137,7 +137,7 @@ object BreakManager : Manager( .lastOrNull { it.breakConfig.doubleBreak || it.type == Secondary }?.context?.itemSelection - ?: StackSelection.EVERYTHING.select() + ?: StackSelection.Everything.select() override val blockedPositions get() = activeInfos.map { it.context.blockPos } + pendingActions.map { it.context.blockPos } diff --git a/src/main/kotlin/com/lambda/interaction/material/StackSelection.kt b/src/main/kotlin/com/lambda/interaction/material/StackSelection.kt index 5391fb204..ca6a0b044 100644 --- a/src/main/kotlin/com/lambda/interaction/material/StackSelection.kt +++ b/src/main/kotlin/com/lambda/interaction/material/StackSelection.kt @@ -38,10 +38,11 @@ import kotlin.reflect.KClass /** * [StackSelection] is a class that holds a predicate for matching [ItemStack]s. */ +@Suppress("unused") @StackSelectionDsl class StackSelection { - var selector: (ItemStack) -> Boolean = EVERYTHING - var comparator: Comparator = NO_COMPARE + var selector: (ItemStack) -> Boolean = Everything + var comparator: Comparator = NoCompare var count: Int = DefaultAmount var inShulkerBox: Boolean = false @@ -83,12 +84,12 @@ class StackSelection { } fun > thenBy(selector: (ItemStack) -> R?): StackSelection = apply { - check(comparator != NO_COMPARE) { "No comparator specified" } + check(comparator != NoCompare) { "No comparator specified" } comparator = comparator.thenBy(selector) } fun > thenByDescending(selector: (ItemStack) -> R?): StackSelection = apply { - check(comparator != NO_COMPARE) { "No comparator specified" } + check(comparator != NoCompare) { "No comparator specified" } comparator = comparator.thenByDescending(selector) } @@ -129,8 +130,8 @@ class StackSelection { } } - fun any() = EVERYTHING - fun none() = NOTHING + fun any() = Everything + fun none() = Nothing /** * [isItem] returns a predicate that matches a specific [Item]. @@ -264,12 +265,12 @@ class StackSelection { itemStack?.let { append(it.name.string) } damage?.let { append(" with damage $it") } when (selector) { - EVERYTHING -> append(" everything") - NOTHING -> append(" nothing") + Everything -> append(" everything") + Nothing -> append(" nothing") else -> append(" custom predicate") } if (inShulkerBox) append(" in shulker box") - if (comparator != NO_COMPARE) append(" sorted by custom comparator") + if (comparator != NoCompare) append(" sorted by custom comparator") } companion object { @@ -278,11 +279,11 @@ class StackSelection { const val DefaultAmount = 1 - val FULL_SHULKERS: (ItemStack) -> Boolean = { stack -> stack.shulkerBoxContents.none { it.isEmpty } } - val EMPTY_SHULKERS: (ItemStack) -> Boolean = { stack -> stack.shulkerBoxContents.all { it.isEmpty } } - val EVERYTHING: (ItemStack) -> Boolean = { true } - val NOTHING: (ItemStack) -> Boolean = { false } - val NO_COMPARE: Comparator = Comparator { _, _ -> 0 } + val FullShulkers: (ItemStack) -> Boolean = { stack -> stack.shulkerBoxContents.none { it.isEmpty } } + val EmptyShulkers: (ItemStack) -> Boolean = { stack -> stack.shulkerBoxContents.all { it.isEmpty } } + val Everything: (ItemStack) -> Boolean = { true } + val Nothing: (ItemStack) -> Boolean = { false } + val NoCompare: Comparator = Comparator { _, _ -> 0 } val efficientToolCache: MutableMap = Collections.synchronizedMap(mutableMapOf()) @@ -307,8 +308,8 @@ class StackSelection { fun selectStack( count: Int = DefaultAmount, inShulkerBox: Boolean = false, - sorter: Comparator = NO_COMPARE, - block: StackSelection.() -> (ItemStack) -> Boolean = { EVERYTHING }, + sorter: Comparator = NoCompare, + block: StackSelection.() -> (ItemStack) -> Boolean = { Everything }, ) = StackSelection().apply { selector = block() comparator = sorter diff --git a/src/main/kotlin/com/lambda/module/Module.kt b/src/main/kotlin/com/lambda/module/Module.kt index 6630cbbb9..a87c405e2 100644 --- a/src/main/kotlin/com/lambda/module/Module.kt +++ b/src/main/kotlin/com/lambda/module/Module.kt @@ -166,62 +166,62 @@ abstract class Module( } @DslMarker - private annotation class ModuleMarker + private annotation class ModuleDsl - @ModuleMarker + @ModuleDsl fun enable() { ModuleEvent.Enabled(this@Module).post() isEnabled = true } - @ModuleMarker + @ModuleDsl fun disable() { ModuleEvent.Disabled(this@Module).post() isEnabled = false } - @ModuleMarker + @ModuleDsl fun toggle() { ModuleEvent.Toggle(this@Module, !isEnabled).post() if (isEnabled) disable() else enable() } - @ModuleMarker + @ModuleDsl fun onEnable(block: SafeContext.() -> Unit) { isEnabledSetting.onValueChange { from, to -> if (!from && to) block() } } - @ModuleMarker + @ModuleDsl fun onDisable(block: SafeContext.() -> Unit) { isEnabledSetting.onValueChange { from, to -> if (from && !to) block() } } - @ModuleMarker + @ModuleDsl fun onToggle(block: SafeContext.(to: Boolean) -> Unit) { isEnabledSetting.onValueChange { from, to -> if (from != to) block(to) } } - @ModuleMarker + @ModuleDsl fun onEnableUnsafe(block: () -> Unit) { isEnabledSetting.onValueChangeUnsafe { from, to -> if (!from && to) block() } } - @ModuleMarker + @ModuleDsl fun onDisableUnsafe(block: () -> Unit) { isEnabledSetting.onValueChangeUnsafe { from, to -> if (from && !to) block() } } - @ModuleMarker + @ModuleDsl fun onToggleUnsafe(block: (to: Boolean) -> Unit) { isEnabledSetting.onValueChangeUnsafe { from, to -> if (from != to) block(to) diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt index 8cc8af750..256f33c59 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt @@ -21,6 +21,7 @@ import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -95,9 +96,10 @@ object AutoArmor : Module( } init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::inventoryConfig) - } + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::inventoryConfig) + } listen { val armorSlots = player.armorSlots diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt index 7074f46c4..ad6bbbe03 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt @@ -19,6 +19,7 @@ package com.lambda.module.modules.combat import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -55,9 +56,10 @@ object AutoTotem : Module( private val friends by setting("Friends", false, "Exclude friends from triggering player-based swaps") { !always && players } init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::inventoryConfig) - } + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::inventoryConfig) + } listen { if (!always && Reason.entries.none { it.check(this) }) return@listen diff --git a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt index 0fc8bd2be..70bcd546a 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt @@ -22,6 +22,7 @@ import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.Tab import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.TargetingSettings +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.event.events.EntityEvent import com.lambda.event.events.TickEvent @@ -145,15 +146,16 @@ object CrystalAura : Module( } init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::buildConfig, ::rotationConfig, ::hotbarConfig, ::inventoryConfig) - buildConfig.apply { - hide( - ::pathing, ::stayInRange, ::collectDrops, ::spleefEntities, - ::maxPendingActions, ::actionTimeout, ::maxBuildDependencies, ::breakBlocks, ::interactBlocks, ::placeBlocks - ) + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::buildConfig, ::rotationConfig, ::hotbarConfig, ::inventoryConfig) + buildConfig.apply { + hide( + ::pathing, ::stayInRange, ::collectDrops, ::spleefEntities, + ::maxPendingActions, ::actionTimeout, ::maxBuildDependencies, ::breakBlocks, ::interactBlocks, ::placeBlocks + ) + } } - } // Async ticking fixedRateTimer( diff --git a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt index cdd21799b..b30c12a65 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt @@ -23,6 +23,7 @@ import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.Tab import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.TargetingSettings +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.event.events.InventoryEvent import com.lambda.event.events.TickEvent @@ -87,19 +88,20 @@ object KillAura : Module( } init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::buildConfig, ::hotbarConfig, ::rotationConfig) - buildConfig.apply { - hide( - ::pathing, ::stayInRange, ::collectDrops, - ::spleefEntities, ::maxPendingActions, ::actionTimeout, - ::maxBuildDependencies, ::blockReach - ) - } - hotbarConfig.apply { - ::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) } + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::buildConfig, ::hotbarConfig, ::rotationConfig) + buildConfig.apply { + hide( + ::pathing, ::stayInRange, ::collectDrops, + ::spleefEntities, ::maxPendingActions, ::actionTimeout, + ::maxBuildDependencies, ::blockReach + ) + } + hotbarConfig.apply { + ::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) } + } } - } listen { cooldownFromSwap = true } diff --git a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt index d66255bcd..2783fdfbd 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt @@ -20,6 +20,7 @@ package com.lambda.module.modules.combat import com.lambda.config.ConfigEditor.editTyped import com.lambda.config.ConfigEditor.hideBlock import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.friend.FriendHandler.isFriend import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint @@ -54,17 +55,18 @@ object PlayerTrap : Module( private var task: Task<*>? = null init { - setDefaultAutomationConfig { - buildConfig.apply { - editTyped( - ::pathing, - ::stayInRange, - ::spleefEntities, - ::collectDrops - ) { defaultValue(false); hide() } + setDefaultAutomationConfig() + .withEdits { + buildConfig.apply { + editTyped( + ::pathing, + ::stayInRange, + ::spleefEntities, + ::collectDrops + ) { defaultValue(false); hide() } + } + hideBlock(::eatConfig) } - hideBlock(::eatConfig) - } onEnable { task = tickingBlueprint { diff --git a/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt b/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt index cd5f5f1c5..ac5de6bd6 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt @@ -20,6 +20,7 @@ package com.lambda.module.modules.combat import com.lambda.config.ConfigEditor.editTyped import com.lambda.config.ConfigEditor.hideBlock import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.withEdits import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint import com.lambda.interaction.construction.verify.TargetState import com.lambda.module.Module @@ -44,17 +45,18 @@ object Surround : Module( private var task: Task<*>? = null init { - setDefaultAutomationConfig { - buildConfig.apply { - editTyped( - ::pathing, - ::stayInRange, - ::spleefEntities, - ::collectDrops - ) { defaultValue(false); hide() } + setDefaultAutomationConfig() + .withEdits { + buildConfig.apply { + editTyped( + ::pathing, + ::stayInRange, + ::spleefEntities, + ::collectDrops + ) { defaultValue(false); hide() } + } + hideBlock(::eatConfig) } - hideBlock(::eatConfig) - } onEnable { task = tickingBlueprint { diff --git a/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt b/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt index f44dec380..8df26bb1e 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt @@ -19,6 +19,7 @@ package com.lambda.module.modules.debug import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.withEdits import com.lambda.event.events.PlayerEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.hotbar.HotbarRequest @@ -32,9 +33,10 @@ object SilentSwap : Module( tag = ModuleTag.Debug, ) { init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::hotbarConfig) - } + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::hotbarConfig) + } listen { if (!HotbarRequest(0, this@SilentSwap).submit().done) { diff --git a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt index f3e4b21e6..de0465ef8 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt @@ -24,6 +24,7 @@ import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -100,11 +101,12 @@ object BetterFirework : Module( get() = !abilities.flying && !isClimbing && !isGliding && !isTouchingWater && !isOnGround && !hasVehicle() && !hasStatusEffect(StatusEffects.LEVITATION) init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::hotbarConfig, ::inventoryConfig) - hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) } - inventoryConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) } - } + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::hotbarConfig, ::inventoryConfig) + hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) } + inventoryConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) } + } listen { when (takeoffState) { diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt index 249ce6c21..79e6b1910 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt @@ -20,6 +20,7 @@ package com.lambda.module.modules.movement import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.Tab import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.withEdits import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest @@ -100,9 +101,10 @@ object ElytraAltitudeControl : Module( val usageDelay = Timer() init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::rotationConfig) - } + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::rotationConfig) + } listen { if (!player.isGliding) return@listen diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt index 8ce8d6737..0ecff58d3 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt @@ -21,6 +21,7 @@ import baritone.api.pathing.goals.GoalGetToBlock import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.Group import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.event.events.ClientEvent import com.lambda.event.events.MovementEvent @@ -109,9 +110,10 @@ object ElytraFly : Module( private val fireworkTimer = Timer() init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::inventoryConfig, ::rotationConfig) - } + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::inventoryConfig, ::rotationConfig) + } listen { when (mode) { diff --git a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt index 1e3e81c0f..de2963895 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt @@ -19,6 +19,7 @@ package com.lambda.module.modules.movement import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.event.events.ClientEvent import com.lambda.event.events.MovementEvent @@ -81,9 +82,10 @@ object Speed : Module( } init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::rotationConfig) - } + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::rotationConfig) + } listen { if (!shouldWork()) { diff --git a/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt b/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt index 64899e0e7..b8d1198c3 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt @@ -20,6 +20,7 @@ package com.lambda.module.modules.player import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.EatConfig.Companion.reasonEating +import com.lambda.config.withEdits import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.module.Module @@ -38,9 +39,10 @@ object AutoEat : Module( private var eatTask: EatTask? = null init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::eatConfig) - } + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::eatConfig) + } listen { val reason = runSafeAutomated { reasonEating() } diff --git a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt index c166018af..780f0663e 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt @@ -22,6 +22,7 @@ import com.lambda.config.ConfigEditor.editTyped import com.lambda.config.ConfigEditor.hide import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.withEdits import com.lambda.event.events.PlayerEvent import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -41,45 +42,46 @@ object FastBreak : Module( private val pendingActions = ConcurrentLinkedQueue() init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::buildConfig, ::breakConfig, ::rotationConfig, ::hotbarConfig) - buildConfig.apply { - hide( - ::pathing, - ::stayInRange, - ::spleefEntities, - ::maxBuildDependencies, - ::collectDrops, - ::blockReach, - ::entityReach, - ::breakBlocks, - ::interactBlocks, - ::placeBlocks - ) - ::maxBuildDependencies.edit { defaultValue(0) } - editTyped( - ::strictRayCast - ) { defaultValue(false); } - hide(::strictRayCast, ::checkSideVisibility) - ::blockReach.edit { defaultValue(Double.MAX_VALUE) } + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::buildConfig, ::breakConfig, ::rotationConfig, ::hotbarConfig) + buildConfig.apply { + hide( + ::pathing, + ::stayInRange, + ::spleefEntities, + ::maxBuildDependencies, + ::collectDrops, + ::blockReach, + ::entityReach, + ::breakBlocks, + ::interactBlocks, + ::placeBlocks + ) + ::maxBuildDependencies.edit { defaultValue(0) } + editTyped( + ::strictRayCast + ) { defaultValue(false); } + hide(::strictRayCast, ::checkSideVisibility) + ::blockReach.edit { defaultValue(Double.MAX_VALUE) } + } + breakConfig.apply { + editTyped( + ::avoidFluids, + ::avoidSupporting, + ::efficientOnly, + ::suitableToolsOnly + ) { defaultValue(false) } + editTyped( + ::rotate, + ::doubleBreak + ) { defaultValue(false); hide() } + ::breaksPerTick.edit { defaultValue(1); hide() } + ::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Input.Post)); hide() } + hide(::sorter, ::unsafeCancels) + } + hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Input.Post)); hide() } } - breakConfig.apply { - editTyped( - ::avoidFluids, - ::avoidSupporting, - ::efficientOnly, - ::suitableToolsOnly - ) { defaultValue(false) } - editTyped( - ::rotate, - ::doubleBreak - ) { defaultValue(false); hide() } - ::breaksPerTick.edit { defaultValue(1); hide() } - ::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Input.Post)); hide() } - hide(::sorter, ::unsafeCancels) - } - hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Input.Post)); hide() } - } listen { it.cancel() } listen { event -> diff --git a/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt b/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt index a4aeeb7af..4201e0bdc 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt @@ -19,6 +19,7 @@ package com.lambda.module.modules.player import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.withEdits import com.lambda.event.events.InventoryEvent import com.lambda.event.events.PlayerEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -48,9 +49,10 @@ object InventoryTweaks : Module( private var lastOpenScreen: ScreenHandler? = null init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::breakConfig, ::interactConfig, ::inventoryConfig, ::hotbarConfig) - } + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::breakConfig, ::interactConfig, ::inventoryConfig, ::hotbarConfig) + } listen { if (it.action != SlotActionType.PICKUP || it.button != 1) return@listen diff --git a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt index 4ac8928bc..d7f6f8113 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt @@ -24,6 +24,7 @@ import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.Group import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.BreakConfig +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.event.events.PlayerEvent import com.lambda.event.events.TickEvent @@ -100,33 +101,34 @@ object PacketMine : Module( private var attackedThisTick = false init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::buildConfig, ::breakConfig, breakConfig::outlineConfig, ::rotationConfig, ::hotbarConfig) - buildConfig.apply { - hide( - ::pathing, - ::stayInRange, - ::spleefEntities, - ::maxBuildDependencies, - ::collectDrops, - ::entityReach, - ::breakBlocks, - ::interactBlocks, - ::placeBlocks - ) - ::maxBuildDependencies.edit { defaultValue(0) } - } - breakConfig.apply { - editTyped( - ::avoidFluids, - ::avoidSupporting, - ::efficientOnly, - ::suitableToolsOnly - ) { defaultValue(false) } - ::swing.edit { defaultValue(BreakConfig.SwingMode.Start) } + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::buildConfig, ::breakConfig, breakConfig::outlineConfig, ::rotationConfig, ::hotbarConfig) + buildConfig.apply { + hide( + ::pathing, + ::stayInRange, + ::spleefEntities, + ::maxBuildDependencies, + ::collectDrops, + ::entityReach, + ::breakBlocks, + ::interactBlocks, + ::placeBlocks + ) + ::maxBuildDependencies.edit { defaultValue(0) } + } + breakConfig.apply { + editTyped( + ::avoidFluids, + ::avoidSupporting, + ::efficientOnly, + ::suitableToolsOnly + ) { defaultValue(false) } + ::swing.edit { defaultValue(BreakConfig.SwingMode.Start) } + } + hotbarConfig::keepTicks.edit { defaultValue(0) } } - hotbarConfig::keepTicks.edit { defaultValue(0) } - } listen { attackedThisTick = false diff --git a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt index 07fbde6f8..a277c773d 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt @@ -20,6 +20,7 @@ package com.lambda.module.modules.player import com.lambda.config.ConfigEditor.edit import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.withEdits import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.interaction.managers.rotating.IRotationRequest.Companion.rotationRequest @@ -43,10 +44,11 @@ object RotationLock : Module( private val customPitch by setting("Custom Pitch", 0.0, -90.0..90.0, 0.1) { pitchMode == Mode.Custom } init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::rotationConfig) - rotationConfig::rotationMode.edit { defaultValue(RotationMode.Lock) } - } + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::rotationConfig) + rotationConfig::rotationMode.edit { defaultValue(RotationMode.Lock) } + } listen { val yaw = when (yawMode) { diff --git a/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt b/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt index a6c49321e..e72162dc7 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt @@ -20,6 +20,7 @@ package com.lambda.module.modules.player import com.lambda.config.ConfigEditor.hide import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -42,12 +43,13 @@ object StackReplenish : Module( private val offhand by setting("Offhand", false, "Replenishes the players offhand stack") init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::inventoryConfig) - inventoryConfig.apply { - hide(::disposables, ::swapWithDisposables, ::providerPriority, ::storePriority) + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::inventoryConfig) + inventoryConfig.apply { + hide(::disposables, ::swapWithDisposables, ::providerPriority, ::storePriority) + } } - } listen { if (player.currentScreenHandler.cursorStack.item !== Items.AIR) return@listen diff --git a/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt b/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt index 0505763f1..52b94e364 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt @@ -19,6 +19,7 @@ package com.lambda.module.modules.player import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.withEdits import com.lambda.event.events.ContainerEvent import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -43,9 +44,10 @@ object ToolSaver : Module( private val replace by setting("Replace", true, "Replaces the tool with the one of the same kind") init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::inventoryConfig) - } + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::inventoryConfig) + } listen { val endangeredStacks = player.hotbarSlots.filter { it.stack.isEndangered } diff --git a/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt b/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt index 201f95dfa..a1af6172d 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt @@ -21,6 +21,7 @@ import com.lambda.Lambda.mc import com.lambda.config.ConfigEditor.edit import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.event.events.MovementEvent import com.lambda.event.events.PlayerEvent @@ -122,12 +123,11 @@ object Freecam : Module( private const val SensitivityFactor = 0.15 init { - setDefaultAutomationConfig { - rotationConfig::rotationMode.edit { - defaultValue(RotationMode.Lock) + setDefaultAutomationConfig() + .withEdits { + rotationConfig::rotationMode.edit { defaultValue(RotationMode.Lock) } + hideAllBlocksExcept(::rotationConfig) } - hideAllBlocksExcept(::rotationConfig) - } onEnable { lastPerspective = mc.options.perspective diff --git a/src/main/kotlin/com/lambda/module/modules/render/XRay.kt b/src/main/kotlin/com/lambda/module/modules/render/XRay.kt index 1d7634a96..0b58bf173 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/XRay.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/XRay.kt @@ -53,6 +53,7 @@ object XRay : Module( @JvmStatic fun isSelected(blockState: BlockState) = mode.select(blockState) + @Suppress("unused") enum class Selection(val select: (BlockState) -> Boolean) { Whitelist({ it.block in selection }), Blacklist({ it.block !in selection }) diff --git a/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt b/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt index 9fc79ed14..a78e51056 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt @@ -22,6 +22,7 @@ import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.Group import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.complex.Bind +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.event.events.ButtonEvent import com.lambda.event.events.PlayerEvent @@ -91,9 +92,10 @@ object AirPlace : Module( ) init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::interactConfig) - } + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::interactConfig) + } listen { if (request?.done == false) { diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt index 5be3817b0..9cbd424be 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt @@ -133,12 +133,13 @@ object AutoPortal : Module( private var buildTask: Task<*>? = null init { - setDefaultAutomationConfig { - hideBlock(::eatConfig) - hotbarConfig::tickStageMask.edit { - defaultValue(mutableSetOf(TickEvent.Pre, TickEvent.Input.Post)) + setDefaultAutomationConfig() + .withEdits { + hideBlock(::eatConfig) + hotbarConfig::tickStageMask.edit { + defaultValue(mutableSetOf(TickEvent.Pre, TickEvent.Input.Post)) + } } - } listen { PosHandler.tick() diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt index 2719fc404..2853171ee 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt @@ -22,6 +22,7 @@ import com.lambda.config.Group import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.event.events.PacketEvent import com.lambda.event.events.TickEvent @@ -92,9 +93,10 @@ object AutoVillagerCycle : Module( private var buildTask: Task<*>? = null init { - setDefaultAutomationConfig { - hideAllBlocksExcept(::rotationConfig, ::inventoryConfig, ::breakConfig, ::interactConfig, ::buildConfig) - } + setDefaultAutomationConfig() + .withEdits { + hideAllBlocksExcept(::rotationConfig, ::inventoryConfig, ::breakConfig, ::interactConfig, ::buildConfig) + } onEnable { allEnchantments.clear() diff --git a/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt b/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt index 8cd17e255..4f4771fb1 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt @@ -19,6 +19,7 @@ package com.lambda.module.modules.world import com.lambda.config.ConfigEditor.editTyped import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.withEdits import com.lambda.interaction.BaritoneHandler import com.lambda.interaction.construction.blueprint.Blueprint.Companion.emptyStructure import com.lambda.interaction.construction.blueprint.PropagatingBlueprint.Companion.propagatingBlueprint @@ -91,11 +92,12 @@ object HighwayTools : Module( } init { - setDefaultAutomationConfig { - buildConfig.apply { - editTyped(::pathing, ::stayInRange) { defaultValue(true) } - } - } + setDefaultAutomationConfig() + .withEdits { + buildConfig.apply { + editTyped(::pathing, ::stayInRange) { defaultValue(true) } + } + } onEnable { octant = player.octant diff --git a/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt b/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt index e6eff41ac..39be4242b 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt @@ -19,6 +19,7 @@ package com.lambda.module.modules.world import com.lambda.config.ConfigEditor.editTyped import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint import com.lambda.interaction.construction.verify.TargetState @@ -56,11 +57,12 @@ object Nuker : Module( private var buildTask: Task<*>? = null init { - setDefaultAutomationConfig { - buildConfig.apply { - editTyped(::pathing, ::stayInRange) { defaultValue(false) } + setDefaultAutomationConfig() + .withEdits { + buildConfig.apply { + editTyped(::pathing, ::stayInRange) { defaultValue(false) } + } } - } onEnable { startBuildTask() diff --git a/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt b/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt index 3093ff204..dc629a1a9 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt @@ -24,6 +24,7 @@ import com.lambda.config.ConfigEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.InteractConfig import com.lambda.config.settings.complex.Bind +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.event.events.TickEvent import com.lambda.event.listener.SafeListener.Companion.listen @@ -60,23 +61,24 @@ object Scaffold : Module( private val pendingActions = ConcurrentLinkedQueue() init { - setDefaultAutomationConfig { - buildConfig.apply { - editTyped(::pathing, ::stayInRange, ::collectDrops, ::spleefEntities) { - defaultValue(false) - hide() + setDefaultAutomationConfig() + .withEdits { + buildConfig.apply { + editTyped(::pathing, ::stayInRange, ::collectDrops, ::spleefEntities) { + defaultValue(false) + hide() + } + ::checkSideVisibility.edit { defaultValue(true) } + hide(::breakBlocks) } - ::checkSideVisibility.edit { defaultValue(true) } - hide(::breakBlocks) - } - interactConfig::airPlace.edit { defaultValue(InteractConfig.AirPlaceMode.None) } - rotationConfig.apply { - ::instant.edit { defaultValue(false) } - ::mean.edit { defaultValue(120.0) } - ::spread.edit { defaultValue(0.0) } + interactConfig::airPlace.edit { defaultValue(InteractConfig.AirPlaceMode.None) } + rotationConfig.apply { + ::instant.edit { defaultValue(false) } + ::mean.edit { defaultValue(120.0) } + ::spread.edit { defaultValue(0.0) } + } + hideAllBlocksExcept(::buildConfig, ::interactConfig, ::rotationConfig, ::hotbarConfig) } - hideAllBlocksExcept(::buildConfig, ::interactConfig, ::rotationConfig, ::hotbarConfig) - } listen { val selection = selectStack { diff --git a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt index acef06d92..50cf0c37f 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt @@ -28,6 +28,7 @@ import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomat import com.lambda.config.settings.blocks.InteractConfig import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress +import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.event.events.ButtonEvent import com.lambda.event.events.ChatEvent @@ -106,7 +107,7 @@ object StashMover : Module( private const val GeneralTab = "General" private const val CommandBindsTab = "Command Binds" - enum class Role(val createTask: () -> Task<*>) { + private enum class Role(val createTask: () -> Task<*>) { MoverBot({ MoverBot() }), PearlBot({ PearlBot() }) } @@ -116,7 +117,7 @@ object StashMover : Module( Drop("Drop") } - @Tab(GeneralTab) val role: Role by setting("Role", Role.MoverBot) + @Tab(GeneralTab) private val role: Role by setting("Role", Role.MoverBot) .onValueChange { _, _ -> clearModule() } @Tab(GeneralTab) private val pearlBotName by setting("PearlBot Name", "Steve") { role == Role.MoverBot } @Tab(GeneralTab) private val moverBotName by setting("MoverBot Name", "Steve") { role == Role.PearlBot } @@ -178,17 +179,18 @@ object StashMover : Module( private var task: Task<*>? = null init { - setDefaultAutomationConfig { - buildConfig.apply { - editTyped(::pathing, ::stayInRange, ::checkSideVisibility) { defaultValue(true) } - hide(::pathing, ::stayInRange, ::collectDrops, ::spleefEntities, ::entityReach) - hideBlock(::eatConfig) - } - interactConfig::airPlace.edit { defaultValue(InteractConfig.AirPlaceMode.None) } - breakConfig.apply { - editTyped(::suitableToolsOnly, ::efficientOnly) { defaultValue(false) } + setDefaultAutomationConfig() + .withEdits { + buildConfig.apply { + editTyped(::pathing, ::stayInRange, ::checkSideVisibility) { defaultValue(true) } + hide(::pathing, ::stayInRange, ::collectDrops, ::spleefEntities, ::entityReach) + hideBlock(::eatConfig) + } + interactConfig::airPlace.edit { defaultValue(InteractConfig.AirPlaceMode.None) } + breakConfig.apply { + editTyped(::suitableToolsOnly, ::efficientOnly) { defaultValue(false) } + } } - } listen { event -> if (!chestPullSelMode && !chestPutSelMode) return@listen diff --git a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt index c97fce65e..db9a60a8e 100644 --- a/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt +++ b/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt @@ -336,7 +336,7 @@ class BuildTask private constructor( } BaritoneHandler.setGoalAndPath(GoalBlock(itemDrop.blockPos)) - return@let true + true } ?: false fun iteratePropagating() = From 94d2307681647516f962dad26d4ae85e90d59f61 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Mon, 18 May 2026 21:29:04 +0100 Subject: [PATCH 22/40] small improvements --- src/main/kotlin/com/lambda/config/Setting.kt | 19 +++++++++---------- .../com/lambda/gui/components/QuickSearch.kt | 8 +------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/com/lambda/config/Setting.kt b/src/main/kotlin/com/lambda/config/Setting.kt index 44225fc40..0b35e328b 100644 --- a/src/main/kotlin/com/lambda/config/Setting.kt +++ b/src/main/kotlin/com/lambda/config/Setting.kt @@ -226,16 +226,15 @@ class Setting, R>( } } - private fun getConfigCommandPath(): Collection { - var current: SettingLayer.Multiple = layer.parent - val layers = mutableListOf(current.commandName) - while (true) { - current = current.parent ?: break - if (current is SettingLayer.Root) break - layers.add(current.commandName) - } - return layers.asReversed() - } + internal fun getConfigCommandPath(): Collection = + buildList { + var current: SettingLayer.Multiple = layer.parent + while (true) { + current = current.parent ?: break + if (current is SettingLayer.Root) break + add(current.commandName) + } + }.asReversed() override fun toString() = "Setting $name: $value of type ${core.type.typeName}" } diff --git a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt index ba92ffc14..76818c343 100644 --- a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt +++ b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt @@ -302,13 +302,7 @@ object QuickSearch { } private fun buildSettingBreadcrumb(configName: String, setting: Setting<*, *>): String { - val path = buildList { - var current: SettingLayer.Multiple? = setting.layer.parent - while (current !is SettingLayer.Root) { - current = current?.parent ?: return@buildList - add(current.name) - } - }.asReversed() + val path = setting.getConfigCommandPath() return if (path.isEmpty()) configName else "$configName » ${path.joinToString(" » ")}" } From 047dc37b395d0e65f70ca745947acbd3931cc5da Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Tue, 19 May 2026 15:35:59 +0100 Subject: [PATCH 23/40] heuristic-based persistent config migration to handle settings moving from group/tab to group/tab --- src/main/kotlin/com/lambda/config/Config.kt | 99 +++++++++++++++---- .../com/lambda/config/ConfigCategory.kt | 15 ++- src/main/kotlin/com/lambda/config/Setting.kt | 3 +- .../settings/blocks/EntityColorSettings.kt | 23 ++--- .../com/lambda/gui/components/QuickSearch.kt | 1 - .../com/lambda/module/hud/Speedometer.kt | 5 +- .../lambda/module/modules/render/Nametags.kt | 2 +- 7 files changed, 101 insertions(+), 47 deletions(-) diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index 63fbb2b77..3638f989b 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -152,8 +152,8 @@ abstract class Config( val path = mutableListOf() property.annotations.forEach { annotation -> when (annotation) { - is Tab -> annotation.tabs.forEach { path.add(SettingLayerSpec(SettingLayerType.Tab, it)) } - is Group -> annotation.groups.forEach { path.add(SettingLayerSpec(SettingLayerType.Group, it)) } + is Tab -> annotation.tabs.forEach { path.add(SettingLayerSpec(MultipleLayerType.Tab, it)) } + is Group -> annotation.groups.forEach { path.add(SettingLayerSpec(MultipleLayerType.Group, it)) } } } return path @@ -194,27 +194,36 @@ abstract class Config( forEachSetting( multiple, false, - { _, multiple -> - val nestedObj = obj[multiple.name] + { _, childMultiple -> + var nestedObj = obj[childMultiple.name] if (nestedObj == null || !nestedObj.isJsonObject) { - logError("No data for ${multiple.type.toString().lowercase()} '${multiple.name}' in '$name'}") + nestedObj = JsonObject() } try { - load(multiple, nestedObj.asJsonObject) + load(childMultiple, nestedObj.asJsonObject) } catch(e: Throwable) { - logError("Failed to deserialize ${multiple.type.toString().lowercase()} '${multiple.name}' in '$name'", e) + logError("Failed to deserialize ${childMultiple.type.toString().lowercase()} '${childMultiple.name}' in '$name'", e) } } - ) { _, single -> + ) { path, single -> val jsonValue = obj[single.setting.name] if (jsonValue != null) { try { single.setting.loadFromJson(jsonValue) } catch (e: Throwable) { - logError("Failed to deserialize setting '$name'", e) + logError("Failed to deserialize setting '${single.setting.name}' in '$name'", e) } } else { - logError("No saved value for setting '${single.setting.name}' in '$name'") + val fallbackValue = findFallbackValue(single.setting.name, path, rootObj) + if (fallbackValue != null) { + try { + single.setting.loadFromJson(fallbackValue) + } catch (e: Throwable) { + logError("Failed to deserialize setting '${single.setting.name}' from fallback in '$name'", e) + } + } else { + logError("No saved value for setting '${single.setting.name}' in '$name'") + } } } } @@ -222,6 +231,54 @@ abstract class Config( load(settingLayers, rootObj) } + private fun findFallbackValue( + settingName: String, + parentLayers: List, + rootObj: JsonObject + ): JsonElement? { + var bestMatch: JsonElement? = null + var bestMatchKey: String? = null + var bestMatchParent: JsonObject? = null + var bestMatchScore = 0 + + fun search(currentObj: JsonObject, jsonPath: List) { + currentObj.entrySet().forEach { (key, element) -> + if (key.endsWith(settingName, ignoreCase = true)) { + var score = 0 + if (key.equals(settingName, ignoreCase = true)) { + score += 10 + } + + val fullPathString = (jsonPath + key).joinToString("") + parentLayers.forEach { layer -> + if (fullPathString.contains(layer.name, ignoreCase = true)) { + score += 5 + } + } + + if (score > bestMatchScore) { + bestMatchScore = score + bestMatch = element + bestMatchKey = key + bestMatchParent = currentObj + } + } + + if (element.isJsonObject) { + search(element.asJsonObject, jsonPath + key) + } + } + } + + search(rootObj, emptyList()) + + if (bestMatch != null && bestMatchParent != null && bestMatchKey != null) { + bestMatchParent.remove(bestMatchKey) + } + + return bestMatch + } + @SettingDsl fun setting( name: String, @@ -467,8 +524,8 @@ abstract class Config( .filter { it.name == spec.name } .also { it.forEach { layer -> - if (spec.type == SettingLayerType.Tab && layer !is SettingLayer.Tab || - spec.type == SettingLayerType.Group && layer !is SettingLayer.Group + if (spec.type == MultipleLayerType.Tab && layer !is SettingLayer.Tab || + spec.type == MultipleLayerType.Group && layer !is SettingLayer.Group ) throw IllegalStateException("Duplicate setting layers with differing types: ${layer.name} with type ${layer.type.toString().lowercase()} and ${spec.name} with type ${spec.type.toString().lowercase()}") } } @@ -477,9 +534,9 @@ abstract class Config( if (existing != null) currentSettingLayer = existing else { val newSettingLayer = when (spec.type) { - SettingLayerType.Tab -> SettingLayer.Tab(spec.name, mutableListOf(), currentSettingLayer) - SettingLayerType.Group -> SettingLayer.Group(spec.name, mutableListOf(), currentSettingLayer) - SettingLayerType.Root -> throw IllegalStateException("Multiple root setting layers; only the base class root layer should ever be created") + MultipleLayerType.Tab -> SettingLayer.Tab(spec.name, mutableListOf(), currentSettingLayer) + MultipleLayerType.Group -> SettingLayer.Group(spec.name, mutableListOf(), currentSettingLayer) + MultipleLayerType.Root -> throw IllegalStateException("Multiple root setting layers; only the base class root layer should ever be created") } currentSettingLayer.layers.add(newSettingLayer) currentSettingLayer = newSettingLayer @@ -515,8 +572,8 @@ abstract class Config( return layer.setting } - enum class SettingLayerType { Root, Tab, Group } - private data class SettingLayerSpec(val type: SettingLayerType, val name: String) + enum class MultipleLayerType { Root, Tab, Group } + private data class SettingLayerSpec(val type: MultipleLayerType, val name: String) private data class LayerSpecInfo(val settingLayerSpecs: List, val settingBlockSpecs: List) sealed interface SettingLayer { @@ -527,7 +584,7 @@ abstract class Config( val layers: MutableList, override val parent: Multiple? ) : SettingLayer, Nameable { - abstract val type: SettingLayerType + abstract val type: MultipleLayerType } class Root : Multiple( @@ -535,7 +592,7 @@ abstract class Config( mutableListOf(), null ) { - override val type = SettingLayerType.Root + override val type = MultipleLayerType.Root } class Tab( @@ -543,7 +600,7 @@ abstract class Config( layers: MutableList, parent: Multiple ) : Multiple(name, layers, parent) { - override val type = SettingLayerType.Tab + override val type = MultipleLayerType.Tab } class Group( @@ -551,7 +608,7 @@ abstract class Config( layers: MutableList, parent: Multiple ) : Multiple(name, layers, parent) { - override val type = SettingLayerType.Group + override val type = MultipleLayerType.Group } class Single, R : Any>( diff --git a/src/main/kotlin/com/lambda/config/ConfigCategory.kt b/src/main/kotlin/com/lambda/config/ConfigCategory.kt index 707906d37..930605984 100644 --- a/src/main/kotlin/com/lambda/config/ConfigCategory.kt +++ b/src/main/kotlin/com/lambda/config/ConfigCategory.kt @@ -38,7 +38,6 @@ import com.lambda.util.CommunicationUtils.logError import com.lambda.util.FileUtils.createIfNotExists import com.lambda.util.FileUtils.ifExists import com.lambda.util.FileUtils.ifNotExists -import com.lambda.util.StringUtils.capitalize import java.io.File import kotlin.concurrent.fixedRateTimer import kotlin.time.Duration.Companion.minutes @@ -106,14 +105,14 @@ abstract class ConfigCategory : Jsonable, Loadable { if (name == schemaKey) return@forEach configByName(name) ?.loadFromJson(value) - ?: Log.warn("No matching setting found for saved setting $name with $value in ${configName.capitalize()} config") + ?: Log.warn("No matching config found for $name in $configName config category") } } protected open fun internalTryLoad() { loadFromFile(primaryFile) .onSuccess { - val message = "${configName.capitalize()} config loaded." + val message = "$configName config loaded." Log.info(message) info(message) } @@ -122,12 +121,12 @@ abstract class ConfigCategory : Jsonable, Loadable { runCatching { loadFromFile(backup) } .onSuccess { - val message = "${configName.capitalize()} config loaded from backup" + val message = "$configName config loaded from backup" Log.info(message) info(message) } .onFailure { error -> - val message = "Failed to load ${configName.capitalize()} config from backup, unrecoverable error" + val message = "Failed to load $configName config from backup, unrecoverable error" Log.error(message, error) logError(message) } @@ -137,12 +136,12 @@ abstract class ConfigCategory : Jsonable, Loadable { protected open fun internalTrySave(logToChat: Boolean) { saveToFile() .onSuccess { - val message = "Saved ${configName.capitalize()} config." + val message = "Saved $configName config." Log.info(message) if (logToChat) info(message) } .onFailure { - val message = "Failed to save ${configName.capitalize()} config" + val message = "Failed to save $configName config" Log.error(message, it) logError(message) } @@ -153,7 +152,7 @@ abstract class ConfigCategory : Jsonable, Loadable { * Encapsulates [JsonIOException] and [JsonSyntaxException] in a runCatching block */ private fun loadFromFile(file: File) = runCatching { - file.ifNotExists { Log.warn("No configuration file found for ${configName.capitalize()}. Creating new file when saving.") } + file.ifNotExists { Log.warn("No configuration file found for $configName. Creating new file when saving.") } .ifExists { val parsed = JsonParser.parseReader(it.reader()).asJsonObject val migrationResult = ConfigMigrations.migrate(configName, parsed) diff --git a/src/main/kotlin/com/lambda/config/Setting.kt b/src/main/kotlin/com/lambda/config/Setting.kt index 0b35e328b..67ff80558 100644 --- a/src/main/kotlin/com/lambda/config/Setting.kt +++ b/src/main/kotlin/com/lambda/config/Setting.kt @@ -30,6 +30,7 @@ import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required import com.lambda.command.CommandRegistry import com.lambda.command.commands.ConfigCommand +import com.lambda.config.Config.MultipleLayerType import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting.ValueListener import com.lambda.context.SafeContext @@ -231,7 +232,7 @@ class Setting, R>( var current: SettingLayer.Multiple = layer.parent while (true) { current = current.parent ?: break - if (current is SettingLayer.Root) break + if (current.type == MultipleLayerType.Root) break add(current.commandName) } }.asReversed() diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/EntityColorSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/EntityColorSettings.kt index 11308a9d6..1589c3681 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/EntityColorSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/EntityColorSettings.kt @@ -21,7 +21,7 @@ import com.lambda.config.Config import com.lambda.config.SettingBlock import com.lambda.context.SafeContext import com.lambda.friend.FriendHandler.isFriend -import com.lambda.util.EntityUtils +import com.lambda.util.EntityUtils.EntityGroup import com.lambda.util.EntityUtils.entityGroup import com.lambda.util.extension.blockColor import com.lambda.util.extension.entityColor @@ -30,6 +30,7 @@ import com.lambda.util.math.lerp import net.minecraft.block.entity.BlockEntity import net.minecraft.client.network.OtherClientPlayerEntity import net.minecraft.entity.Entity +import net.minecraft.entity.player.PlayerEntity import java.awt.Color class EntityColorSettings(override val c: Config) : SettingBlock, EntityColorsConfig { @@ -54,9 +55,9 @@ class EntityColorSettings(override val c: Config) : SettingBlock, EntityColorsCo val group = entity.entityGroup return if (useNaturalColors && !hasSpecialCase(entity, group)) entityColor(entity) else when (group) { - EntityUtils.EntityGroup.Player -> + EntityGroup.Player -> when { - entity is OtherClientPlayerEntity && entity.isFriend && separateFriendColor -> friendColor + entity is PlayerEntity && entity.isFriend && separateFriendColor -> friendColor else -> if (playerDistanceGradient) lerp( @@ -66,12 +67,12 @@ class EntityColorSettings(override val c: Config) : SettingBlock, EntityColorsCo ) else playerColor } - EntityUtils.EntityGroup.Mob -> mobColor - EntityUtils.EntityGroup.Passive -> passiveColor - EntityUtils.EntityGroup.Vehicle -> vehicleColor - EntityUtils.EntityGroup.Projectile -> projectileColor - EntityUtils.EntityGroup.Boss -> bossColor - EntityUtils.EntityGroup.Decoration -> decorationColor + EntityGroup.Mob -> mobColor + EntityGroup.Passive -> passiveColor + EntityGroup.Vehicle -> vehicleColor + EntityGroup.Projectile -> projectileColor + EntityGroup.Boss -> bossColor + EntityGroup.Decoration -> decorationColor else -> miscColor } } @@ -81,7 +82,7 @@ class EntityColorSettings(override val c: Config) : SettingBlock, EntityColorsCo if (useNaturalColors) safeContext.blockColor(blockEntity.cachedState, blockEntity.pos) else blockColor - private fun hasSpecialCase(entity: Entity, group: EntityUtils.EntityGroup) = - group == EntityUtils.EntityGroup.Player && + private fun hasSpecialCase(entity: Entity, group: EntityGroup) = + group == EntityGroup.Player && ((entity is OtherClientPlayerEntity && entity.isFriend && separateFriendColor) || playerDistanceGradient) } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt index 76818c343..36f67c63d 100644 --- a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt +++ b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt @@ -21,7 +21,6 @@ import com.lambda.Lambda.mc import com.lambda.command.CommandRegistry import com.lambda.command.LambdaCommand import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer import com.lambda.config.ConfigLoader import com.lambda.config.Setting import com.lambda.event.events.ButtonEvent diff --git a/src/main/kotlin/com/lambda/module/hud/Speedometer.kt b/src/main/kotlin/com/lambda/module/hud/Speedometer.kt index fe20b5f54..9eeb8fe0d 100644 --- a/src/main/kotlin/com/lambda/module/hud/Speedometer.kt +++ b/src/main/kotlin/com/lambda/module/hud/Speedometer.kt @@ -23,7 +23,6 @@ import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.module.HudModule import com.lambda.module.tag.ModuleTag -import com.lambda.threading.runSafe import com.lambda.util.SpeedUnit import net.minecraft.util.math.Vec3d @@ -68,8 +67,6 @@ object Speedometer : HudModule( } override fun ImGuiBuilder.buildLayout() { - runSafe { - text("Speed: %.2f %s".format(speed, speedUnit.unitName)) - } + text("Speed: %.2f %s".format(speed, speedUnit.unitName)) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt b/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt index ba497188c..6cbf18dc6 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt @@ -245,7 +245,7 @@ object Nametags : Module( @JvmStatic fun shouldRenderNametag(entity: Entity) = - (entity !== mc.player || !mc.options.perspective.isFirstPerson) && + (entity !== mc.player || !mc.options.perspective.isFirstPerson || Freecam.isEnabled) && entitySelectionSettings.isSelected(entity) && (entity !is LivingEntity || entity.isAlive) @Suppress("unused") From c25ef536a4a88ae36da3135284bc9d673da807b6 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Wed, 20 May 2026 23:41:46 +0100 Subject: [PATCH 24/40] move value change listeners into the Setting class --- .../kotlin/com/lambda/config/BaseEditor.kt | 2 +- src/main/kotlin/com/lambda/config/Config.kt | 42 +++++++-------- src/main/kotlin/com/lambda/config/Setting.kt | 28 +++++----- .../lambda/config/settings/StringSetting.kt | 2 +- .../settings/comparable/BooleanSetting.kt | 2 +- .../config/settings/comparable/EnumSetting.kt | 20 ++----- .../settings/complex/BlockPosSetting.kt | 4 +- .../config/settings/complex/ColorSetting.kt | 2 +- .../config/settings/complex/KeybindSetting.kt | 4 +- .../config/settings/complex/Vec3dSetting.kt | 2 +- .../config/settings/numeric/DoubleSetting.kt | 37 +++++++------ .../config/settings/numeric/FloatSetting.kt | 53 +++++++++---------- .../config/settings/numeric/IntegerSetting.kt | 2 +- .../config/settings/numeric/LongSetting.kt | 19 ++++--- .../containers/EnderChestContainer.kt | 6 +-- .../lambda/module/modules/render/RadiusESP.kt | 4 +- 16 files changed, 106 insertions(+), 123 deletions(-) diff --git a/src/main/kotlin/com/lambda/config/BaseEditor.kt b/src/main/kotlin/com/lambda/config/BaseEditor.kt index d25126c0a..e164fe5a7 100644 --- a/src/main/kotlin/com/lambda/config/BaseEditor.kt +++ b/src/main/kotlin/com/lambda/config/BaseEditor.kt @@ -167,7 +167,7 @@ object ConfigEditor { fun defaultValue(value: T) = settings.forEach { it.core.defaultValue = value - it.core.value = value + it.value = value } } diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index 3638f989b..fc4ae6daa 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -173,10 +173,12 @@ abstract class Config( false, { _, multiple -> val nested = JsonObject() - target.add(multiple.name, nested) process(multiple, nested) + if (nested.isEmpty) return@forEachSetting + target.add(multiple.name, nested) } ) { _, single -> + if (!single.setting.isModified) return@forEachSetting try { target.add(single.setting.name, single.setting.toJson()) } catch (e: Throwable) { @@ -202,7 +204,7 @@ abstract class Config( try { load(childMultiple, nestedObj.asJsonObject) } catch(e: Throwable) { - logError("Failed to deserialize ${childMultiple.type.toString().lowercase()} '${childMultiple.name}' in '$name'", e) + logError("Failed to deserialize ${childMultiple.multipleType.toString().lowercase()} '${childMultiple.name}' in '$name'", e) } } ) { path, single -> @@ -520,15 +522,15 @@ abstract class Config( layerSpecInfo.settingLayerSpecs.forEach { spec -> val existing = currentSettingLayer.layers .asSequence() - .filterIsInstance() .filter { it.name == spec.name } .also { it.forEach { layer -> if (spec.type == MultipleLayerType.Tab && layer !is SettingLayer.Tab || spec.type == MultipleLayerType.Group && layer !is SettingLayer.Group - ) throw IllegalStateException("Duplicate setting layers with differing types: ${layer.name} with type ${layer.type.toString().lowercase()} and ${spec.name} with type ${spec.type.toString().lowercase()}") + ) throw IllegalStateException("Duplicate setting layers with differing types: ('${layer.name}') in '${this@Config.name}'") } } + .filterIsInstance() .firstOrNull() if (existing != null) currentSettingLayer = existing @@ -544,8 +546,8 @@ abstract class Config( } if (currentSettingLayer.layers.any { - it is SettingLayer.Single<*, *> && it.setting.name == name - }) throw IllegalStateException("Duplicate setting name ('$name') within ${currentSettingLayer.name}") + it.name == name + }) throw IllegalStateException("Duplicate layer name ('$name') within ${currentSettingLayer.name}") var currentBlockLayer: BlockLayer = settingBlockLayers layerSpecInfo.settingBlockSpecs.forEach { index -> @@ -572,56 +574,52 @@ abstract class Config( return layer.setting } - enum class MultipleLayerType { Root, Tab, Group } - private data class SettingLayerSpec(val type: MultipleLayerType, val name: String) + enum class SettingLayerType { Root, Tab, Group, Single } + enum class MultipleLayerType { Root, Tab, Group } + private data class SettingLayerSpec(val type: MultipleLayerType, val name: String) private data class LayerSpecInfo(val settingLayerSpecs: List, val settingBlockSpecs: List) sealed interface SettingLayer { + val name: String val parent: SettingLayer? sealed class Multiple( override val name: String, + val multipleType: MultipleLayerType, val layers: MutableList, override val parent: Multiple? - ) : SettingLayer, Nameable { - abstract val type: MultipleLayerType - } + ) : SettingLayer, Nameable class Root : Multiple( "Root", + MultipleLayerType.Root, mutableListOf(), null - ) { - override val type = MultipleLayerType.Root - } + ) class Tab( name: String, layers: MutableList, parent: Multiple - ) : Multiple(name, layers, parent) { - override val type = MultipleLayerType.Tab - } + ) : Multiple(name, MultipleLayerType.Tab, layers, parent) class Group( name: String, layers: MutableList, parent: Multiple - ) : Multiple(name, layers, parent) { - override val type = MultipleLayerType.Group - } + ) : Multiple(name, MultipleLayerType.Group, layers, parent) class Single, R : Any>( override val parent: Multiple, val blockLayer: BlockLayer, - name: String, + override val name: String, description: String, settingCore: T, config: Config, visibility: () -> Boolean, ) : SettingLayer { val setting = Setting(name, description, settingCore, config, this, visibility) - } + } } sealed class BlockLayer { diff --git a/src/main/kotlin/com/lambda/config/Setting.kt b/src/main/kotlin/com/lambda/config/Setting.kt index 67ff80558..56b062c14 100644 --- a/src/main/kotlin/com/lambda/config/Setting.kt +++ b/src/main/kotlin/com/lambda/config/Setting.kt @@ -30,9 +30,7 @@ import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required import com.lambda.command.CommandRegistry import com.lambda.command.commands.ConfigCommand -import com.lambda.config.Config.MultipleLayerType import com.lambda.config.Config.SettingLayer -import com.lambda.config.Setting.ValueListener import com.lambda.context.SafeContext import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.threading.runSafe @@ -108,11 +106,18 @@ class Setting, R>( var value by this + val listeners = mutableListOf>() + val isModified get() = value != core.defaultValue operator fun getValue(thisRef: Any?, property: KProperty<*>) = core.value operator fun setValue(thisRef: Any?, property: KProperty<*>, value: R) { + val oldValue = core.value core.value = value + listeners.forEach { + if (it.requiresValueChange && oldValue == value) return@forEach + it.execute(oldValue, value) + } } fun reset(silent: Boolean = false) { @@ -148,7 +153,7 @@ class Setting, R>( */ @SettingDsl fun onValueChange(block: SafeContext.(from: R, to: R) -> Unit) = apply { - core.listeners.add(ValueListener(true) { from, to -> + listeners.add(ValueListener(true) { from, to -> runSafe { block(from, to) } @@ -157,12 +162,12 @@ class Setting, R>( @SettingDsl fun onValueChangeUnsafe(block: (from: R, to: R) -> Unit) = apply { - core.listeners.add(ValueListener(true, block)) + listeners.add(ValueListener(true, block)) } @SettingDsl fun onValueSet(block: (from: R, to: R) -> Unit) = apply { - core.listeners.add(ValueListener(false, block)) + listeners.add(ValueListener(false, block)) } @SettingDsl @@ -232,7 +237,7 @@ class Setting, R>( var current: SettingLayer.Multiple = layer.parent while (true) { current = current.parent ?: break - if (current.type == MultipleLayerType.Root) break + if (current.multipleType == Config.MultipleLayerType.Root) break add(current.commandName) } }.asReversed() @@ -245,15 +250,12 @@ abstract class SettingCore( val type: Type ) : Jsonable { open var value = defaultValue + context(setting: Setting<*, T>) + protected var internalValue + get() = value set(value) { - val oldValue = field - field = value - listeners.forEach { - if (it.requiresValueChange && oldValue == value) return@forEach - it.execute(oldValue, value) - } + setting.value = value } - val listeners = mutableListOf>() context(setting: Setting<*, T>) abstract fun ImGuiBuilder.buildLayout() diff --git a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt index 079c5084b..9262164ec 100644 --- a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt @@ -47,7 +47,7 @@ class StringSetting( if (multiline) { inputTextMultiline(setting.name, ::value, flags = flags) } else { - inputText(setting.name, ::value, flags) + inputText(setting.name, setting::value, flags) } lambdaTooltip(setting.description) } diff --git a/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt b/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt index f732d037c..40506cb29 100644 --- a/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt @@ -37,7 +37,7 @@ class BooleanSetting(defaultValue: Boolean) : SettingCore( ) { context(setting: Setting<*, Boolean>) override fun ImGuiBuilder.buildLayout() { - checkbox(setting.name, ::value) + checkbox(setting.name, setting::value) lambdaTooltip(setting.description) } diff --git a/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt b/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt index 2b55f965c..6ebd589e5 100644 --- a/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings.comparable -import com.google.gson.JsonElement import com.google.gson.reflect.TypeToken import com.lambda.brigadier.CommandResult.Companion.failure import com.lambda.brigadier.CommandResult.Companion.success @@ -33,7 +32,6 @@ import com.lambda.util.StringUtils.capitalize import com.lambda.util.extension.CommandBuilder import com.lambda.util.extension.displayValue import net.minecraft.command.CommandRegistryAccess -import kotlin.properties.Delegates /** * @see [com.lambda.config.Config] @@ -42,26 +40,18 @@ class EnumSetting>(defaultValue: T) : SettingCore( defaultValue, TypeToken.get(defaultValue.declaringJavaClass).type ) { - var index by Delegates.observable(value.ordinal) { _, _, to -> - value = value.enumValues[to % value.enumValues.size] - } - - override fun loadFromJson(serialized: JsonElement) { - super.loadFromJson(serialized) - index = value.ordinal // super bug fix for imgui - } - - context(setting: Setting<*, T>) + context(setting: Setting<*, T>) override fun ImGuiBuilder.buildLayout() { val values = value.enumValues val currentDisplay = value.displayValue + val currentIndex = value.ordinal combo("##${setting.name}", preview = "${setting.name}: $currentDisplay") { values.forEachIndexed { idx, v -> - val isSelected = idx == index + val isSelected = idx == currentIndex selectable(v.displayValue, isSelected) { - if (!isSelected) index = idx + if (!isSelected) internalValue = values[idx % values.size] } (v as? Describable)?.let { lambdaTooltip(it.description) } @@ -71,7 +61,7 @@ class EnumSetting>(defaultValue: T) : SettingCore( lambdaTooltip(setting.description) } - context(setting: Setting<*, T>) + context(setting: Setting<*, T>) override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { required(word(setting.name)) { parameter -> suggests { _, builder -> diff --git a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt index 2853df57b..8bc616d5e 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt @@ -44,13 +44,13 @@ class BlockPosSetting(defaultValue: BlockPos) : SettingCore( override fun ImGuiBuilder.buildLayout() { button("Set##${setting.name}") { mc.crosshairTarget?.blockResult?.blockPos?.let { - value = it + internalValue = it } ?: info("No block under crosshair") } lambdaTooltip("Set the coordinates to the block you are currently looking at") sameLine() treeNode(setting.name, id = setting.name) { - inputVec3i("##${setting.name}", value) { value = it.blockPos } + inputVec3i("##${setting.name}", internalValue) { internalValue = it.blockPos } } lambdaTooltip(setting.description) } diff --git a/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt index 9c78e6cb3..d17ef9710 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt @@ -39,7 +39,7 @@ class ColorSetting(defaultValue: Color) : SettingCore( ) { context(setting: Setting<*, Color>) override fun ImGuiBuilder.buildLayout() { - colorEdit(setting.name, ::value) + colorEdit(setting.name, setting::value) lambdaTooltip(setting.description) } diff --git a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt index 6d82e74c3..9f7bb34e9 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt @@ -125,7 +125,7 @@ class KeybindSetting( sameLine() withId("##Unbind-${this@KeybindSetting.hashCode()}") { smallButton("Unbind") { - value = Bind.EMPTY + internalValue = Bind.EMPTY listening = false } } @@ -136,7 +136,7 @@ class KeybindSetting( if (listening) { InputUtils.newMouseEvent() ?.let { - value = Bind(0, it.modifiers, it.button) + internalValue = Bind(0, it.modifiers, it.button) listening = false return } diff --git a/src/main/kotlin/com/lambda/config/settings/complex/Vec3dSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/Vec3dSetting.kt index 17aa606f8..91fd3489c 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/Vec3dSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/Vec3dSetting.kt @@ -35,7 +35,7 @@ class Vec3dSetting(defaultValue: Vec3d) : SettingCore( ) { context(setting: Setting<*, Vec3d>) override fun ImGuiBuilder.buildLayout() { - inputVec3d(setting.name, ::value as Vec3d) // FixMe: what the fuck + inputVec3d(setting.name, setting::value as Vec3d) // FixMe: what the fuck lambdaTooltip(setting.description) } diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt index 7aab3f3b6..468106de4 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt @@ -25,6 +25,7 @@ import com.lambda.brigadier.required import com.lambda.config.Setting import com.lambda.config.settings.NumericSetting import com.lambda.gui.dsl.ImGuiBuilder +import com.lambda.imgui.type.ImInt import com.lambda.util.extension.CommandBuilder import com.lambda.util.math.MathUtils.roundToStep import net.minecraft.command.CommandRegistryAccess @@ -44,26 +45,24 @@ class DoubleSetting( step, unit ) { - private var valueIndex: Int - get() = ((value - range.start) / step).roundToInt() - set(index) { - value = (range.start + index * step) - .roundToStep(step) - .coerceIn(range) - } - context(setting: Setting<*, Double>) - override fun ImGuiBuilder.buildSlider() { - val maxIndex = ((range.endInclusive - range.start) / step).toInt() - slider("##${setting.name}", ::valueIndex, 0, maxIndex, "") - } + override fun ImGuiBuilder.buildSlider() { + val maxIndex = ((range.endInclusive - range.start) / step).toInt() + val currentIndex = ((value - range.start) / step).roundToInt() + val imInt = ImInt(currentIndex) + slider("##${setting.name}", imInt, 0, maxIndex, "") { + internalValue = (range.start + imInt.get() * step) + .roundToStep(step) + .coerceIn(range) + } + } context(setting: Setting<*, Double>) - override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { - required(double(setting.name, range.start, range.endInclusive)) { parameter -> - execute { - setting.trySetValue(parameter().value()) - } - } - } + override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { + required(double(setting.name, range.start, range.endInclusive)) { parameter -> + execute { + setting.trySetValue(parameter().value()) + } + } + } } diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt index 0a9bb300c..87241b2ab 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt @@ -24,6 +24,7 @@ import com.lambda.brigadier.required import com.lambda.config.Setting import com.lambda.config.settings.NumericSetting import com.lambda.gui.dsl.ImGuiBuilder +import com.lambda.imgui.type.ImInt import com.lambda.util.extension.CommandBuilder import com.lambda.util.math.MathUtils.roundToStep import net.minecraft.command.CommandRegistryAccess @@ -33,36 +34,34 @@ import kotlin.math.roundToInt * @see [com.lambda.config.Config] */ class FloatSetting( - defaultValue: Float, - override var range: ClosedRange, - override var step: Float = 1f, - unit: String, + defaultValue: Float, + override var range: ClosedRange, + override var step: Float = 1f, + unit: String, ) : NumericSetting( - defaultValue, - range, - step, - unit + defaultValue, + range, + step, + unit ) { - private var valueIndex: Int - get() = ((value - range.start) / step).roundToInt() - set(index) { - value = (range.start + index * step) - .roundToStep(step) - .coerceIn(range) - } - context(setting: Setting<*, Float>) - override fun ImGuiBuilder.buildSlider() { - val maxIndex = ((range.endInclusive - range.start) / step).toInt() - slider("##${setting.name}", ::valueIndex, 0, maxIndex, "") - } + override fun ImGuiBuilder.buildSlider() { + val maxIndex = ((range.endInclusive - range.start) / step).toInt() + val currentIndex = ((value - range.start) / step).roundToInt() + val imInt = ImInt(currentIndex) + slider("##${setting.name}", imInt, 0, maxIndex, "") { + internalValue = (range.start + imInt.get() * step) + .roundToStep(step) + .coerceIn(range) + } + } context(setting: Setting<*, Float>) - override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { - required(float(setting.name, range.start, range.endInclusive)) { parameter -> - execute { - setting.trySetValue(parameter().value()) - } - } - } + override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { + required(float(setting.name, range.start, range.endInclusive)) { parameter -> + execute { + setting.trySetValue(parameter().value()) + } + } + } } diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/IntegerSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/IntegerSetting.kt index 99748da62..09ad264b3 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/IntegerSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/IntegerSetting.kt @@ -43,7 +43,7 @@ class IntegerSetting( ) { context(setting: Setting<*, Int>) override fun ImGuiBuilder.buildSlider() { - slider("##${setting.name}", ::value, range.start, range.endInclusive, "") + slider("##${setting.name}", setting::value, range.start, range.endInclusive, "") } context(setting: Setting<*, Int>) diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt index 8c3511caa..b1f8f133a 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt @@ -24,6 +24,7 @@ import com.lambda.brigadier.required import com.lambda.config.Setting import com.lambda.config.settings.NumericSetting import com.lambda.gui.dsl.ImGuiBuilder +import com.lambda.imgui.type.ImInt import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandRegistryAccess @@ -41,20 +42,18 @@ class LongSetting( step, unit ) { - // ToDo: No worky for super large numbers - private var valueIndex: Int - get() = ((value - range.start) / step).toInt() - set(index) { - value = (range.start + index * step).coerceIn(range) - } - - context(setting: Setting<*, Long>) + context(setting: Setting<*, Long>) override fun ImGuiBuilder.buildSlider() { + // ToDo: No worky for super large numbers val maxIndex = ((range.endInclusive - range.start) / step).toInt() - slider("##${setting.name}", ::valueIndex, 0, maxIndex, "") + val currentIndex = ((value - range.start) / step).toInt() + val imInt = ImInt(currentIndex) + slider("##${setting.name}", imInt, 0, maxIndex, "") { + internalValue = (range.start + imInt.get() * step).coerceIn(range) + } } - context(setting: Setting<*, Long>) + context(setting: Setting<*, Long>) override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { required(long(setting.name, range.start, range.endInclusive)) { parameter -> execute { diff --git a/src/main/kotlin/com/lambda/interaction/material/container/containers/EnderChestContainer.kt b/src/main/kotlin/com/lambda/interaction/material/container/containers/EnderChestContainer.kt index ace829524..2ee7da2de 100644 --- a/src/main/kotlin/com/lambda/interaction/material/container/containers/EnderChestContainer.kt +++ b/src/main/kotlin/com/lambda/interaction/material/container/containers/EnderChestContainer.kt @@ -34,7 +34,6 @@ import com.lambda.util.text.literal import net.minecraft.block.entity.EnderChestBlockEntity import net.minecraft.item.ItemStack import net.minecraft.item.Items -import net.minecraft.util.math.BlockPos object EnderChestContainer : MaterialContainer(Rank.EnderChest), ExternalContainer { context(safeContext: SafeContext) @@ -47,8 +46,6 @@ object EnderChestContainer : MaterialContainer(Rank.EnderChest), ExternalContain override val description = buildText { literal("Ender Chest") } - private var placePos = BlockPos.ORIGIN - context(automatedSafeContext: AutomatedSafeContext) override fun accessThen(exitAfter: Boolean, taskGenerator: TaskGenerator) = Items.ENDER_CHEST @@ -56,10 +53,9 @@ object EnderChestContainer : MaterialContainer(Rank.EnderChest), ExternalContain .findSlotsWithMaterial() .firstOrNull()?.let { slot -> PlaceContainerTask(slot, automatedSafeContext).then { pos -> - placePos = pos OpenContainerTask(pos, automatedSafeContext).then { taskGenerator.invoke(automatedSafeContext, Unit).thenOrNull { - if (exitAfter) automatedSafeContext.breakAndCollectBlock(placePos, lifeMaintenance = false) + if (exitAfter) automatedSafeContext.breakAndCollectBlock(pos, lifeMaintenance = false) else null } } diff --git a/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt b/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt index d6ce66c19..199e6c17a 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt @@ -51,9 +51,9 @@ object RadiusESP : Module( @Group(RenderGroup) private val beaconColor by setting("Beacon Color", Color(0, 255, 255, 255)) { beacons }.onValueChange(::rebuildMesh) @Group(RenderGroup) private val spawnerColor by setting("Spawner Color", Color(255, 0, 0, 255)) { spawners }.onValueChange(::rebuildMesh) - @Group(RenderGroup) private var fill: Boolean by setting("Fill", true).onValueChange(::rebuildMesh) + @Group(RenderGroup) private var fill: Boolean by setting("Box Fill", true).onValueChange(::rebuildMesh) .onValueChange { _, to -> if (!to) outline = true } - @Group(RenderGroup) private var outline: Boolean by setting("Outline", true).onValueChange(::rebuildMesh) + @Group(RenderGroup) private var outline: Boolean by setting("Box Outline", true).onValueChange(::rebuildMesh) .onValueChange { _, to -> if (!to) fill = true } @Group(RenderGroup) private val fillAlpha by setting("Fill Alpha", 0.1, 0.0..1.0, 0.01).onValueChange(::rebuildMesh) @Group(RenderGroup, OutlineGroup) private val worldLineConfig by settingBlock(WorldLineSettings(this)) From a86a2f3ea6a571acaaadc7742cbd6ace09a53711 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Thu, 21 May 2026 13:13:44 +0100 Subject: [PATCH 25/40] recursive hideAllExcepts as its cleaner and more intuitive --- .../kotlin/com/lambda/config/BaseEditor.kt | 39 ++++++++++--------- .../module/modules/player/PacketMine.kt | 2 +- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/main/kotlin/com/lambda/config/BaseEditor.kt b/src/main/kotlin/com/lambda/config/BaseEditor.kt index e164fe5a7..2c487e223 100644 --- a/src/main/kotlin/com/lambda/config/BaseEditor.kt +++ b/src/main/kotlin/com/lambda/config/BaseEditor.kt @@ -63,14 +63,8 @@ object ConfigEditor { @SettingEditorDsl context(editContext: EditContext.ConfigEditContext) - fun hideAllBlocksExcept(vararg except: SettingBlockProperty) { - val exceptBlocks = except.map { it.settingBlock.layer } - fun processBlock(blockLayer: BlockLayer) { - blockLayer.layers.forEach(::processBlock) - if (blockLayer !in exceptBlocks) blockLayer.settingLayers.forEach(::hide) - } - processBlock(editContext.c.settingBlockLayers) - } + fun hideAllBlocksExcept(vararg except: SettingBlockProperty, recursive: Boolean = true) = + hideAllBlocksExcept(editContext.c.settingBlockLayers, *except, recursive = recursive) @SettingEditorDsl context(editContext: EditContext.BlockEditContext) @@ -82,14 +76,8 @@ object ConfigEditor { @SettingEditorDsl context(editContext: EditContext.BlockEditContext) - fun hideAllBlocksExcept(vararg except: SettingBlockProperty) { - val exceptBlocks = except.map { it.settingBlock.layer } - fun processBlock(blockLayer: BlockLayer) { - blockLayer.layers.forEach(::processBlock) - if (blockLayer !in exceptBlocks) blockLayer.settingLayers.forEach(::hide) - } - processBlock(editContext.block.layer) - } + fun hideAllBlocksExcept(vararg except: SettingBlockProperty, recursive: Boolean = true) = + hideAllBlocksExcept(editContext.block.layer, *except, recursive = recursive) @SettingEditorDsl context(_: EditContext) @@ -130,10 +118,13 @@ object ConfigEditor { @SettingEditorDsl context(_: EditContext) - fun hideBlockExcept(settingBlock: SettingBlockProperty, vararg except: SettingProperty) { + fun hideBlockExcept(settingBlock: SettingBlockProperty, vararg except: SettingProperty, recursive: Boolean = true) { val exceptSettings = except.map { it.setting } - settingBlock.settingBlock.layer.settingLayers.forEach { layer -> - if (layer.setting !in exceptSettings) hide(layer) + fun processBlock(blockLayer: BlockLayer) { + blockLayer.settingLayers.forEach { single -> + if (single.setting !in exceptSettings) hide(single) + } + if (recursive) blockLayer.layers.forEach(::processBlock) } } @@ -182,6 +173,16 @@ object ConfigEditor { parentLayer.parent?.layers?.remove(parentLayer) } + private fun hideAllBlocksExcept(root: BlockLayer, vararg except: SettingBlockProperty, recursive: Boolean) { + val exceptBlocks = except.map { it.settingBlock.layer } + fun processBlock(blockLayer: BlockLayer) { + val unProtected = blockLayer !in exceptBlocks + if (unProtected) blockLayer.settingLayers.forEach(::hide) + if (unProtected || !recursive) blockLayer.layers.forEach(::processBlock) + } + processBlock(root) + } + private typealias Property = KProperty0 private typealias SettingProperty = KProperty0 private typealias SettingBlockProperty = KProperty0 diff --git a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt index d7f6f8113..5a615003d 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt @@ -103,7 +103,7 @@ object PacketMine : Module( init { setDefaultAutomationConfig() .withEdits { - hideAllBlocksExcept(::buildConfig, ::breakConfig, breakConfig::outlineConfig, ::rotationConfig, ::hotbarConfig) + hideAllBlocksExcept(::buildConfig, ::breakConfig, ::rotationConfig, ::hotbarConfig) buildConfig.apply { hide( ::pathing, From c3f454d22ce37584c6f0d9434d462ab22b0f37cb Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Thu, 21 May 2026 16:06:31 +0100 Subject: [PATCH 26/40] compilation errors --- .../com/lambda/module/modules/player/InventoryResync.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/module/modules/player/InventoryResync.kt b/src/main/kotlin/com/lambda/module/modules/player/InventoryResync.kt index 8860fe5b3..075503c33 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/InventoryResync.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/InventoryResync.kt @@ -28,14 +28,14 @@ import com.lambda.util.TickTimer object InventoryResync : Module( name = "InventoryResync", description = "Resyncs your inventory, with a delay between resyncs", - tag = ModuleTag.PLAYER + tag = ModuleTag.Player, + modulePriority = 10 ) { private val delay by setting("Delay", 100, 0..1000, 5, unit = " ticks") private val timer = TickTimer() init { - setModulePriority(10) listen { timer.tick() if (!timer.hasSurpassed(delay)) return@listen From 0e60ae1e7f040db28923ab15ac5b5c6d8504d555 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Sun, 24 May 2026 02:28:47 +0100 Subject: [PATCH 27/40] jackson move checkpoint --- build.gradle.kts | 6 +- gradle.properties | 1 + src/main/kotlin/com/lambda/Lambda.kt | 31 +- .../kotlin/com/lambda/config/BaseEditor.kt | 2 +- src/main/kotlin/com/lambda/config/Config.kt | 2 - .../com/lambda/config/ConfigCategory.kt | 5 +- src/main/kotlin/com/lambda/config/JsonOps.kt | 409 ++++++++++++++++++ .../lambda/config/{Codec.kt => Serializer.kt} | 20 +- src/main/kotlin/com/lambda/config/Setting.kt | 4 +- .../com/lambda/config/codecs/BindCodec.kt | 43 -- .../com/lambda/config/codecs/BlockCodec.kt | 50 --- .../com/lambda/config/codecs/BlockPosCodec.kt | 53 --- .../com/lambda/config/codecs/ColorCodec.kt | 55 --- .../lambda/config/codecs/GameProfileCodec.kt | 66 --- .../lambda/config/codecs/ItemStackCodec.kt | 52 --- .../com/lambda/config/codecs/KeyCodeCodec.kt | 49 --- .../com/lambda/config/codecs/OptionalCodec.kt | 41 -- .../com/lambda/config/codecs/TextCodec.kt | 50 --- .../com/lambda/config/codecs/UUIDCodec.kt | 61 --- .../config/serializers/BindSerializer.kt | 50 +++ .../config/serializers/BlockSerializer.kt | 49 +++ .../config/serializers/ColorSerializer.kt | 53 +++ .../serializers/ConfigCategorySerializer.kt | 55 +++ .../ItemSerializer.kt} | 38 +- .../config/serializers/ItemStackSerializer.kt | 47 ++ .../config/serializers/KeyCodeSerializer.kt | 43 ++ .../config/serializers/TextSerializer.kt | 45 ++ .../config/serializers/UuidSerializer.kt | 65 +++ .../lambda/config/settings/NumericSetting.kt | 4 +- .../collections/BlockCollectionSetting.kt | 4 +- .../settings/collections/CollectionSetting.kt | 5 +- .../collections/ItemCollectionSetting.kt | 4 +- .../config/settings/complex/KeybindSetting.kt | 5 + src/main/kotlin/com/lambda/module/Module.kt | 1 + .../kotlin/com/lambda/network/LambdaHttp.kt | 1 - 35 files changed, 897 insertions(+), 572 deletions(-) create mode 100644 src/main/kotlin/com/lambda/config/JsonOps.kt rename src/main/kotlin/com/lambda/config/{Codec.kt => Serializer.kt} (59%) delete mode 100644 src/main/kotlin/com/lambda/config/codecs/BindCodec.kt delete mode 100644 src/main/kotlin/com/lambda/config/codecs/BlockCodec.kt delete mode 100644 src/main/kotlin/com/lambda/config/codecs/BlockPosCodec.kt delete mode 100644 src/main/kotlin/com/lambda/config/codecs/ColorCodec.kt delete mode 100644 src/main/kotlin/com/lambda/config/codecs/GameProfileCodec.kt delete mode 100644 src/main/kotlin/com/lambda/config/codecs/ItemStackCodec.kt delete mode 100644 src/main/kotlin/com/lambda/config/codecs/KeyCodeCodec.kt delete mode 100644 src/main/kotlin/com/lambda/config/codecs/OptionalCodec.kt delete mode 100644 src/main/kotlin/com/lambda/config/codecs/TextCodec.kt delete mode 100644 src/main/kotlin/com/lambda/config/codecs/UUIDCodec.kt create mode 100644 src/main/kotlin/com/lambda/config/serializers/BindSerializer.kt create mode 100644 src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt create mode 100644 src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt create mode 100644 src/main/kotlin/com/lambda/config/serializers/ConfigCategorySerializer.kt rename src/main/kotlin/com/lambda/config/{codecs/ItemCodec.kt => serializers/ItemSerializer.kt} (53%) create mode 100644 src/main/kotlin/com/lambda/config/serializers/ItemStackSerializer.kt create mode 100644 src/main/kotlin/com/lambda/config/serializers/KeyCodeSerializer.kt create mode 100644 src/main/kotlin/com/lambda/config/serializers/TextSerializer.kt create mode 100644 src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt diff --git a/build.gradle.kts b/build.gradle.kts index 843669b4c..c2ed3e8bb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -30,6 +30,7 @@ val discordIPCVersion: String by project val classGraphVersion: String by project val kotlinVersion: String by project val ktorVersion: String by project +val jacksonVersion: String by project val mockkVersion: String by project val spairVersion: String by project val lwjglVersion: String by project @@ -80,6 +81,7 @@ repositories { } fabricApi { + @Suppress("UnstableApiUsage") configureTests { modId = "${base.archivesName}-tests" eula = true @@ -173,7 +175,9 @@ dependencies { exclude(group = "org.slf4j") } includeLib("io.ktor:ktor-client-content-negotiation:$ktorVersion") - includeLib("io.ktor:ktor-serialization-gson:$ktorVersion") + includeLib("tools.jackson.core:jackson-core:$jacksonVersion") + includeLib("tools.jackson.core:jackson-databind:$jacksonVersion") + includeLib("tools.jackson.module:jackson-datatype-jdk8:$jacksonVersion") // Add mods modImplementation("com.github.rfresh2:baritone-fabric:$minecraftVersion-SNAPSHOT") diff --git a/gradle.properties b/gradle.properties index 6571d170b..c6e8b2555 100644 --- a/gradle.properties +++ b/gradle.properties @@ -35,6 +35,7 @@ baritoneVersion=1.14.0 discordIPCVersion=6f6b6cce17 classGraphVersion=4.8.184 ktorVersion=3.3.3 +jacksonVersion=3.1.1 mockkVersion=1.14.7 spairVersion=1.90.0 diff --git a/src/main/kotlin/com/lambda/Lambda.kt b/src/main/kotlin/com/lambda/Lambda.kt index 6dcb49f85..974d7bec5 100644 --- a/src/main/kotlin/com/lambda/Lambda.kt +++ b/src/main/kotlin/com/lambda/Lambda.kt @@ -17,9 +17,7 @@ package com.lambda -import com.google.gson.Gson -import com.google.gson.GsonBuilder -import com.lambda.config.Codec +import com.lambda.config.Serializer import com.lambda.core.Loader import com.lambda.event.events.ClientEvent import com.lambda.event.listener.UnsafeListener.Companion.listenOnceUnsafe @@ -31,6 +29,9 @@ import net.fabricmc.loader.api.FabricLoader import net.minecraft.client.MinecraftClient import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger +import tools.jackson.databind.module.SimpleModule +import tools.jackson.module.kotlin.jsonMapper +import tools.jackson.module.kotlin.kotlinModule object Lambda : ClientModInitializer { const val ModName = "Lambda" @@ -49,15 +50,23 @@ object Lambda : ClientModInitializer { val isDebug = System.getProperty("lambda.dev") != null - val gson: Gson = GsonBuilder() - .setPrettyPrinting() - .apply { - getInstances>() - .forEach { codec -> - registerTypeAdapter(codec.type, codec) + /** + * A Jackson [tools.jackson.databind.json.JsonMapper]. + * + * We use Jackson over Gson (unlike Minecraft) as it allows for updating existing objects + * rather than creating new instances when deserializing. + */ + val mapper = jsonMapper { + defaultPrettyPrinter() + addModules( + kotlinModule(), + SimpleModule().apply { + getInstances>().forEach { serializer -> + serializer.register() } - } - .create() + } + ) + } override fun onInitializeClient() {} // nop diff --git a/src/main/kotlin/com/lambda/config/BaseEditor.kt b/src/main/kotlin/com/lambda/config/BaseEditor.kt index 2c487e223..327158361 100644 --- a/src/main/kotlin/com/lambda/config/BaseEditor.kt +++ b/src/main/kotlin/com/lambda/config/BaseEditor.kt @@ -157,8 +157,8 @@ object ConfigEditor { @SettingEditorDsl fun defaultValue(value: T) = settings.forEach { - it.core.defaultValue = value it.value = value + it.core.defaultValue = it.value } } diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index fc4ae6daa..87fa083fb 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -223,8 +223,6 @@ abstract class Config( } catch (e: Throwable) { logError("Failed to deserialize setting '${single.setting.name}' from fallback in '$name'", e) } - } else { - logError("No saved value for setting '${single.setting.name}' in '$name'") } } } diff --git a/src/main/kotlin/com/lambda/config/ConfigCategory.kt b/src/main/kotlin/com/lambda/config/ConfigCategory.kt index 930605984..49a01a764 100644 --- a/src/main/kotlin/com/lambda/config/ConfigCategory.kt +++ b/src/main/kotlin/com/lambda/config/ConfigCategory.kt @@ -23,7 +23,6 @@ import com.google.gson.JsonObject import com.google.gson.JsonParser import com.google.gson.JsonSyntaxException import com.lambda.Lambda.Log -import com.lambda.Lambda.gson import com.lambda.config.ConfigLoader.configByName import com.lambda.config.ConfigLoader.configCategories import com.lambda.config.categories.ModuleCategory @@ -95,7 +94,9 @@ abstract class ConfigCategory : Jsonable, Loadable { ) } configs.forEach { - add(it.name, it.toJson()) + val json = it.toJson() + if (json.isEmpty) return@forEach + add(it.name, json) } } diff --git a/src/main/kotlin/com/lambda/config/JsonOps.kt b/src/main/kotlin/com/lambda/config/JsonOps.kt new file mode 100644 index 000000000..7bc235118 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/JsonOps.kt @@ -0,0 +1,409 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config + +import com.mojang.datafixers.util.Pair +import com.mojang.serialization.DataResult +import com.mojang.serialization.DynamicOps +import com.mojang.serialization.Lifecycle +import com.mojang.serialization.ListBuilder +import com.mojang.serialization.MapLike +import com.mojang.serialization.RecordBuilder +import tools.jackson.databind.JsonNode +import tools.jackson.databind.node.ArrayNode +import tools.jackson.databind.node.JsonNodeFactory +import tools.jackson.databind.node.NullNode +import tools.jackson.databind.node.ObjectNode +import java.math.BigDecimal +import java.math.BigInteger +import java.util.* +import java.util.function.BiConsumer +import java.util.function.Consumer +import java.util.function.UnaryOperator +import java.util.stream.Stream +import java.util.stream.StreamSupport + +/** + * A translation of Minecraft's [com.mojang.serialization.JsonOps], built to use Jackson instead of Gson + */ +class JsonOps private constructor(private val compressed: Boolean) : DynamicOps { + @Suppress("unused") + companion object { + val Uncompressed = JsonOps(false) + val Compressed = JsonOps(true) + } + + override fun empty(): JsonNode = NullNode.getInstance() + + override fun emptyMap(): JsonNode = JsonNodeFactory.instance.objectNode() + + override fun emptyList(): JsonNode = JsonNodeFactory.instance.arrayNode() + + override fun convertTo(outOps: DynamicOps, input: JsonNode): U { + return when { + input.isObject -> convertMap(outOps, input) + input.isArray -> convertList(outOps, input) + input.isNull -> outOps.empty() + input.isString -> outOps.createString(input.stringValue()) + input.isBoolean -> outOps.createBoolean(input.booleanValue()) + input.isNumber -> { + when (val number = input.numberValue()) { + is Byte -> outOps.createByte(number) + is Short -> outOps.createShort(number) + is Int -> { + val asByte = number.toByte() + if (asByte.toInt() == number) outOps.createByte(asByte) + else { + val asShort = number.toShort() + if (asShort.toInt() == number) outOps.createShort(asShort) + else outOps.createInt(number) + } + } + is Long -> { + val asByte = number.toByte() + if (asByte.toLong() == number) outOps.createByte(asByte) + else { + val asShort = number.toShort() + if (asShort.toLong() == number) outOps.createShort(asShort) + else { + val asInt = number.toInt() + if (asInt.toLong() == number) outOps.createInt(asInt) + else outOps.createLong(number) + } + } + } + is Float -> outOps.createFloat(number) + is Double -> outOps.createDouble(number) + else -> { + val big = number as? BigDecimal ?: BigDecimal(number.toString()) + try { + when (val l = big.longValueExact()) { + l.toByte().toLong() -> outOps.createByte(l.toByte()) + l.toShort().toLong() -> outOps.createShort(l.toShort()) + l.toInt().toLong() -> outOps.createInt(l.toInt()) + else -> outOps.createLong(l) + } + } catch (_: ArithmeticException) { + val d = big.toDouble() + if (d.toFloat().toDouble() == d) outOps.createFloat(d.toFloat()) + else outOps.createDouble(d) + } + } + } + } + else -> throw IllegalArgumentException("Unknown JSON node type: $input") + } + } + + override fun getNumberValue(input: JsonNode): DataResult = + when { + input.isNumber -> DataResult.success(input.numberValue()) + compressed && input.isString -> { + try { + DataResult.success(Integer.parseInt(input.stringValue())) + } catch (e: NumberFormatException) { + DataResult.error { "Not a number: $e $input" } + } + } + else -> DataResult.error { "Not a number: $input" } + } + + override fun createNumeric(i: Number): JsonNode = + when (i) { + is Byte -> JsonNodeFactory.instance.numberNode(i) + is Short -> JsonNodeFactory.instance.numberNode(i) + is Int -> JsonNodeFactory.instance.numberNode(i) + is Long -> JsonNodeFactory.instance.numberNode(i) + is BigInteger -> JsonNodeFactory.instance.numberNode(i) + is Float -> JsonNodeFactory.instance.numberNode(i) + is Double -> JsonNodeFactory.instance.numberNode(i) + is BigDecimal -> JsonNodeFactory.instance.numberNode(i) + else -> throw IllegalStateException("Unknown number type: $i") + } + + override fun getBooleanValue(input: JsonNode): DataResult = + if (input.isBoolean) DataResult.success(input.booleanValue()) + else DataResult.error { "Not a boolean: $input" } + + override fun createBoolean(value: Boolean): JsonNode = JsonNodeFactory.instance.booleanNode(value) + + override fun getStringValue(input: JsonNode): DataResult = + when { + input.isString -> DataResult.success(input.stringValue()) + compressed && input.isNumber -> DataResult.success(input.asString()) + else -> DataResult.error { "Not a string: $input" } + } + + override fun createString(value: String): JsonNode = JsonNodeFactory.instance.stringNode(value) + + override fun mergeToList(list: JsonNode, value: JsonNode): DataResult { + if (!list.isArray && list != empty()) { + return DataResult.error({ "mergeToList called with not a list: $list" }, list) + } + + val result = JsonNodeFactory.instance.arrayNode() + if (list != empty()) { + result.addAll(list as ArrayNode) + } + result.add(value) + return DataResult.success(result) + } + + override fun mergeToList(list: JsonNode, values: List): DataResult { + if (!list.isArray && list != empty()) { + return DataResult.error({ "mergeToList called with not a list: $list" }, list) + } + + if (values.isEmpty()) { + return if (list == empty()) DataResult.success(emptyList()) + else DataResult.success(list) + } + + val result = JsonNodeFactory.instance.arrayNode() + if (list != empty()) { + result.addAll(list as ArrayNode) + } + values.forEach(result::add) + return DataResult.success(result) + } + + override fun mergeToMap(map: JsonNode, key: JsonNode, value: JsonNode): DataResult { + if (!map.isObject && map != empty()) { + return DataResult.error({ "mergeToMap called with not a map: $map" }, map) + } + if (!key.isString && !compressed) { + return DataResult.error({ "key is not a string: $key" }, map) + } + + val output = JsonNodeFactory.instance.objectNode() + if (map != empty()) { + output.setAll(map as ObjectNode) + } + val keyStr = if (key.isString) key.stringValue() else key.asString() + output.set(keyStr, value) + + return DataResult.success(output) + } + + override fun mergeToMap(map: JsonNode, values: MapLike): DataResult { + if (!map.isObject && map != empty()) { + return DataResult.error({ "mergeToMap called with not a map: $map" }, map) + } + + val valuesIterator = values.entries().iterator() + if (!valuesIterator.hasNext()) { + return if (map == empty()) DataResult.success(emptyMap()) + else DataResult.success(map) + } + + val output = JsonNodeFactory.instance.objectNode() + if (map != empty()) { + output.setAll(map as ObjectNode) + } + + val missed = mutableListOf() + + valuesIterator.forEachRemaining { (key, value) -> + if (!key.isString && !compressed) { + missed.add(key) + return@forEachRemaining + } + val keyStr = if (key.isString) key.stringValue() else key.asString() + output.set(keyStr, value) + } + + if (missed.isNotEmpty()) { + return DataResult.error({ "some keys are not strings: $missed" }, output) + } + + return DataResult.success(output) + } + + override fun getMapValues(input: JsonNode): DataResult>> { + if (!input.isObject) { + return DataResult.error { "Not a JSON object: $input" } + } + val obj = input as ObjectNode + return DataResult.success(obj.propertyStream().map { (key, value) -> + Pair(createString(key), if (value.isNull) null else value) + }) + } + + override fun getMapEntries(input: JsonNode): DataResult>> { + return if (!input.isObject) { + DataResult.error { "Not a JSON object: $input" } + } else DataResult.success(Consumer { c -> + val obj = input as ObjectNode + obj.propertyStream().map { (key, value) -> + if (!value.isNull) c.accept(createString(key), value) + } + }) + } + + override fun getMap(input: JsonNode): DataResult> { + if (!input.isObject) { + return DataResult.error { "Not a JSON object: $input" } + } + val obj = input as ObjectNode + return DataResult.success(object : MapLike { + override fun get(key: JsonNode): JsonNode? { + if (!key.isString) return null + val element = obj.get(key.stringValue()) + return if (element != null && element.isNull) null else element + } + + override fun get(key: String): JsonNode? { + val element = obj.get(key) + return if (element != null && element.isNull) null else element + } + + override fun entries(): Stream> { + return obj.propertyStream().map { (key, value) -> + Pair(createString(key), value) + } + } + + override fun toString(): String = "MapLike[$obj]" + }) + } + + override fun createMap(map: Stream>): JsonNode { + val result = JsonNodeFactory.instance.objectNode() + map.forEach { (key, value) -> + if (!key.isString) throw IllegalArgumentException("Key is not a string: $key") + result.set(key.stringValue(), value) + } + return result + } + + override fun getStream(input: JsonNode): DataResult> { + return if (input.isArray) { + val array = input as ArrayNode + DataResult.success(StreamSupport.stream(array.spliterator(), false) + .map { if (it.isNull) null else it }) + } else DataResult.error { "Not a json array: $input" } + } + + override fun getList(input: JsonNode): DataResult>> { + if (input.isArray) { + val array = input as ArrayNode + return DataResult.success(Consumer { c -> + array.forEach { element -> + if (!element.isNull) c.accept(element) + } + }) + } + return DataResult.error { "Not a json array: $input" } + } + + override fun createList(input: Stream): JsonNode { + val result = JsonNodeFactory.instance.arrayNode() + input.forEach(result::add) + return result + } + + override fun remove(input: JsonNode, key: String): JsonNode { + if (input.isObject) { + val result = JsonNodeFactory.instance.objectNode() + val obj = input as ObjectNode + obj.propertyStream().forEach { (k, v) -> + if (!Objects.equals(k, key)) { + result.set(k, v) + } + } + return result + } + return input + } + + override fun toString(): String = "JSON" + + override fun listBuilder(): ListBuilder = ArrayBuilder() + + private inner class ArrayBuilder : ListBuilder { + private var builder: DataResult = DataResult.success(JsonNodeFactory.instance.arrayNode(), Lifecycle.stable()) + + override fun ops(): DynamicOps = this@JsonOps + + override fun add(value: JsonNode): ListBuilder = + apply { + builder = builder.map { b -> + b.add(value) + b + } + } + + override fun add(value: DataResult): ListBuilder = + apply { + builder = builder.apply2stable({ b, element -> + b.add(element) + b + }, value) + } + + override fun withErrorsFrom(result: DataResult<*>): ListBuilder = + apply { builder = builder.flatMap { r -> result.map { r } } } + + override fun mapError(onError: UnaryOperator): ListBuilder = + apply { builder = builder.mapError(onError) } + + override fun build(prefix: JsonNode): DataResult { + val result = builder.flatMap { b -> + if (!prefix.isArray && prefix != ops().empty()) { + return@flatMap DataResult.error({ "Cannot append a list to not a list: $prefix" }, prefix) + } + val array = JsonNodeFactory.instance.arrayNode() + if (prefix != ops().empty()) { + array.addAll(prefix as ArrayNode) + } + array.addAll(b) + DataResult.success(array, Lifecycle.stable()) + } + + builder = DataResult.success(JsonNodeFactory.instance.arrayNode(), Lifecycle.stable()) + return result + } + } + + override fun compressMaps(): Boolean = compressed + + override fun mapBuilder(): RecordBuilder = JsonRecordBuilder() + + private inner class JsonRecordBuilder : RecordBuilder.AbstractStringBuilder(this@JsonOps) { + override fun initBuilder(): ObjectNode = JsonNodeFactory.instance.objectNode() + + override fun append(key: String, value: JsonNode, builder: ObjectNode): ObjectNode = + builder.apply { builder.set(key, value) } + + override fun build(builder: ObjectNode, prefix: JsonNode): DataResult { + return when { + prefix.isNull -> DataResult.success(builder) + prefix.isObject -> { + val result = JsonNodeFactory.instance.objectNode() + result.setAll(prefix as ObjectNode) + result.setAll(builder) + DataResult.success(result) + } + else -> DataResult.error({ "mergeToMap called with not a map: $prefix" }, prefix) + } + } + } + + private operator fun Pair.component1(): JsonNode = first + private operator fun Pair.component2(): JsonNode = second +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/Codec.kt b/src/main/kotlin/com/lambda/config/Serializer.kt similarity index 59% rename from src/main/kotlin/com/lambda/config/Codec.kt rename to src/main/kotlin/com/lambda/config/Serializer.kt index 5f0971aaf..254e12ac8 100644 --- a/src/main/kotlin/com/lambda/config/Codec.kt +++ b/src/main/kotlin/com/lambda/config/Serializer.kt @@ -17,12 +17,22 @@ package com.lambda.config -import com.google.gson.JsonDeserializer -import com.google.gson.JsonSerializer -import java.lang.reflect.Type +import com.lambda.Lambda +import tools.jackson.databind.deser.std.StdDeserializer +import tools.jackson.databind.module.SimpleModule +import tools.jackson.databind.ser.std.StdSerializer interface Stringifiable { fun stringify(value: T): String } -interface Codec : JsonSerializer, JsonDeserializer { - val type: Type +abstract class Serializer { + val mapper = Lambda.mapper + abstract val type: Class + abstract val serializer: StdSerializer + abstract val deSerializer: StdDeserializer + + context(simpleModule: SimpleModule) + fun register() { + simpleModule.addSerializer(type, serializer) + simpleModule.addDeserializer(type, deSerializer) + } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/Setting.kt b/src/main/kotlin/com/lambda/config/Setting.kt index 56b062c14..5dc8588a2 100644 --- a/src/main/kotlin/com/lambda/config/Setting.kt +++ b/src/main/kotlin/com/lambda/config/Setting.kt @@ -106,7 +106,7 @@ class Setting, R>( var value by this - val listeners = mutableListOf>() + private val listeners = mutableListOf>() val isModified get() = value != core.defaultValue @@ -291,4 +291,4 @@ abstract class SettingCore( } @DslMarker -internal annotation class SettingDsl \ No newline at end of file +annotation class SettingDsl \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/codecs/BindCodec.kt b/src/main/kotlin/com/lambda/config/codecs/BindCodec.kt deleted file mode 100644 index d6915d913..000000000 --- a/src/main/kotlin/com/lambda/config/codecs/BindCodec.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.codecs - -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import com.google.gson.JsonSerializationContext -import com.lambda.config.Codec -import com.lambda.config.settings.complex.Bind -import java.lang.reflect.Type - -@Suppress("unused") -object BindCodec : Codec { - override val type = Bind::class.java - - override fun serialize(src: Bind, typeOfSrc: Type, context: JsonSerializationContext): JsonElement = - JsonObject().apply { - addProperty("key", src.key) - addProperty("modifiers", src.modifiers) - addProperty("mouse", src.mouse) - } - - override fun deserialize(json: JsonElement, typeOfT: Type, context: JsonDeserializationContext) = - json.asJsonObject.let { obj -> - Bind(obj.get("key").asInt, obj.get("modifiers").asInt, obj.get("mouse").asInt) - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/codecs/BlockCodec.kt b/src/main/kotlin/com/lambda/config/codecs/BlockCodec.kt deleted file mode 100644 index d77877ec4..000000000 --- a/src/main/kotlin/com/lambda/config/codecs/BlockCodec.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.codecs - -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonElement -import com.google.gson.JsonSerializationContext -import com.lambda.config.Codec -import com.lambda.config.Stringifiable -import com.mojang.serialization.JsonOps -import net.minecraft.block.Block -import net.minecraft.registry.Registries -import java.lang.reflect.Type - -object BlockCodec : Codec, Stringifiable { - override val type = Block::class.java - - override fun serialize( - src: Block, - typeOfSrc: Type, - context: JsonSerializationContext, - ): JsonElement = - Registries.BLOCK.codec.encodeStart(JsonOps.INSTANCE, src) - .orThrow - - override fun deserialize( - json: JsonElement?, - typeOfT: Type?, - context: JsonDeserializationContext?, - ): Block = - Registries.BLOCK.codec.parse(JsonOps.INSTANCE, json) - .orThrow - - override fun stringify(value: Block) = Registries.BLOCK.getId(value).path.replaceFirstChar { it.uppercase() } -} diff --git a/src/main/kotlin/com/lambda/config/codecs/BlockPosCodec.kt b/src/main/kotlin/com/lambda/config/codecs/BlockPosCodec.kt deleted file mode 100644 index 0faf37eea..000000000 --- a/src/main/kotlin/com/lambda/config/codecs/BlockPosCodec.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.codecs - -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonElement -import com.google.gson.JsonSerializationContext -import com.lambda.config.Codec -import com.lambda.config.Stringifiable -import com.lambda.util.FormattingUtils.format -import com.mojang.serialization.JsonOps -import net.minecraft.util.math.BlockPos -import java.lang.reflect.Type -import kotlin.jvm.optionals.getOrElse - -@Suppress("unused") -object BlockPosCodec : Codec, Stringifiable { - override val type = BlockPos::class.java - - override fun serialize( - src: BlockPos, - typeOfSrc: Type, - context: JsonSerializationContext, - ): JsonElement = - BlockPos.CODEC.encodeStart(JsonOps.INSTANCE, src) - .orThrow - - override fun deserialize( - json: JsonElement?, - typeOfT: Type?, - context: JsonDeserializationContext?, - ): BlockPos = - BlockPos.CODEC.parse(JsonOps.INSTANCE, json) - .result() - .getOrElse { BlockPos.ORIGIN } - - override fun stringify(value: BlockPos) = value.format() -} diff --git a/src/main/kotlin/com/lambda/config/codecs/ColorCodec.kt b/src/main/kotlin/com/lambda/config/codecs/ColorCodec.kt deleted file mode 100644 index dbe57b1ae..000000000 --- a/src/main/kotlin/com/lambda/config/codecs/ColorCodec.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.codecs - -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonElement -import com.google.gson.JsonParseException -import com.google.gson.JsonPrimitive -import com.google.gson.JsonSerializationContext -import com.lambda.config.Codec -import com.lambda.config.Stringifiable -import java.awt.Color -import java.lang.reflect.Type - -@Suppress("unused") -object ColorCodec : Codec, Stringifiable { - override val type = Color::class.java - - override fun serialize( - src: Color, - typeOfSrc: Type, - context: JsonSerializationContext?, - ): JsonElement = - JsonPrimitive("${src.red},${src.green},${src.blue},${src.alpha}") - - override fun deserialize( - json: JsonElement, - typeOfT: Type, - context: JsonDeserializationContext?, - ): Color = - json.asString.split(",").let { - when (it.size) { - 3 -> Color(it[0].toInt(), it[1].toInt(), it[2].toInt()) - 4 -> Color(it[0].toInt(), it[1].toInt(), it[2].toInt(), it[3].toInt()) - else -> throw JsonParseException("Invalid color format") - } - } - - override fun stringify(value: Color) = "${value.red},${value.green},${value.blue},${value.alpha}" -} diff --git a/src/main/kotlin/com/lambda/config/codecs/GameProfileCodec.kt b/src/main/kotlin/com/lambda/config/codecs/GameProfileCodec.kt deleted file mode 100644 index b8ebfcf00..000000000 --- a/src/main/kotlin/com/lambda/config/codecs/GameProfileCodec.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.codecs - -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import com.google.gson.JsonSerializationContext -import com.lambda.config.Codec -import com.lambda.config.Stringifiable -import com.mojang.authlib.GameProfile -import java.lang.reflect.Type -import java.util.* - -// Yeah yeah I know, there's already a serializer for GameProfile in the Minecraft codebase. -// But who cares, I'm doing it again. -// What you gon' do bout it, huh? -// That's what I thought. -@Suppress("unused") -object GameProfileCodec : Codec, Stringifiable { - override val type = GameProfile::class.java - - override fun serialize( - src: GameProfile, - typeOfSrc: Type?, - context: JsonSerializationContext?, - ): JsonElement = - JsonObject().apply { - addProperty("name", src.name) - addProperty("id", src.id.toString()) - } - - override fun deserialize( - json: JsonElement, - typeOfT: Type?, - context: JsonDeserializationContext?, - ): GameProfile { - val name = json.asJsonObject.get("name").asString - val id = json.asJsonObject.get("id").asString - val parsedId = - if (id.length == 32) id.replaceFirst( - "(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})".toRegex(), - "$1-$2-$3-$4-$5" - ) - else id - - return GameProfile(UUID.fromString(parsedId), name) - } - - override fun stringify(value: GameProfile) = value.toString() -} diff --git a/src/main/kotlin/com/lambda/config/codecs/ItemStackCodec.kt b/src/main/kotlin/com/lambda/config/codecs/ItemStackCodec.kt deleted file mode 100644 index b35d0e19e..000000000 --- a/src/main/kotlin/com/lambda/config/codecs/ItemStackCodec.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.codecs - -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonElement -import com.google.gson.JsonSerializationContext -import com.lambda.config.Codec -import com.lambda.config.Stringifiable -import com.mojang.serialization.JsonOps -import net.minecraft.item.ItemStack -import java.lang.reflect.Type -import kotlin.jvm.optionals.getOrElse - -@Suppress("unused") -object ItemStackCodec : Codec, Stringifiable { - override val type = ItemStack::class.java - - override fun serialize( - stack: ItemStack, - typeOfSrc: Type, - context: JsonSerializationContext - ): JsonElement = - ItemStack.CODEC.encodeStart(JsonOps.INSTANCE, stack) - .orThrow - - override fun deserialize( - json: JsonElement, - typeOfT: Type, - context: JsonDeserializationContext - ): ItemStack = - ItemStack.CODEC.parse(JsonOps.INSTANCE, json) - .result() - .getOrElse { ItemStack.EMPTY } - - override fun stringify(value: ItemStack) = value.itemName.string.uppercase() -} diff --git a/src/main/kotlin/com/lambda/config/codecs/KeyCodeCodec.kt b/src/main/kotlin/com/lambda/config/codecs/KeyCodeCodec.kt deleted file mode 100644 index 4c8292cc2..000000000 --- a/src/main/kotlin/com/lambda/config/codecs/KeyCodeCodec.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.codecs - -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonElement -import com.google.gson.JsonNull -import com.google.gson.JsonParseException -import com.google.gson.JsonPrimitive -import com.google.gson.JsonSerializationContext -import com.lambda.config.Codec -import com.lambda.util.KeyCode -import java.lang.reflect.Type - -@Suppress("unused") -object KeyCodeCodec : Codec { - override val type = KeyCode::class.java - - override fun serialize( - src: KeyCode?, - typeOfSrc: Type?, - context: JsonSerializationContext?, - ): JsonElement = - src?.let { - JsonPrimitive(it.name) - } ?: JsonNull.INSTANCE - - override fun deserialize( - json: JsonElement?, - typeOfT: Type?, - context: JsonDeserializationContext?, - ): KeyCode = - json?.asString?.let(KeyCode::fromKeyName) ?: throw JsonParseException("Invalid key code format") -} diff --git a/src/main/kotlin/com/lambda/config/codecs/OptionalCodec.kt b/src/main/kotlin/com/lambda/config/codecs/OptionalCodec.kt deleted file mode 100644 index 0067d0b31..000000000 --- a/src/main/kotlin/com/lambda/config/codecs/OptionalCodec.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.codecs - -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonElement -import com.google.gson.JsonNull -import com.google.gson.JsonSerializationContext -import com.lambda.config.Codec -import java.lang.reflect.Type -import java.util.* - -@Suppress("unused") -object OptionalCodec : Codec> { - override val type = Optional::class.java - - override fun serialize(src: Optional?, typeOfSrc: Type?, context: JsonSerializationContext?): JsonElement = - src?.map { context?.serialize(it) }?.orElse(JsonNull.INSTANCE) ?: JsonNull.INSTANCE - - override fun deserialize( - json: JsonElement?, - typeOfT: Type?, - context: JsonDeserializationContext?, - ): Optional = - Optional.ofNullable(json?.let { context?.deserialize(it, typeOfT) ?: Optional.empty() }) -} diff --git a/src/main/kotlin/com/lambda/config/codecs/TextCodec.kt b/src/main/kotlin/com/lambda/config/codecs/TextCodec.kt deleted file mode 100644 index ec20eaac2..000000000 --- a/src/main/kotlin/com/lambda/config/codecs/TextCodec.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.codecs - -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonElement -import com.google.gson.JsonSerializationContext -import com.lambda.config.Codec -import com.mojang.serialization.JsonOps -import net.minecraft.text.Text -import net.minecraft.text.TextCodecs -import java.lang.reflect.Type -import kotlin.jvm.optionals.getOrElse - -@Suppress("unused") -object TextCodec : Codec { - override val type = Text::class.java - - override fun serialize( - src: Text, - typeOfSrc: Type, - context: JsonSerializationContext, - ): JsonElement = - TextCodecs.CODEC.encodeStart(JsonOps.INSTANCE, src) - .orThrow - - override fun deserialize( - json: JsonElement?, - typeOfT: Type?, - context: JsonDeserializationContext?, - ): Text = - TextCodecs.CODEC.parse(JsonOps.INSTANCE, json) - .result() - .getOrElse { Text.empty() } -} diff --git a/src/main/kotlin/com/lambda/config/codecs/UUIDCodec.kt b/src/main/kotlin/com/lambda/config/codecs/UUIDCodec.kt deleted file mode 100644 index f7e0f4abd..000000000 --- a/src/main/kotlin/com/lambda/config/codecs/UUIDCodec.kt +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.codecs - -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonElement -import com.google.gson.JsonParseException -import com.google.gson.JsonSerializationContext -import com.lambda.config.Codec -import com.lambda.config.Stringifiable -import java.lang.reflect.Type -import java.util.* - -@Suppress("unused") -object UUIDCodec : Codec, Stringifiable { - override val type = UUID::class.java - - override fun serialize( - src: UUID, - typeOfSrc: Type?, - context: JsonSerializationContext?, - ): JsonElement = context?.serialize(src.toString()) ?: throw JsonParseException("No serialization context") - - override fun deserialize( - json: JsonElement, - typeOfT: Type?, - context: JsonDeserializationContext?, - ): UUID { - val rawId = when { - json.isJsonPrimitive -> json.asString - json.isJsonObject && json.asJsonObject.has("id") -> json.asJsonObject.get("id").asString - else -> throw JsonParseException("Cannot deserialize UUID from: $json") - } - - val parsedId = - if (rawId.length == 32) rawId.replaceFirst( - "(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})".toRegex(), - "$1-$2-$3-$4-$5" - ) - else rawId - - return UUID.fromString(parsedId) - } - - override fun stringify(value: UUID) = value.toString() -} diff --git a/src/main/kotlin/com/lambda/config/serializers/BindSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/BindSerializer.kt new file mode 100644 index 000000000..67bac4684 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/serializers/BindSerializer.kt @@ -0,0 +1,50 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.serializers + +import com.lambda.config.Serializer +import com.lambda.config.settings.complex.Bind +import tools.jackson.core.JsonGenerator +import tools.jackson.core.JsonParser +import tools.jackson.databind.DeserializationContext +import tools.jackson.databind.SerializationContext +import tools.jackson.databind.deser.std.StdDeserializer +import tools.jackson.databind.node.ObjectNode +import tools.jackson.databind.ser.std.StdSerializer + +@Suppress("unused") +object BindSerializer : Serializer() { + override val type = Bind::class.java + + override val serializer = object : StdSerializer(type) { + override fun serialize(value: Bind, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeStartObject() + .writeNumberProperty("key", value.key) + .writeNumberProperty("modifiers", value.modifiers) + .writeNumberProperty("mouse", value.mouse) + .writeEndObject() + } + } + + override val deSerializer = object : StdDeserializer(type) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Bind { + val node = p.readValueAsTree() + return Bind(node.get("key").asInt(), node.get("modifiers").asInt(), node.get("mouse").asInt()) + } + } +} diff --git a/src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt new file mode 100644 index 000000000..7c41df8b3 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt @@ -0,0 +1,49 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.serializers + +import com.lambda.config.JsonOps +import com.lambda.config.Serializer +import com.lambda.config.Stringifiable +import kotlinx.serialization.json.internal.writeJson +import net.minecraft.block.Block +import net.minecraft.registry.Registries +import net.minecraft.util.Identifier +import tools.jackson.core.JsonGenerator +import tools.jackson.core.JsonParser +import tools.jackson.databind.DeserializationContext +import tools.jackson.databind.SerializationContext +import tools.jackson.databind.deser.std.StdDeserializer +import tools.jackson.databind.ser.std.StdSerializer + +object BlockSerializer : Serializer(), Stringifiable { + override val type = Block::class.java + + override val serializer = object : StdSerializer(type) { + override fun serialize(value: Block, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeTree((Registries.BLOCK.codec.encodeStart(JsonOps.Uncompressed, value).orThrow)) + } + } + + override val deSerializer = object : StdDeserializer(type) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext) = + Registries.BLOCK.codec.parse(JsonOps.Uncompressed, p.readValueAsTree()).orThrow + } + + override fun stringify(value: Block) = Registries.BLOCK.getId(value).path.replaceFirstChar { it.uppercase() } +} diff --git a/src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt new file mode 100644 index 000000000..3e4f123c7 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt @@ -0,0 +1,53 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.serializers + +import com.google.gson.JsonParseException +import com.lambda.config.Serializer +import com.lambda.config.Stringifiable +import tools.jackson.core.JsonGenerator +import tools.jackson.core.JsonParser +import tools.jackson.databind.DeserializationContext +import tools.jackson.databind.SerializationContext +import tools.jackson.databind.deser.std.StdDeserializer +import tools.jackson.databind.ser.std.StdSerializer +import java.awt.Color + +@Suppress("unused") +object ColorSerializer : Serializer(), Stringifiable { + override val type = Color::class.java + + override val serializer = object : StdSerializer(type) { + override fun serialize(value: Color, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeString("${value.red},${value.green},${value.blue},${value.alpha}") + } + } + + override val deSerializer = object : StdDeserializer(type) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Color { + val color = p.valueAsString.split(",") + return when (color.size) { + 3 -> Color(color[0].toInt(), color[1].toInt(), color[2].toInt()) + 4 -> Color(color[0].toInt(), color[1].toInt(), color[2].toInt(), color[3].toInt()) + else -> throw JsonParseException("Invalid color format") + } + } + } + + override fun stringify(value: Color) = "${value.red},${value.green},${value.blue},${value.alpha}" +} diff --git a/src/main/kotlin/com/lambda/config/serializers/ConfigCategorySerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ConfigCategorySerializer.kt new file mode 100644 index 000000000..5404566fd --- /dev/null +++ b/src/main/kotlin/com/lambda/config/serializers/ConfigCategorySerializer.kt @@ -0,0 +1,55 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.serializers + +import com.lambda.config.ConfigCategory +import com.lambda.config.Serializer +import tools.jackson.core.JsonGenerator +import tools.jackson.core.JsonParser +import tools.jackson.databind.DeserializationContext +import tools.jackson.databind.SerializationContext +import tools.jackson.databind.deser.std.StdDeserializer +import tools.jackson.databind.node.ObjectNode +import tools.jackson.databind.ser.std.StdSerializer + +object ConfigCategorySerializer : Serializer() { + override val type = ConfigCategory::class.java + + override val serializer = object : StdSerializer(type) { + override fun serialize(value: ConfigCategory, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeStartObject() + value.configs.forEach { config -> + val serialized = mapper.valueToTree(config) + if (serialized.isEmpty) return@forEach + gen.writeName(config.name) + gen.writeTree(serialized) + } + gen.writeEndObject() + } + } + + override val deSerializer = object : StdDeserializer(type) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): ConfigCategory { + throw IllegalStateException("Attempted to initialize a ConfigCategory directly from JSON! All ConfigCategory's should be updated after standard initialization.") + } + + override fun deserialize(jp: JsonParser, ctxt: DeserializationContext, newValue: ConfigCategory): ConfigCategory { + return super.deserialize(jp, ctxt, newValue) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/codecs/ItemCodec.kt b/src/main/kotlin/com/lambda/config/serializers/ItemSerializer.kt similarity index 53% rename from src/main/kotlin/com/lambda/config/codecs/ItemCodec.kt rename to src/main/kotlin/com/lambda/config/serializers/ItemSerializer.kt index b56a5f8d5..c59e02c6c 100644 --- a/src/main/kotlin/com/lambda/config/codecs/ItemCodec.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ItemSerializer.kt @@ -15,34 +15,34 @@ * along with this program. If not, see . */ -package com.lambda.config.codecs +package com.lambda.config.serializers -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonElement -import com.google.gson.JsonPrimitive -import com.google.gson.JsonSerializationContext -import com.lambda.config.Codec +import com.lambda.config.Serializer import com.lambda.config.Stringifiable import net.minecraft.item.Item import net.minecraft.registry.Registries import net.minecraft.util.Identifier -import java.lang.reflect.Type +import tools.jackson.core.JsonGenerator +import tools.jackson.core.JsonParser +import tools.jackson.databind.DeserializationContext +import tools.jackson.databind.SerializationContext +import tools.jackson.databind.deser.std.StdDeserializer +import tools.jackson.databind.ser.std.StdSerializer -object ItemCodec : Codec, Stringifiable { +object ItemSerializer : Serializer(), Stringifiable { override val type = Item::class.java - override fun serialize( - item: Item, - typeOfSrc: Type, - context: JsonSerializationContext - ): JsonElement = JsonPrimitive(item.toString()) + override val serializer = object : StdSerializer(type) { + override fun serialize(value: Item, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeString(value.toString()) + } + } - override fun deserialize( - json: JsonElement, - typeOfT: Type, - context: JsonDeserializationContext - ): Item = - Registries.ITEM.get(Identifier.of(json.asString)) // Watch out!! Errors are silently catched by gson!! + override val deSerializer = object : StdDeserializer(type) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Item { + return Registries.ITEM.get(Identifier.of(p.valueAsString)) + } + } override fun stringify(value: Item) = value.name.string.replaceFirstChar { it.uppercase() } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/ItemStackSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ItemStackSerializer.kt new file mode 100644 index 000000000..f57ddcc9f --- /dev/null +++ b/src/main/kotlin/com/lambda/config/serializers/ItemStackSerializer.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.serializers + +import com.lambda.config.JsonOps +import com.lambda.config.Serializer +import com.lambda.config.Stringifiable +import net.minecraft.item.ItemStack +import tools.jackson.core.JsonGenerator +import tools.jackson.core.JsonParser +import tools.jackson.databind.DeserializationContext +import tools.jackson.databind.SerializationContext +import tools.jackson.databind.deser.std.StdDeserializer +import tools.jackson.databind.ser.std.StdSerializer + +@Suppress("unused") +object ItemStackSerializer : Serializer(), Stringifiable { + override val type = ItemStack::class.java + + override val serializer = object : StdSerializer(type) { + override fun serialize(value: ItemStack, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeTree(ItemStack.CODEC.encodeStart(JsonOps.Uncompressed, value).orThrow) + } + } + + override val deSerializer = object : StdDeserializer(type) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext) = + ItemStack.CODEC.parse(JsonOps.Uncompressed, p.readValueAsTree()).orThrow + } + + override fun stringify(value: ItemStack) = value.itemName.string.uppercase() +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/KeyCodeSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/KeyCodeSerializer.kt new file mode 100644 index 000000000..2fe73fe09 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/serializers/KeyCodeSerializer.kt @@ -0,0 +1,43 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.serializers + +import com.lambda.config.Serializer +import com.lambda.util.KeyCode +import tools.jackson.core.JsonGenerator +import tools.jackson.core.JsonParser +import tools.jackson.databind.DeserializationContext +import tools.jackson.databind.SerializationContext +import tools.jackson.databind.deser.std.StdDeserializer +import tools.jackson.databind.ser.std.StdSerializer + +@Suppress("unused") +object KeyCodeSerializer : Serializer() { + override val type = KeyCode::class.java + + override val serializer = object : StdSerializer(type) { + override fun serialize(value: KeyCode, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeString(value.name) + } + } + + override val deSerializer = object : StdDeserializer(type) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext) = + KeyCode.fromKeyName(p.readValueAs(String::class.java)) + } +} diff --git a/src/main/kotlin/com/lambda/config/serializers/TextSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/TextSerializer.kt new file mode 100644 index 000000000..6fcbb833b --- /dev/null +++ b/src/main/kotlin/com/lambda/config/serializers/TextSerializer.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.serializers + +import com.lambda.config.JsonOps +import com.lambda.config.Serializer +import net.minecraft.text.Text +import net.minecraft.text.TextCodecs +import tools.jackson.core.JsonGenerator +import tools.jackson.core.JsonParser +import tools.jackson.databind.DeserializationContext +import tools.jackson.databind.SerializationContext +import tools.jackson.databind.deser.std.StdDeserializer +import tools.jackson.databind.ser.std.StdSerializer + +@Suppress("unused") +object TextSerializer : Serializer() { + override val type = Text::class.java + + override val serializer = object : StdSerializer(type) { + override fun serialize(value: Text, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeTree(TextCodecs.CODEC.encodeStart(JsonOps.Uncompressed, value).orThrow) + } + } + + override val deSerializer = object : StdDeserializer(type) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext) = + TextCodecs.CODEC.parse(JsonOps.Uncompressed, p.readValueAsTree()).orThrow + } +} diff --git a/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt new file mode 100644 index 000000000..496e938b7 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt @@ -0,0 +1,65 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.serializers + +import com.google.gson.JsonDeserializationContext +import com.google.gson.JsonElement +import com.google.gson.JsonParseException +import com.google.gson.JsonSerializationContext +import com.lambda.config.Serializer +import com.lambda.config.Stringifiable +import tools.jackson.core.JsonGenerator +import tools.jackson.core.JsonParser +import tools.jackson.databind.DeserializationContext +import tools.jackson.databind.JsonNode +import tools.jackson.databind.SerializationContext +import tools.jackson.databind.deser.std.StdDeserializer +import tools.jackson.databind.ser.std.StdSerializer +import java.lang.reflect.Type +import java.util.* + +@Suppress("unused") +object UuidSerializer : Serializer(), Stringifiable { + override val type = UUID::class.java + + override val serializer = object : StdSerializer(type) { + override fun serialize(value: UUID, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeString(value.toString()) + } + } + + override val deSerializer = object : StdDeserializer(type) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): UUID { + val jsonNode = p.readValueAsTree() + + val rawId = when { + jsonNode.isString -> jsonNode.stringValue() + jsonNode.isObject && jsonNode.has("id") -> jsonNode.get("id").textValue() + else -> throw IllegalStateException("Cannot deserialize UUID from: $jsonNode") + } + + val parsedId = if (rawId.length == 32) + rawId.replace(Regex("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})"), "$1-$2-$3-$4-$5") + else rawId + + return UUID.fromString(parsedId) + } + } + + override fun stringify(value: UUID) = value.toString() +} diff --git a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt index b095cb288..7c858cb67 100644 --- a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt @@ -95,21 +95,19 @@ abstract class NumericSetting( } } + @Suppress("unchecked_cast", "unused") companion object { @SettingEditorDsl - @Suppress("unchecked_cast") fun ConfigEditor.TypedEditBuilder.range(range: ClosedRange) where T : Number, T : Comparable { (settings as Collection>).forEach { it.range = range } } @SettingEditorDsl - @Suppress("unchecked_cast") fun ConfigEditor.TypedEditBuilder.step(step: T) where T : Number, T : Comparable { (settings as Collection>).forEach { it.step = step } } @SettingEditorDsl - @Suppress("unchecked_cast") fun ConfigEditor.TypedEditBuilder.unit(unit: String) where T : Number, T : Comparable { (settings as Collection>).forEach { it.unit = unit} } diff --git a/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt index 971351e00..c22576a2e 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt @@ -19,7 +19,7 @@ package com.lambda.config.settings.collections import com.google.gson.reflect.TypeToken import com.lambda.config.Setting -import com.lambda.config.codecs.BlockCodec +import com.lambda.config.serializers.BlockSerializer import com.lambda.gui.dsl.ImGuiBuilder import net.minecraft.block.Block @@ -33,5 +33,5 @@ class BlockCollectionSetting( serialize = true, ) { context(_: Setting<*, MutableCollection>) - override fun ImGuiBuilder.buildLayout() = buildDualPane("block") { BlockCodec.stringify(it) } + override fun ImGuiBuilder.buildLayout() = buildDualPane("block") { BlockSerializer.stringify(it) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt index b5d5cca92..4e9dea970 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt @@ -23,6 +23,7 @@ import com.lambda.Lambda.gson import com.lambda.config.ConfigEditor import com.lambda.config.Setting import com.lambda.config.SettingCore +import com.lambda.config.SettingDsl import com.lambda.config.SettingEditorDsl import com.lambda.context.SafeContext import com.lambda.gui.dsl.ImGuiBuilder @@ -182,16 +183,18 @@ open class CollectionSetting( @Suppress("unused") companion object { + @SettingDsl fun , R : Any> Setting>.onSelect(block: SafeContext.(R) -> Unit) = apply { core.selectListeners.add(block) } + @SettingDsl fun , R : Any> Setting>.onDeselect(block: SafeContext.(R) -> Unit) = apply { core.deselectListeners.add(block) } + @Suppress("unchecked_cast") @SettingEditorDsl - @Suppress("unchecked_cast") fun ConfigEditor.TypedEditBuilder>.immutableCollection(collection: Collection) { (settings as Collection>).forEach { it.immutableCollection = collection } } diff --git a/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt index 1888547ea..45980b614 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt @@ -19,7 +19,7 @@ package com.lambda.config.settings.collections import com.google.gson.reflect.TypeToken import com.lambda.config.Setting -import com.lambda.config.codecs.ItemCodec +import com.lambda.config.serializers.ItemSerializer import com.lambda.gui.dsl.ImGuiBuilder import net.minecraft.item.Item @@ -33,5 +33,5 @@ class ItemCollectionSetting( serialize = true, ) { context(_: Setting<*, MutableCollection>) - override fun ImGuiBuilder.buildLayout() = buildDualPane("item") { ItemCodec.stringify(it) } + override fun ImGuiBuilder.buildLayout() = buildDualPane("item") { ItemSerializer.stringify(it) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt index 9f7bb34e9..02ca071af 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt @@ -17,6 +17,7 @@ package com.lambda.config.settings.complex +import com.fasterxml.jackson.annotation.JsonIgnore import com.google.gson.reflect.TypeToken import com.lambda.brigadier.CommandResult.Companion.failure import com.lambda.brigadier.CommandResult.Companion.success @@ -28,6 +29,7 @@ import com.lambda.brigadier.optional import com.lambda.brigadier.required import com.lambda.config.Setting import com.lambda.config.SettingCore +import com.lambda.config.SettingDsl import com.lambda.context.SafeContext import com.lambda.event.Muteable import com.lambda.event.events.ButtonEvent @@ -197,14 +199,17 @@ class KeybindSetting( @Suppress("unused") companion object { + @SettingDsl fun Setting.onPress(block: SafeContext.(ButtonEvent) -> Unit) = apply { core.pressListeners.add(block) } + @SettingDsl fun Setting.onRepeat(block: SafeContext.(ButtonEvent) -> Unit) = apply { core.repeatListeners.add(block) } + @SettingDsl fun Setting.onRelease(block: SafeContext.(ButtonEvent) -> Unit) = apply { core.releaseListeners.add(block) } diff --git a/src/main/kotlin/com/lambda/module/Module.kt b/src/main/kotlin/com/lambda/module/Module.kt index a87c405e2..bb7ee3d2f 100644 --- a/src/main/kotlin/com/lambda/module/Module.kt +++ b/src/main/kotlin/com/lambda/module/Module.kt @@ -147,6 +147,7 @@ abstract class Module( val drawSetting = setting("Draw", true, "Draws the module in the module list hud element") { false } var isEnabled by isEnabledSetting + private set val isDisabled get() = !isEnabled val keybind by keybindSetting diff --git a/src/main/kotlin/com/lambda/network/LambdaHttp.kt b/src/main/kotlin/com/lambda/network/LambdaHttp.kt index 3805f11d2..fb1f780cf 100644 --- a/src/main/kotlin/com/lambda/network/LambdaHttp.kt +++ b/src/main/kotlin/com/lambda/network/LambdaHttp.kt @@ -23,7 +23,6 @@ import io.ktor.client.plugins.contentnegotiation.* import io.ktor.client.request.* import io.ktor.client.statement.* import io.ktor.http.* -import io.ktor.serialization.gson.* import java.io.File import java.io.OutputStream From 5e7a3df2d34e0eea125c1c4bc01df4e09b1a5403 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Sun, 24 May 2026 18:25:17 +0100 Subject: [PATCH 28/40] merge issues and kotlin module in gradle --- build.gradle.kts | 2 +- .../config/serializers/BlockSerializer.kt | 2 -- .../config/serializers/UuidSerializer.kt | 7 +--- .../config/settings/complex/KeybindSetting.kt | 1 - .../graphics/mc/renderer/ChunkedRenderer.kt | 3 -- .../graphics/mc/renderer/ImmediateRenderer.kt | 2 -- .../graphics/mc/renderer/TickedRenderer.kt | 2 -- .../module/modules/movement/ElytraFly.kt | 2 +- .../lambda/module/modules/render/Search.kt | 33 +++++++++---------- .../lambda/module/modules/render/Tracers.kt | 1 - src/main/resources/lambda.mixins.json | 2 +- 11 files changed, 19 insertions(+), 38 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index c2ed3e8bb..002bf838c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -177,7 +177,7 @@ dependencies { includeLib("io.ktor:ktor-client-content-negotiation:$ktorVersion") includeLib("tools.jackson.core:jackson-core:$jacksonVersion") includeLib("tools.jackson.core:jackson-databind:$jacksonVersion") - includeLib("tools.jackson.module:jackson-datatype-jdk8:$jacksonVersion") + includeLib("tools.jackson.module:jackson-module-kotlin:$jacksonVersion") // Add mods modImplementation("com.github.rfresh2:baritone-fabric:$minecraftVersion-SNAPSHOT") diff --git a/src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt index 7c41df8b3..fa5bde89b 100644 --- a/src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt @@ -20,10 +20,8 @@ package com.lambda.config.serializers import com.lambda.config.JsonOps import com.lambda.config.Serializer import com.lambda.config.Stringifiable -import kotlinx.serialization.json.internal.writeJson import net.minecraft.block.Block import net.minecraft.registry.Registries -import net.minecraft.util.Identifier import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext diff --git a/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt index 496e938b7..b12b68627 100644 --- a/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt @@ -17,10 +17,6 @@ package com.lambda.config.serializers -import com.google.gson.JsonDeserializationContext -import com.google.gson.JsonElement -import com.google.gson.JsonParseException -import com.google.gson.JsonSerializationContext import com.lambda.config.Serializer import com.lambda.config.Stringifiable import tools.jackson.core.JsonGenerator @@ -30,7 +26,6 @@ import tools.jackson.databind.JsonNode import tools.jackson.databind.SerializationContext import tools.jackson.databind.deser.std.StdDeserializer import tools.jackson.databind.ser.std.StdSerializer -import java.lang.reflect.Type import java.util.* @Suppress("unused") @@ -49,7 +44,7 @@ object UuidSerializer : Serializer(), Stringifiable { val rawId = when { jsonNode.isString -> jsonNode.stringValue() - jsonNode.isObject && jsonNode.has("id") -> jsonNode.get("id").textValue() + jsonNode.isObject && jsonNode.has("id") -> jsonNode.get("id").stringValue() else -> throw IllegalStateException("Cannot deserialize UUID from: $jsonNode") } diff --git a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt index 02ca071af..e54f2e2d9 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings.complex -import com.fasterxml.jackson.annotation.JsonIgnore import com.google.gson.reflect.TypeToken import com.lambda.brigadier.CommandResult.Companion.failure import com.lambda.brigadier.CommandResult.Companion.success diff --git a/src/main/kotlin/com/lambda/graphics/mc/renderer/ChunkedRenderer.kt b/src/main/kotlin/com/lambda/graphics/mc/renderer/ChunkedRenderer.kt index e8347ed73..d168984d9 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/renderer/ChunkedRenderer.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/renderer/ChunkedRenderer.kt @@ -22,8 +22,6 @@ import com.lambda.context.SafeContext import com.lambda.event.events.RenderEvent import com.lambda.event.events.TickEvent import com.lambda.event.events.WorldEvent -import com.lambda.event.listener.SafeListener.Companion.listen -import com.lambda.event.listener.SafeListener.Companion.listenConcurrently import com.lambda.event.listener.UnsafeListener.Companion.listenConcurrentlyUnsafe import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.graphics.RenderMain @@ -36,7 +34,6 @@ import com.lambda.util.world.FastVector import com.lambda.util.world.fastVectorOf import com.mojang.blaze3d.buffers.GpuBufferSlice import com.mojang.blaze3d.systems.RenderSystem -import net.minecraft.client.world.ClientWorld import net.minecraft.util.math.Vec3d import net.minecraft.world.chunk.WorldChunk import org.joml.Vector3f diff --git a/src/main/kotlin/com/lambda/graphics/mc/renderer/ImmediateRenderer.kt b/src/main/kotlin/com/lambda/graphics/mc/renderer/ImmediateRenderer.kt index fed55bd71..ab45fcf90 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/renderer/ImmediateRenderer.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/renderer/ImmediateRenderer.kt @@ -18,9 +18,7 @@ package com.lambda.graphics.mc.renderer import com.lambda.Lambda.mc -import com.lambda.context.SafeContext import com.lambda.event.events.RenderEvent -import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.graphics.RenderMain import com.lambda.graphics.mc.RegionRenderer diff --git a/src/main/kotlin/com/lambda/graphics/mc/renderer/TickedRenderer.kt b/src/main/kotlin/com/lambda/graphics/mc/renderer/TickedRenderer.kt index 8eeb6d47b..cd0734dc6 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/renderer/TickedRenderer.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/renderer/TickedRenderer.kt @@ -18,10 +18,8 @@ package com.lambda.graphics.mc.renderer import com.lambda.Lambda.mc -import com.lambda.context.SafeContext import com.lambda.event.events.RenderEvent import com.lambda.event.events.TickEvent -import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.graphics.RenderMain import com.lambda.graphics.mc.RegionRenderer diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt index 877c7b2e0..af3e98b20 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt @@ -82,7 +82,7 @@ object ElytraFly : Module( private val takeoff by setting("Takeoff", true, "Automatically jumps and initiates gliding") { mode == FlyMode.Bounce } private val autoPitch by setting("Auto Pitch", true, "Automatically pitches the players rotation down to bounce at faster speeds") { mode == FlyMode.Bounce } - private val pitch by setting("Pitch", 80, 0..90, 1) { mode == FlyMode.Bounce && autoPitch } + private val pitch by setting("Pitch", 80.0, 0.0..90.0, 0.000001) { mode == FlyMode.Bounce && autoPitch } private val jump by setting("Jump", true, "Automatically jumps") { mode == FlyMode.Bounce } private val flagPause by setting("Flag Pause", 5, 0..100, 1, "How long to pause if the server flags you for a movement check", "ticks") { mode == FlyMode.Bounce } diff --git a/src/main/kotlin/com/lambda/module/modules/render/Search.kt b/src/main/kotlin/com/lambda/module/modules/render/Search.kt index 972de03d6..51fc4fa90 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Search.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Search.kt @@ -18,9 +18,6 @@ package com.lambda.module.modules.render import com.lambda.Lambda.mc -import com.lambda.config.applyEdits -import com.lambda.config.groups.ScreenLineSettings -import com.lambda.config.groups.WorldLineSettings import com.lambda.config.ConfigEditor.editTyped import com.lambda.config.ConfigEditor.forEachSetting import com.lambda.config.ConfigEditor.hide @@ -32,7 +29,6 @@ import com.lambda.config.settings.collections.CollectionSetting.Companion.onSele import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.event.events.WorldEvent -import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.graphics.mc.RenderBuilder import com.lambda.graphics.mc.renderer.ChunkedRenderer.Companion.chunkedRenderer @@ -42,7 +38,6 @@ import com.lambda.graphics.util.DirectionMask import com.lambda.graphics.util.DirectionMask.buildSideMesh import com.lambda.graphics.util.DynamicAABB.Companion.interpolatedBox import com.lambda.module.Module -import com.lambda.module.modules.render.Search.chunkedRenderer import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe import com.lambda.util.EntityUtils.decorationEntityMap @@ -153,19 +148,21 @@ object Search : Module( } init { - immediateRenderer("Search Immediate Renderer") { safeContext -> - safeContext.world.entities.forEach { entity -> - if (entity.entityGroup.nameToDisplayNameMap[entity::class.simpleName] in entities) { - val entityColor = getEntityColor(entity) - box( - listOf(entity.interpolatedBox), - DirectionMask.None, - if (useNaturalColor) entityColor.setAlpha(naturalColorAlpha) else entityFillColor, - if (useNaturalColor) entityColor else entityOutlineColor - ) - if (tracers) tracer(Pair(entity.interpolatedBox.center, getTracerColors(entityColor))) - } - } + immediateRenderer("Search Immediate Renderer") { + runSafe { + world.entities.forEach { entity -> + if (entity.entityGroup.nameToDisplayNameMap[entity::class.simpleName] in entities) { + val entityColor = getEntityColor(entity) + box( + listOf(entity.interpolatedBox), + DirectionMask.None, + if (useNaturalColor) entityColor.setAlpha(naturalColorAlpha) else entityFillColor, + if (useNaturalColor) entityColor else entityOutlineColor + ) + if (tracers) tracer(Pair(entity.interpolatedBox.center, getTracerColors(entityColor))) + } + } + } if (tracers) tracerBlockPositions.values.forEach { tracer(it) } } diff --git a/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt b/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt index 0e2ec7e08..300d4be98 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt @@ -30,7 +30,6 @@ import com.lambda.graphics.mc.renderer.RendererUtils.worldToScreenNormalized import com.lambda.module.Module import com.lambda.module.tag.ModuleTag import com.lambda.threading.runSafe -import com.lambda.util.NamedEnum import com.lambda.util.extension.prevPos import com.lambda.util.extension.tickDelta import com.lambda.util.math.lerp diff --git a/src/main/resources/lambda.mixins.json b/src/main/resources/lambda.mixins.json index 33829e0d4..35bd9479b 100644 --- a/src/main/resources/lambda.mixins.json +++ b/src/main/resources/lambda.mixins.json @@ -29,6 +29,7 @@ "network.HandshakeC2SPacketMixin", "network.LoginHelloC2SPacketMixin", "network.LoginKeyC2SPacketMixin", + "render.AbstractBlockRenderContextMixin", "render.AbstractTerrainRenderContextMixin", "render.ArmorFeatureRendererMixin", "render.BlockEntityRendererMixin", @@ -63,7 +64,6 @@ "render.RenderLayersMixin", "render.ScreenHandlerMixin", "render.ScreenMixin", - "render.AbstractBlockRenderContextMixin", "render.SodiumBlockRendererMixin", "render.SodiumFluidRendererImplMixin", "render.SodiumLightDataAccessMixin", From 33221ad2e983dd27368954d4dff8c2615dd75f42 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Sun, 24 May 2026 23:20:05 +0100 Subject: [PATCH 29/40] merge issues --- .../kotlin/com/lambda/graphics/mc/renderer/ChunkedRenderer.kt | 1 + src/main/kotlin/com/lambda/module/modules/render/Search.kt | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/kotlin/com/lambda/graphics/mc/renderer/ChunkedRenderer.kt b/src/main/kotlin/com/lambda/graphics/mc/renderer/ChunkedRenderer.kt index 488070d31..d7aebfca2 100644 --- a/src/main/kotlin/com/lambda/graphics/mc/renderer/ChunkedRenderer.kt +++ b/src/main/kotlin/com/lambda/graphics/mc/renderer/ChunkedRenderer.kt @@ -27,6 +27,7 @@ import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.graphics.RenderMain import com.lambda.graphics.mc.RegionRenderer import com.lambda.graphics.mc.RenderBuilder +import com.lambda.graphics.mc.RenderDsl import com.lambda.module.Module import com.lambda.module.modules.client.Client import com.lambda.util.world.FastVector diff --git a/src/main/kotlin/com/lambda/module/modules/render/Search.kt b/src/main/kotlin/com/lambda/module/modules/render/Search.kt index 366e6101d..d71a84056 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Search.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Search.kt @@ -27,8 +27,6 @@ import com.lambda.config.settings.collections.CollectionSetting.Companion.onDese import com.lambda.config.settings.collections.CollectionSetting.Companion.onSelect import com.lambda.config.withEdits import com.lambda.context.SafeContext -import com.lambda.event.events.WorldEvent -import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe import com.lambda.graphics.mc.RenderBuilder import com.lambda.graphics.mc.renderer.ChunkedRenderer.Companion.chunkedRenderer import com.lambda.graphics.mc.renderer.ImmediateRenderer.Companion.immediateRenderer From 3f9a8abcde05830e04007847f8601a6d26138d0c Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Tue, 26 May 2026 01:50:24 +0100 Subject: [PATCH 30/40] jackson config serializers --- src/main/kotlin/com/lambda/config/Config.kt | 25 ++--- .../kotlin/com/lambda/config/Serializer.kt | 2 + .../config/serializers/BindSerializer.kt | 50 --------- .../config/serializers/BlockSerializer.kt | 4 +- .../config/serializers/ColorSerializer.kt | 4 +- .../serializers/ConfigCategorySerializer.kt | 102 ++++++++++++++++-- .../config/serializers/ItemSerializer.kt | 4 +- .../config/serializers/ItemStackSerializer.kt | 4 +- .../config/serializers/KeyCodeSerializer.kt | 4 +- .../config/serializers/TextSerializer.kt | 4 +- .../config/serializers/UuidSerializer.kt | 4 +- .../config/settings/complex/KeybindSetting.kt | 14 +-- .../kotlin/com/lambda/module/HudModule.kt | 2 +- src/main/kotlin/com/lambda/module/Module.kt | 2 +- .../lambda/module/modules/combat/AutoArmor.kt | 2 +- .../module/modules/movement/BetterFirework.kt | 2 +- .../lambda/module/modules/world/AutoPortal.kt | 2 +- .../module/modules/world/AutoVillagerCycle.kt | 2 +- .../lambda/module/modules/world/Scaffold.kt | 4 +- .../lambda/module/modules/world/StashMover.kt | 16 +-- 20 files changed, 145 insertions(+), 108 deletions(-) delete mode 100644 src/main/kotlin/com/lambda/config/serializers/BindSerializer.kt diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index 87fa083fb..fcc5b458e 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -203,7 +203,7 @@ abstract class Config( } try { load(childMultiple, nestedObj.asJsonObject) - } catch(e: Throwable) { + } catch (e: Throwable) { logError("Failed to deserialize ${childMultiple.multipleType.toString().lowercase()} '${childMultiple.name}' in '$name'", e) } } @@ -486,20 +486,15 @@ abstract class Config( .let { settingBlock -> val path = try { registrationQueue.removeFirst().settingBlockSpecs - } catch(_: NoSuchElementException) { - throw IllegalStateException("Setting block registered from an unknown location for config '$name'; layer path was not queued before setting block initialization") + } catch (_: NoSuchElementException) { + throw IllegalStateException("Setting block registered from an unknown location for config '$name'. Layer path was not queued before setting block initialization") } var currentLayer: BlockLayer = settingBlockLayers path.forEach { index -> - val existing = currentLayer.layers.getOrNull(index) - if (existing != null) currentLayer = existing - else { - val layer = BlockLayer.Block(currentLayer) - currentLayer.layers.add(layer) - currentLayer = layer - } + currentLayer = currentLayer.layers.getOrNull(index) + ?: throw IllegalStateException("Empty setting block registered in config '$name'. Setting blocks must have at least one setting in them") } SettingBlockWrapper(settingBlock, currentLayer) @@ -512,8 +507,8 @@ abstract class Config( internal fun , R : Any> setting(name: String, description: String, settingCore: T, visibility: () -> Boolean): Setting { val layerSpecInfo = try { registrationQueue.removeFirst() - } catch(_: NoSuchElementException) { - throw IllegalStateException("Setting registered from an unknown location for config '$name'; layer path was not queued before setting initialization") + } catch (_: NoSuchElementException) { + throw IllegalStateException("Setting registered from an unknown location for config '$name'. Layer path was not queued before setting initialization") } var currentSettingLayer: SettingLayer.Multiple = settingLayers @@ -536,7 +531,7 @@ abstract class Config( val newSettingLayer = when (spec.type) { MultipleLayerType.Tab -> SettingLayer.Tab(spec.name, mutableListOf(), currentSettingLayer) MultipleLayerType.Group -> SettingLayer.Group(spec.name, mutableListOf(), currentSettingLayer) - MultipleLayerType.Root -> throw IllegalStateException("Multiple root setting layers; only the base class root layer should ever be created") + MultipleLayerType.Root -> throw IllegalStateException("Multiple root setting layers. Only the base class root layer should ever be created") } currentSettingLayer.layers.add(newSettingLayer) currentSettingLayer = newSettingLayer @@ -559,9 +554,9 @@ abstract class Config( } val layer = SettingLayer.Single( + name, currentSettingLayer, currentBlockLayer, - name, description, settingCore, this@Config, @@ -608,9 +603,9 @@ abstract class Config( ) : Multiple(name, MultipleLayerType.Group, layers, parent) class Single, R : Any>( + override val name: String, override val parent: Multiple, val blockLayer: BlockLayer, - override val name: String, description: String, settingCore: T, config: Config, diff --git a/src/main/kotlin/com/lambda/config/Serializer.kt b/src/main/kotlin/com/lambda/config/Serializer.kt index 254e12ac8..fc83c39fc 100644 --- a/src/main/kotlin/com/lambda/config/Serializer.kt +++ b/src/main/kotlin/com/lambda/config/Serializer.kt @@ -35,4 +35,6 @@ abstract class Serializer { simpleModule.addSerializer(type, serializer) simpleModule.addDeserializer(type, deSerializer) } + + fun initFromJsonException(objName: String) = IllegalStateException("Attempted to initialize a $objName directly from JSON! All $objName's should be updated after standard initialization.") } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/BindSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/BindSerializer.kt deleted file mode 100644 index 67bac4684..000000000 --- a/src/main/kotlin/com/lambda/config/serializers/BindSerializer.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.serializers - -import com.lambda.config.Serializer -import com.lambda.config.settings.complex.Bind -import tools.jackson.core.JsonGenerator -import tools.jackson.core.JsonParser -import tools.jackson.databind.DeserializationContext -import tools.jackson.databind.SerializationContext -import tools.jackson.databind.deser.std.StdDeserializer -import tools.jackson.databind.node.ObjectNode -import tools.jackson.databind.ser.std.StdSerializer - -@Suppress("unused") -object BindSerializer : Serializer() { - override val type = Bind::class.java - - override val serializer = object : StdSerializer(type) { - override fun serialize(value: Bind, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeStartObject() - .writeNumberProperty("key", value.key) - .writeNumberProperty("modifiers", value.modifiers) - .writeNumberProperty("mouse", value.mouse) - .writeEndObject() - } - } - - override val deSerializer = object : StdDeserializer(type) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Bind { - val node = p.readValueAsTree() - return Bind(node.get("key").asInt(), node.get("modifiers").asInt(), node.get("mouse").asInt()) - } - } -} diff --git a/src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt index fa5bde89b..5cc6d9e66 100644 --- a/src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt @@ -33,8 +33,8 @@ object BlockSerializer : Serializer(), Stringifiable { override val type = Block::class.java override val serializer = object : StdSerializer(type) { - override fun serialize(value: Block, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeTree((Registries.BLOCK.codec.encodeStart(JsonOps.Uncompressed, value).orThrow)) + override fun serialize(block: Block, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeTree((Registries.BLOCK.codec.encodeStart(JsonOps.Uncompressed, block).orThrow)) } } diff --git a/src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt index 3e4f123c7..665463811 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt @@ -33,8 +33,8 @@ object ColorSerializer : Serializer(), Stringifiable { override val type = Color::class.java override val serializer = object : StdSerializer(type) { - override fun serialize(value: Color, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeString("${value.red},${value.green},${value.blue},${value.alpha}") + override fun serialize(color: Color, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeString("${color.red},${color.green},${color.blue},${color.alpha}") } } diff --git a/src/main/kotlin/com/lambda/config/serializers/ConfigCategorySerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ConfigCategorySerializer.kt index 5404566fd..9219087f4 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ConfigCategorySerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ConfigCategorySerializer.kt @@ -15,26 +15,31 @@ * along with this program. If not, see . */ +@file:Suppress("unused") + package com.lambda.config.serializers +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.ConfigCategory import com.lambda.config.Serializer +import com.lambda.config.Setting import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext +import tools.jackson.databind.JsonNode import tools.jackson.databind.SerializationContext import tools.jackson.databind.deser.std.StdDeserializer -import tools.jackson.databind.node.ObjectNode import tools.jackson.databind.ser.std.StdSerializer object ConfigCategorySerializer : Serializer() { override val type = ConfigCategory::class.java override val serializer = object : StdSerializer(type) { - override fun serialize(value: ConfigCategory, gen: JsonGenerator, ctxt: SerializationContext) { + override fun serialize(category: ConfigCategory, gen: JsonGenerator, ctxt: SerializationContext) { gen.writeStartObject() - value.configs.forEach { config -> - val serialized = mapper.valueToTree(config) + category.configs.forEach { config -> + val serialized = mapper.valueToTree(config) if (serialized.isEmpty) return@forEach gen.writeName(config.name) gen.writeTree(serialized) @@ -45,11 +50,94 @@ object ConfigCategorySerializer : Serializer() { override val deSerializer = object : StdDeserializer(type) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext): ConfigCategory { - throw IllegalStateException("Attempted to initialize a ConfigCategory directly from JSON! All ConfigCategory's should be updated after standard initialization.") + throw initFromJsonException("ConfigCategory") + } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, category: ConfigCategory) = + category.apply { + val categoryJson = mapper.readTree(p) + configs.forEach { config -> + val configJson = categoryJson.get(config.name) ?: return@forEach + mapper.updateValue(config, configJson) + } + } + } +} + +object ConfigSerializer : Serializer() { + override val type = Config::class.java + + override val serializer = object : StdSerializer(type) { + override fun serialize(config: Config, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeObjectPropertyStart(config.name) + .writePOJO(config.settingLayers) + .writeEndObject() + } + } + + override val deSerializer = object : StdDeserializer(type) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Config { + throw initFromJsonException("Config") + } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, config: Config) = + config.apply { mapper.updateValue(settingLayers, mapper.readTree(p)) } + } +} + +object MultipleSerializer : Serializer() { + override val type = SettingLayer.Multiple::class.java + + override val serializer = object : StdSerializer(type) { + override fun serialize(multiple: SettingLayer.Multiple, gen: JsonGenerator, ctxt: SerializationContext) { + val notRoot = multiple !is SettingLayer.Root + if (notRoot) gen.writeObjectPropertyStart(multiple.name) + multiple.layers.forEach { layer -> + if (layer is SettingLayer.Single<*, *> && !layer.setting.isModified) return@forEach + gen.writePOJOProperty(layer.name, layer) + } + if (notRoot) gen.writeEndObject() + } + } + + override val deSerializer = object : StdDeserializer(type) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SettingLayer.Multiple { + throw initFromJsonException("Multiple") + } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, multiple: SettingLayer.Multiple) = + multiple.apply { + val multipleJson = mapper.readTree(p) + layers.forEach { layer -> + val layerJson = multipleJson.get(layer.name) ?: return@forEach + mapper.updateValue(layer, layerJson) + } + } + } +} + +object SingleSerializer : Serializer>() { + override val type = SettingLayer.Single::class.java + + override val serializer = object : StdSerializer>(type) { + override fun serialize(single: SettingLayer.Single<*, *>, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writePOJOProperty(single.name, single.setting.value) } + } - override fun deserialize(jp: JsonParser, ctxt: DeserializationContext, newValue: ConfigCategory): ConfigCategory { - return super.deserialize(jp, ctxt, newValue) + override val deSerializer = object : StdDeserializer>(type) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SettingLayer.Single<*, *> { + throw initFromJsonException("Single") } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, single: SettingLayer.Single<*, *>) = + single.apply { + try { + @Suppress("unchecked_cast") + (setting as Setting<*, Any>).value = p.readValueAs(setting.value.javaClass) + } catch (e: Throwable) { + throw IllegalStateException("Failed to deserialize setting '${setting.name}'", e) + } + } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/ItemSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ItemSerializer.kt index c59e02c6c..9d9b7b49c 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ItemSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ItemSerializer.kt @@ -33,8 +33,8 @@ object ItemSerializer : Serializer(), Stringifiable { override val type = Item::class.java override val serializer = object : StdSerializer(type) { - override fun serialize(value: Item, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeString(value.toString()) + override fun serialize(item: Item, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeString(item.toString()) } } diff --git a/src/main/kotlin/com/lambda/config/serializers/ItemStackSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ItemStackSerializer.kt index f57ddcc9f..0b4cbbc88 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ItemStackSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ItemStackSerializer.kt @@ -33,8 +33,8 @@ object ItemStackSerializer : Serializer(), Stringifiable { override val type = ItemStack::class.java override val serializer = object : StdSerializer(type) { - override fun serialize(value: ItemStack, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeTree(ItemStack.CODEC.encodeStart(JsonOps.Uncompressed, value).orThrow) + override fun serialize(itemStack: ItemStack, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeTree(ItemStack.CODEC.encodeStart(JsonOps.Uncompressed, itemStack).orThrow) } } diff --git a/src/main/kotlin/com/lambda/config/serializers/KeyCodeSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/KeyCodeSerializer.kt index 2fe73fe09..3a56ddd66 100644 --- a/src/main/kotlin/com/lambda/config/serializers/KeyCodeSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/KeyCodeSerializer.kt @@ -31,8 +31,8 @@ object KeyCodeSerializer : Serializer() { override val type = KeyCode::class.java override val serializer = object : StdSerializer(type) { - override fun serialize(value: KeyCode, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeString(value.name) + override fun serialize(keyCode: KeyCode, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeString(keyCode.name) } } diff --git a/src/main/kotlin/com/lambda/config/serializers/TextSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/TextSerializer.kt index 6fcbb833b..6363c3087 100644 --- a/src/main/kotlin/com/lambda/config/serializers/TextSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/TextSerializer.kt @@ -33,8 +33,8 @@ object TextSerializer : Serializer() { override val type = Text::class.java override val serializer = object : StdSerializer(type) { - override fun serialize(value: Text, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeTree(TextCodecs.CODEC.encodeStart(JsonOps.Uncompressed, value).orThrow) + override fun serialize(text: Text, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeTree(TextCodecs.CODEC.encodeStart(JsonOps.Uncompressed, text).orThrow) } } diff --git a/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt index b12b68627..888c96b2b 100644 --- a/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt @@ -33,8 +33,8 @@ object UuidSerializer : Serializer(), Stringifiable { override val type = UUID::class.java override val serializer = object : StdSerializer(type) { - override fun serialize(value: UUID, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeString(value.toString()) + override fun serialize(uuid: UUID, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeString(uuid.toString()) } } diff --git a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt index e54f2e2d9..bb7bb45d1 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt @@ -17,6 +17,7 @@ package com.lambda.config.settings.complex +import com.fasterxml.jackson.annotation.JsonIgnore import com.google.gson.reflect.TypeToken import com.lambda.brigadier.CommandResult.Companion.failure import com.lambda.brigadier.CommandResult.Companion.success @@ -126,7 +127,7 @@ class KeybindSetting( sameLine() withId("##Unbind-${this@KeybindSetting.hashCode()}") { smallButton("Unbind") { - internalValue = Bind.EMPTY + internalValue = Bind.Empty listening = false } } @@ -150,7 +151,7 @@ class KeybindSetting( if ((it.isPressed && !isModKey) || (it.isReleased && isModKey)) { when (it.translated) { KeyCode.Escape -> {} - KeyCode.Backspace, KeyCode.Delete -> value = Bind.EMPTY + KeyCode.Backspace, KeyCode.Delete -> value = Bind.Empty else -> value = Bind(it.translated.code, it.modifiers, -1) } @@ -173,18 +174,18 @@ class KeybindSetting( optional(boolean("mouse button")) { isMouseButton -> executeWithResult { val isMouse = if (isMouseButton != null) isMouseButton().value() else false - var bind = Bind.EMPTY + var bind = Bind.Empty if (isMouse) { val num = try { name().value().toInt() - } catch(_: NumberFormatException) { + } catch (_: NumberFormatException) { return@executeWithResult failure("${name().value()} doesn't match with a mouse button") } bind = Bind(0, 0, mouse = num) } else { bind = try { Bind(KeyCode.valueOf(name().value()).code, 0) - } catch(_: IllegalArgumentException) { + } catch (_: IllegalArgumentException) { return@executeWithResult failure("${name().value()} doesn't match with a bind") } } @@ -221,6 +222,7 @@ data class Bind( val modifiers: Int, val mouse: Int = -1, ) { + @JsonIgnore val trueMods = buildList { if (modifiers and GLFW_MOD_SHIFT != 0) add(KeyCode.LeftShift) if (modifiers and GLFW_MOD_CONTROL != 0) add(KeyCode.LeftControl) @@ -253,6 +255,6 @@ data class Bind( "Key Code: $key, Modifiers: ${trueMods.joinToString(separator = "+") { it.name }}, Mouse Button: ${Mouse.entries.getOrNull(mouse) ?: "None"}" companion object { - val EMPTY = Bind(0, 0, -1) + val Empty = Bind(0, 0, -1) } } diff --git a/src/main/kotlin/com/lambda/module/HudModule.kt b/src/main/kotlin/com/lambda/module/HudModule.kt index 9b3d571e4..83443d5cf 100644 --- a/src/main/kotlin/com/lambda/module/HudModule.kt +++ b/src/main/kotlin/com/lambda/module/HudModule.kt @@ -28,7 +28,7 @@ abstract class HudModule( tag: ModuleTag, alwaysListening: Boolean = false, enabledByDefault: Boolean = false, - defaultKeybind: Bind = Bind.EMPTY, + defaultKeybind: Bind = Bind.Empty, ) : Module(name, description, tag, alwaysListening, enabledByDefault, defaultKeybind = defaultKeybind), Layout { val backgroundColor = setting("Background Color", Color(0, 0, 0, 0)) } diff --git a/src/main/kotlin/com/lambda/module/Module.kt b/src/main/kotlin/com/lambda/module/Module.kt index bb7ee3d2f..116286b24 100644 --- a/src/main/kotlin/com/lambda/module/Module.kt +++ b/src/main/kotlin/com/lambda/module/Module.kt @@ -126,7 +126,7 @@ abstract class Module( private val alwaysListening: Boolean = false, enabledByDefault: Boolean = false, modulePriority: Int = 0, - defaultKeybind: Bind = Bind.EMPTY, + defaultKeybind: Bind = Bind.Empty, autoDisable: Boolean = false ) : Nameable, Muteable, OwnerPriority, Config(name, ModuleCategory), IMutableAutomationConfig by MutableAutomationConfig() diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt index 256f33c59..fa23dca86 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt @@ -48,7 +48,7 @@ object AutoArmor : Module( tag = ModuleTag.Combat ) { private var elytraPriority by setting("Elytra Priority", true, "Prioritizes elytra's over other armor pieces in the chest slot") - private val toggleElytraPriority by setting("Toggle Elytra Priority", Bind.EMPTY) + private val toggleElytraPriority by setting("Toggle Elytra Priority", Bind.Empty) .onPress { elytraPriority = !elytraPriority } private val minDurabilityPercentage by setting("Min Durability", 5, 0..100, 1, "Minimum durability percentage before being swapped for a new piece", "%") private val headProtection by setting("Preferred Head Protection", Protection.Protection) diff --git a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt index de0465ef8..cfdbefd70 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt @@ -75,7 +75,7 @@ object BetterFirework : Module( else if (player.canTakeoff) takeoffState = TakeoffState.Jumping } @Suppress("unused") - private var midFlightActivationKey by setting("Mid-Flight Activation Key", Bind.EMPTY, "Firework use key for mid flight activation") + private var midFlightActivationKey by setting("Mid-Flight Activation Key", Bind.Empty, "Firework use key for mid flight activation") .onPress { if (player.isGliding) takeoffState = TakeoffState.StartFlying } private var middleClickCancel by setting("Middle Click Cancel", false, description = "Cancel pick block action on middle mouse click") { activateButton.key != KeyCode.Unbound.code } private var fireworkInteract by setting("Right Click Fly", true, "Automatically start flying when right clicking fireworks") diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt index 990a35762..8e2547d3d 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt @@ -82,7 +82,7 @@ object AutoPortal : Module( private const val FillGroup = "Fill" private const val OutlineGroup = "Outline" - private val previewPlace by setting("Preview Place", Bind.EMPTY, "The keybind to preview the portal placement and subsequentially place the portal") + private val previewPlace by setting("Preview Place", Bind.Empty, "The keybind to preview the portal placement and subsequentially place the portal") .onPress { preview = true } .onRelease { preview = false diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt index 2853171ee..020c0262d 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt @@ -70,7 +70,7 @@ object AutoVillagerCycle : Module( private val interactDelay by setting("Interact Delay", 20, 1..40, 1, "Ticks to wait before interacting with the villager", " ticks") private val breakDelay by setting("Break Delay", 5, 1..20, 1, "Ticks to wait after breaking the lectern", " ticks") private val searchRange by setting("Search Range", 5.0, 1.0..10.0, 0.5, "Range to search for nearby villagers", " blocks") - private val startCyclingBind by setting("Start Cycling", Bind.EMPTY, "Press to start/stop cycling") + private val startCyclingBind by setting("Start Cycling", Bind.Empty, "Press to start/stop cycling") .onPress { if (cycleState != CycleState.Idle) { info("Stopped villager cycling.") diff --git a/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt b/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt index dc629a1a9..097d113ec 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt @@ -55,8 +55,8 @@ object Scaffold : Module( private val blacklistedBlocks by setting("Blacklisted Blocks", mutableSetOf()) private val bridgeRange by setting("Bridge Range", 5, 0..5, 1, "The range at which blocks can be placed to help build support for the player", unit = " blocks") private val onlyBelow by setting("Only Below", true, "Restricts bridging to only below the player to avoid place spam if it's impossible to reach the supporting position") { bridgeRange > 0 } - private val descend by setting("Descend", Bind.EMPTY, "Lower the place position by one to allow the player to lower y level") - private val descendAmount by setting("Descend Amount", 1, 1..5, 1, "The amount to lower the place position by when descending", unit = " blocks") { descend != Bind.EMPTY } + private val descend by setting("Descend", Bind.Empty, "Lower the place position by one to allow the player to lower y level") + private val descendAmount by setting("Descend Amount", 1, 1..5, 1, "The amount to lower the place position by when descending", unit = " blocks") { descend != Bind.Empty } private val pendingActions = ConcurrentLinkedQueue() diff --git a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt index 50cf0c37f..b6b0a1f87 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt @@ -140,21 +140,21 @@ object StashMover : Module( @Tab(GeneralTab) private val breakEmptyPullContainers by setting("Break Empty Pull Containers", false, "Breaks empty pull containers after taking their items") { role == Role.MoverBot } @Tab(GeneralTab) private val disconnectOnFinish by setting("Disconnect On Finish", false, "Disconnects the mover bot when it's finished") { role == Role.MoverBot } @Tab(GeneralTab) private val disconnectOnFail by setting("Disconnect On Fail", false, "Disconnects the mover bot if it fails") { role == Role.MoverBot } - @Tab(GeneralTab) private val startStop by setting("Start/Stop", Bind.EMPTY, "Starts and stops the selected role") + @Tab(GeneralTab) private val startStop by setting("Start/Stop", Bind.Empty, "Starts and stops the selected role") .onPress { event -> event.cancel(); startStop() } - @Tab(GeneralTab) private val pauseUnpause by setting("Pause/Unpause", Bind.EMPTY, "Pauses and unpauses the selected role") + @Tab(GeneralTab) private val pauseUnpause by setting("Pause/Unpause", Bind.Empty, "Pauses and unpauses the selected role") .onPress { event -> event.cancel(); pauseUnpause() } - @Tab(CommandBindsTab) private val indexSelectedContainers by setting("Index Selected Containers", Bind.EMPTY, "Indexes the selected containers to pull/push items from/to") { role == Role.MoverBot } + @Tab(CommandBindsTab) private val indexSelectedContainers by setting("Index Selected Containers", Bind.Empty, "Indexes the selected containers to pull/push items from/to") { role == Role.MoverBot } .onPress { event -> event.cancel(); indexSelectedContainers() } - @Tab(CommandBindsTab) private val removeSelectedContainers by setting("Remove Selected Containers", Bind.EMPTY, "Removes the selected containers from being pull/pushed from/to") { role == Role.MoverBot } + @Tab(CommandBindsTab) private val removeSelectedContainers by setting("Remove Selected Containers", Bind.Empty, "Removes the selected containers from being pull/pushed from/to") { role == Role.MoverBot } .onPress { event -> event.cancel(); removeSelectedContainers() } - @Tab(CommandBindsTab) private val setItemThrowPosAndRotation by setting("Set Item Throw", Bind.EMPTY, "Sets the item throw position and rotation. (This is usually set to throw into hoppers to pickup the items)") { role == Role.MoverBot } + @Tab(CommandBindsTab) private val setItemThrowPosAndRotation by setting("Set Item Throw", Bind.Empty, "Sets the item throw position and rotation. (This is usually set to throw into hoppers to pickup the items)") { role == Role.MoverBot } .onPress { event -> event.cancel(); setItemThrow() } - @Tab(CommandBindsTab) private val setPearlButtonPos by setting("Set Pearl Button Pos", Bind.EMPTY, "Sets the button used to dispense a pearl for the player") { role == Role.MoverBot } + @Tab(CommandBindsTab) private val setPearlButtonPos by setting("Set Pearl Button Pos", Bind.Empty, "Sets the button used to dispense a pearl for the player") { role == Role.MoverBot } .onPress { event -> event.cancel(); setPearlButtonPos() } - @Tab(CommandBindsTab) private val setPearlThrowPosAndRotation by setting("Set Pearl Throw", Bind.EMPTY, "Sets the pearl throw position and rotation. (This is best if you throw somewhat sideways into a line of bubble columns)") { role == Role.MoverBot } + @Tab(CommandBindsTab) private val setPearlThrowPosAndRotation by setting("Set Pearl Throw", Bind.Empty, "Sets the pearl throw position and rotation. (This is best if you throw somewhat sideways into a line of bubble columns)") { role == Role.MoverBot } .onPress { event -> event.cancel(); setPearlThrow() } - @Tab(CommandBindsTab) private val setPearlBotButton by setting("Set PearlBot Button", Bind.EMPTY, "Sets the button position for the pearl bot to press to load the mover bot") { role == Role.PearlBot } + @Tab(CommandBindsTab) private val setPearlBotButton by setting("Set PearlBot Button", Bind.Empty, "Sets the button position for the pearl bot to press to load the mover bot") { role == Role.PearlBot } .onPress { event -> event.cancel(); setPearlBotButton() } private var sel1: BlockPos? = null From d71ddd87f1592638bd2362b1b18bac164ebcabf3 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Thu, 28 May 2026 22:49:34 +0100 Subject: [PATCH 31/40] compilation errors and base type adapters/load/save logic --- build.gradle.kts | 5 +- src/main/kotlin/com/lambda/Lambda.kt | 25 ++-- .../lambda/command/commands/ReplayCommand.kt | 1 + src/main/kotlin/com/lambda/config/Config.kt | 127 +----------------- .../com/lambda/config/ConfigCategory.kt | 76 +++-------- src/main/kotlin/com/lambda/config/Setting.kt | 74 +++++----- .../config/{Serializer.kt => TypeAdapter.kt} | 15 ++- .../automation/IMutableAutomationConfig.kt | 4 +- .../config/categories/AutomationCategory.kt | 4 +- .../lambda/config/categories/FontCategory.kt | 4 +- .../config/categories/FriendCategory.kt | 4 +- .../lambda/config/categories/GuiCategory.kt | 4 +- .../lambda/config/categories/HudCategory.kt | 4 +- .../config/categories/LambdaCategory.kt | 4 +- .../config/categories/ModuleCategory.kt | 8 +- .../config/categories/SecretsCategory.kt | 4 +- .../categories/UserAutomationCategory.kt | 18 ++- .../lambda/config/migration/MigrationUtils.kt | 121 +++++++++++++++++ .../com/lambda/config/migration/Migrations.kt | 123 ++++++++--------- .../migrations/AutomationConfigMigration.kt | 24 ++-- .../migrations/FriendConfigMigration.kt | 34 +++-- .../migrations/GuiConfigMigration.kt} | 29 ++-- .../migrations/ModuleConfigMigration.kt | 36 +++++ .../UserAutomationConfigMigration.kt | 36 +++++ ...BlockSerializer.kt => BlockTypeAdapter.kt} | 10 +- .../ClassCollectionSettingTypeAdapter.kt | 74 ++++++++++ .../CollectionSettingTypeAdapter.kt | 73 ++++++++++ ...ColorSerializer.kt => ColorTypeAdapter.kt} | 12 +- ...alizer.kt => ConfigCategoryTypeAdapter.kt} | 78 +++++++---- .../serializers/FunctionSettingTypeAdapter.kt | 44 ++++++ ...kSerializer.kt => ItemStackTypeAdapter.kt} | 10 +- .../{ItemSerializer.kt => ItemTypeAdapter.kt} | 10 +- ...odeSerializer.kt => KeyCodeTypeAdapter.kt} | 10 +- .../{TextSerializer.kt => TextTypeAdapter.kt} | 10 +- .../{UuidSerializer.kt => UuidTypeAdapter.kt} | 13 +- .../com/lambda/config/settings/CharSetting.kt | 4 +- .../lambda/config/settings/FunctionSetting.kt | 11 +- .../lambda/config/settings/NumericSetting.kt | 12 +- .../lambda/config/settings/StringSetting.kt | 6 +- .../collections/BlockCollectionSetting.kt | 8 +- .../collections/ClassCollectionSetting.kt | 21 +-- .../settings/collections/CollectionSetting.kt | 55 +++----- .../collections/ItemCollectionSetting.kt | 8 +- .../config/settings/collections/MapSetting.kt | 7 +- .../settings/comparable/BooleanSetting.kt | 4 +- .../config/settings/comparable/EnumSetting.kt | 16 +-- .../settings/complex/BlockPosSetting.kt | 8 +- .../config/settings/complex/BlockSetting.kt | 4 +- .../config/settings/complex/ColorSetting.kt | 4 +- .../config/settings/complex/KeybindSetting.kt | 16 +-- .../config/settings/complex/Vec3dSetting.kt | 4 +- .../config/settings/numeric/DoubleSetting.kt | 4 +- .../config/settings/numeric/FloatSetting.kt | 4 +- .../config/settings/numeric/LongSetting.kt | 4 +- src/main/kotlin/com/lambda/gui/MenuBar.kt | 8 +- .../kotlin/com/lambda/network/LambdaHttp.kt | 5 +- .../com/lambda/network/NetworkHandler.kt | 4 +- .../network/api/v1/models/Authentication.kt | 16 +-- .../com/lambda/network/api/v1/models/Cape.kt | 6 +- .../lambda/network/api/v1/models/Player.kt | 10 +- .../kotlin/com/lambda/util/StringUtils.kt | 3 - 61 files changed, 789 insertions(+), 591 deletions(-) rename src/main/kotlin/com/lambda/config/{Serializer.kt => TypeAdapter.kt} (79%) create mode 100644 src/main/kotlin/com/lambda/config/migration/MigrationUtils.kt rename src/main/kotlin/com/lambda/config/{Jsonable.kt => migration/migrations/GuiConfigMigration.kt} (54%) create mode 100644 src/main/kotlin/com/lambda/config/migration/migrations/ModuleConfigMigration.kt create mode 100644 src/main/kotlin/com/lambda/config/migration/migrations/UserAutomationConfigMigration.kt rename src/main/kotlin/com/lambda/config/serializers/{BlockSerializer.kt => BlockTypeAdapter.kt} (81%) create mode 100644 src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingTypeAdapter.kt create mode 100644 src/main/kotlin/com/lambda/config/serializers/CollectionSettingTypeAdapter.kt rename src/main/kotlin/com/lambda/config/serializers/{ColorSerializer.kt => ColorTypeAdapter.kt} (81%) rename src/main/kotlin/com/lambda/config/serializers/{ConfigCategorySerializer.kt => ConfigCategoryTypeAdapter.kt} (61%) create mode 100644 src/main/kotlin/com/lambda/config/serializers/FunctionSettingTypeAdapter.kt rename src/main/kotlin/com/lambda/config/serializers/{ItemStackSerializer.kt => ItemStackTypeAdapter.kt} (80%) rename src/main/kotlin/com/lambda/config/serializers/{ItemSerializer.kt => ItemTypeAdapter.kt} (81%) rename src/main/kotlin/com/lambda/config/serializers/{KeyCodeSerializer.kt => KeyCodeTypeAdapter.kt} (79%) rename src/main/kotlin/com/lambda/config/serializers/{TextSerializer.kt => TextTypeAdapter.kt} (81%) rename src/main/kotlin/com/lambda/config/serializers/{UuidSerializer.kt => UuidTypeAdapter.kt} (80%) diff --git a/build.gradle.kts b/build.gradle.kts index 002bf838c..c3c4df407 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -175,6 +175,7 @@ dependencies { exclude(group = "org.slf4j") } includeLib("io.ktor:ktor-client-content-negotiation:$ktorVersion") + includeLib("io.ktor:ktor-serialization-jackson:$ktorVersion") includeLib("tools.jackson.core:jackson-core:$jacksonVersion") includeLib("tools.jackson.core:jackson-databind:$jacksonVersion") includeLib("tools.jackson.module:jackson-module-kotlin:$jacksonVersion") @@ -225,7 +226,7 @@ tasks { kotlin { compilerOptions { - freeCompilerArgs.addAll("-Xcontext-parameters", "-Xconsistent-data-class-copy-visibility") + freeCompilerArgs.addAll("-Xcontext-parameters", "-Xconsistent-data-class-copy-visibility", "-Xannotation-default-target=param-property") } jvmToolchain(21) @@ -271,4 +272,4 @@ publishing { } } } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/Lambda.kt b/src/main/kotlin/com/lambda/Lambda.kt index 974d7bec5..99e94e90b 100644 --- a/src/main/kotlin/com/lambda/Lambda.kt +++ b/src/main/kotlin/com/lambda/Lambda.kt @@ -17,7 +17,8 @@ package com.lambda -import com.lambda.config.Serializer +import com.lambda.Lambda.mapper +import com.lambda.config.TypeAdapter import com.lambda.core.Loader import com.lambda.event.events.ClientEvent import com.lambda.event.listener.UnsafeListener.Companion.listenOnceUnsafe @@ -29,7 +30,9 @@ import net.fabricmc.loader.api.FabricLoader import net.minecraft.client.MinecraftClient import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger +import tools.jackson.databind.SerializationFeature import tools.jackson.databind.module.SimpleModule +import tools.jackson.databind.type.TypeFactory import tools.jackson.module.kotlin.jsonMapper import tools.jackson.module.kotlin.kotlinModule @@ -39,9 +42,10 @@ object Lambda : ClientModInitializer { const val Symbol = "λ" const val AppId = "1221289599427416127" const val RepoUrl = "https://github.com/lambda-client/lambda" - val Version: String = FabricLoader.getInstance() - .getModContainer("lambda").orElseThrow() - .metadata.version.friendlyString + val Version: String = + FabricLoader.getInstance() + .getModContainer("lambda").orElseThrow() + .metadata.version.friendlyString val Log: Logger = LogManager.getLogger(Symbol) @@ -57,17 +61,22 @@ object Lambda : ClientModInitializer { * rather than creating new instances when deserializing. */ val mapper = jsonMapper { - defaultPrettyPrinter() + enable(SerializationFeature.INDENT_OUTPUT) addModules( - kotlinModule(), + kotlinModule(), SimpleModule().apply { - getInstances>().forEach { serializer -> - serializer.register() + getInstances>().forEach { registerable -> + registerable.register() } } ) } + /** + * The configured [TypeFactory] produced by [mapper]. + */ + val typeFactory: TypeFactory = mapper.typeFactory + override fun onInitializeClient() {} // nop init { diff --git a/src/main/kotlin/com/lambda/command/commands/ReplayCommand.kt b/src/main/kotlin/com/lambda/command/commands/ReplayCommand.kt index 5aca80603..becf8dfd0 100644 --- a/src/main/kotlin/com/lambda/command/commands/ReplayCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/ReplayCommand.kt @@ -33,6 +33,7 @@ import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandSource.suggestMatching import kotlin.io.path.exists +@Suppress("unused") object ReplayCommand : LambdaCommand( name = "replay", usage = "replay ", diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index fcc5b458e..3cd4b9a56 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -17,9 +17,7 @@ package com.lambda.config -import com.google.gson.JsonElement -import com.google.gson.JsonObject -import com.google.gson.reflect.TypeToken +import com.lambda.Lambda.typeFactory import com.lambda.config.ConfigLoader.configs import com.lambda.config.settings.CharSetting import com.lambda.config.settings.FunctionSetting @@ -43,7 +41,6 @@ import com.lambda.config.settings.numeric.IntegerSetting import com.lambda.config.settings.numeric.LongSetting import com.lambda.event.Muteable import com.lambda.imgui.flag.ImGuiInputTextFlags -import com.lambda.util.CommunicationUtils.logError import com.lambda.util.KeyCode import com.lambda.util.Nameable import net.minecraft.block.Block @@ -69,13 +66,13 @@ import kotlin.reflect.jvm.javaField abstract class Config( final override val name: String, configCategory: ConfigCategory -) : Jsonable, Nameable { +) : Nameable { internal val settingLayers = SettingLayer.Root() internal val settingBlockLayers = BlockLayer.Root() private val registrationQueue = ArrayDeque() init { - if (configs.any { it.name == name }) throw IllegalStateException("Configs with name $name already exists") + if (configs.any { it.name == name }) throw IllegalStateException("Configs with name $name already exists.") enqueueProperties(this::class, emptyList(), emptyList()) configCategory.configs.add(this) } @@ -165,120 +162,6 @@ abstract class Config( } } - final override fun toJson() = - JsonObject().apply { - fun process(multiple: SettingLayer.Multiple, target: JsonObject) { - forEachSetting( - multiple, - false, - { _, multiple -> - val nested = JsonObject() - process(multiple, nested) - if (nested.isEmpty) return@forEachSetting - target.add(multiple.name, nested) - } - ) { _, single -> - if (!single.setting.isModified) return@forEachSetting - try { - target.add(single.setting.name, single.setting.toJson()) - } catch (e: Throwable) { - logError("Failed to serialize '${single.setting}'", e) - } - } - } - process(settingLayers, this) - } - - final override fun loadFromJson(serialized: JsonElement) { - val rootObj = serialized.asJsonObject - - fun load(multiple: SettingLayer.Multiple, obj: JsonObject) { - forEachSetting( - multiple, - false, - { _, childMultiple -> - var nestedObj = obj[childMultiple.name] - if (nestedObj == null || !nestedObj.isJsonObject) { - nestedObj = JsonObject() - } - try { - load(childMultiple, nestedObj.asJsonObject) - } catch (e: Throwable) { - logError("Failed to deserialize ${childMultiple.multipleType.toString().lowercase()} '${childMultiple.name}' in '$name'", e) - } - } - ) { path, single -> - val jsonValue = obj[single.setting.name] - if (jsonValue != null) { - try { - single.setting.loadFromJson(jsonValue) - } catch (e: Throwable) { - logError("Failed to deserialize setting '${single.setting.name}' in '$name'", e) - } - } else { - val fallbackValue = findFallbackValue(single.setting.name, path, rootObj) - if (fallbackValue != null) { - try { - single.setting.loadFromJson(fallbackValue) - } catch (e: Throwable) { - logError("Failed to deserialize setting '${single.setting.name}' from fallback in '$name'", e) - } - } - } - } - } - - load(settingLayers, rootObj) - } - - private fun findFallbackValue( - settingName: String, - parentLayers: List, - rootObj: JsonObject - ): JsonElement? { - var bestMatch: JsonElement? = null - var bestMatchKey: String? = null - var bestMatchParent: JsonObject? = null - var bestMatchScore = 0 - - fun search(currentObj: JsonObject, jsonPath: List) { - currentObj.entrySet().forEach { (key, element) -> - if (key.endsWith(settingName, ignoreCase = true)) { - var score = 0 - if (key.equals(settingName, ignoreCase = true)) { - score += 10 - } - - val fullPathString = (jsonPath + key).joinToString("") - parentLayers.forEach { layer -> - if (fullPathString.contains(layer.name, ignoreCase = true)) { - score += 5 - } - } - - if (score > bestMatchScore) { - bestMatchScore = score - bestMatch = element - bestMatchKey = key - bestMatchParent = currentObj - } - } - - if (element.isJsonObject) { - search(element.asJsonObject, jsonPath + key) - } - } - } - - search(rootObj, emptyList()) - - if (bestMatch != null && bestMatchParent != null && bestMatchKey != null) { - bestMatchParent.remove(bestMatchKey) - } - - return bestMatch - } - @SettingDsl fun setting( name: String, @@ -347,7 +230,7 @@ abstract class Config( name, description, if (displayClassName) ClassCollectionSetting(immutableList, defaultValue.toMutableList()) - else CollectionSetting(defaultValue.toMutableList(), immutableList, TypeToken.getParameterized(Collection::class.java, T::class.java).type, serialize), + else CollectionSetting(defaultValue.toMutableList(), immutableList, typeFactory.constructCollectionType(Collection::class.java, T::class.java), serialize), visibility ) @@ -363,7 +246,7 @@ abstract class Config( description, MapSetting( defaultValue.toMutableMap(), - TypeToken.getParameterized(MutableMap::class.java, K::class.java, V::class.java).type + typeFactory.constructMapType(MutableMap::class.java, K::class.java, V::class.java) ), visibility ) diff --git a/src/main/kotlin/com/lambda/config/ConfigCategory.kt b/src/main/kotlin/com/lambda/config/ConfigCategory.kt index 49a01a764..edc0b45e0 100644 --- a/src/main/kotlin/com/lambda/config/ConfigCategory.kt +++ b/src/main/kotlin/com/lambda/config/ConfigCategory.kt @@ -17,16 +17,11 @@ package com.lambda.config -import com.google.gson.JsonElement -import com.google.gson.JsonIOException -import com.google.gson.JsonObject -import com.google.gson.JsonParser -import com.google.gson.JsonSyntaxException import com.lambda.Lambda.Log -import com.lambda.config.ConfigLoader.configByName +import com.lambda.Lambda.mapper import com.lambda.config.ConfigLoader.configCategories import com.lambda.config.categories.ModuleCategory -import com.lambda.config.migration.ConfigMigrations +import com.lambda.config.migration.ConfigMigrationHandler import com.lambda.core.Loadable import com.lambda.event.events.ClientEvent import com.lambda.event.listener.UnsafeListener.Companion.listenUnsafe @@ -51,12 +46,12 @@ import kotlin.time.Duration.Companion.minutes * * See also [ModuleCategory]. * - * @property configName The name of the configuration. + * @property name The name of the configuration. * @property primary The primary file where the configuration is saved. * @property configs A set of [Config] objects that this configuration manages. */ -abstract class ConfigCategory : Jsonable, Loadable { - abstract val configName: String +abstract class ConfigCategory : Loadable { + abstract val name: String abstract val primaryFile: File private val backup get() = File("${primaryFile.parent}/${primaryFile.nameWithoutExtension}-backup.${primaryFile.extension}") override val priority = 1 @@ -64,12 +59,12 @@ abstract class ConfigCategory : Jsonable, Loadable { val configs = mutableSetOf() final override fun load(): String { - if (configCategories.any { it.configName == configName }) - throw IllegalStateException("Configuration with name $configName already exists") + if (configCategories.any { it.name == name }) + throw IllegalStateException("Config category with name $name already exists") fixedRateTimer( daemon = true, - name = "Scheduler-config-${configName}", + name = "Scheduler-config-category-${name}", initialDelay = 5.minutes.inWholeMilliseconds, period = 5.minutes.inWholeMilliseconds, ) { trySaveToFile() } @@ -84,36 +79,10 @@ abstract class ConfigCategory : Jsonable, Loadable { fun tryLoadFromFile() = runIO { internalTryLoad() } fun trySaveToFile(logToChat: Boolean = false) = runIO { internalTrySave(logToChat) } - final override fun toJson() = - JsonObject().apply { - val latestSchemaVersion = ConfigMigrations.latestVersion(configName) - if (latestSchemaVersion > 1) { - addProperty( - ConfigMigrations.schemaVersionKey(configName) ?: ConfigMigrations.DefaultSchemaVersionKey, - latestSchemaVersion - ) - } - configs.forEach { - val json = it.toJson() - if (json.isEmpty) return@forEach - add(it.name, json) - } - } - - final override fun loadFromJson(serialized: JsonElement) { - val schemaKey = ConfigMigrations.schemaVersionKey(configName) ?: ConfigMigrations.DefaultSchemaVersionKey - serialized.asJsonObject.entrySet().forEach { (name, value) -> - if (name == schemaKey) return@forEach - configByName(name) - ?.loadFromJson(value) - ?: Log.warn("No matching config found for $name in $configName config category") - } - } - protected open fun internalTryLoad() { loadFromFile(primaryFile) .onSuccess { - val message = "$configName config loaded." + val message = "$name config category loaded." Log.info(message) info(message) } @@ -122,12 +91,12 @@ abstract class ConfigCategory : Jsonable, Loadable { runCatching { loadFromFile(backup) } .onSuccess { - val message = "$configName config loaded from backup" + val message = "$name config category loaded from backup" Log.info(message) info(message) } .onFailure { error -> - val message = "Failed to load $configName config from backup, unrecoverable error" + val message = "Failed to load $name config category from backup, unrecoverable error" Log.error(message, error) logError(message) } @@ -137,40 +106,37 @@ abstract class ConfigCategory : Jsonable, Loadable { protected open fun internalTrySave(logToChat: Boolean) { saveToFile() .onSuccess { - val message = "Saved $configName config." + val message = "Saved $name category." Log.info(message) if (logToChat) info(message) } .onFailure { - val message = "Failed to save $configName config" + val message = "Failed to save $name category" Log.error(message, it) logError(message) } } - /** - * Loads the config from the [file] - * Encapsulates [JsonIOException] and [JsonSyntaxException] in a runCatching block - */ private fun loadFromFile(file: File) = runCatching { - file.ifNotExists { Log.warn("No configuration file found for $configName. Creating new file when saving.") } + file.ifNotExists { Log.warn("No config file found for $name. Creating new file when saving.") } .ifExists { - val parsed = JsonParser.parseReader(it.reader()).asJsonObject - val migrationResult = ConfigMigrations.migrate(configName, parsed) + val parsed = mapper.readTree(it) + if (!parsed.isObject) return@ifExists + val migrationResult = ConfigMigrationHandler.migrate(this@ConfigCategory, parsed.asObject()) - if (migrationResult.migrated && file == primary) { - file.writeText(gson.toJson(migrationResult.json)) + if (migrationResult.migrated && file == primaryFile) { + mapper.writeValue(file, migrationResult.json) file.copyTo(backup, true) } - loadFromJson(migrationResult.json) + mapper.updateValue(this@ConfigCategory, migrationResult.json) } } private fun saveToFile() = runCatching { primaryFile.createIfNotExists() .let { - it.writeText(gson.toJson(toJson())) + mapper.writeValue(it, this) it.copyTo(backup, true) } } diff --git a/src/main/kotlin/com/lambda/config/Setting.kt b/src/main/kotlin/com/lambda/config/Setting.kt index 5dc8588a2..402aac77b 100644 --- a/src/main/kotlin/com/lambda/config/Setting.kt +++ b/src/main/kotlin/com/lambda/config/Setting.kt @@ -18,10 +18,7 @@ package com.lambda.config import com.google.common.base.Defaults.defaultValue -import com.google.gson.JsonElement -import com.google.gson.JsonParser -import com.lambda.Lambda.Log -import com.lambda.Lambda.gson +import com.lambda.Lambda.mapper import com.lambda.brigadier.CommandResult.Companion.failure import com.lambda.brigadier.CommandResult.Companion.success import com.lambda.brigadier.argument.string @@ -47,7 +44,6 @@ import com.lambda.util.text.highlighted import com.lambda.util.text.hoverEvent import com.lambda.util.text.literal import net.minecraft.command.CommandRegistryAccess -import java.lang.reflect.Type import kotlin.reflect.KProperty /** @@ -100,7 +96,7 @@ class Setting, R>( val config: Config, val layer: SettingLayer.Single<*, *>, var visibility: () -> Boolean -) : Nameable, Describable, Jsonable { +) : Nameable, Describable { val originalCore = core var disabled = { false } @@ -110,10 +106,10 @@ class Setting, R>( val isModified get() = value != core.defaultValue - operator fun getValue(thisRef: Any?, property: KProperty<*>) = core.value + operator fun getValue(thisRef: Any?, property: KProperty<*>) = core.coreValue operator fun setValue(thisRef: Any?, property: KProperty<*>, value: R) { - val oldValue = core.value - core.value = value + val oldValue = core.coreValue + core.coreValue = value listeners.forEach { if (it.requiresValueChange && oldValue == value) return@forEach it.execute(oldValue, value) @@ -136,15 +132,6 @@ class Setting, R>( fun ImGuiBuilder.buildLayout() = with(core) { buildLayout() } fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) = with(core) { buildCommand(registry) } - override fun toJson() = originalCore.toJson() - override fun loadFromJson(serialized: JsonElement) { - runCatching { - originalCore.loadFromJson(serialized) - }.onFailure { - Log.warn("Failed to load setting $name with value $serialized") - } - } - class ValueListener(val requiresValueChange: Boolean, val execute: (from: T, to: T) -> Unit) /** @@ -242,52 +229,55 @@ class Setting, R>( } }.asReversed() - override fun toString() = "Setting $name: $value of type ${core.type.typeName}" + override fun toString() = "Setting $name: $value" } abstract class SettingCore( - var defaultValue: T, - val type: Type -) : Jsonable { - open var value = defaultValue + var defaultValue: T +) { + /** + * The core value. Setting this variable bypasses all setting callbacks for value changes and is only used + * by the serialization logic when loading from the config files. This isn't considered changing the setting, rather + * applying its default value. For example, When setting the cores value inside the [buildLayout] or [buildCommand] methods, + * the [settingValue] should be used so the appropriate callbacks are invoked. + */ + open var coreValue = defaultValue + + /** + * A wrapper for the [coreValue] used to invoke the [setting]'s value-change callbacks + */ context(setting: Setting<*, T>) - protected var internalValue - get() = value + protected var settingValue + get() = coreValue set(value) { setting.value = value } + /** + * A function invoked to build the core's gui interface. + */ context(setting: Setting<*, T>) abstract fun ImGuiBuilder.buildLayout() + /** + * Builds the core's command using the [com.lambda.brigadier.BrigadierDsl] + */ context(setting: Setting<*, T>) open fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { required(string("value as JSON")) { value -> executeWithResult { val valueString = value().value() - val parsed = try { - JsonParser.parseString("\"$valueString\"") - } catch (_: Exception) { - return@executeWithResult failure("$valueString is not a valid JSON string.") - } ?: return@executeWithResult failure("No config found for $name.") - val previous = this@SettingCore.value + val previous = settingValue try { - loadFromJson(parsed) - } catch (_: Exception) { - return@executeWithResult failure("Failed to load $valueString as a ${type::class.simpleName} for $name in ${setting.config.name}.") + settingValue = mapper.readValue(valueString, settingValue?.javaClass) + } catch (_: Throwable) { + return@executeWithResult failure("Failed to deserialize $valueString as a ${type::class.simpleName} for $name in ${setting.config.name}.") } - ConfigCommand.info(setting.setMessage(previous, this@SettingCore.value)) + ConfigCommand.info(setting.setMessage(previous, this@SettingCore.coreValue)) return@executeWithResult success() } } } - - override fun toJson(): JsonElement = - gson.toJsonTree(value, type) - - override fun loadFromJson(serialized: JsonElement) { - value = gson.fromJson(serialized, type) - } } @DslMarker diff --git a/src/main/kotlin/com/lambda/config/Serializer.kt b/src/main/kotlin/com/lambda/config/TypeAdapter.kt similarity index 79% rename from src/main/kotlin/com/lambda/config/Serializer.kt rename to src/main/kotlin/com/lambda/config/TypeAdapter.kt index fc83c39fc..ed02ca35a 100644 --- a/src/main/kotlin/com/lambda/config/Serializer.kt +++ b/src/main/kotlin/com/lambda/config/TypeAdapter.kt @@ -24,17 +24,22 @@ import tools.jackson.databind.ser.std.StdSerializer interface Stringifiable { fun stringify(value: T): String } -abstract class Serializer { - val mapper = Lambda.mapper +abstract class TypeAdapter { + val mapper by lazy { Lambda.mapper } abstract val type: Class abstract val serializer: StdSerializer - abstract val deSerializer: StdDeserializer + abstract val deserializer: StdDeserializer context(simpleModule: SimpleModule) fun register() { - simpleModule.addSerializer(type, serializer) - simpleModule.addDeserializer(type, deSerializer) + with(simpleModule) { + addSerializer(type, serializer) + addDeserializer(type, deserializer) + } } fun initFromJsonException(objName: String) = IllegalStateException("Attempted to initialize a $objName directly from JSON! All $objName's should be updated after standard initialization.") + + protected typealias Serializer = StdSerializer + protected typealias Deserializer = StdDeserializer } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt index 2b88d81e3..fca93ce2a 100644 --- a/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt @@ -70,9 +70,9 @@ class MutableAutomationConfig : IMutableAutomationConfig { val otherSetting = otherLayer.layers .asSequence() .filterIsInstance>() - .find { it.setting.name == single.setting.name } + .find { it.name == single.name } ?.setting ?: return@forEachSetting - if (single.setting.core.type != otherSetting.core.type) + if (single.setting.core::class != otherSetting.core::class) throw IllegalStateException("Settings with the same name do not have the same type.") @Suppress("UNCHECKED_CAST") (single.setting as Setting, Any>).core = otherSetting.core as SettingCore diff --git a/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt b/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt index b7419dbaa..6deb59062 100644 --- a/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/AutomationCategory.kt @@ -22,6 +22,6 @@ import com.lambda.util.FolderRegistry import java.io.File object AutomationCategory : ConfigCategory() { - override val configName = "automation" - override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() + override val name = "automation" + override val primaryFile: File = FolderRegistry.config.resolve("$name.json").toFile() } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/FontCategory.kt b/src/main/kotlin/com/lambda/config/categories/FontCategory.kt index c863835cb..234609277 100644 --- a/src/main/kotlin/com/lambda/config/categories/FontCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/FontCategory.kt @@ -22,6 +22,6 @@ import com.lambda.util.FolderRegistry import java.io.File object FontCategory : ConfigCategory() { - override val configName get() = "font" - override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() + override val name get() = "font" + override val primaryFile: File = FolderRegistry.config.resolve("$name.json").toFile() } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt b/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt index 884641e90..ff5b62483 100644 --- a/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/FriendCategory.kt @@ -22,6 +22,6 @@ import com.lambda.util.FolderRegistry import java.io.File object FriendCategory : ConfigCategory() { - override val configName get() = "friends" - override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() + override val name get() = "friends" + override val primaryFile: File = FolderRegistry.config.resolve("$name.json").toFile() } diff --git a/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt b/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt index db0537133..2851a3799 100644 --- a/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/GuiCategory.kt @@ -22,6 +22,6 @@ import com.lambda.util.FolderRegistry import java.io.File object GuiCategory : ConfigCategory() { - override val configName get() = "gui" - override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() + override val name get() = "gui" + override val primaryFile: File = FolderRegistry.config.resolve("$name.json").toFile() } diff --git a/src/main/kotlin/com/lambda/config/categories/HudCategory.kt b/src/main/kotlin/com/lambda/config/categories/HudCategory.kt index e5e08e7d7..5a0046250 100644 --- a/src/main/kotlin/com/lambda/config/categories/HudCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/HudCategory.kt @@ -22,6 +22,6 @@ import com.lambda.util.FolderRegistry import java.io.File object HudCategory : ConfigCategory() { - override val configName get() = "hud" - override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() + override val name get() = "hud" + override val primaryFile: File = FolderRegistry.config.resolve("$name.json").toFile() } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt b/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt index 9bb534df3..8851a4c7f 100644 --- a/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/LambdaCategory.kt @@ -22,6 +22,6 @@ import com.lambda.util.FolderRegistry import java.io.File object LambdaCategory : ConfigCategory() { - override val configName get() = "lambda" - override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() + override val name get() = "lambda" + override val primaryFile: File = FolderRegistry.config.resolve("$name.json").toFile() } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt b/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt index f6dfc88ce..75eb37f5a 100644 --- a/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/ModuleCategory.kt @@ -18,7 +18,7 @@ package com.lambda.config.categories import com.lambda.config.ConfigCategory -import com.lambda.config.categories.ModuleCategory.configName +import com.lambda.config.categories.ModuleCategory.name import com.lambda.util.FolderRegistry import java.io.File @@ -27,10 +27,10 @@ import java.io.File * * This object is used to save and load the settings of all [Module]s in the system. * - * @property configName The name of the configuration. + * @property name The name of the configuration. * @property primary The primary file where the configuration is saved. */ object ModuleCategory : ConfigCategory() { - override val configName get() = "modules" - override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() + override val name get() = "modules" + override val primaryFile: File = FolderRegistry.config.resolve("$name.json").toFile() } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt b/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt index c5b8d4e1a..acb6354a3 100644 --- a/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/SecretsCategory.kt @@ -22,6 +22,6 @@ import com.lambda.util.FolderRegistry import java.io.File object SecretsCategory : ConfigCategory() { - override val configName get() = "secrets" - override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() + override val name get() = "secrets" + override val primaryFile: File = FolderRegistry.config.resolve("$name.json").toFile() } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt b/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt index ece048ebe..fef2d103b 100644 --- a/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt +++ b/src/main/kotlin/com/lambda/config/categories/UserAutomationCategory.kt @@ -17,7 +17,7 @@ package com.lambda.config.categories -import com.google.gson.JsonParser +import com.lambda.Lambda.mapper import com.lambda.config.ConfigCategory import com.lambda.config.automation.UserAutomationConfig import com.lambda.module.ModuleRegistry.moduleNameMap @@ -26,15 +26,19 @@ import com.lambda.util.FolderRegistry import java.io.File object UserAutomationCategory : ConfigCategory() { - override val configName get() = "custom_automation" - override val primaryFile: File = FolderRegistry.config.resolve("$configName.json").toFile() + override val name get() = "custom_automation" + override val primaryFile: File = FolderRegistry.config.resolve("$name.json").toFile() override fun internalTryLoad() { primaryFile.ifExists { - JsonParser.parseReader(it.reader()).asJsonObject.entrySet().forEach { (name, _) -> - if (configs.any { config -> config.name == name }) return@forEach - UserAutomationConfig(name) - } + mapper.readTree(it) + .takeIf { it.isObject } + ?.asObject() + ?.propertyStream() + ?.forEach { (key, _) -> + if (configs.any { config -> config.name == key }) return@forEach + UserAutomationConfig(key) + } } super.internalTryLoad() configs.forEach { diff --git a/src/main/kotlin/com/lambda/config/migration/MigrationUtils.kt b/src/main/kotlin/com/lambda/config/migration/MigrationUtils.kt new file mode 100644 index 000000000..12fa3b23e --- /dev/null +++ b/src/main/kotlin/com/lambda/config/migration/MigrationUtils.kt @@ -0,0 +1,121 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.migration + +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer +import com.lambda.config.ConfigCategory +import com.lambda.util.CommunicationUtils.logError +import tools.jackson.databind.JsonNode +import tools.jackson.databind.node.ObjectNode + +object MigrationUtils { + fun locateAndMoveMisplacedSettings(category: ConfigCategory, rootNode: ObjectNode): Int { + var settingsMoved = 0 + category.configs.forEach { config -> + val configNode = rootNode.get(config.name) ?: return@forEach + if (!configNode.isObject) return@forEach + settingsMoved += locateAndMoveMisplacedSettings(config, configNode.asObject()) + } + return settingsMoved + } + + private fun locateAndMoveMisplacedSettings(config: Config, rootNode: ObjectNode): Int { + var settingsMoved = 0 + fun walk(multiple: SettingLayer.Multiple, obj: ObjectNode) { + config.forEachSetting( + multiple, + false, + { _, childMultiple -> + val existing = obj.get(childMultiple.name) + val nestedObj: ObjectNode = when { + existing != null && existing.isObject -> existing.asObject() + existing == null || existing.isNull -> obj.putObject(childMultiple.name) + else -> return@forEachSetting + } + try { + walk(childMultiple, nestedObj) + } catch (e: Throwable) { + logError("Failed to relocate settings in ${childMultiple.multipleType.toString().lowercase()} '${childMultiple.name}' in '${config.name}'", e) + } + } + ) { path, single -> + if (obj.has(single.name)) return@forEachSetting + + val fallbackValue = locateAndRemove(single.name, path, rootNode) ?: return@forEachSetting + try { + obj.set(single.name, fallbackValue) + settingsMoved++ + } catch (e: Throwable) { + logError("Failed to relocate setting '${single.name}' in '${config.name}'", e) + } + } + } + + walk(config.settingLayers, rootNode) + return settingsMoved + } + + private fun locateAndRemove( + settingName: String, + parentLayers: List, + rootObj: ObjectNode + ): JsonNode? { + var bestMatch: JsonNode? = null + var bestMatchKey: String? = null + var bestMatchParent: ObjectNode? = null + var bestMatchScore = 0 + + fun search(currentObj: ObjectNode, jsonPath: List) { + currentObj.propertyStream().forEach { (key, element) -> + if (key.endsWith(settingName, ignoreCase = true)) { + var score = 0 + if (key.equals(settingName, ignoreCase = true)) { + score += 10 + } + + val fullPathString = (jsonPath + key).joinToString("") + parentLayers.forEach { layer -> + if (fullPathString.contains(layer.name, ignoreCase = true)) { + score += 5 + } + } + + if (score > bestMatchScore) { + bestMatchScore = score + bestMatch = element + bestMatchKey = key + bestMatchParent = currentObj + } + } + + if (element.isObject) { + search(element.asObject(), jsonPath + key) + } + } + } + + search(rootObj, emptyList()) + + if (bestMatch != null && bestMatchParent != null && bestMatchKey != null) { + bestMatchParent.remove(bestMatchKey) + } + + return bestMatch + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/migration/Migrations.kt b/src/main/kotlin/com/lambda/config/migration/Migrations.kt index 2eb15a950..e5cd0ca66 100644 --- a/src/main/kotlin/com/lambda/config/migration/Migrations.kt +++ b/src/main/kotlin/com/lambda/config/migration/Migrations.kt @@ -17,84 +17,51 @@ package com.lambda.config.migration -import com.google.gson.JsonArray -import com.google.gson.JsonElement -import com.google.gson.JsonObject import com.lambda.Lambda.Log +import com.lambda.config.ConfigCategory import com.lambda.core.Loadable import com.lambda.util.ReflectionUtils.getInstances -import java.util.* +import tools.jackson.databind.node.ArrayNode +import tools.jackson.databind.node.ObjectNode import kotlin.math.max -interface ConfigMigration { - val configName: String - val latestVersion: Int - val schemaVersionKey: String get() = ConfigMigrations.DefaultSchemaVersionKey - fun applyStep(fromVersion: Int, root: JsonObject): StepResult? -} - -data class StepResult( - val toVersion: Int, - val changed: Boolean = true, -) - -data class MigrationResult( - val json: JsonObject, - val migrated: Boolean, -) - -abstract class StepConfigMigration : ConfigMigration { - private val steps = mutableMapOf Unit>>() - - protected fun step(fromVersion: Int, toVersion: Int, migrate: JsonObject.() -> Unit) { - steps[fromVersion] = toVersion to migrate - } - - final override fun applyStep(fromVersion: Int, root: JsonObject): StepResult? { - val step = steps[fromVersion] ?: return null - val (toVersion, block) = step - root.block() - return StepResult(toVersion = toVersion, changed = true) - } -} - -object ConfigMigrations : Loadable { +object ConfigMigrationHandler : Loadable { const val DefaultSchemaVersionKey = "_schemaVersion" override val priority: Int = 2 @Volatile private var initialized = false - private var byConfig = emptyMap() + private var byCategory = emptyMap() override fun load(): String { refreshRegistry() - return "Loaded ${byConfig.size} config migrations" + return "Loaded ${byCategory.size} config migrations" } - fun schemaVersionKey(configName: String): String? { + fun schemaVersionKey(category: ConfigCategory): String? { ensureInitialized() - return byConfig[configName]?.schemaVersionKey + return byCategory[category]?.schemaVersionKey } - fun latestVersion(configName: String): Int { + fun latestVersion(category: ConfigCategory): Int { ensureInitialized() - return byConfig[configName]?.latestVersion ?: 1 + return byCategory[category]?.latestVersion ?: 1 } - fun migrate(configName: String, original: JsonObject): MigrationResult { + fun migrate(category: ConfigCategory, original: ObjectNode): MigrationResult { ensureInitialized() - val migration = byConfig[configName] ?: return MigrationResult(original.deepCopy(), false) + val migration = byCategory[category] ?: return MigrationResult(original.deepCopy(), false) if (migration.latestVersion <= 1) return MigrationResult(original.deepCopy(), false) val json = original.deepCopy() var currentVersion = runCatching { - json.get(migration.schemaVersionKey)?.takeIf { it.isJsonPrimitive }?.asInt + json.get(migration.schemaVersionKey)?.takeIf { it.isNumber }?.asInt() }.getOrNull() ?: 1 var migrated = false if (currentVersion > migration.latestVersion) { Log.warn( - "Config ${configName.replaceFirstChar { it.uppercase() }} has schema version $currentVersion " + + "Config category '${category.name}' has schema version $currentVersion " + "which is newer than supported ${migration.latestVersion}" ) return MigrationResult(json, false) @@ -106,7 +73,7 @@ object ConfigMigrations : Loadable { val stepResult = migration.applyStep(fromVersion, json) if (stepResult == null) { Log.warn( - "Missing migration step for ${configName.replaceFirstChar { it.uppercase() }} " + + "Missing migration step for '${category.name}' config category " + "schema version $fromVersion -> ?. Expected latest schema version is ${migration.latestVersion}" ) break @@ -115,12 +82,12 @@ object ConfigMigrations : Loadable { currentVersion = stepResult.toVersion migrated = migrated || stepResult.changed if (currentVersion > 1) { - json.addProperty(migration.schemaVersionKey, currentVersion) + json.put(migration.schemaVersionKey, currentVersion) migrated = true } } catch (t: Throwable) { Log.error( - "Failed to migrate ${configName.replaceFirstChar { it.uppercase() }} config " + + "Failed to migrate ${category.name} config category " + "from v$currentVersion to next version", t ) @@ -130,9 +97,9 @@ object ConfigMigrations : Loadable { val normalizedVersion = max(1, currentVersion) if (normalizedVersion > 1) { - val existingVersion = runCatching { json.get(migration.schemaVersionKey)?.asInt }.getOrNull() + val existingVersion = runCatching { json.get(migration.schemaVersionKey)?.asInt() }.getOrNull() if (existingVersion != normalizedVersion) { - json.addProperty(migration.schemaVersionKey, normalizedVersion) + json.put(migration.schemaVersionKey, normalizedVersion) migrated = true } } else if (json.has(migration.schemaVersionKey)) { @@ -146,14 +113,14 @@ object ConfigMigrations : Loadable { @Synchronized private fun refreshRegistry() { val discovered = getInstances() - val duplicates = discovered.groupBy { it.configName }.filter { it.value.size > 1 } + val duplicates = discovered.groupBy { it.category }.filter { it.value.size > 1 } if (duplicates.isNotEmpty()) { duplicates.keys.forEach { key -> Log.warn("Multiple config migrations found for '$key'. Using the last discovered migration.") } } - byConfig = discovered.associateBy { it.configName } + byCategory = discovered.associateBy { it.category } initialized = true } @@ -162,25 +129,41 @@ object ConfigMigrations : Loadable { } } -fun JsonObject.objectOrCreate(key: String): JsonObject = - getAsJsonObject(key) ?: JsonObject().also { add(key, it) } +abstract class StepConfigMigration : ConfigMigration { + private val steps = mutableMapOf Unit>>() -fun JsonObject.arrayOrCreate(key: String): JsonArray = - getAsJsonArray(key) ?: JsonArray().also { add(key, it) } + protected fun step(fromVersion: Int, toVersion: Int, migrate: (ObjectNode) -> Unit) { + steps[fromVersion] = toVersion to migrate + } -fun JsonElement.parseUuidOrNull(): UUID? { - val raw = when { - isJsonPrimitive -> asString - isJsonObject && asJsonObject.has("id") -> asJsonObject.get("id").asString - else -> return null + final override fun applyStep(fromVersion: Int, root: ObjectNode): StepResult? { + val step = steps[fromVersion] ?: return null + val (toVersion, block) = step + root.block() + return StepResult(toVersion = toVersion, changed = true) } - val normalized = - if (raw.length == 32) raw.replaceFirst( - "(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})".toRegex(), - "$1-$2-$3-$4-$5" - ) - else raw + fun ObjectNode.objectOrCreate(key: String): ObjectNode = + get(key) as? ObjectNode ?: putObject(key) - return runCatching { UUID.fromString(normalized) }.getOrNull() + fun ObjectNode.arrayOrCreate(key: String): ArrayNode = + get(key) as? ArrayNode ?: putArray(key) } + +interface ConfigMigration { + val category: ConfigCategory + val latestVersion: Int + val schemaVersionKey: String get() = ConfigMigrationHandler.DefaultSchemaVersionKey + fun applyStep(fromVersion: Int, root: ObjectNode): StepResult? +} + +data class StepResult( + val toVersion: Int, + val changed: Boolean = true, +) + +data class MigrationResult( + val json: ObjectNode, + val migrated: Boolean, +) + diff --git a/src/main/kotlin/com/lambda/config/migration/migrations/AutomationConfigMigration.kt b/src/main/kotlin/com/lambda/config/migration/migrations/AutomationConfigMigration.kt index 3c2a458b8..6ab5afd3f 100644 --- a/src/main/kotlin/com/lambda/config/migration/migrations/AutomationConfigMigration.kt +++ b/src/main/kotlin/com/lambda/config/migration/migrations/AutomationConfigMigration.kt @@ -18,28 +18,36 @@ package com.lambda.config.migration.migrations import com.lambda.Lambda.Log +import com.lambda.config.categories.AutomationCategory +import com.lambda.config.migration.MigrationUtils import com.lambda.config.migration.StepConfigMigration @Suppress("unused") object AutomationConfigMigration : StepConfigMigration() { - override val configName = "automation" - override val latestVersion = 2 + override val category = AutomationCategory + override val latestVersion = 3 init { - step(1, 2) { + step(1, 2) { root -> var updateCount = 0 - entrySet().forEach { configPair -> - getAsJsonObject(configPair.key)?.let { config -> + root.propertyStream().forEach { configPair -> + root.get(configPair.key).takeIf { it.isObject }?.asObject()?.let { config -> config.get("Limit Timeframe")?.let { limitTimeframe -> - if (limitTimeframe.asInt < 50) { - config.addProperty("Limit Timeframe", 310) + if (!limitTimeframe.isInt) return@forEach + if (limitTimeframe.asInt() < 50) { + config.put("Limit Timeframe", 310) updateCount++ } } } } - Log.info("Migrated Automation config schema v1 -> v2: $updateCount settings updated") + Log.info("Migrated Automation config category schema v1 -> v2: $updateCount settings updated") + } + + step(2, 3) { root -> + val count = MigrationUtils.locateAndMoveMisplacedSettings(category, root) + Log.info("Migrated Automation config category schema v2 -> v3: $count settings moved") } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/migration/migrations/FriendConfigMigration.kt b/src/main/kotlin/com/lambda/config/migration/migrations/FriendConfigMigration.kt index 8a32f01d9..8b517b428 100644 --- a/src/main/kotlin/com/lambda/config/migration/migrations/FriendConfigMigration.kt +++ b/src/main/kotlin/com/lambda/config/migration/migrations/FriendConfigMigration.kt @@ -17,24 +17,22 @@ package com.lambda.config.migration.migrations -import com.google.gson.JsonArray import com.lambda.Lambda.Log +import com.lambda.config.categories.FriendCategory import com.lambda.config.migration.StepConfigMigration -import com.lambda.config.migration.arrayOrCreate -import com.lambda.config.migration.objectOrCreate -import com.lambda.config.migration.parseUuidOrNull +import tools.jackson.databind.JsonNode import java.util.* @Suppress("unused") object FriendConfigMigration : StepConfigMigration() { - override val configName = "friends" + override val category = FriendCategory override val latestVersion = 2 init { - step(1, 2) { - val config = objectOrCreate("friends") + step(1, 2) { root -> + val config = root.objectOrCreate("friends") val rawFriends = config.arrayOrCreate("friends") - val migrated = JsonArray() + val migrated = config.putArray("friends") val seen = mutableSetOf() var dropped = 0 @@ -46,8 +44,24 @@ object FriendConfigMigration : StepConfigMigration() { ?: run { dropped++ } } - config.add("friends", migrated) - Log.info("Migrated Friend config schema v1 -> v2: ${migrated.size()} entries converted, $dropped entries dropped") + Log.info("Migrated Friend config category schema v1 -> v2: ${migrated.size()} entries converted, $dropped entries dropped") } } + + fun JsonNode.parseUuidOrNull(): UUID? { + val raw = when { + isString -> asString() + isObject && asObject().has("id") -> asObject().get("id").asString() + else -> return null + } + + val normalized = + if (raw.length == 32) raw.replaceFirst( + "(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})".toRegex(), + "$1-$2-$3-$4-$5" + ) + else raw + + return runCatching { UUID.fromString(normalized) }.getOrNull() + } } diff --git a/src/main/kotlin/com/lambda/config/Jsonable.kt b/src/main/kotlin/com/lambda/config/migration/migrations/GuiConfigMigration.kt similarity index 54% rename from src/main/kotlin/com/lambda/config/Jsonable.kt rename to src/main/kotlin/com/lambda/config/migration/migrations/GuiConfigMigration.kt index e3ac6fe8c..a111315a9 100644 --- a/src/main/kotlin/com/lambda/config/Jsonable.kt +++ b/src/main/kotlin/com/lambda/config/migration/migrations/GuiConfigMigration.kt @@ -15,19 +15,22 @@ * along with this program. If not, see . */ -package com.lambda.config +package com.lambda.config.migration.migrations -import com.google.gson.Gson -import com.google.gson.JsonElement +import com.lambda.Lambda.Log +import com.lambda.config.categories.GuiCategory +import com.lambda.config.migration.MigrationUtils +import com.lambda.config.migration.StepConfigMigration +@Suppress("unused") +object GuiConfigMigration : StepConfigMigration() { + override val category = GuiCategory + override val latestVersion = 2 -/** - * Interface for objects that can be serialized to and deserialized from JSON ([Gson]). - */ -interface Jsonable { - /** Serializes the object to a [JsonElement] */ - fun toJson(): JsonElement - - /** Loads the object's state from a [JsonElement] */ - fun loadFromJson(serialized: JsonElement) -} + init { + step(1, 2) { root -> + val count = MigrationUtils.locateAndMoveMisplacedSettings(category, root) + Log.info("Migrated Gui config category schema v1 -> v2: $count settings moved") + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/migration/migrations/ModuleConfigMigration.kt b/src/main/kotlin/com/lambda/config/migration/migrations/ModuleConfigMigration.kt new file mode 100644 index 000000000..3576f4f75 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/migration/migrations/ModuleConfigMigration.kt @@ -0,0 +1,36 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.migration.migrations + +import com.lambda.Lambda.Log +import com.lambda.config.categories.ModuleCategory +import com.lambda.config.migration.MigrationUtils +import com.lambda.config.migration.StepConfigMigration + +@Suppress("unused") +object ModuleConfigMigration : StepConfigMigration() { + override val category = ModuleCategory + override val latestVersion = 2 + + init { + step(1, 2) { root -> + val count = MigrationUtils.locateAndMoveMisplacedSettings(category, root) + Log.info("Migrated Module config category schema v1 -> v2: $count settings moved") + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/migration/migrations/UserAutomationConfigMigration.kt b/src/main/kotlin/com/lambda/config/migration/migrations/UserAutomationConfigMigration.kt new file mode 100644 index 000000000..e4dcf0bf6 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/migration/migrations/UserAutomationConfigMigration.kt @@ -0,0 +1,36 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.migration.migrations + +import com.lambda.Lambda.Log +import com.lambda.config.categories.UserAutomationCategory +import com.lambda.config.migration.MigrationUtils +import com.lambda.config.migration.StepConfigMigration + +@Suppress("unused") +object UserAutomationConfigMigration : StepConfigMigration() { + override val category = UserAutomationCategory + override val latestVersion = 2 + + init { + step(1, 2) { root -> + val count = MigrationUtils.locateAndMoveMisplacedSettings(category, root) + Log.info("Migrated User Automation config category schema v1 -> v2: $count settings moved") + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/BlockTypeAdapter.kt similarity index 81% rename from src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt rename to src/main/kotlin/com/lambda/config/serializers/BlockTypeAdapter.kt index 5cc6d9e66..c752ff9dc 100644 --- a/src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/BlockTypeAdapter.kt @@ -18,27 +18,25 @@ package com.lambda.config.serializers import com.lambda.config.JsonOps -import com.lambda.config.Serializer import com.lambda.config.Stringifiable +import com.lambda.config.TypeAdapter import net.minecraft.block.Block import net.minecraft.registry.Registries import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.SerializationContext -import tools.jackson.databind.deser.std.StdDeserializer -import tools.jackson.databind.ser.std.StdSerializer -object BlockSerializer : Serializer(), Stringifiable { +object BlockTypeAdapter : TypeAdapter(), Stringifiable { override val type = Block::class.java - override val serializer = object : StdSerializer(type) { + override val serializer = object : Serializer(type) { override fun serialize(block: Block, gen: JsonGenerator, ctxt: SerializationContext) { gen.writeTree((Registries.BLOCK.codec.encodeStart(JsonOps.Uncompressed, block).orThrow)) } } - override val deSerializer = object : StdDeserializer(type) { + override val deserializer = object : Deserializer(type) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext) = Registries.BLOCK.codec.parse(JsonOps.Uncompressed, p.readValueAsTree()).orThrow } diff --git a/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingTypeAdapter.kt new file mode 100644 index 000000000..0f40547f0 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingTypeAdapter.kt @@ -0,0 +1,74 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.serializers + +import com.fasterxml.jackson.core.JsonParseException +import com.lambda.config.SettingCore +import com.lambda.config.TypeAdapter +import com.lambda.config.settings.collections.ClassCollectionSetting +import com.lambda.util.ReflectionUtils.className +import tools.jackson.core.JsonGenerator +import tools.jackson.core.JsonParser +import tools.jackson.databind.DeserializationContext +import tools.jackson.databind.JsonNode +import tools.jackson.databind.SerializationContext + +@Suppress("unused") +object ClassCollectionSettingTypeAdapter : TypeAdapter>() { + override val type = ClassCollectionSetting::class.java + + override val serializer = object : Serializer>(type) { + override fun serialize( + setting: ClassCollectionSetting<*>, + gen: JsonGenerator, + ctxt: SerializationContext + ) { + gen.writeStartArray() + setting.coreValue.forEach { element -> + gen.writeString(element.className) + } + gen.writeEndArray() + } + } + + override val deserializer = object : Deserializer>(type) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): ClassCollectionSetting<*> { + throw initFromJsonException("ClassCollectionSetting") + } + + override fun deserialize( + p: JsonParser, + ctxt: DeserializationContext, + settingCore: ClassCollectionSetting<*> + ): ClassCollectionSetting<*> = + settingCore.apply { + val arrayNode = p.readValueAsTree() + if (!arrayNode.isArray) throw JsonParseException("ClassCollectionSetting's serialized value is not an array.") + val classNames = mutableListOf() + arrayNode.forEach { node -> + if (!node.isString) throw JsonParseException("ClassCollectionSetting's serialized array contains a non-string value.") + if (node.isString) classNames.add(node.stringValue()) + } + + @Suppress("unchecked_cast") + (settingCore as SettingCore).coreValue = classNames.mapNotNull { className -> + settingCore.immutableCollection.find { it.className == className } + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/CollectionSettingTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/CollectionSettingTypeAdapter.kt new file mode 100644 index 000000000..a90b12cb3 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/serializers/CollectionSettingTypeAdapter.kt @@ -0,0 +1,73 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.serializers + +import com.fasterxml.jackson.core.JsonParseException +import com.lambda.config.TypeAdapter +import com.lambda.config.settings.collections.CollectionSetting +import tools.jackson.core.JsonGenerator +import tools.jackson.core.JsonParser +import tools.jackson.databind.DeserializationContext +import tools.jackson.databind.JsonNode +import tools.jackson.databind.SerializationContext + +@Suppress("unused") +object CollectionSettingTypeAdapter : TypeAdapter>() { + override val type = CollectionSetting::class.java + + override val serializer = object : Serializer>(type) { + override fun serialize(collection: CollectionSetting<*>, gen: JsonGenerator, ctxt: SerializationContext) { + if (collection.serialize) mapper.writeValue(gen, collection.coreValue) + else { + gen.writeStartArray() + collection.coreValue.forEach { element -> + gen.writeString(element.toString()) + } + gen.writeEndArray() + } + } + } + + override val deserializer = object : Deserializer>(type) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): CollectionSetting<*> { + throw initFromJsonException("CollectionSetting") + } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, collection: CollectionSetting<*>) = + collection.apply { + val newValue = mutableListOf() + + if (serialize) { + val deserialized = mapper.readValue>(p, type) + newValue.addAll(deserialized) + } else { + val node = p.readValueAsTree() + if (!node.isArray) throw JsonParseException("CollectionSetting's serialized value is not an array.") + node.values().forEach { element -> + if (!element.isString) throw JsonParseException("CollectionSetting's serialized array contains a non-string value. A CollectionSetting's JSON array must only contain strings if CollectionSetting.serialize is false.") + val str = element.stringValue() + val matched = immutableCollection.find { it.toString() == str } + if (matched != null) newValue.add(matched) + } + } + + @Suppress("unchecked_cast") + (this as CollectionSetting).coreValue = newValue + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ColorTypeAdapter.kt similarity index 81% rename from src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt rename to src/main/kotlin/com/lambda/config/serializers/ColorTypeAdapter.kt index 665463811..6f33876b2 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ColorTypeAdapter.kt @@ -17,28 +17,26 @@ package com.lambda.config.serializers -import com.google.gson.JsonParseException -import com.lambda.config.Serializer +import com.fasterxml.jackson.core.JsonParseException import com.lambda.config.Stringifiable +import com.lambda.config.TypeAdapter import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.SerializationContext -import tools.jackson.databind.deser.std.StdDeserializer -import tools.jackson.databind.ser.std.StdSerializer import java.awt.Color @Suppress("unused") -object ColorSerializer : Serializer(), Stringifiable { +object ColorTypeAdapter : TypeAdapter(), Stringifiable { override val type = Color::class.java - override val serializer = object : StdSerializer(type) { + override val serializer = object : Serializer(type) { override fun serialize(color: Color, gen: JsonGenerator, ctxt: SerializationContext) { gen.writeString("${color.red},${color.green},${color.blue},${color.alpha}") } } - override val deSerializer = object : StdDeserializer(type) { + override val deserializer = object : Deserializer(type) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Color { val color = p.valueAsString.split(",") return when (color.size) { diff --git a/src/main/kotlin/com/lambda/config/serializers/ConfigCategorySerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryTypeAdapter.kt similarity index 61% rename from src/main/kotlin/com/lambda/config/serializers/ConfigCategorySerializer.kt rename to src/main/kotlin/com/lambda/config/serializers/ConfigCategoryTypeAdapter.kt index 9219087f4..109fb5734 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ConfigCategorySerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryTypeAdapter.kt @@ -22,33 +22,38 @@ package com.lambda.config.serializers import com.lambda.config.Config import com.lambda.config.Config.SettingLayer import com.lambda.config.ConfigCategory -import com.lambda.config.Serializer import com.lambda.config.Setting +import com.lambda.config.TypeAdapter +import com.lambda.config.migration.ConfigMigrationHandler import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.JsonNode import tools.jackson.databind.SerializationContext -import tools.jackson.databind.deser.std.StdDeserializer -import tools.jackson.databind.ser.std.StdSerializer -object ConfigCategorySerializer : Serializer() { +object ConfigCategoryTypeAdapter : TypeAdapter() { override val type = ConfigCategory::class.java - override val serializer = object : StdSerializer(type) { + override val serializer = object : Serializer(type) { override fun serialize(category: ConfigCategory, gen: JsonGenerator, ctxt: SerializationContext) { gen.writeStartObject() + val latestSchemaVersion = ConfigMigrationHandler.latestVersion(category) + if (latestSchemaVersion > 1) { + gen.writeNumberProperty( + ConfigMigrationHandler.schemaVersionKey(category) ?: ConfigMigrationHandler.DefaultSchemaVersionKey, + latestSchemaVersion + ) + } category.configs.forEach { config -> val serialized = mapper.valueToTree(config) if (serialized.isEmpty) return@forEach - gen.writeName(config.name) - gen.writeTree(serialized) + gen.writePOJOProperty(config.name, serialized) } gen.writeEndObject() } } - override val deSerializer = object : StdDeserializer(type) { + override val deserializer = object : Deserializer(type) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext): ConfigCategory { throw initFromJsonException("ConfigCategory") } @@ -64,10 +69,10 @@ object ConfigCategorySerializer : Serializer() { } } -object ConfigSerializer : Serializer() { +object ConfigTypeAdapter : TypeAdapter() { override val type = Config::class.java - override val serializer = object : StdSerializer(type) { + override val serializer = object : Serializer(type) { override fun serialize(config: Config, gen: JsonGenerator, ctxt: SerializationContext) { gen.writeObjectPropertyStart(config.name) .writePOJO(config.settingLayers) @@ -75,7 +80,7 @@ object ConfigSerializer : Serializer() { } } - override val deSerializer = object : StdDeserializer(type) { + override val deserializer = object : Deserializer(type) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Config { throw initFromJsonException("Config") } @@ -85,22 +90,24 @@ object ConfigSerializer : Serializer() { } } -object MultipleSerializer : Serializer() { +object MultipleTypeAdapter : TypeAdapter() { override val type = SettingLayer.Multiple::class.java - override val serializer = object : StdSerializer(type) { + override val serializer = object : Serializer(type) { override fun serialize(multiple: SettingLayer.Multiple, gen: JsonGenerator, ctxt: SerializationContext) { val notRoot = multiple !is SettingLayer.Root if (notRoot) gen.writeObjectPropertyStart(multiple.name) multiple.layers.forEach { layer -> if (layer is SettingLayer.Single<*, *> && !layer.setting.isModified) return@forEach - gen.writePOJOProperty(layer.name, layer) + val serialized = mapper.valueToTree(layer) + if (serialized.isObject && serialized.isEmpty) return@forEach + gen.writePOJOProperty(layer.name, serialized) } if (notRoot) gen.writeEndObject() } } - override val deSerializer = object : StdDeserializer(type) { + override val deserializer = object : Deserializer(type) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SettingLayer.Multiple { throw initFromJsonException("Multiple") } @@ -116,28 +123,47 @@ object MultipleSerializer : Serializer() { } } -object SingleSerializer : Serializer>() { +object SingleTypeAdapter : TypeAdapter>() { override val type = SettingLayer.Single::class.java - override val serializer = object : StdSerializer>(type) { + override val serializer = object : Serializer>(type) { override fun serialize(single: SettingLayer.Single<*, *>, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writePOJOProperty(single.name, single.setting.value) + gen.writePOJOProperty(single.name, single.setting) } } - override val deSerializer = object : StdDeserializer>(type) { + override val deserializer = object : Deserializer>(type) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SettingLayer.Single<*, *> { throw initFromJsonException("Single") } override fun deserialize(p: JsonParser, ctxt: DeserializationContext, single: SettingLayer.Single<*, *>) = - single.apply { - try { - @Suppress("unchecked_cast") - (setting as Setting<*, Any>).value = p.readValueAs(setting.value.javaClass) - } catch (e: Throwable) { - throw IllegalStateException("Failed to deserialize setting '${setting.name}'", e) - } + try { + single.apply { mapper.updateValue(setting, mapper.readTree(p)) } + } catch (e: Throwable) { + throw IllegalStateException("Failed to deserialize setting '${single.name}'", e) + } + } +} + +object SettingTypeAdapter : TypeAdapter>() { + override val type = Setting::class.java + + override val serializer = object : Serializer>(type) { + override fun serialize(setting: Setting<*, *>, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writePOJOProperty(setting.name, setting.value) + } + } + + override val deserializer = object : Deserializer>(type) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Setting<*, *>? { + throw initFromJsonException("Setting") + } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, setting: Setting<*, *>) = + setting.apply { + @Suppress("unchecked_cast") + (this as Setting<*, Any>).core.coreValue = p.readValueAs(value.javaClass) } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/FunctionSettingTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/FunctionSettingTypeAdapter.kt new file mode 100644 index 000000000..6d3faf219 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/serializers/FunctionSettingTypeAdapter.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config.serializers + +import com.lambda.config.TypeAdapter +import com.lambda.config.settings.FunctionSetting +import tools.jackson.core.JsonGenerator +import tools.jackson.core.JsonParser +import tools.jackson.databind.DeserializationContext +import tools.jackson.databind.SerializationContext + +@Suppress("unused") +object FunctionSettingTypeAdapter : TypeAdapter>() { + override val type = FunctionSetting::class.java + + override val serializer = object : Serializer>(type) { + override fun serialize(functionSetting: FunctionSetting<*>, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeNull() + } + } + + override val deserializer = object : Deserializer>(type) { + override fun deserialize(p: JsonParser?, ctxt: DeserializationContext?): FunctionSetting<*>? { + throw initFromJsonException("FunctionSetting") + } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, functionSetting: FunctionSetting<*>) = functionSetting + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/ItemStackSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ItemStackTypeAdapter.kt similarity index 80% rename from src/main/kotlin/com/lambda/config/serializers/ItemStackSerializer.kt rename to src/main/kotlin/com/lambda/config/serializers/ItemStackTypeAdapter.kt index 0b4cbbc88..2d8da37f2 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ItemStackSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ItemStackTypeAdapter.kt @@ -18,27 +18,25 @@ package com.lambda.config.serializers import com.lambda.config.JsonOps -import com.lambda.config.Serializer import com.lambda.config.Stringifiable +import com.lambda.config.TypeAdapter import net.minecraft.item.ItemStack import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.SerializationContext -import tools.jackson.databind.deser.std.StdDeserializer -import tools.jackson.databind.ser.std.StdSerializer @Suppress("unused") -object ItemStackSerializer : Serializer(), Stringifiable { +object ItemStackTypeAdapter : TypeAdapter(), Stringifiable { override val type = ItemStack::class.java - override val serializer = object : StdSerializer(type) { + override val serializer = object : Serializer(type) { override fun serialize(itemStack: ItemStack, gen: JsonGenerator, ctxt: SerializationContext) { gen.writeTree(ItemStack.CODEC.encodeStart(JsonOps.Uncompressed, itemStack).orThrow) } } - override val deSerializer = object : StdDeserializer(type) { + override val deserializer = object : Deserializer(type) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext) = ItemStack.CODEC.parse(JsonOps.Uncompressed, p.readValueAsTree()).orThrow } diff --git a/src/main/kotlin/com/lambda/config/serializers/ItemSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ItemTypeAdapter.kt similarity index 81% rename from src/main/kotlin/com/lambda/config/serializers/ItemSerializer.kt rename to src/main/kotlin/com/lambda/config/serializers/ItemTypeAdapter.kt index 9d9b7b49c..7ca90cc00 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ItemSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ItemTypeAdapter.kt @@ -17,8 +17,8 @@ package com.lambda.config.serializers -import com.lambda.config.Serializer import com.lambda.config.Stringifiable +import com.lambda.config.TypeAdapter import net.minecraft.item.Item import net.minecraft.registry.Registries import net.minecraft.util.Identifier @@ -26,19 +26,17 @@ import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.SerializationContext -import tools.jackson.databind.deser.std.StdDeserializer -import tools.jackson.databind.ser.std.StdSerializer -object ItemSerializer : Serializer(), Stringifiable { +object ItemTypeAdapter : TypeAdapter(), Stringifiable { override val type = Item::class.java - override val serializer = object : StdSerializer(type) { + override val serializer = object : Serializer(type) { override fun serialize(item: Item, gen: JsonGenerator, ctxt: SerializationContext) { gen.writeString(item.toString()) } } - override val deSerializer = object : StdDeserializer(type) { + override val deserializer = object : Deserializer(type) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Item { return Registries.ITEM.get(Identifier.of(p.valueAsString)) } diff --git a/src/main/kotlin/com/lambda/config/serializers/KeyCodeSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/KeyCodeTypeAdapter.kt similarity index 79% rename from src/main/kotlin/com/lambda/config/serializers/KeyCodeSerializer.kt rename to src/main/kotlin/com/lambda/config/serializers/KeyCodeTypeAdapter.kt index 3a56ddd66..f132d6a7f 100644 --- a/src/main/kotlin/com/lambda/config/serializers/KeyCodeSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/KeyCodeTypeAdapter.kt @@ -17,26 +17,24 @@ package com.lambda.config.serializers -import com.lambda.config.Serializer +import com.lambda.config.TypeAdapter import com.lambda.util.KeyCode import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.SerializationContext -import tools.jackson.databind.deser.std.StdDeserializer -import tools.jackson.databind.ser.std.StdSerializer @Suppress("unused") -object KeyCodeSerializer : Serializer() { +object KeyCodeTypeAdapter : TypeAdapter() { override val type = KeyCode::class.java - override val serializer = object : StdSerializer(type) { + override val serializer = object : Serializer(type) { override fun serialize(keyCode: KeyCode, gen: JsonGenerator, ctxt: SerializationContext) { gen.writeString(keyCode.name) } } - override val deSerializer = object : StdDeserializer(type) { + override val deserializer = object : Deserializer(type) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext) = KeyCode.fromKeyName(p.readValueAs(String::class.java)) } diff --git a/src/main/kotlin/com/lambda/config/serializers/TextSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/TextTypeAdapter.kt similarity index 81% rename from src/main/kotlin/com/lambda/config/serializers/TextSerializer.kt rename to src/main/kotlin/com/lambda/config/serializers/TextTypeAdapter.kt index 6363c3087..95277c5e8 100644 --- a/src/main/kotlin/com/lambda/config/serializers/TextSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/TextTypeAdapter.kt @@ -18,27 +18,25 @@ package com.lambda.config.serializers import com.lambda.config.JsonOps -import com.lambda.config.Serializer +import com.lambda.config.TypeAdapter import net.minecraft.text.Text import net.minecraft.text.TextCodecs import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.SerializationContext -import tools.jackson.databind.deser.std.StdDeserializer -import tools.jackson.databind.ser.std.StdSerializer @Suppress("unused") -object TextSerializer : Serializer() { +object TextTypeAdapter : TypeAdapter() { override val type = Text::class.java - override val serializer = object : StdSerializer(type) { + override val serializer = object : Serializer(type) { override fun serialize(text: Text, gen: JsonGenerator, ctxt: SerializationContext) { gen.writeTree(TextCodecs.CODEC.encodeStart(JsonOps.Uncompressed, text).orThrow) } } - override val deSerializer = object : StdDeserializer(type) { + override val deserializer = object : Deserializer(type) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext) = TextCodecs.CODEC.parse(JsonOps.Uncompressed, p.readValueAsTree()).orThrow } diff --git a/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/UuidTypeAdapter.kt similarity index 80% rename from src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt rename to src/main/kotlin/com/lambda/config/serializers/UuidTypeAdapter.kt index 888c96b2b..4782c5365 100644 --- a/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/UuidTypeAdapter.kt @@ -17,35 +17,34 @@ package com.lambda.config.serializers -import com.lambda.config.Serializer +import com.fasterxml.jackson.core.JsonParseException import com.lambda.config.Stringifiable +import com.lambda.config.TypeAdapter import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.JsonNode import tools.jackson.databind.SerializationContext -import tools.jackson.databind.deser.std.StdDeserializer -import tools.jackson.databind.ser.std.StdSerializer import java.util.* @Suppress("unused") -object UuidSerializer : Serializer(), Stringifiable { +object UuidTypeAdapter : TypeAdapter(), Stringifiable { override val type = UUID::class.java - override val serializer = object : StdSerializer(type) { + override val serializer = object : Serializer(type) { override fun serialize(uuid: UUID, gen: JsonGenerator, ctxt: SerializationContext) { gen.writeString(uuid.toString()) } } - override val deSerializer = object : StdDeserializer(type) { + override val deserializer = object : Deserializer(type) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext): UUID { val jsonNode = p.readValueAsTree() val rawId = when { jsonNode.isString -> jsonNode.stringValue() jsonNode.isObject && jsonNode.has("id") -> jsonNode.get("id").stringValue() - else -> throw IllegalStateException("Cannot deserialize UUID from: $jsonNode") + else -> throw JsonParseException("Cannot deserialize UUID from: $jsonNode") } val parsedId = if (rawId.length == 32) diff --git a/src/main/kotlin/com/lambda/config/settings/CharSetting.kt b/src/main/kotlin/com/lambda/config/settings/CharSetting.kt index 712616fda..b28f8de39 100644 --- a/src/main/kotlin/com/lambda/config/settings/CharSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/CharSetting.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings -import com.google.gson.reflect.TypeToken import com.lambda.brigadier.CommandResult.Companion.failure import com.lambda.brigadier.CommandResult.Companion.success import com.lambda.brigadier.argument.value @@ -34,8 +33,7 @@ import net.minecraft.command.CommandRegistryAccess * @see [com.lambda.config.Config] */ class CharSetting(defaultValue: Char) : SettingCore( - defaultValue, - TypeToken.get(Char::class.java).type + defaultValue ) { context(_: Setting<*, Char>) override fun ImGuiBuilder.buildLayout() {} diff --git a/src/main/kotlin/com/lambda/config/settings/FunctionSetting.kt b/src/main/kotlin/com/lambda/config/settings/FunctionSetting.kt index f46f69da2..035f99847 100644 --- a/src/main/kotlin/com/lambda/config/settings/FunctionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/FunctionSetting.kt @@ -17,23 +17,16 @@ package com.lambda.config.settings -import com.google.gson.JsonElement -import com.google.gson.JsonNull -import com.google.gson.reflect.TypeToken import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.gui.dsl.ImGuiBuilder open class FunctionSetting(defaultValue: () -> T) : SettingCore<() -> T>( - defaultValue, - TypeToken.get(defaultValue::class.java).type + defaultValue ) { context(setting: Setting<*, () -> T>) override fun ImGuiBuilder.buildLayout() { - button(setting.name) { value() } + button(setting.name) { coreValue() } lambdaTooltip(setting.description) } - - override fun toJson(): JsonElement = JsonNull.INSTANCE - override fun loadFromJson(serialized: JsonElement) { value = defaultValue } } diff --git a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt index 7c858cb67..265cd6792 100644 --- a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings -import com.google.gson.reflect.TypeToken import com.lambda.config.ConfigEditor import com.lambda.config.Setting import com.lambda.config.SettingCore @@ -39,18 +38,17 @@ abstract class NumericSetting( open var step: T, var unit: String ) : SettingCore( - defaultValue, - TypeToken.get(defaultValue::class.java).type + defaultValue ) where T : Number, T : Comparable { - override var value: T - get() = super.value + override var coreValue: T + get() = super.coreValue set(newVal) { - super.value = newVal.coerceIn(range) + super.coreValue = newVal.coerceIn(range) } private val formatter = NumberFormat.getNumberInstance(Locale.getDefault()) - override fun toString() = "${formatter.format(value)}$unit" + override fun toString() = "${formatter.format(coreValue)}$unit" /** * Subclasses must implement this to provide their specific slider widget. diff --git a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt index 9262164ec..c7fb1acc4 100644 --- a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings -import com.google.gson.reflect.TypeToken import com.lambda.brigadier.argument.greedyString import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute @@ -39,13 +38,12 @@ class StringSetting( var multiline: Boolean = false, var flags: Int = ImGuiInputTextFlags.None, ) : SettingCore( - defaultValue, - TypeToken.get(String::class.java).type + defaultValue ) { context(setting: Setting<*, String>) override fun ImGuiBuilder.buildLayout() { if (multiline) { - inputTextMultiline(setting.name, ::value, flags = flags) + inputTextMultiline(setting.name, ::coreValue, flags = flags) } else { inputText(setting.name, setting::value, flags) } diff --git a/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt index c22576a2e..e605f28a9 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt @@ -17,9 +17,9 @@ package com.lambda.config.settings.collections -import com.google.gson.reflect.TypeToken +import com.lambda.Lambda.typeFactory import com.lambda.config.Setting -import com.lambda.config.serializers.BlockSerializer +import com.lambda.config.serializers.BlockTypeAdapter import com.lambda.gui.dsl.ImGuiBuilder import net.minecraft.block.Block @@ -29,9 +29,9 @@ class BlockCollectionSetting( ) : CollectionSetting( defaultValue, immutableCollection, - TypeToken.getParameterized(Collection::class.java, Block::class.java).type, + typeFactory.constructCollectionType(MutableCollection::class.java, Block::class.java), serialize = true, ) { context(_: Setting<*, MutableCollection>) - override fun ImGuiBuilder.buildLayout() = buildDualPane("block") { BlockSerializer.stringify(it) } + override fun ImGuiBuilder.buildLayout() = buildDualPane("block") { BlockTypeAdapter.stringify(it) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt index 0ea823e8a..b444e13aa 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt @@ -17,9 +17,7 @@ package com.lambda.config.settings.collections -import com.google.gson.JsonElement -import com.google.gson.reflect.TypeToken -import com.lambda.Lambda.gson +import com.lambda.Lambda.typeFactory import com.lambda.config.Setting import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.util.ReflectionUtils.className @@ -29,27 +27,14 @@ import com.lambda.util.ReflectionUtils.className * @see [com.lambda.config.Config] */ class ClassCollectionSetting( - private val immutableCollection: Collection, + immutableCollection: Collection, defaultValue: MutableCollection ) : CollectionSetting( defaultValue, immutableCollection, - TypeToken.getParameterized(Collection::class.java, Any::class.java).type, + typeFactory.constructCollectionType(Collection::class.java, Any::class.java), serialize = false, ) { context(_: Setting<*, MutableCollection>) override fun ImGuiBuilder.buildLayout() = buildDualPane("item") { it.className } - - // When serializing the list to json we do not want to serialize the elements' classes, but their stringified representation. - // If we do serialize the classes we'll run into missing type adapters errors by Gson. - // This is intended behaviour. If you wish your collection settings to display something else then you must extend this class. - override fun toJson(): JsonElement = gson.toJsonTree(value.map { it.className }) - - override fun loadFromJson(serialized: JsonElement) { - val strList = gson.fromJson>(serialized, type) - .mapNotNull { str -> immutableCollection.find { it.className == str } } - .toMutableList() - - value = strList - } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt index 4e9dea970..ae780b01e 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt @@ -17,9 +17,6 @@ package com.lambda.config.settings.collections -import com.google.gson.JsonElement -import com.google.gson.reflect.TypeToken -import com.lambda.Lambda.gson import com.lambda.config.ConfigEditor import com.lambda.config.Setting import com.lambda.config.SettingCore @@ -35,7 +32,7 @@ import com.lambda.imgui.flag.ImGuiChildFlags import com.lambda.imgui.flag.ImGuiPopupFlags import com.lambda.imgui.flag.ImGuiSelectableFlags.DontClosePopups import com.lambda.threading.runSafe -import java.lang.reflect.Type +import tools.jackson.databind.JavaType /** * This generic collection settings handles all [Comparable] values (i.e., not classes) and serialize @@ -49,22 +46,19 @@ import java.lang.reflect.Type */ open class CollectionSetting( defaultValue: MutableCollection, - private var immutableCollection: Collection, - type: Type, - private val serialize: Boolean, + var immutableCollection: Collection, + val type: JavaType, + val serialize: Boolean, ) : SettingCore>( - defaultValue, - type + defaultValue ) { - override var value - get() = super.value + override var coreValue + get() = super.coreValue set(newVal) { - super.value = newVal.toMutableList() + super.coreValue = newVal.toMutableList() } private var searchFilter = "" - private val strListType = - TypeToken.getParameterized(Collection::class.java, String::class.java).type val selectListeners = mutableListOf Unit>() val deselectListeners = mutableListOf Unit>() @@ -74,10 +68,10 @@ open class CollectionSetting( context(setting: Setting<*, MutableCollection>) fun ImGuiBuilder.buildDualPane(itemName: String, toString: (R) -> String) { - val text = if (value.size == 1) itemName else "${itemName}s" + val text = if (settingValue.size == 1) itemName else "${itemName}s" val popupId = "##${setting.name}-collection-popup" - button("${setting.name}: ${value.size} $text") { + button("${setting.name}: ${settingValue.size} $text") { ImGui.openPopup(popupId) } @@ -87,9 +81,9 @@ open class CollectionSetting( val q = searchFilter.trim() val filteredDeselected = immutableCollection - .filter { item -> !value.contains(item) && (q.isEmpty() || toString(item).contains(q, ignoreCase = true)) } + .filter { item -> !settingValue.contains(item) && (q.isEmpty() || toString(item).contains(q, ignoreCase = true)) } val filteredSelected = immutableCollection - .filter { item -> value.contains(item) && (q.isEmpty() || toString(item).contains(q, ignoreCase = true)) } + .filter { item -> settingValue.contains(item) && (q.isEmpty() || toString(item).contains(q, ignoreCase = true)) } val availableWidth = getContentRegionAvail().x val swapButtonWidth = 30f @@ -111,7 +105,7 @@ open class CollectionSetting( label = toString(v), flags = DontClosePopups ) { - value.add(v) + settingValue.add(v) runSafe { selectListeners.forEach { listener -> listener(v) } } } } @@ -125,17 +119,17 @@ open class CollectionSetting( group { cursorPosY += paneHeight / 2f button("<>", swapButtonWidth) { - val currentlySelected = value.toList() + val currentlySelected = settingValue.toList() val allItems = immutableCollection.toList() - value.clear() + settingValue.clear() allItems.forEach { item -> if (!currentlySelected.contains(item)) { - value.add(item) + settingValue.add(item) } } runSafe { currentlySelected.forEach { v -> deselectListeners.forEach { listener -> listener(v) } } - value.forEach { v -> selectListeners.forEach { listener -> listener(v) } } + settingValue.forEach { v -> selectListeners.forEach { listener -> listener(v) } } } } } @@ -157,7 +151,7 @@ open class CollectionSetting( label = toString(v), flags = DontClosePopups ) { - value.remove(v) + settingValue.remove(v) runSafe { deselectListeners.forEach { listener -> listener(v) } } } } @@ -168,19 +162,6 @@ open class CollectionSetting( } } - override fun toJson(): JsonElement = - gson.toJsonTree(value, type) - - override fun loadFromJson(serialized: JsonElement) { - val strList = - if (serialize) gson.fromJson(serialized, type) - else gson.fromJson>(serialized, strListType) - .mapNotNull { str -> immutableCollection.find { it.toString() == str } } - .toMutableList() - - value = strList - } - @Suppress("unused") companion object { @SettingDsl diff --git a/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt index 45980b614..3920dda15 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt @@ -17,9 +17,9 @@ package com.lambda.config.settings.collections -import com.google.gson.reflect.TypeToken +import com.lambda.Lambda.typeFactory import com.lambda.config.Setting -import com.lambda.config.serializers.ItemSerializer +import com.lambda.config.serializers.ItemTypeAdapter import com.lambda.gui.dsl.ImGuiBuilder import net.minecraft.item.Item @@ -29,9 +29,9 @@ class ItemCollectionSetting( ) : CollectionSetting( defaultValue, immutableCollection, - TypeToken.getParameterized(Collection::class.java, Item::class.java).type, + typeFactory.constructCollectionType(Collection::class.java, Item::class.java), serialize = true, ) { context(_: Setting<*, MutableCollection>) - override fun ImGuiBuilder.buildLayout() = buildDualPane("item") { ItemSerializer.stringify(it) } + override fun ImGuiBuilder.buildLayout() = buildDualPane("item") { ItemTypeAdapter.stringify(it) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt index 683098db6..93037c252 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt @@ -20,17 +20,16 @@ package com.lambda.config.settings.collections import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.gui.dsl.ImGuiBuilder -import java.lang.reflect.Type +import tools.jackson.databind.JavaType /** * @see [com.lambda.config.Config] */ class MapSetting( defaultValue: MutableMap, - type: Type + val type: JavaType ) : SettingCore>( - defaultValue, - type + defaultValue ) { context(_: Setting<*, MutableMap>) override fun ImGuiBuilder.buildLayout() {} diff --git a/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt b/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt index 40506cb29..54647ad29 100644 --- a/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings.comparable -import com.google.gson.reflect.TypeToken import com.lambda.brigadier.argument.boolean import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute @@ -32,8 +31,7 @@ import net.minecraft.command.CommandRegistryAccess * @see [com.lambda.config.Config] */ class BooleanSetting(defaultValue: Boolean) : SettingCore( - defaultValue, - TypeToken.get(Boolean::class.java).type + defaultValue ) { context(setting: Setting<*, Boolean>) override fun ImGuiBuilder.buildLayout() { diff --git a/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt b/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt index 6ebd589e5..1f51fae31 100644 --- a/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings.comparable -import com.google.gson.reflect.TypeToken import com.lambda.brigadier.CommandResult.Companion.failure import com.lambda.brigadier.CommandResult.Companion.success import com.lambda.brigadier.argument.value @@ -37,21 +36,20 @@ import net.minecraft.command.CommandRegistryAccess * @see [com.lambda.config.Config] */ class EnumSetting>(defaultValue: T) : SettingCore( - defaultValue, - TypeToken.get(defaultValue.declaringJavaClass).type + defaultValue ) { context(setting: Setting<*, T>) override fun ImGuiBuilder.buildLayout() { - val values = value.enumValues - val currentDisplay = value.displayValue - val currentIndex = value.ordinal + val values = settingValue.enumValues + val currentDisplay = settingValue.displayValue + val currentIndex = settingValue.ordinal combo("##${setting.name}", preview = "${setting.name}: $currentDisplay") { values.forEachIndexed { idx, v -> val isSelected = idx == currentIndex selectable(v.displayValue, isSelected) { - if (!isSelected) internalValue = values[idx % values.size] + if (!isSelected) settingValue = values[idx % values.size] } (v as? Describable)?.let { lambdaTooltip(it.description) } @@ -65,11 +63,11 @@ class EnumSetting>(defaultValue: T) : SettingCore( override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { required(word(setting.name)) { parameter -> suggests { _, builder -> - value.enumValues.forEach { builder.suggest(it.name.capitalize()) } + settingValue.enumValues.forEach { builder.suggest(it.name.capitalize()) } builder.buildFuture() } executeWithResult { - val newValue = value.enumValues.find { it.name.equals(parameter().value(), true) } + val newValue = settingValue.enumValues.find { it.name.equals(parameter().value(), true) } ?: return@executeWithResult failure("Invalid value") setting.trySetValue(newValue) return@executeWithResult success() diff --git a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt index 8bc616d5e..067c2428b 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings.complex -import com.google.gson.reflect.TypeToken import com.lambda.Lambda.mc import com.lambda.brigadier.argument.integer import com.lambda.brigadier.argument.value @@ -37,20 +36,19 @@ import net.minecraft.util.math.BlockPos * @see [com.lambda.config.Config] */ class BlockPosSetting(defaultValue: BlockPos) : SettingCore( - defaultValue, - TypeToken.get(BlockPos::class.java).type + defaultValue ) { context(setting: Setting<*, BlockPos>) override fun ImGuiBuilder.buildLayout() { button("Set##${setting.name}") { mc.crosshairTarget?.blockResult?.blockPos?.let { - internalValue = it + settingValue = it } ?: info("No block under crosshair") } lambdaTooltip("Set the coordinates to the block you are currently looking at") sameLine() treeNode(setting.name, id = setting.name) { - inputVec3i("##${setting.name}", internalValue) { internalValue = it.blockPos } + inputVec3i("##${setting.name}", settingValue) { settingValue = it.blockPos } } lambdaTooltip(setting.description) } diff --git a/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt index 10b88f54c..edf99eeff 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings.complex -import com.google.gson.reflect.TypeToken import com.lambda.brigadier.argument.blockState import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute @@ -33,8 +32,7 @@ import net.minecraft.command.CommandRegistryAccess * @see [com.lambda.config.Config] */ class BlockSetting(defaultValue: Block) : SettingCore( - defaultValue, - TypeToken.get(Block::class.java).type + defaultValue ) { context(_: Setting<*, Block>) override fun ImGuiBuilder.buildLayout() {} diff --git a/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt index d17ef9710..0d44a41c5 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings.complex -import com.google.gson.reflect.TypeToken import com.lambda.brigadier.argument.integer import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute @@ -34,8 +33,7 @@ import java.awt.Color * @see [com.lambda.config.Config] */ class ColorSetting(defaultValue: Color) : SettingCore( - defaultValue, - TypeToken.get(Color::class.java).type + defaultValue ) { context(setting: Setting<*, Color>) override fun ImGuiBuilder.buildLayout() { diff --git a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt index bb7bb45d1..513458260 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt @@ -18,7 +18,6 @@ package com.lambda.config.settings.complex import com.fasterxml.jackson.annotation.JsonIgnore -import com.google.gson.reflect.TypeToken import com.lambda.brigadier.CommandResult.Companion.failure import com.lambda.brigadier.CommandResult.Companion.success import com.lambda.brigadier.argument.boolean @@ -60,8 +59,7 @@ class KeybindSetting( private val alwaysListening: Boolean, private val screenCheck: Boolean ) : SettingCore( - defaultValue, - TypeToken.get(Bind::class.java).type + defaultValue ), Muteable { constructor(defaultValue: KeyCode, muteable: Muteable?, alwaysListen: Boolean, screenCheck: Boolean) : this(Bind(defaultValue.code, 0, -1), muteable, alwaysListen, screenCheck) @@ -83,7 +81,7 @@ class KeybindSetting( private fun SafeContext.onButtonEvent(event: ButtonEvent) { if (mc.options.commandKey.isPressed || (screenCheck && mc.currentScreen != null) || - !event.satisfies(value)) return + !event.satisfies(coreValue)) return if (event.isPressed) { if (event.isRepeated) repeatListeners.forEach { it(event) } @@ -96,7 +94,7 @@ class KeybindSetting( text(setting.name) sameLine() - val bind = value + val bind = coreValue val preview = if (listening) "Press any key…" else bind.name @@ -127,7 +125,7 @@ class KeybindSetting( sameLine() withId("##Unbind-${this@KeybindSetting.hashCode()}") { smallButton("Unbind") { - internalValue = Bind.Empty + settingValue = Bind.Empty listening = false } } @@ -138,7 +136,7 @@ class KeybindSetting( if (listening) { InputUtils.newMouseEvent() ?.let { - internalValue = Bind(0, it.modifiers, it.button) + settingValue = Bind(0, it.modifiers, it.button) listening = false return } @@ -151,8 +149,8 @@ class KeybindSetting( if ((it.isPressed && !isModKey) || (it.isReleased && isModKey)) { when (it.translated) { KeyCode.Escape -> {} - KeyCode.Backspace, KeyCode.Delete -> value = Bind.Empty - else -> value = Bind(it.translated.code, it.modifiers, -1) + KeyCode.Backspace, KeyCode.Delete -> coreValue = Bind.Empty + else -> coreValue = Bind(it.translated.code, it.modifiers, -1) } listening = false diff --git a/src/main/kotlin/com/lambda/config/settings/complex/Vec3dSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/Vec3dSetting.kt index 91fd3489c..0db002a87 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/Vec3dSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/Vec3dSetting.kt @@ -17,7 +17,6 @@ package com.lambda.config.settings.complex -import com.google.gson.reflect.TypeToken import com.lambda.brigadier.argument.double import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute @@ -30,8 +29,7 @@ import net.minecraft.command.CommandRegistryAccess import net.minecraft.util.math.Vec3d class Vec3dSetting(defaultValue: Vec3d) : SettingCore( - defaultValue, - TypeToken.get(Vec3d::class.java).type + defaultValue ) { context(setting: Setting<*, Vec3d>) override fun ImGuiBuilder.buildLayout() { diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt index 468106de4..4311277cd 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt @@ -48,10 +48,10 @@ class DoubleSetting( context(setting: Setting<*, Double>) override fun ImGuiBuilder.buildSlider() { val maxIndex = ((range.endInclusive - range.start) / step).toInt() - val currentIndex = ((value - range.start) / step).roundToInt() + val currentIndex = ((coreValue - range.start) / step).roundToInt() val imInt = ImInt(currentIndex) slider("##${setting.name}", imInt, 0, maxIndex, "") { - internalValue = (range.start + imInt.get() * step) + settingValue = (range.start + imInt.get() * step) .roundToStep(step) .coerceIn(range) } diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt index 87241b2ab..f866a213f 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt @@ -47,10 +47,10 @@ class FloatSetting( context(setting: Setting<*, Float>) override fun ImGuiBuilder.buildSlider() { val maxIndex = ((range.endInclusive - range.start) / step).toInt() - val currentIndex = ((value - range.start) / step).roundToInt() + val currentIndex = ((coreValue - range.start) / step).roundToInt() val imInt = ImInt(currentIndex) slider("##${setting.name}", imInt, 0, maxIndex, "") { - internalValue = (range.start + imInt.get() * step) + settingValue = (range.start + imInt.get() * step) .roundToStep(step) .coerceIn(range) } diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt index b1f8f133a..f74245dd5 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt @@ -46,10 +46,10 @@ class LongSetting( override fun ImGuiBuilder.buildSlider() { // ToDo: No worky for super large numbers val maxIndex = ((range.endInclusive - range.start) / step).toInt() - val currentIndex = ((value - range.start) / step).toInt() + val currentIndex = ((coreValue - range.start) / step).toInt() val imInt = ImInt(currentIndex) slider("##${setting.name}", imInt, 0, maxIndex, "") { - internalValue = (range.start + imInt.get() * step).coerceIn(range) + settingValue = (range.start + imInt.get() * step).coerceIn(range) } } diff --git a/src/main/kotlin/com/lambda/gui/MenuBar.kt b/src/main/kotlin/com/lambda/gui/MenuBar.kt index d6636bf3d..b54ab77f1 100644 --- a/src/main/kotlin/com/lambda/gui/MenuBar.kt +++ b/src/main/kotlin/com/lambda/gui/MenuBar.kt @@ -122,9 +122,9 @@ object MenuBar { info("Saved ${ConfigLoader.configCategories.size} configuration files.") } ConfigLoader.configCategories.forEach { config -> - menuItem("Save ${config.configName}") { + menuItem("Save ${config.name}") { config.trySaveToFile(true) - info("Saved ${config.configName}") + info("Saved ${config.name}") } } } @@ -134,9 +134,9 @@ object MenuBar { info("Loaded ${ConfigLoader.configCategories.size} configuration files.") } ConfigLoader.configCategories.forEach { config -> - menuItem("Load ${config.configName}") { + menuItem("Load ${config.name}") { config.tryLoadFromFile() - info("Loaded ${config.configName}") + info("Loaded ${config.name}") } } } diff --git a/src/main/kotlin/com/lambda/network/LambdaHttp.kt b/src/main/kotlin/com/lambda/network/LambdaHttp.kt index fb1f780cf..9062a40a0 100644 --- a/src/main/kotlin/com/lambda/network/LambdaHttp.kt +++ b/src/main/kotlin/com/lambda/network/LambdaHttp.kt @@ -17,19 +17,18 @@ package com.lambda.network -import com.lambda.Lambda import io.ktor.client.* import io.ktor.client.plugins.contentnegotiation.* import io.ktor.client.request.* import io.ktor.client.statement.* import io.ktor.http.* +import io.ktor.serialization.jackson.* import java.io.File import java.io.OutputStream val LambdaHttp = HttpClient { install(ContentNegotiation) { - // Use our gson instance - register(ContentType.Application.Json, GsonConverter(Lambda.gson)) + register(ContentType.Application.Json, JacksonConverter()) } } diff --git a/src/main/kotlin/com/lambda/network/NetworkHandler.kt b/src/main/kotlin/com/lambda/network/NetworkHandler.kt index 065ddeb78..72d1e7cf8 100644 --- a/src/main/kotlin/com/lambda/network/NetworkHandler.kt +++ b/src/main/kotlin/com/lambda/network/NetworkHandler.kt @@ -17,6 +17,7 @@ package com.lambda.network +import com.lambda.Lambda.mapper import com.lambda.Lambda.mc import com.lambda.config.Config import com.lambda.config.categories.SecretsCategory @@ -24,7 +25,6 @@ import com.lambda.core.Loadable import com.lambda.network.api.v1.models.Authentication import com.lambda.network.api.v1.models.Authentication.Data import com.lambda.util.StringUtils.base64UrlDecode -import com.lambda.util.StringUtils.json import com.lambda.util.collections.updatableLazy object NetworkHandler : Config( @@ -43,7 +43,7 @@ object NetworkHandler : Config( if (parts.size != 3) return@updatableLazy null val payload = parts[1] - val data = payload.base64UrlDecode().json() + val data = mapper.readValue(payload.base64UrlDecode(), Data::class.java) return@updatableLazy if (System.currentTimeMillis() < data.expirationDate) null else data diff --git a/src/main/kotlin/com/lambda/network/api/v1/models/Authentication.kt b/src/main/kotlin/com/lambda/network/api/v1/models/Authentication.kt index f91d78e7d..3a5cbf243 100644 --- a/src/main/kotlin/com/lambda/network/api/v1/models/Authentication.kt +++ b/src/main/kotlin/com/lambda/network/api/v1/models/Authentication.kt @@ -17,29 +17,29 @@ package com.lambda.network.api.v1.models -import com.google.gson.annotations.SerializedName +import com.fasterxml.jackson.annotation.JsonProperty data class Authentication( - @SerializedName("access_token") + @JsonProperty("access_token") val accessToken: String, - @SerializedName("expires_in") + @JsonProperty("expires_in") val expiresIn: Long, - @SerializedName("token_type") + @JsonProperty("token_type") val tokenType: String, ) { data class Data( - @SerializedName("nbf") + @JsonProperty("nbf") val notBefore: Long, - @SerializedName("iat") + @JsonProperty("iat") val issuedAt: Long, - @SerializedName("exp") + @JsonProperty("exp") val expirationDate: Long, - @SerializedName("data") + @JsonProperty("data") val data: Player, ) } diff --git a/src/main/kotlin/com/lambda/network/api/v1/models/Cape.kt b/src/main/kotlin/com/lambda/network/api/v1/models/Cape.kt index 30853200e..ae22cb2b0 100644 --- a/src/main/kotlin/com/lambda/network/api/v1/models/Cape.kt +++ b/src/main/kotlin/com/lambda/network/api/v1/models/Cape.kt @@ -17,15 +17,15 @@ package com.lambda.network.api.v1.models -import com.google.gson.annotations.SerializedName +import com.fasterxml.jackson.annotation.JsonProperty import com.lambda.network.LambdaAPI import java.util.* class Cape( - @SerializedName("uuid") + @JsonProperty("uuid") val uuid: UUID, - @SerializedName("type") + @JsonProperty("type") val id: String, ) { val url: String diff --git a/src/main/kotlin/com/lambda/network/api/v1/models/Player.kt b/src/main/kotlin/com/lambda/network/api/v1/models/Player.kt index a8f8137dc..fc3b52b1f 100644 --- a/src/main/kotlin/com/lambda/network/api/v1/models/Player.kt +++ b/src/main/kotlin/com/lambda/network/api/v1/models/Player.kt @@ -17,20 +17,20 @@ package com.lambda.network.api.v1.models -import com.google.gson.annotations.SerializedName +import com.fasterxml.jackson.annotation.JsonProperty import java.util.* data class Player( - @SerializedName("name") + @JsonProperty("name") val name: String, - @SerializedName("id") + @JsonProperty("id") val uuid: UUID, - @SerializedName("discord_id") + @JsonProperty("discord_id") val discordId: String, // Whether the player is verified or not - @SerializedName("unsafe") + @JsonProperty("unsafe") val unsafe: Boolean, ) diff --git a/src/main/kotlin/com/lambda/util/StringUtils.kt b/src/main/kotlin/com/lambda/util/StringUtils.kt index 65660b4d9..e42936e68 100644 --- a/src/main/kotlin/com/lambda/util/StringUtils.kt +++ b/src/main/kotlin/com/lambda/util/StringUtils.kt @@ -18,7 +18,6 @@ package com.lambda.util import com.lambda.Lambda -import com.lambda.Lambda.gson import net.minecraft.util.Identifier import java.security.MessageDigest import java.util.* @@ -90,8 +89,6 @@ object StringUtils { return cost[len0 - 1] } - inline fun String.json() = gson.fromJson(this, T::class.java) - fun String.base64UrlDecode() = Base64.getUrlDecoder().decode(toByteArray()).decodeToString() /** From f4236222ade8012cbb127b46aa1e7282439789fa Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Fri, 29 May 2026 03:33:32 +0100 Subject: [PATCH 32/40] actually loads. Some small issues still --- src/main/kotlin/com/lambda/Lambda.kt | 13 +++- .../com/lambda/config/ConfigCategory.kt | 2 +- .../com/lambda/config/FallbackTypeAdapters.kt | 63 +++++++++++++++++++ .../kotlin/com/lambda/config/TypeAdapter.kt | 8 ++- .../config/serializers/BlockTypeAdapter.kt | 2 +- .../ClassCollectionSettingTypeAdapter.kt | 3 +- .../CollectionSettingTypeAdapter.kt | 6 +- ...t => ConfigCategoryFallbackTypeAdapter.kt} | 25 ++++---- .../serializers/ItemStackTypeAdapter.kt | 2 +- .../config/serializers/KeyCodeTypeAdapter.kt | 2 +- .../config/serializers/TextTypeAdapter.kt | 2 +- .../config/serializers/UuidTypeAdapter.kt | 3 +- 12 files changed, 105 insertions(+), 26 deletions(-) create mode 100644 src/main/kotlin/com/lambda/config/FallbackTypeAdapters.kt rename src/main/kotlin/com/lambda/config/serializers/{ConfigCategoryTypeAdapter.kt => ConfigCategoryFallbackTypeAdapter.kt} (88%) diff --git a/src/main/kotlin/com/lambda/Lambda.kt b/src/main/kotlin/com/lambda/Lambda.kt index 99e94e90b..33cbd5758 100644 --- a/src/main/kotlin/com/lambda/Lambda.kt +++ b/src/main/kotlin/com/lambda/Lambda.kt @@ -18,6 +18,8 @@ package com.lambda import com.lambda.Lambda.mapper +import com.lambda.config.FallbackTypeAdapter +import com.lambda.config.FallbackTypeAdapters import com.lambda.config.TypeAdapter import com.lambda.core.Loader import com.lambda.event.events.ClientEvent @@ -34,6 +36,7 @@ import tools.jackson.databind.SerializationFeature import tools.jackson.databind.module.SimpleModule import tools.jackson.databind.type.TypeFactory import tools.jackson.module.kotlin.jsonMapper +import tools.jackson.module.kotlin.KotlinFeature import tools.jackson.module.kotlin.kotlinModule object Lambda : ClientModInitializer { @@ -63,11 +66,19 @@ object Lambda : ClientModInitializer { val mapper = jsonMapper { enable(SerializationFeature.INDENT_OUTPUT) addModules( - kotlinModule(), + kotlinModule { disable(KotlinFeature.SingletonSupport) }, SimpleModule().apply { getInstances>().forEach { registerable -> registerable.register() } + }, + object : SimpleModule() { + override fun setupModule(context: SetupContext) { + val fallbackSerializers = FallbackTypeAdapters(getInstances>().associateBy { it.type }) + context.addSerializers(fallbackSerializers) + context.addDeserializers(fallbackSerializers) + super.setupModule(context) + } } ) } diff --git a/src/main/kotlin/com/lambda/config/ConfigCategory.kt b/src/main/kotlin/com/lambda/config/ConfigCategory.kt index edc0b45e0..4a92699b3 100644 --- a/src/main/kotlin/com/lambda/config/ConfigCategory.kt +++ b/src/main/kotlin/com/lambda/config/ConfigCategory.kt @@ -89,7 +89,7 @@ abstract class ConfigCategory : Loadable { .onFailure { primaryError -> Log.error(primaryError) - runCatching { loadFromFile(backup) } + runCatching { loadFromFile(backup).getOrThrow() } .onSuccess { val message = "$name config category loaded from backup" Log.info(message) diff --git a/src/main/kotlin/com/lambda/config/FallbackTypeAdapters.kt b/src/main/kotlin/com/lambda/config/FallbackTypeAdapters.kt new file mode 100644 index 000000000..68e140832 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/FallbackTypeAdapters.kt @@ -0,0 +1,63 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config + +import com.fasterxml.jackson.annotation.JsonFormat +import tools.jackson.databind.* +import tools.jackson.databind.deser.Deserializers +import tools.jackson.databind.ser.Serializers + +class FallbackTypeAdapters( + private val fallbacks: Map, FallbackTypeAdapter<*>> +) : Serializers, Deserializers { + override fun findSerializer( + config: SerializationConfig, + type: JavaType, + beanDescRef: BeanDescription.Supplier, + formatOverrides: JsonFormat.Value? + ): ValueSerializer<*>? { + fallbacks.forEach { (baseType, typeAdapter) -> + val serializer = typeAdapter.serializer + if (baseType.isAssignableFrom(type.rawClass)) { + return serializer + } + } + return null + } + + override fun findBeanDeserializer( + type: JavaType, + config: DeserializationConfig, + beanDescRef: BeanDescription.Supplier + ): ValueDeserializer<*>? { + fallbacks.forEach { (baseType, typeAdapter) -> + val deserializer = typeAdapter.deserializer + if (baseType.isAssignableFrom(type.rawClass)) { + return deserializer + } + } + return null + } + + override fun hasDeserializerFor(config: DeserializationConfig, valueType: Class<*>?): Boolean { + if (valueType == null) return false + return fallbacks.any { (baseType, _) -> + baseType.isAssignableFrom(valueType) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/TypeAdapter.kt b/src/main/kotlin/com/lambda/config/TypeAdapter.kt index ed02ca35a..5c04ab99a 100644 --- a/src/main/kotlin/com/lambda/config/TypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/TypeAdapter.kt @@ -24,7 +24,7 @@ import tools.jackson.databind.ser.std.StdSerializer interface Stringifiable { fun stringify(value: T): String } -abstract class TypeAdapter { +abstract class BaseTypeAdapter { val mapper by lazy { Lambda.mapper } abstract val type: Class abstract val serializer: StdSerializer @@ -42,4 +42,8 @@ abstract class TypeAdapter { protected typealias Serializer = StdSerializer protected typealias Deserializer = StdDeserializer -} \ No newline at end of file +} + +abstract class FallbackTypeAdapter : BaseTypeAdapter() + +abstract class TypeAdapter : BaseTypeAdapter() \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/BlockTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/BlockTypeAdapter.kt index c752ff9dc..17e568509 100644 --- a/src/main/kotlin/com/lambda/config/serializers/BlockTypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/serializers/BlockTypeAdapter.kt @@ -38,7 +38,7 @@ object BlockTypeAdapter : TypeAdapter(), Stringifiable { override val deserializer = object : Deserializer(type) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext) = - Registries.BLOCK.codec.parse(JsonOps.Uncompressed, p.readValueAsTree()).orThrow + Registries.BLOCK.codec.parse(JsonOps.Uncompressed, mapper.readTree(p)).orThrow } override fun stringify(value: Block) = Registries.BLOCK.getId(value).path.replaceFirstChar { it.uppercase() } diff --git a/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingTypeAdapter.kt index 0f40547f0..507426f70 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingTypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingTypeAdapter.kt @@ -25,7 +25,6 @@ import com.lambda.util.ReflectionUtils.className import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext -import tools.jackson.databind.JsonNode import tools.jackson.databind.SerializationContext @Suppress("unused") @@ -57,7 +56,7 @@ object ClassCollectionSettingTypeAdapter : TypeAdapter settingCore: ClassCollectionSetting<*> ): ClassCollectionSetting<*> = settingCore.apply { - val arrayNode = p.readValueAsTree() + val arrayNode = mapper.readTree(p) if (!arrayNode.isArray) throw JsonParseException("ClassCollectionSetting's serialized value is not an array.") val classNames = mutableListOf() arrayNode.forEach { node -> diff --git a/src/main/kotlin/com/lambda/config/serializers/CollectionSettingTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/CollectionSettingTypeAdapter.kt index a90b12cb3..e03ec8bf7 100644 --- a/src/main/kotlin/com/lambda/config/serializers/CollectionSettingTypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/serializers/CollectionSettingTypeAdapter.kt @@ -23,7 +23,6 @@ import com.lambda.config.settings.collections.CollectionSetting import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext -import tools.jackson.databind.JsonNode import tools.jackson.databind.SerializationContext @Suppress("unused") @@ -53,10 +52,11 @@ object CollectionSettingTypeAdapter : TypeAdapter>() { val newValue = mutableListOf() if (serialize) { - val deserialized = mapper.readValue>(p, type) + val tree = mapper.readTree(p) + val deserialized = mapper.treeToValue>(tree, type) newValue.addAll(deserialized) } else { - val node = p.readValueAsTree() + val node = mapper.readTree(p) if (!node.isArray) throw JsonParseException("CollectionSetting's serialized value is not an array.") node.values().forEach { element -> if (!element.isString) throw JsonParseException("CollectionSetting's serialized array contains a non-string value. A CollectionSetting's JSON array must only contain strings if CollectionSetting.serialize is false.") diff --git a/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackTypeAdapter.kt similarity index 88% rename from src/main/kotlin/com/lambda/config/serializers/ConfigCategoryTypeAdapter.kt rename to src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackTypeAdapter.kt index 109fb5734..c172abdbc 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryTypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackTypeAdapter.kt @@ -19,11 +19,12 @@ package com.lambda.config.serializers +import com.lambda.Lambda.Log import com.lambda.config.Config import com.lambda.config.Config.SettingLayer import com.lambda.config.ConfigCategory import com.lambda.config.Setting -import com.lambda.config.TypeAdapter +import com.lambda.config.FallbackTypeAdapter import com.lambda.config.migration.ConfigMigrationHandler import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser @@ -31,7 +32,7 @@ import tools.jackson.databind.DeserializationContext import tools.jackson.databind.JsonNode import tools.jackson.databind.SerializationContext -object ConfigCategoryTypeAdapter : TypeAdapter() { +object ConfigCategoryFallbackTypeAdapter : FallbackTypeAdapter() { override val type = ConfigCategory::class.java override val serializer = object : Serializer(type) { @@ -69,7 +70,7 @@ object ConfigCategoryTypeAdapter : TypeAdapter() { } } -object ConfigTypeAdapter : TypeAdapter() { +object ConfigFallbackTypeAdapter : FallbackTypeAdapter() { override val type = Config::class.java override val serializer = object : Serializer(type) { @@ -90,7 +91,7 @@ object ConfigTypeAdapter : TypeAdapter() { } } -object MultipleTypeAdapter : TypeAdapter() { +object MultipleFallbackTypeAdapter : FallbackTypeAdapter() { override val type = SettingLayer.Multiple::class.java override val serializer = object : Serializer(type) { @@ -123,7 +124,7 @@ object MultipleTypeAdapter : TypeAdapter() { } } -object SingleTypeAdapter : TypeAdapter>() { +object SingleFallbackTypeAdapter : FallbackTypeAdapter>() { override val type = SettingLayer.Single::class.java override val serializer = object : Serializer>(type) { @@ -138,15 +139,17 @@ object SingleTypeAdapter : TypeAdapter>() { } override fun deserialize(p: JsonParser, ctxt: DeserializationContext, single: SettingLayer.Single<*, *>) = - try { - single.apply { mapper.updateValue(setting, mapper.readTree(p)) } - } catch (e: Throwable) { - throw IllegalStateException("Failed to deserialize setting '${single.name}'", e) + single.apply { + try { + mapper.updateValue(setting, mapper.readTree(p)) + } catch (e: Throwable) { + Log.error("Failed to deserialize setting '${name}'", e) + } } } } -object SettingTypeAdapter : TypeAdapter>() { +object SettingFallbackTypeAdapter : FallbackTypeAdapter>() { override val type = Setting::class.java override val serializer = object : Serializer>(type) { @@ -163,7 +166,7 @@ object SettingTypeAdapter : TypeAdapter>() { override fun deserialize(p: JsonParser, ctxt: DeserializationContext, setting: Setting<*, *>) = setting.apply { @Suppress("unchecked_cast") - (this as Setting<*, Any>).core.coreValue = p.readValueAs(value.javaClass) + (this as Setting<*, Any>).core.coreValue = mapper.treeToValue(mapper.readTree(p), value.javaClass) } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/ItemStackTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/ItemStackTypeAdapter.kt index 2d8da37f2..453f09a46 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ItemStackTypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ItemStackTypeAdapter.kt @@ -38,7 +38,7 @@ object ItemStackTypeAdapter : TypeAdapter(), Stringifiable override val deserializer = object : Deserializer(type) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext) = - ItemStack.CODEC.parse(JsonOps.Uncompressed, p.readValueAsTree()).orThrow + ItemStack.CODEC.parse(JsonOps.Uncompressed, mapper.readTree(p)).orThrow } override fun stringify(value: ItemStack) = value.itemName.string.uppercase() diff --git a/src/main/kotlin/com/lambda/config/serializers/KeyCodeTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/KeyCodeTypeAdapter.kt index f132d6a7f..16877a4ed 100644 --- a/src/main/kotlin/com/lambda/config/serializers/KeyCodeTypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/serializers/KeyCodeTypeAdapter.kt @@ -36,6 +36,6 @@ object KeyCodeTypeAdapter : TypeAdapter() { override val deserializer = object : Deserializer(type) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext) = - KeyCode.fromKeyName(p.readValueAs(String::class.java)) + KeyCode.fromKeyName(p.string) } } diff --git a/src/main/kotlin/com/lambda/config/serializers/TextTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/TextTypeAdapter.kt index 95277c5e8..39c09acd0 100644 --- a/src/main/kotlin/com/lambda/config/serializers/TextTypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/serializers/TextTypeAdapter.kt @@ -38,6 +38,6 @@ object TextTypeAdapter : TypeAdapter() { override val deserializer = object : Deserializer(type) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext) = - TextCodecs.CODEC.parse(JsonOps.Uncompressed, p.readValueAsTree()).orThrow + TextCodecs.CODEC.parse(JsonOps.Uncompressed, mapper.readTree(p)).orThrow } } diff --git a/src/main/kotlin/com/lambda/config/serializers/UuidTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/UuidTypeAdapter.kt index 4782c5365..35dae3072 100644 --- a/src/main/kotlin/com/lambda/config/serializers/UuidTypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/serializers/UuidTypeAdapter.kt @@ -23,7 +23,6 @@ import com.lambda.config.TypeAdapter import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext -import tools.jackson.databind.JsonNode import tools.jackson.databind.SerializationContext import java.util.* @@ -39,7 +38,7 @@ object UuidTypeAdapter : TypeAdapter(), Stringifiable { override val deserializer = object : Deserializer(type) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext): UUID { - val jsonNode = p.readValueAsTree() + val jsonNode = mapper.readTree(p) val rawId = when { jsonNode.isString -> jsonNode.stringValue() From 4916b56eab75b347dd174e3bf4bfc9e01b1b3341 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Fri, 29 May 2026 22:38:47 +0100 Subject: [PATCH 33/40] better serializer setup --- src/main/kotlin/com/lambda/Lambda.kt | 20 +- ...TypeAdapters.kt => FallbackSerializers.kt} | 34 ++-- .../config/{TypeAdapter.kt => Serializers.kt} | 44 +++-- ...BlockTypeAdapter.kt => BlockSerializer.kt} | 25 ++- .../ClassCollectionSettingSerializer.kt | 63 +++++++ .../ClassCollectionSettingTypeAdapter.kt | 73 -------- .../CollectionSettingSerializer.kt | 71 ++++++++ .../CollectionSettingTypeAdapter.kt | 73 -------- ...ColorTypeAdapter.kt => ColorSerializer.kt} | 38 ++-- .../ConfigCategoryFallbackSerializer.kt | 153 ++++++++++++++++ .../ConfigCategoryFallbackTypeAdapter.kt | 172 ------------------ ...dapter.kt => FunctionSettingSerializer.kt} | 28 ++- .../{ItemTypeAdapter.kt => ItemSerializer.kt} | 27 ++- ...kTypeAdapter.kt => ItemStackSerializer.kt} | 26 ++- ...odeTypeAdapter.kt => KeyCodeSerializer.kt} | 26 ++- .../{TextTypeAdapter.kt => TextSerializer.kt} | 26 ++- .../{UuidTypeAdapter.kt => UuidSerializer.kt} | 48 +++-- .../collections/BlockCollectionSetting.kt | 4 +- .../collections/ItemCollectionSetting.kt | 4 +- 19 files changed, 463 insertions(+), 492 deletions(-) rename src/main/kotlin/com/lambda/config/{FallbackTypeAdapters.kt => FallbackSerializers.kt} (61%) rename src/main/kotlin/com/lambda/config/{TypeAdapter.kt => Serializers.kt} (53%) rename src/main/kotlin/com/lambda/config/serializers/{BlockTypeAdapter.kt => BlockSerializer.kt} (63%) create mode 100644 src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingSerializer.kt delete mode 100644 src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingTypeAdapter.kt create mode 100644 src/main/kotlin/com/lambda/config/serializers/CollectionSettingSerializer.kt delete mode 100644 src/main/kotlin/com/lambda/config/serializers/CollectionSettingTypeAdapter.kt rename src/main/kotlin/com/lambda/config/serializers/{ColorTypeAdapter.kt => ColorSerializer.kt} (54%) create mode 100644 src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt delete mode 100644 src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackTypeAdapter.kt rename src/main/kotlin/com/lambda/config/serializers/{FunctionSettingTypeAdapter.kt => FunctionSettingSerializer.kt} (56%) rename src/main/kotlin/com/lambda/config/serializers/{ItemTypeAdapter.kt => ItemSerializer.kt} (68%) rename src/main/kotlin/com/lambda/config/serializers/{ItemStackTypeAdapter.kt => ItemStackSerializer.kt} (60%) rename src/main/kotlin/com/lambda/config/serializers/{KeyCodeTypeAdapter.kt => KeyCodeSerializer.kt} (62%) rename src/main/kotlin/com/lambda/config/serializers/{TextTypeAdapter.kt => TextSerializer.kt} (61%) rename src/main/kotlin/com/lambda/config/serializers/{UuidTypeAdapter.kt => UuidSerializer.kt} (50%) diff --git a/src/main/kotlin/com/lambda/Lambda.kt b/src/main/kotlin/com/lambda/Lambda.kt index 33cbd5758..51b4e51a8 100644 --- a/src/main/kotlin/com/lambda/Lambda.kt +++ b/src/main/kotlin/com/lambda/Lambda.kt @@ -18,9 +18,11 @@ package com.lambda import com.lambda.Lambda.mapper -import com.lambda.config.FallbackTypeAdapter -import com.lambda.config.FallbackTypeAdapters -import com.lambda.config.TypeAdapter +import com.lambda.config.Deserializer +import com.lambda.config.FallbackDeserializer +import com.lambda.config.FallbackSerializer +import com.lambda.config.FallbackSerializers +import com.lambda.config.Serializer import com.lambda.core.Loader import com.lambda.event.events.ClientEvent import com.lambda.event.listener.UnsafeListener.Companion.listenOnceUnsafe @@ -35,8 +37,8 @@ import org.apache.logging.log4j.Logger import tools.jackson.databind.SerializationFeature import tools.jackson.databind.module.SimpleModule import tools.jackson.databind.type.TypeFactory -import tools.jackson.module.kotlin.jsonMapper import tools.jackson.module.kotlin.KotlinFeature +import tools.jackson.module.kotlin.jsonMapper import tools.jackson.module.kotlin.kotlinModule object Lambda : ClientModInitializer { @@ -68,13 +70,15 @@ object Lambda : ClientModInitializer { addModules( kotlinModule { disable(KotlinFeature.SingletonSupport) }, SimpleModule().apply { - getInstances>().forEach { registerable -> - registerable.register() - } + getInstances>().forEach { it.register() } + getInstances>().forEach { it.register() } }, object : SimpleModule() { override fun setupModule(context: SetupContext) { - val fallbackSerializers = FallbackTypeAdapters(getInstances>().associateBy { it.type }) + val fallbackSerializers = FallbackSerializers( + getInstances>().associateBy { it.type }, + getInstances>().associateBy { it.type } + ) context.addSerializers(fallbackSerializers) context.addDeserializers(fallbackSerializers) super.setupModule(context) diff --git a/src/main/kotlin/com/lambda/config/FallbackTypeAdapters.kt b/src/main/kotlin/com/lambda/config/FallbackSerializers.kt similarity index 61% rename from src/main/kotlin/com/lambda/config/FallbackTypeAdapters.kt rename to src/main/kotlin/com/lambda/config/FallbackSerializers.kt index 68e140832..90991a59f 100644 --- a/src/main/kotlin/com/lambda/config/FallbackTypeAdapters.kt +++ b/src/main/kotlin/com/lambda/config/FallbackSerializers.kt @@ -18,12 +18,18 @@ package com.lambda.config import com.fasterxml.jackson.annotation.JsonFormat -import tools.jackson.databind.* +import tools.jackson.databind.BeanDescription +import tools.jackson.databind.DeserializationConfig +import tools.jackson.databind.JavaType +import tools.jackson.databind.SerializationConfig +import tools.jackson.databind.ValueDeserializer +import tools.jackson.databind.ValueSerializer import tools.jackson.databind.deser.Deserializers import tools.jackson.databind.ser.Serializers -class FallbackTypeAdapters( - private val fallbacks: Map, FallbackTypeAdapter<*>> +class FallbackSerializers( + val fallbackSerializers: Map, FallbackSerializer<*>>, + val fallbackDeserializers: Map, FallbackDeserializer<*>> ) : Serializers, Deserializers { override fun findSerializer( config: SerializationConfig, @@ -31,11 +37,8 @@ class FallbackTypeAdapters( beanDescRef: BeanDescription.Supplier, formatOverrides: JsonFormat.Value? ): ValueSerializer<*>? { - fallbacks.forEach { (baseType, typeAdapter) -> - val serializer = typeAdapter.serializer - if (baseType.isAssignableFrom(type.rawClass)) { - return serializer - } + fallbackSerializers.forEach { (baseType, serializer) -> + if (baseType.isAssignableFrom(type.rawClass)) return serializer } return null } @@ -45,19 +48,12 @@ class FallbackTypeAdapters( config: DeserializationConfig, beanDescRef: BeanDescription.Supplier ): ValueDeserializer<*>? { - fallbacks.forEach { (baseType, typeAdapter) -> - val deserializer = typeAdapter.deserializer - if (baseType.isAssignableFrom(type.rawClass)) { - return deserializer - } + fallbackDeserializers.forEach { (baseType, deserializer) -> + if (baseType.isAssignableFrom(type.rawClass)) return deserializer } return null } - override fun hasDeserializerFor(config: DeserializationConfig, valueType: Class<*>?): Boolean { - if (valueType == null) return false - return fallbacks.any { (baseType, _) -> - baseType.isAssignableFrom(valueType) - } - } + override fun hasDeserializerFor(config: DeserializationConfig, valueType: Class<*>?) = + valueType != null && fallbackDeserializers.any { (baseType, _) -> baseType.isAssignableFrom(valueType) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/TypeAdapter.kt b/src/main/kotlin/com/lambda/config/Serializers.kt similarity index 53% rename from src/main/kotlin/com/lambda/config/TypeAdapter.kt rename to src/main/kotlin/com/lambda/config/Serializers.kt index 5c04ab99a..2b26cf14a 100644 --- a/src/main/kotlin/com/lambda/config/TypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/Serializers.kt @@ -15,35 +15,51 @@ * along with this program. If not, see . */ +@file:Suppress("unused") + package com.lambda.config import com.lambda.Lambda import tools.jackson.databind.deser.std.StdDeserializer +import tools.jackson.databind.json.JsonMapper import tools.jackson.databind.module.SimpleModule import tools.jackson.databind.ser.std.StdSerializer +abstract class Serializer(type: Class) : BaseSerializer(type) +abstract class Deserializer(type: Class) : BaseDeserializer(type) + +abstract class FallbackSerializer(type: Class) : BaseSerializer(type) +abstract class FallbackDeserializer(type: Class) : BaseDeserializer(type) + interface Stringifiable { fun stringify(value: T): String } -abstract class BaseTypeAdapter { - val mapper by lazy { Lambda.mapper } - abstract val type: Class - abstract val serializer: StdSerializer - abstract val deserializer: StdDeserializer +sealed class BaseSerializer(final override val type: Class) : StdSerializer(type), JsonModRegisterable { + override val mapper by lazy { Lambda.mapper } context(simpleModule: SimpleModule) - fun register() { + override fun register() { with(simpleModule) { - addSerializer(type, serializer) - addDeserializer(type, deserializer) + addSerializer(type, this@BaseSerializer) } } +} +sealed class BaseDeserializer(final override val type: Class) : StdDeserializer(type), JsonModRegisterable { + override val mapper by lazy { Lambda.mapper } - fun initFromJsonException(objName: String) = IllegalStateException("Attempted to initialize a $objName directly from JSON! All $objName's should be updated after standard initialization.") - - protected typealias Serializer = StdSerializer - protected typealias Deserializer = StdDeserializer + context(simpleModule: SimpleModule) + override fun register() { + with(simpleModule) { + addDeserializer(type, this@BaseDeserializer) + } + } } -abstract class FallbackTypeAdapter : BaseTypeAdapter() +interface JsonModRegisterable { + val mapper: JsonMapper + val type: Class -abstract class TypeAdapter : BaseTypeAdapter() \ No newline at end of file + context(simpleModule: SimpleModule) + fun register() + + fun initFromJsonException(objName: String) = IllegalStateException("Attempted to initialize a $objName directly from JSON! All $objName's should be updated after standard initialization.") +} diff --git a/src/main/kotlin/com/lambda/config/serializers/BlockTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt similarity index 63% rename from src/main/kotlin/com/lambda/config/serializers/BlockTypeAdapter.kt rename to src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt index 17e568509..133e5937b 100644 --- a/src/main/kotlin/com/lambda/config/serializers/BlockTypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/serializers/BlockSerializer.kt @@ -15,11 +15,14 @@ * along with this program. If not, see . */ +@file:Suppress("unused") + package com.lambda.config.serializers +import com.lambda.config.Deserializer import com.lambda.config.JsonOps +import com.lambda.config.Serializer import com.lambda.config.Stringifiable -import com.lambda.config.TypeAdapter import net.minecraft.block.Block import net.minecraft.registry.Registries import tools.jackson.core.JsonGenerator @@ -27,19 +30,15 @@ import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.SerializationContext -object BlockTypeAdapter : TypeAdapter(), Stringifiable { - override val type = Block::class.java - - override val serializer = object : Serializer(type) { - override fun serialize(block: Block, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeTree((Registries.BLOCK.codec.encodeStart(JsonOps.Uncompressed, block).orThrow)) - } - } - - override val deserializer = object : Deserializer(type) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext) = - Registries.BLOCK.codec.parse(JsonOps.Uncompressed, mapper.readTree(p)).orThrow +object BlockSerializer : Serializer(Block::class.java), Stringifiable { + override fun serialize(block: Block, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeTree((Registries.BLOCK.codec.encodeStart(JsonOps.Uncompressed, block).orThrow)) } override fun stringify(value: Block) = Registries.BLOCK.getId(value).path.replaceFirstChar { it.uppercase() } } + +object BlockDeserializer : Deserializer(Block::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Block = + Registries.BLOCK.codec.parse(JsonOps.Uncompressed, mapper.readTree(p)).orThrow +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingSerializer.kt new file mode 100644 index 000000000..76fda4a2a --- /dev/null +++ b/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingSerializer.kt @@ -0,0 +1,63 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +@file:Suppress("unused") + +package com.lambda.config.serializers + +import com.fasterxml.jackson.core.JsonParseException +import com.lambda.config.Deserializer +import com.lambda.config.Serializer +import com.lambda.config.SettingCore +import com.lambda.config.settings.collections.ClassCollectionSetting +import com.lambda.util.ReflectionUtils.className +import tools.jackson.core.JsonGenerator +import tools.jackson.core.JsonParser +import tools.jackson.databind.DeserializationContext +import tools.jackson.databind.SerializationContext + +object ClassCollectionSettingSerializer : Serializer>(ClassCollectionSetting::class.java) { + override fun serialize(setting: ClassCollectionSetting<*>, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeStartArray() + setting.coreValue.forEach { element -> + gen.writeString(element.className) + } + gen.writeEndArray() + } +} + +object ClassCollectionSettingDeserializer : Deserializer>(ClassCollectionSetting::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): ClassCollectionSetting<*> { + throw initFromJsonException("ClassCollectionSetting") + } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, settingCore: ClassCollectionSetting<*>): ClassCollectionSetting<*> = + settingCore.apply { + val arrayNode = mapper.readTree(p) + if (!arrayNode.isArray) throw JsonParseException("ClassCollectionSetting's serialized value is not an array.") + val classNames = mutableListOf() + arrayNode.forEach { node -> + if (!node.isString) throw JsonParseException("ClassCollectionSetting's serialized array contains a non-string value.") + if (node.isString) classNames.add(node.stringValue()) + } + + @Suppress("unchecked_cast") + (settingCore as SettingCore).coreValue = classNames.mapNotNull { className -> + settingCore.immutableCollection.find { it.className == className } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingTypeAdapter.kt deleted file mode 100644 index 507426f70..000000000 --- a/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingTypeAdapter.kt +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.serializers - -import com.fasterxml.jackson.core.JsonParseException -import com.lambda.config.SettingCore -import com.lambda.config.TypeAdapter -import com.lambda.config.settings.collections.ClassCollectionSetting -import com.lambda.util.ReflectionUtils.className -import tools.jackson.core.JsonGenerator -import tools.jackson.core.JsonParser -import tools.jackson.databind.DeserializationContext -import tools.jackson.databind.SerializationContext - -@Suppress("unused") -object ClassCollectionSettingTypeAdapter : TypeAdapter>() { - override val type = ClassCollectionSetting::class.java - - override val serializer = object : Serializer>(type) { - override fun serialize( - setting: ClassCollectionSetting<*>, - gen: JsonGenerator, - ctxt: SerializationContext - ) { - gen.writeStartArray() - setting.coreValue.forEach { element -> - gen.writeString(element.className) - } - gen.writeEndArray() - } - } - - override val deserializer = object : Deserializer>(type) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): ClassCollectionSetting<*> { - throw initFromJsonException("ClassCollectionSetting") - } - - override fun deserialize( - p: JsonParser, - ctxt: DeserializationContext, - settingCore: ClassCollectionSetting<*> - ): ClassCollectionSetting<*> = - settingCore.apply { - val arrayNode = mapper.readTree(p) - if (!arrayNode.isArray) throw JsonParseException("ClassCollectionSetting's serialized value is not an array.") - val classNames = mutableListOf() - arrayNode.forEach { node -> - if (!node.isString) throw JsonParseException("ClassCollectionSetting's serialized array contains a non-string value.") - if (node.isString) classNames.add(node.stringValue()) - } - - @Suppress("unchecked_cast") - (settingCore as SettingCore).coreValue = classNames.mapNotNull { className -> - settingCore.immutableCollection.find { it.className == className } - } - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/CollectionSettingSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/CollectionSettingSerializer.kt new file mode 100644 index 000000000..8b78159ff --- /dev/null +++ b/src/main/kotlin/com/lambda/config/serializers/CollectionSettingSerializer.kt @@ -0,0 +1,71 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +@file:Suppress("unused") + +package com.lambda.config.serializers + +import com.fasterxml.jackson.core.JsonParseException +import com.lambda.config.Deserializer +import com.lambda.config.Serializer +import com.lambda.config.settings.collections.CollectionSetting +import tools.jackson.core.JsonGenerator +import tools.jackson.core.JsonParser +import tools.jackson.databind.DeserializationContext +import tools.jackson.databind.SerializationContext + +object CollectionSettingSerializer : Serializer>(CollectionSetting::class.java) { + override fun serialize(setting: CollectionSetting<*>, gen: JsonGenerator, ctxt: SerializationContext) { + if (setting.serialize) mapper.writeValue(gen, setting.coreValue) + else { + gen.writeStartArray() + setting.coreValue.forEach { element -> + gen.writeString(element.toString()) + } + gen.writeEndArray() + } + } +} + +object CollectionSettingDeserializer : Deserializer>(CollectionSetting::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): CollectionSetting<*> { + throw initFromJsonException("CollectionSetting") + } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, setting: CollectionSetting<*>): CollectionSetting<*> = + setting.apply { + val newValue = mutableListOf() + + if (serialize) { + val tree = mapper.readTree(p) + val deserialized = mapper.treeToValue>(tree, type) + newValue.addAll(deserialized) + } else { + val node = mapper.readTree(p) + if (!node.isArray) throw JsonParseException("CollectionSetting's serialized value is not an array.") + node.forEach { element -> + if (!element.isString) throw JsonParseException("CollectionSetting's serialized array contains a non-string value. A CollectionSetting's JSON array must only contain strings if CollectionSetting.serialize is false.") + val str = element.stringValue() + val matched = immutableCollection.find { it.toString() == str } + if (matched != null) newValue.add(matched) + } + } + + @Suppress("unchecked_cast") + (this as CollectionSetting).coreValue = newValue + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/CollectionSettingTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/CollectionSettingTypeAdapter.kt deleted file mode 100644 index e03ec8bf7..000000000 --- a/src/main/kotlin/com/lambda/config/serializers/CollectionSettingTypeAdapter.kt +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.lambda.config.serializers - -import com.fasterxml.jackson.core.JsonParseException -import com.lambda.config.TypeAdapter -import com.lambda.config.settings.collections.CollectionSetting -import tools.jackson.core.JsonGenerator -import tools.jackson.core.JsonParser -import tools.jackson.databind.DeserializationContext -import tools.jackson.databind.SerializationContext - -@Suppress("unused") -object CollectionSettingTypeAdapter : TypeAdapter>() { - override val type = CollectionSetting::class.java - - override val serializer = object : Serializer>(type) { - override fun serialize(collection: CollectionSetting<*>, gen: JsonGenerator, ctxt: SerializationContext) { - if (collection.serialize) mapper.writeValue(gen, collection.coreValue) - else { - gen.writeStartArray() - collection.coreValue.forEach { element -> - gen.writeString(element.toString()) - } - gen.writeEndArray() - } - } - } - - override val deserializer = object : Deserializer>(type) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): CollectionSetting<*> { - throw initFromJsonException("CollectionSetting") - } - - override fun deserialize(p: JsonParser, ctxt: DeserializationContext, collection: CollectionSetting<*>) = - collection.apply { - val newValue = mutableListOf() - - if (serialize) { - val tree = mapper.readTree(p) - val deserialized = mapper.treeToValue>(tree, type) - newValue.addAll(deserialized) - } else { - val node = mapper.readTree(p) - if (!node.isArray) throw JsonParseException("CollectionSetting's serialized value is not an array.") - node.values().forEach { element -> - if (!element.isString) throw JsonParseException("CollectionSetting's serialized array contains a non-string value. A CollectionSetting's JSON array must only contain strings if CollectionSetting.serialize is false.") - val str = element.stringValue() - val matched = immutableCollection.find { it.toString() == str } - if (matched != null) newValue.add(matched) - } - } - - @Suppress("unchecked_cast") - (this as CollectionSetting).coreValue = newValue - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/ColorTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt similarity index 54% rename from src/main/kotlin/com/lambda/config/serializers/ColorTypeAdapter.kt rename to src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt index 6f33876b2..0cef40d4b 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ColorTypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt @@ -15,37 +15,35 @@ * along with this program. If not, see . */ +@file:Suppress("unused") + package com.lambda.config.serializers import com.fasterxml.jackson.core.JsonParseException +import com.lambda.config.Deserializer +import com.lambda.config.Serializer import com.lambda.config.Stringifiable -import com.lambda.config.TypeAdapter import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.SerializationContext import java.awt.Color -@Suppress("unused") -object ColorTypeAdapter : TypeAdapter(), Stringifiable { - override val type = Color::class.java - - override val serializer = object : Serializer(type) { - override fun serialize(color: Color, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeString("${color.red},${color.green},${color.blue},${color.alpha}") - } - } - - override val deserializer = object : Deserializer(type) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Color { - val color = p.valueAsString.split(",") - return when (color.size) { - 3 -> Color(color[0].toInt(), color[1].toInt(), color[2].toInt()) - 4 -> Color(color[0].toInt(), color[1].toInt(), color[2].toInt(), color[3].toInt()) - else -> throw JsonParseException("Invalid color format") - } - } +object ColorSerializer : Serializer(Color::class.java), Stringifiable { + override fun serialize(color: Color, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeString("${color.red},${color.green},${color.blue},${color.alpha}") } override fun stringify(value: Color) = "${value.red},${value.green},${value.blue},${value.alpha}" } + +object ColorDeserializer : Deserializer(Color::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Color { + val color = p.valueAsString.split(",") + return when (color.size) { + 3 -> Color(color[0].toInt(), color[1].toInt(), color[2].toInt()) + 4 -> Color(color[0].toInt(), color[1].toInt(), color[2].toInt(), color[3].toInt()) + else -> throw JsonParseException("Invalid color format") + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt new file mode 100644 index 000000000..68d0d1efa --- /dev/null +++ b/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt @@ -0,0 +1,153 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +@file:Suppress("unused") + +package com.lambda.config.serializers + +import com.lambda.Lambda.Log +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer +import com.lambda.config.ConfigCategory +import com.lambda.config.FallbackDeserializer +import com.lambda.config.FallbackSerializer +import com.lambda.config.Setting +import com.lambda.config.migration.ConfigMigrationHandler +import tools.jackson.core.JsonGenerator +import tools.jackson.core.JsonParser +import tools.jackson.databind.DeserializationContext +import tools.jackson.databind.JsonNode +import tools.jackson.databind.SerializationContext + +object ConfigCategoryFallbackSerializer : FallbackSerializer(ConfigCategory::class.java) { + override fun serialize(category: ConfigCategory, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeStartObject() + val latestSchemaVersion = ConfigMigrationHandler.latestVersion(category) + if (latestSchemaVersion > 1) { + gen.writeNumberProperty( + ConfigMigrationHandler.schemaVersionKey(category) ?: ConfigMigrationHandler.DefaultSchemaVersionKey, + latestSchemaVersion + ) + } + category.configs.forEach { config -> + val serialized = mapper.valueToTree(config) + if (serialized.isEmpty) return@forEach + gen.writePOJOProperty(config.name, serialized) + } + gen.writeEndObject() + } +} + +object ConfigCategoryFallbackDeserializer : FallbackDeserializer(ConfigCategory::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): ConfigCategory { + throw initFromJsonException("ConfigCategory") + } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, category: ConfigCategory): ConfigCategory = + category.apply { + val categoryJson = mapper.readTree(p) + configs.forEach { config -> + val configJson = categoryJson.get(config.name) ?: return@forEach + mapper.updateValue(config, configJson) + } + } +} + +object ConfigFallbackSerializer : FallbackSerializer(Config::class.java) { + override fun serialize(config: Config, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeObjectPropertyStart(config.name) + .writePOJO(config.settingLayers) + .writeEndObject() + } +} + +object ConfigFallbackDeserializer : FallbackDeserializer(Config::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Config { + throw initFromJsonException("Config") + } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, config: Config): Config = + config.apply { mapper.updateValue(settingLayers, mapper.readTree(p)) } +} + +object MultipleFallbackSerializer : FallbackSerializer(SettingLayer.Multiple::class.java) { + override fun serialize(multiple: SettingLayer.Multiple, gen: JsonGenerator, ctxt: SerializationContext) { + val notRoot = multiple !is SettingLayer.Root + if (notRoot) gen.writeObjectPropertyStart(multiple.name) + multiple.layers.forEach { layer -> + if (layer is SettingLayer.Single<*, *> && !layer.setting.isModified) return@forEach + val serialized = mapper.valueToTree(layer) + if (serialized.isObject && serialized.isEmpty) return@forEach + gen.writePOJOProperty(layer.name, serialized) + } + if (notRoot) gen.writeEndObject() + } +} + +object MultipleFallbackDeserializer : FallbackDeserializer(SettingLayer.Multiple::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SettingLayer.Multiple { + throw initFromJsonException("Multiple") + } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, multiple: SettingLayer.Multiple): SettingLayer.Multiple = + multiple.apply { + val multipleJson = mapper.readTree(p) + layers.forEach { layer -> + val layerJson = multipleJson.get(layer.name) ?: return@forEach + mapper.updateValue(layer, layerJson) + } + } +} + +object SingleFallbackSerializer : FallbackSerializer>(SettingLayer.Single::class.java) { + override fun serialize(single: SettingLayer.Single<*, *>, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writePOJOProperty(single.name, single.setting) + } +} + +object SingleFallbackDeserializer : FallbackDeserializer>(SettingLayer.Single::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SettingLayer.Single<*, *> { + throw initFromJsonException("Single") + } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, single: SettingLayer.Single<*, *>): SettingLayer.Single<*, *> = + single.apply { + try { + mapper.updateValue(setting, mapper.readTree(p)) + } catch (e: Throwable) { + Log.error("Failed to deserialize setting '${name}'", e) + } + } +} + +object SettingFallbackSerializer : FallbackSerializer>(Setting::class.java) { + override fun serialize(setting: Setting<*, *>, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writePOJOProperty(setting.name, setting.value) + } +} + +object SettingFallbackDeserializer : FallbackDeserializer>(Setting::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Setting<*, *>? { + throw initFromJsonException("Setting") + } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, setting: Setting<*, *>) = + setting.apply { + @Suppress("unchecked_cast") + (this as Setting<*, Any>).core.coreValue = mapper.treeToValue(mapper.readTree(p), value.javaClass) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackTypeAdapter.kt deleted file mode 100644 index c172abdbc..000000000 --- a/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackTypeAdapter.kt +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright 2026 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -@file:Suppress("unused") - -package com.lambda.config.serializers - -import com.lambda.Lambda.Log -import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer -import com.lambda.config.ConfigCategory -import com.lambda.config.Setting -import com.lambda.config.FallbackTypeAdapter -import com.lambda.config.migration.ConfigMigrationHandler -import tools.jackson.core.JsonGenerator -import tools.jackson.core.JsonParser -import tools.jackson.databind.DeserializationContext -import tools.jackson.databind.JsonNode -import tools.jackson.databind.SerializationContext - -object ConfigCategoryFallbackTypeAdapter : FallbackTypeAdapter() { - override val type = ConfigCategory::class.java - - override val serializer = object : Serializer(type) { - override fun serialize(category: ConfigCategory, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeStartObject() - val latestSchemaVersion = ConfigMigrationHandler.latestVersion(category) - if (latestSchemaVersion > 1) { - gen.writeNumberProperty( - ConfigMigrationHandler.schemaVersionKey(category) ?: ConfigMigrationHandler.DefaultSchemaVersionKey, - latestSchemaVersion - ) - } - category.configs.forEach { config -> - val serialized = mapper.valueToTree(config) - if (serialized.isEmpty) return@forEach - gen.writePOJOProperty(config.name, serialized) - } - gen.writeEndObject() - } - } - - override val deserializer = object : Deserializer(type) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): ConfigCategory { - throw initFromJsonException("ConfigCategory") - } - - override fun deserialize(p: JsonParser, ctxt: DeserializationContext, category: ConfigCategory) = - category.apply { - val categoryJson = mapper.readTree(p) - configs.forEach { config -> - val configJson = categoryJson.get(config.name) ?: return@forEach - mapper.updateValue(config, configJson) - } - } - } -} - -object ConfigFallbackTypeAdapter : FallbackTypeAdapter() { - override val type = Config::class.java - - override val serializer = object : Serializer(type) { - override fun serialize(config: Config, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeObjectPropertyStart(config.name) - .writePOJO(config.settingLayers) - .writeEndObject() - } - } - - override val deserializer = object : Deserializer(type) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Config { - throw initFromJsonException("Config") - } - - override fun deserialize(p: JsonParser, ctxt: DeserializationContext, config: Config) = - config.apply { mapper.updateValue(settingLayers, mapper.readTree(p)) } - } -} - -object MultipleFallbackTypeAdapter : FallbackTypeAdapter() { - override val type = SettingLayer.Multiple::class.java - - override val serializer = object : Serializer(type) { - override fun serialize(multiple: SettingLayer.Multiple, gen: JsonGenerator, ctxt: SerializationContext) { - val notRoot = multiple !is SettingLayer.Root - if (notRoot) gen.writeObjectPropertyStart(multiple.name) - multiple.layers.forEach { layer -> - if (layer is SettingLayer.Single<*, *> && !layer.setting.isModified) return@forEach - val serialized = mapper.valueToTree(layer) - if (serialized.isObject && serialized.isEmpty) return@forEach - gen.writePOJOProperty(layer.name, serialized) - } - if (notRoot) gen.writeEndObject() - } - } - - override val deserializer = object : Deserializer(type) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SettingLayer.Multiple { - throw initFromJsonException("Multiple") - } - - override fun deserialize(p: JsonParser, ctxt: DeserializationContext, multiple: SettingLayer.Multiple) = - multiple.apply { - val multipleJson = mapper.readTree(p) - layers.forEach { layer -> - val layerJson = multipleJson.get(layer.name) ?: return@forEach - mapper.updateValue(layer, layerJson) - } - } - } -} - -object SingleFallbackTypeAdapter : FallbackTypeAdapter>() { - override val type = SettingLayer.Single::class.java - - override val serializer = object : Serializer>(type) { - override fun serialize(single: SettingLayer.Single<*, *>, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writePOJOProperty(single.name, single.setting) - } - } - - override val deserializer = object : Deserializer>(type) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SettingLayer.Single<*, *> { - throw initFromJsonException("Single") - } - - override fun deserialize(p: JsonParser, ctxt: DeserializationContext, single: SettingLayer.Single<*, *>) = - single.apply { - try { - mapper.updateValue(setting, mapper.readTree(p)) - } catch (e: Throwable) { - Log.error("Failed to deserialize setting '${name}'", e) - } - } - } -} - -object SettingFallbackTypeAdapter : FallbackTypeAdapter>() { - override val type = Setting::class.java - - override val serializer = object : Serializer>(type) { - override fun serialize(setting: Setting<*, *>, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writePOJOProperty(setting.name, setting.value) - } - } - - override val deserializer = object : Deserializer>(type) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Setting<*, *>? { - throw initFromJsonException("Setting") - } - - override fun deserialize(p: JsonParser, ctxt: DeserializationContext, setting: Setting<*, *>) = - setting.apply { - @Suppress("unchecked_cast") - (this as Setting<*, Any>).core.coreValue = mapper.treeToValue(mapper.readTree(p), value.javaClass) - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/FunctionSettingTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/FunctionSettingSerializer.kt similarity index 56% rename from src/main/kotlin/com/lambda/config/serializers/FunctionSettingTypeAdapter.kt rename to src/main/kotlin/com/lambda/config/serializers/FunctionSettingSerializer.kt index 6d3faf219..7dd14355f 100644 --- a/src/main/kotlin/com/lambda/config/serializers/FunctionSettingTypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/serializers/FunctionSettingSerializer.kt @@ -15,30 +15,28 @@ * along with this program. If not, see . */ +@file:Suppress("unused") + package com.lambda.config.serializers -import com.lambda.config.TypeAdapter +import com.lambda.config.Deserializer +import com.lambda.config.Serializer import com.lambda.config.settings.FunctionSetting import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.SerializationContext -@Suppress("unused") -object FunctionSettingTypeAdapter : TypeAdapter>() { - override val type = FunctionSetting::class.java - - override val serializer = object : Serializer>(type) { - override fun serialize(functionSetting: FunctionSetting<*>, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeNull() - } +object FunctionSettingSerializer : Serializer>(FunctionSetting::class.java) { + override fun serialize(functionSetting: FunctionSetting<*>, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeNull() } +} - override val deserializer = object : Deserializer>(type) { - override fun deserialize(p: JsonParser?, ctxt: DeserializationContext?): FunctionSetting<*>? { - throw initFromJsonException("FunctionSetting") - } - - override fun deserialize(p: JsonParser, ctxt: DeserializationContext, functionSetting: FunctionSetting<*>) = functionSetting +object FunctionSettingDeserializer : Deserializer>(FunctionSetting::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): FunctionSetting<*> { + throw initFromJsonException("FunctionSetting") } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, functionSetting: FunctionSetting<*>): FunctionSetting<*> = functionSetting } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/ItemTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/ItemSerializer.kt similarity index 68% rename from src/main/kotlin/com/lambda/config/serializers/ItemTypeAdapter.kt rename to src/main/kotlin/com/lambda/config/serializers/ItemSerializer.kt index 7ca90cc00..b6c401253 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ItemTypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ItemSerializer.kt @@ -15,10 +15,13 @@ * along with this program. If not, see . */ +@file:Suppress("unused") + package com.lambda.config.serializers +import com.lambda.config.Deserializer +import com.lambda.config.Serializer import com.lambda.config.Stringifiable -import com.lambda.config.TypeAdapter import net.minecraft.item.Item import net.minecraft.registry.Registries import net.minecraft.util.Identifier @@ -27,20 +30,16 @@ import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.SerializationContext -object ItemTypeAdapter : TypeAdapter(), Stringifiable { - override val type = Item::class.java - - override val serializer = object : Serializer(type) { - override fun serialize(item: Item, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeString(item.toString()) - } - } - - override val deserializer = object : Deserializer(type) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Item { - return Registries.ITEM.get(Identifier.of(p.valueAsString)) - } +object ItemSerializer : Serializer(Item::class.java), Stringifiable { + override fun serialize(item: Item, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeString(item.toString()) } override fun stringify(value: Item) = value.name.string.replaceFirstChar { it.uppercase() } +} + +object ItemDeserializer : Deserializer(Item::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Item { + return Registries.ITEM.get(Identifier.of(p.valueAsString)) + } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/ItemStackTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/ItemStackSerializer.kt similarity index 60% rename from src/main/kotlin/com/lambda/config/serializers/ItemStackTypeAdapter.kt rename to src/main/kotlin/com/lambda/config/serializers/ItemStackSerializer.kt index 453f09a46..3d213039e 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ItemStackTypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ItemStackSerializer.kt @@ -15,31 +15,29 @@ * along with this program. If not, see . */ +@file:Suppress("unused") + package com.lambda.config.serializers +import com.lambda.config.Deserializer import com.lambda.config.JsonOps +import com.lambda.config.Serializer import com.lambda.config.Stringifiable -import com.lambda.config.TypeAdapter import net.minecraft.item.ItemStack import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.SerializationContext -@Suppress("unused") -object ItemStackTypeAdapter : TypeAdapter(), Stringifiable { - override val type = ItemStack::class.java - - override val serializer = object : Serializer(type) { - override fun serialize(itemStack: ItemStack, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeTree(ItemStack.CODEC.encodeStart(JsonOps.Uncompressed, itemStack).orThrow) - } - } - - override val deserializer = object : Deserializer(type) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext) = - ItemStack.CODEC.parse(JsonOps.Uncompressed, mapper.readTree(p)).orThrow +object ItemStackSerializer : Serializer(ItemStack::class.java), Stringifiable { + override fun serialize(itemStack: ItemStack, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeTree(ItemStack.CODEC.encodeStart(JsonOps.Uncompressed, itemStack).orThrow) } override fun stringify(value: ItemStack) = value.itemName.string.uppercase() +} + +object ItemStackDeserializer : Deserializer(ItemStack::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): ItemStack = + ItemStack.CODEC.parse(JsonOps.Uncompressed, mapper.readTree(p)).orThrow } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/KeyCodeTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/KeyCodeSerializer.kt similarity index 62% rename from src/main/kotlin/com/lambda/config/serializers/KeyCodeTypeAdapter.kt rename to src/main/kotlin/com/lambda/config/serializers/KeyCodeSerializer.kt index 16877a4ed..cba41b9a4 100644 --- a/src/main/kotlin/com/lambda/config/serializers/KeyCodeTypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/serializers/KeyCodeSerializer.kt @@ -15,27 +15,25 @@ * along with this program. If not, see . */ +@file:Suppress("unused") + package com.lambda.config.serializers -import com.lambda.config.TypeAdapter +import com.lambda.config.Deserializer +import com.lambda.config.Serializer import com.lambda.util.KeyCode import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.SerializationContext -@Suppress("unused") -object KeyCodeTypeAdapter : TypeAdapter() { - override val type = KeyCode::class.java - - override val serializer = object : Serializer(type) { - override fun serialize(keyCode: KeyCode, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeString(keyCode.name) - } - } - - override val deserializer = object : Deserializer(type) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext) = - KeyCode.fromKeyName(p.string) +object KeyCodeSerializer : Serializer(KeyCode::class.java) { + override fun serialize(keyCode: KeyCode, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeString(keyCode.name) } } + +object KeyCodeDeserializer : Deserializer(KeyCode::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): KeyCode = + KeyCode.fromKeyName(p.string) +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/TextTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/TextSerializer.kt similarity index 61% rename from src/main/kotlin/com/lambda/config/serializers/TextTypeAdapter.kt rename to src/main/kotlin/com/lambda/config/serializers/TextSerializer.kt index 39c09acd0..415ddb266 100644 --- a/src/main/kotlin/com/lambda/config/serializers/TextTypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/serializers/TextSerializer.kt @@ -15,10 +15,13 @@ * along with this program. If not, see . */ +@file:Suppress("unused") + package com.lambda.config.serializers +import com.lambda.config.Deserializer import com.lambda.config.JsonOps -import com.lambda.config.TypeAdapter +import com.lambda.config.Serializer import net.minecraft.text.Text import net.minecraft.text.TextCodecs import tools.jackson.core.JsonGenerator @@ -26,18 +29,13 @@ import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.SerializationContext -@Suppress("unused") -object TextTypeAdapter : TypeAdapter() { - override val type = Text::class.java - - override val serializer = object : Serializer(type) { - override fun serialize(text: Text, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeTree(TextCodecs.CODEC.encodeStart(JsonOps.Uncompressed, text).orThrow) - } - } - - override val deserializer = object : Deserializer(type) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext) = - TextCodecs.CODEC.parse(JsonOps.Uncompressed, mapper.readTree(p)).orThrow +object TextSerializer : Serializer(Text::class.java) { + override fun serialize(text: Text, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeTree(TextCodecs.CODEC.encodeStart(JsonOps.Uncompressed, text).orThrow) } } + +object TextDeserializer : Deserializer(Text::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Text = + TextCodecs.CODEC.parse(JsonOps.Uncompressed, mapper.readTree(p)).orThrow +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/UuidTypeAdapter.kt b/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt similarity index 50% rename from src/main/kotlin/com/lambda/config/serializers/UuidTypeAdapter.kt rename to src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt index 35dae3072..1501dae40 100644 --- a/src/main/kotlin/com/lambda/config/serializers/UuidTypeAdapter.kt +++ b/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt @@ -15,44 +15,42 @@ * along with this program. If not, see . */ +@file:Suppress("unused") + package com.lambda.config.serializers import com.fasterxml.jackson.core.JsonParseException +import com.lambda.config.Deserializer +import com.lambda.config.Serializer import com.lambda.config.Stringifiable -import com.lambda.config.TypeAdapter import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.SerializationContext import java.util.* -@Suppress("unused") -object UuidTypeAdapter : TypeAdapter(), Stringifiable { - override val type = UUID::class.java - - override val serializer = object : Serializer(type) { - override fun serialize(uuid: UUID, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writeString(uuid.toString()) - } +object UuidSerializer : Serializer(UUID::class.java), Stringifiable { + override fun serialize(uuid: UUID, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeString(uuid.toString()) } - override val deserializer = object : Deserializer(type) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): UUID { - val jsonNode = mapper.readTree(p) - - val rawId = when { - jsonNode.isString -> jsonNode.stringValue() - jsonNode.isObject && jsonNode.has("id") -> jsonNode.get("id").stringValue() - else -> throw JsonParseException("Cannot deserialize UUID from: $jsonNode") - } + override fun stringify(value: UUID) = value.toString() +} - val parsedId = if (rawId.length == 32) - rawId.replace(Regex("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})"), "$1-$2-$3-$4-$5") - else rawId +object UuidDeserializer : Deserializer(UUID::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): UUID { + val jsonNode = mapper.readTree(p) - return UUID.fromString(parsedId) + val rawId = when { + jsonNode.isString -> jsonNode.stringValue() + jsonNode.isObject && jsonNode.has("id") -> jsonNode.get("id").stringValue() + else -> throw JsonParseException("Cannot deserialize UUID from: $jsonNode") } - } - override fun stringify(value: UUID) = value.toString() -} + val parsedId = if (rawId.length == 32) + rawId.replace(Regex("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})"), "$1-$2-$3-$4-$5") + else rawId + + return UUID.fromString(parsedId) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt index e605f28a9..9cbe9c2b4 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt @@ -19,7 +19,7 @@ package com.lambda.config.settings.collections import com.lambda.Lambda.typeFactory import com.lambda.config.Setting -import com.lambda.config.serializers.BlockTypeAdapter +import com.lambda.config.serializers.BlockSerializer import com.lambda.gui.dsl.ImGuiBuilder import net.minecraft.block.Block @@ -33,5 +33,5 @@ class BlockCollectionSetting( serialize = true, ) { context(_: Setting<*, MutableCollection>) - override fun ImGuiBuilder.buildLayout() = buildDualPane("block") { BlockTypeAdapter.stringify(it) } + override fun ImGuiBuilder.buildLayout() = buildDualPane("block") { BlockSerializer.stringify(it) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt index 3920dda15..23422f002 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt @@ -19,7 +19,7 @@ package com.lambda.config.settings.collections import com.lambda.Lambda.typeFactory import com.lambda.config.Setting -import com.lambda.config.serializers.ItemTypeAdapter +import com.lambda.config.serializers.ItemSerializer import com.lambda.gui.dsl.ImGuiBuilder import net.minecraft.item.Item @@ -33,5 +33,5 @@ class ItemCollectionSetting( serialize = true, ) { context(_: Setting<*, MutableCollection>) - override fun ImGuiBuilder.buildLayout() = buildDualPane("item") { ItemTypeAdapter.stringify(it) } + override fun ImGuiBuilder.buildLayout() = buildDualPane("item") { ItemSerializer.stringify(it) } } \ No newline at end of file From 6b0fa9c5eced11e437abb635f2fdeb6b2cfa67c3 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Sun, 31 May 2026 00:31:00 +0100 Subject: [PATCH 34/40] better isModified --- src/main/kotlin/com/lambda/Lambda.kt | 2 +- .../com/lambda/config/FallbackSerializers.kt | 58 ++++++++++++++----- src/main/kotlin/com/lambda/config/Setting.kt | 4 +- .../CollectionSettingSerializer.kt | 12 ++-- .../ConfigCategoryFallbackSerializer.kt | 24 ++++---- .../settings/collections/CollectionSetting.kt | 2 + 6 files changed, 67 insertions(+), 35 deletions(-) diff --git a/src/main/kotlin/com/lambda/Lambda.kt b/src/main/kotlin/com/lambda/Lambda.kt index 51b4e51a8..caa28dce2 100644 --- a/src/main/kotlin/com/lambda/Lambda.kt +++ b/src/main/kotlin/com/lambda/Lambda.kt @@ -62,7 +62,7 @@ object Lambda : ClientModInitializer { /** * A Jackson [tools.jackson.databind.json.JsonMapper]. * - * We use Jackson over Gson (unlike Minecraft) as it allows for updating existing objects + * Jackson is used over Gson (unlike Minecraft) as it allows for updating existing objects * rather than creating new instances when deserializing. */ val mapper = jsonMapper { diff --git a/src/main/kotlin/com/lambda/config/FallbackSerializers.kt b/src/main/kotlin/com/lambda/config/FallbackSerializers.kt index 90991a59f..f0bcc4e6f 100644 --- a/src/main/kotlin/com/lambda/config/FallbackSerializers.kt +++ b/src/main/kotlin/com/lambda/config/FallbackSerializers.kt @@ -27,33 +27,61 @@ import tools.jackson.databind.ValueSerializer import tools.jackson.databind.deser.Deserializers import tools.jackson.databind.ser.Serializers +/** + * A combined [Serializers] and [Deserializers] implementation that resolves + * serializers/deserializers by walking the class hierarchy to find the closest + * registered supertype. This allows registering a single serializer for a base + * class (e.g., [com.lambda.config.SettingCore]) that handles all its subclasses. + * + * Exact-match serializers registered via [tools.jackson.databind.module.SimpleModule.addSerializer] + * take priority over these fallbacks in Jackson's resolution order. + */ class FallbackSerializers( - val fallbackSerializers: Map, FallbackSerializer<*>>, - val fallbackDeserializers: Map, FallbackDeserializer<*>> + private val serializers: Map, FallbackSerializer<*>>, + private val deserializers: Map, FallbackDeserializer<*>> ) : Serializers, Deserializers { override fun findSerializer( config: SerializationConfig, type: JavaType, beanDescRef: BeanDescription.Supplier, formatOverrides: JsonFormat.Value? - ): ValueSerializer<*>? { - fallbackSerializers.forEach { (baseType, serializer) -> - if (baseType.isAssignableFrom(type.rawClass)) return serializer - } - return null - } + ): ValueSerializer<*>? = findClosestSupertype(type.rawClass, serializers) override fun findBeanDeserializer( type: JavaType, config: DeserializationConfig, beanDescRef: BeanDescription.Supplier - ): ValueDeserializer<*>? { - fallbackDeserializers.forEach { (baseType, deserializer) -> - if (baseType.isAssignableFrom(type.rawClass)) return deserializer + ): ValueDeserializer<*>? = findClosestSupertype(type.rawClass, deserializers) + + override fun hasDeserializerFor(config: DeserializationConfig, valueType: Class<*>?): Boolean = + valueType != null && findClosestSupertype(valueType, deserializers) != null + + /** + * Finds the value mapped to the closest supertype of [target] among the [candidates] map keys. + * "Closest" is determined by the shortest inheritance distance up the class hierarchy. + */ + private fun findClosestSupertype(target: Class<*>, candidates: Map, V>): V? { + var bestValue: V? = null + var bestDistance = Int.MAX_VALUE + + candidates.forEach { (candidateClass, value) -> + if (!candidateClass.isAssignableFrom(target)) return@forEach + val distance = inheritanceDistance(target, candidateClass) + if (distance < bestDistance) { + bestDistance = distance + bestValue = value + } } - return null + return bestValue } - override fun hasDeserializerFor(config: DeserializationConfig, valueType: Class<*>?) = - valueType != null && fallbackDeserializers.any { (baseType, _) -> baseType.isAssignableFrom(valueType) } -} \ No newline at end of file + private fun inheritanceDistance(sub: Class<*>, superClass: Class<*>): Int { + var distance = 0 + var current: Class<*>? = sub + while (current != null && current != superClass) { + distance++ + current = current.superclass + } + return if (current == superClass) distance else Int.MAX_VALUE + } +} diff --git a/src/main/kotlin/com/lambda/config/Setting.kt b/src/main/kotlin/com/lambda/config/Setting.kt index 402aac77b..e8176b07d 100644 --- a/src/main/kotlin/com/lambda/config/Setting.kt +++ b/src/main/kotlin/com/lambda/config/Setting.kt @@ -104,7 +104,7 @@ class Setting, R>( private val listeners = mutableListOf>() - val isModified get() = value != core.defaultValue + val isModified get() = originalCore.isModified operator fun getValue(thisRef: Any?, property: KProperty<*>) = core.coreValue operator fun setValue(thisRef: Any?, property: KProperty<*>, value: R) { @@ -253,6 +253,8 @@ abstract class SettingCore( setting.value = value } + open val isModified get() = coreValue != defaultValue + /** * A function invoked to build the core's gui interface. */ diff --git a/src/main/kotlin/com/lambda/config/serializers/CollectionSettingSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/CollectionSettingSerializer.kt index 8b78159ff..c48457599 100644 --- a/src/main/kotlin/com/lambda/config/serializers/CollectionSettingSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/CollectionSettingSerializer.kt @@ -20,15 +20,15 @@ package com.lambda.config.serializers import com.fasterxml.jackson.core.JsonParseException -import com.lambda.config.Deserializer -import com.lambda.config.Serializer +import com.lambda.config.FallbackDeserializer +import com.lambda.config.FallbackSerializer import com.lambda.config.settings.collections.CollectionSetting import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.SerializationContext -object CollectionSettingSerializer : Serializer>(CollectionSetting::class.java) { +object CollectionSettingSerializer : FallbackSerializer>(CollectionSetting::class.java) { override fun serialize(setting: CollectionSetting<*>, gen: JsonGenerator, ctxt: SerializationContext) { if (setting.serialize) mapper.writeValue(gen, setting.coreValue) else { @@ -41,13 +41,13 @@ object CollectionSettingSerializer : Serializer>(Collection } } -object CollectionSettingDeserializer : Deserializer>(CollectionSetting::class.java) { +object CollectionSettingDeserializer : FallbackDeserializer>(CollectionSetting::class.java) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext): CollectionSetting<*> { throw initFromJsonException("CollectionSetting") } - override fun deserialize(p: JsonParser, ctxt: DeserializationContext, setting: CollectionSetting<*>): CollectionSetting<*> = - setting.apply { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, settingCore: CollectionSetting<*>): CollectionSetting<*> = + settingCore.apply { val newValue = mutableListOf() if (serialize) { diff --git a/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt index 68d0d1efa..64dcb95e7 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt @@ -25,7 +25,7 @@ import com.lambda.config.Config.SettingLayer import com.lambda.config.ConfigCategory import com.lambda.config.FallbackDeserializer import com.lambda.config.FallbackSerializer -import com.lambda.config.Setting +import com.lambda.config.SettingCore import com.lambda.config.migration.ConfigMigrationHandler import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser @@ -115,7 +115,7 @@ object MultipleFallbackDeserializer : FallbackDeserializer>(SettingLayer.Single::class.java) { override fun serialize(single: SettingLayer.Single<*, *>, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writePOJOProperty(single.name, single.setting) + gen.writePOJOProperty(single.name, single.setting.originalCore) } } @@ -127,27 +127,27 @@ object SingleFallbackDeserializer : FallbackDeserializer): SettingLayer.Single<*, *> = single.apply { try { - mapper.updateValue(setting, mapper.readTree(p)) + mapper.updateValue(setting.originalCore, mapper.readTree(p)) } catch (e: Throwable) { Log.error("Failed to deserialize setting '${name}'", e) } } } -object SettingFallbackSerializer : FallbackSerializer>(Setting::class.java) { - override fun serialize(setting: Setting<*, *>, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writePOJOProperty(setting.name, setting.value) +object SettingCoreFallbackSerializer : FallbackSerializer>(SettingCore::class.java) { + override fun serialize(core: SettingCore<*>, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writePOJO(core.coreValue) } } -object SettingFallbackDeserializer : FallbackDeserializer>(Setting::class.java) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Setting<*, *>? { - throw initFromJsonException("Setting") +object SettingCoreFallbackDeserializer : FallbackDeserializer>(SettingCore::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SettingCore<*> { + throw initFromJsonException("SettingCore") } - override fun deserialize(p: JsonParser, ctxt: DeserializationContext, setting: Setting<*, *>) = - setting.apply { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, core: SettingCore<*>) = + core.apply { @Suppress("unchecked_cast") - (this as Setting<*, Any>).core.coreValue = mapper.treeToValue(mapper.readTree(p), value.javaClass) + (this as SettingCore).coreValue = mapper.treeToValue(mapper.readTree(p), coreValue.javaClass) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt index ae780b01e..6d9784f61 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt @@ -63,6 +63,8 @@ open class CollectionSetting( val selectListeners = mutableListOf Unit>() val deselectListeners = mutableListOf Unit>() + override val isModified get() = coreValue.size != defaultValue.size || defaultValue.any { !coreValue.contains(it) } + context(_: Setting<*, MutableCollection>) override fun ImGuiBuilder.buildLayout() = buildDualPane("item") { it.toString() } From 77b00bc0020da8f42c5a29097ad94781f063a80b Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Sun, 31 May 2026 01:58:55 +0100 Subject: [PATCH 35/40] fixed json module order --- src/main/kotlin/com/lambda/Lambda.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/lambda/Lambda.kt b/src/main/kotlin/com/lambda/Lambda.kt index caa28dce2..ac822275b 100644 --- a/src/main/kotlin/com/lambda/Lambda.kt +++ b/src/main/kotlin/com/lambda/Lambda.kt @@ -68,11 +68,6 @@ object Lambda : ClientModInitializer { val mapper = jsonMapper { enable(SerializationFeature.INDENT_OUTPUT) addModules( - kotlinModule { disable(KotlinFeature.SingletonSupport) }, - SimpleModule().apply { - getInstances>().forEach { it.register() } - getInstances>().forEach { it.register() } - }, object : SimpleModule() { override fun setupModule(context: SetupContext) { val fallbackSerializers = FallbackSerializers( @@ -83,7 +78,12 @@ object Lambda : ClientModInitializer { context.addDeserializers(fallbackSerializers) super.setupModule(context) } - } + }, + SimpleModule().apply { + getInstances>().forEach { it.register() } + getInstances>().forEach { it.register() } + }, + kotlinModule { disable(KotlinFeature.SingletonSupport) } ) } From 161f9cc2eb8e8136a56d8cd2cea05054eeb70870 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Sun, 31 May 2026 12:34:22 +0100 Subject: [PATCH 36/40] fix collection setting issues --- src/main/kotlin/com/lambda/Lambda.kt | 12 ++++++++++++ src/main/kotlin/com/lambda/config/BaseEditor.kt | 4 ++-- .../config/settings/blocks/TargetingSettings.kt | 2 +- .../config/settings/collections/CollectionSetting.kt | 5 ++--- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/lambda/Lambda.kt b/src/main/kotlin/com/lambda/Lambda.kt index ac822275b..6a23293b7 100644 --- a/src/main/kotlin/com/lambda/Lambda.kt +++ b/src/main/kotlin/com/lambda/Lambda.kt @@ -34,6 +34,9 @@ import net.fabricmc.loader.api.FabricLoader import net.minecraft.client.MinecraftClient import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger +import tools.jackson.core.util.DefaultIndenter +import tools.jackson.core.util.DefaultPrettyPrinter +import tools.jackson.core.util.Separators import tools.jackson.databind.SerializationFeature import tools.jackson.databind.module.SimpleModule import tools.jackson.databind.type.TypeFactory @@ -66,6 +69,15 @@ object Lambda : ClientModInitializer { * rather than creating new instances when deserializing. */ val mapper = jsonMapper { + defaultPrettyPrinter( + DefaultPrettyPrinter( + Separators.createDefaultInstance().withObjectNameValueSpacing(Separators.Spacing.AFTER) + ).apply { + val tabIndenter = DefaultIndenter("\t", DefaultIndenter.SYS_LF) + indentObjectsWith(tabIndenter) + indentArraysWith(tabIndenter) + } + ) enable(SerializationFeature.INDENT_OUTPUT) addModules( object : SimpleModule() { diff --git a/src/main/kotlin/com/lambda/config/BaseEditor.kt b/src/main/kotlin/com/lambda/config/BaseEditor.kt index 327158361..f1fe02df7 100644 --- a/src/main/kotlin/com/lambda/config/BaseEditor.kt +++ b/src/main/kotlin/com/lambda/config/BaseEditor.kt @@ -83,7 +83,7 @@ object ConfigEditor { context(_: EditContext) fun SettingProperty.edit(edits: TypedEditBuilder.(SettingCore) -> Unit) { val delegate = setting - TypedEditBuilder(listOf(delegate)).edits(delegate.core) + TypedEditBuilder(listOf(delegate)).edits(delegate.originalCore) } @SettingEditorDsl @@ -158,7 +158,7 @@ object ConfigEditor { fun defaultValue(value: T) = settings.forEach { it.value = value - it.core.defaultValue = it.value + it.originalCore.defaultValue = value } } diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt index fb61fcf0a..570b2c92e 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt @@ -60,7 +60,7 @@ abstract class TargetingSettings( */ override val targetingRange by c.setting("Targeting Range", defaultRange, 1.0..maxRange, 0.05) override val targets by c.settingBlock(EntitySelectionSettings(c)) - .withEdits(c) { hide(::self, ::blockEntities) } + .withEdits(c) { hide(::self, ::enableBlockEntities, ::blockEntities) } /** * Validates whether a given entity is targetable by the player based on current settings. diff --git a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt index 6d9784f61..15e77dfcf 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt @@ -52,10 +52,9 @@ open class CollectionSetting( ) : SettingCore>( defaultValue ) { - override var coreValue - get() = super.coreValue + override var coreValue: MutableCollection = defaultValue.toMutableList() set(newVal) { - super.coreValue = newVal.toMutableList() + field = newVal.toMutableList() } private var searchFilter = "" From a1c54a6d853ca87a057d43f0fefefe7211eb93e2 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Sun, 31 May 2026 14:05:38 +0100 Subject: [PATCH 37/40] cleanup --- src/main/kotlin/com/lambda/Lambda.kt | 129 ++++++++++++++------------- 1 file changed, 67 insertions(+), 62 deletions(-) diff --git a/src/main/kotlin/com/lambda/Lambda.kt b/src/main/kotlin/com/lambda/Lambda.kt index 6a23293b7..e6b135a8a 100644 --- a/src/main/kotlin/com/lambda/Lambda.kt +++ b/src/main/kotlin/com/lambda/Lambda.kt @@ -45,73 +45,78 @@ import tools.jackson.module.kotlin.jsonMapper import tools.jackson.module.kotlin.kotlinModule object Lambda : ClientModInitializer { - const val ModName = "Lambda" - const val ModId = "lambda" - const val Symbol = "λ" - const val AppId = "1221289599427416127" - const val RepoUrl = "https://github.com/lambda-client/lambda" - val Version: String = - FabricLoader.getInstance() - .getModContainer("lambda").orElseThrow() - .metadata.version.friendlyString + const val ModName = "Lambda" + const val ModId = "lambda" + const val Symbol = "λ" + const val AppId = "1221289599427416127" + const val RepoUrl = "https://github.com/lambda-client/lambda" + val Version: String = + FabricLoader.getInstance() + .getModContainer("lambda").orElseThrow() + .metadata.version.friendlyString - val Log: Logger = LogManager.getLogger(Symbol) + val Log: Logger = LogManager.getLogger(Symbol) - @JvmStatic - val mc: MinecraftClient by lazy { MinecraftClient.getInstance() } + @JvmStatic + val mc: MinecraftClient by lazy { MinecraftClient.getInstance() } - val isDebug = System.getProperty("lambda.dev") != null + val isDebug = System.getProperty("lambda.dev") != null - /** - * A Jackson [tools.jackson.databind.json.JsonMapper]. - * - * Jackson is used over Gson (unlike Minecraft) as it allows for updating existing objects - * rather than creating new instances when deserializing. - */ - val mapper = jsonMapper { - defaultPrettyPrinter( - DefaultPrettyPrinter( - Separators.createDefaultInstance().withObjectNameValueSpacing(Separators.Spacing.AFTER) - ).apply { - val tabIndenter = DefaultIndenter("\t", DefaultIndenter.SYS_LF) - indentObjectsWith(tabIndenter) - indentArraysWith(tabIndenter) - } - ) - enable(SerializationFeature.INDENT_OUTPUT) - addModules( - object : SimpleModule() { - override fun setupModule(context: SetupContext) { - val fallbackSerializers = FallbackSerializers( - getInstances>().associateBy { it.type }, - getInstances>().associateBy { it.type } - ) - context.addSerializers(fallbackSerializers) - context.addDeserializers(fallbackSerializers) - super.setupModule(context) - } - }, - SimpleModule().apply { - getInstances>().forEach { it.register() } - getInstances>().forEach { it.register() } - }, - kotlinModule { disable(KotlinFeature.SingletonSupport) } - ) - } + /** + * A Jackson [tools.jackson.databind.json.JsonMapper]. + * + * Jackson is used over Gson (unlike Minecraft) as it allows for updating existing objects + * rather than creating new instances when deserializing. + * + * We use the base Kotlin module with `SingletonSupport` disabled, as it overrides our serialization. + * We also use a simple module for our standard serializers and deserializers. + * Finally, we use a custom module that searches through the supertypes of the given object to find + * the closest related type with a registered serializer or deserializer, depending on the action. + */ + val mapper = jsonMapper { + defaultPrettyPrinter( + DefaultPrettyPrinter( + Separators.createDefaultInstance().withObjectNameValueSpacing(Separators.Spacing.AFTER) + ).apply { + val tabIndenter = DefaultIndenter("\t", DefaultIndenter.SYS_LF) + indentObjectsWith(tabIndenter) + indentArraysWith(tabIndenter) + } + ) + enable(SerializationFeature.INDENT_OUTPUT) + addModules( + object : SimpleModule() { + override fun setupModule(context: SetupContext) { + val fallbackSerializers = FallbackSerializers( + getInstances>().associateBy { it.type }, + getInstances>().associateBy { it.type } + ) + context.addSerializers(fallbackSerializers) + context.addDeserializers(fallbackSerializers) + super.setupModule(context) + } + }, + SimpleModule().apply { + getInstances>().forEach { it.register() } + getInstances>().forEach { it.register() } + }, + kotlinModule { disable(KotlinFeature.SingletonSupport) } + ) + } - /** - * The configured [TypeFactory] produced by [mapper]. - */ - val typeFactory: TypeFactory = mapper.typeFactory + /** + * The configured [TypeFactory] produced by [mapper]. + */ + val typeFactory: TypeFactory = mapper.typeFactory - override fun onInitializeClient() {} // nop + override fun onInitializeClient() {} // nop - init { - // We want the opengl context to be created - listenOnceUnsafe({ Int.MAX_VALUE }) { - Log.info("$ModName $Version initialized in ${Loader.initialize()} ms\n") - if (ClickGuiLayout.setLambdaWindowIcon) setLambdaWindowIcon() - true - } - } + init { + // We want the opengl context to be created + listenOnceUnsafe({ Int.MAX_VALUE }) { + Log.info("$ModName $Version initialized in ${Loader.initialize()} ms\n") + if (ClickGuiLayout.setLambdaWindowIcon) setLambdaWindowIcon() + true + } + } } From f0e055d92432f64d4f6a85168ee5a011cfe79586 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Tue, 2 Jun 2026 20:38:53 +0100 Subject: [PATCH 38/40] compiles --- src/main/kotlin/com/lambda/Lambda.kt | 2 +- .../lambda/command/commands/PrefixCommand.kt | 4 +- .../kotlin/com/lambda/config/BaseEditor.kt | 17 +- src/main/kotlin/com/lambda/config/Config.kt | 414 +++++++++--------- src/main/kotlin/com/lambda/config/Setting.kt | 124 ++---- .../automation/IMutableAutomationConfig.kt | 2 +- .../ClassCollectionSettingSerializer.kt | 12 +- .../CollectionSettingSerializer.kt | 6 +- .../ConfigCategoryFallbackSerializer.kt | 18 +- .../serializers/FunctionSettingSerializer.kt | 10 +- .../com/lambda/config/settings/CharSetting.kt | 35 +- .../lambda/config/settings/FunctionSetting.kt | 18 +- .../lambda/config/settings/NumericSetting.kt | 121 ++--- .../lambda/config/settings/StringSetting.kt | 26 +- .../collections/BlockCollectionSetting.kt | 14 +- .../collections/ClassCollectionSetting.kt | 14 +- .../settings/collections/CollectionSetting.kt | 79 ++-- .../collections/ItemCollectionSetting.kt | 10 +- .../config/settings/collections/MapSetting.kt | 17 +- .../settings/comparable/BooleanSetting.kt | 40 +- .../config/settings/comparable/EnumSetting.kt | 40 +- .../settings/complex/BlockPosSetting.kt | 52 +-- .../config/settings/complex/BlockSetting.kt | 36 +- .../config/settings/complex/ColorSetting.kt | 28 +- .../config/settings/complex/KeybindSetting.kt | 68 +-- .../config/settings/complex/Vec3dSetting.kt | 25 +- .../config/settings/numeric/DoubleSetting.kt | 35 +- .../config/settings/numeric/FloatSetting.kt | 29 +- .../config/settings/numeric/IntegerSetting.kt | 25 +- .../config/settings/numeric/LongSetting.kt | 31 +- .../com/lambda/gui/components/QuickSearch.kt | 4 +- .../lambda/gui/components/SettingsWidget.kt | 2 +- 32 files changed, 688 insertions(+), 670 deletions(-) diff --git a/src/main/kotlin/com/lambda/Lambda.kt b/src/main/kotlin/com/lambda/Lambda.kt index e6b135a8a..1fc8bfbd0 100644 --- a/src/main/kotlin/com/lambda/Lambda.kt +++ b/src/main/kotlin/com/lambda/Lambda.kt @@ -68,7 +68,7 @@ object Lambda : ClientModInitializer { * Jackson is used over Gson (unlike Minecraft) as it allows for updating existing objects * rather than creating new instances when deserializing. * - * We use the base Kotlin module with `SingletonSupport` disabled, as it overrides our serialization. + * We use the base [tools.jackson.module.kotlin.KotlinModule] with `SingletonSupport` disabled, as it overrides our serialization. * We also use a simple module for our standard serializers and deserializers. * Finally, we use a custom module that searches through the supertypes of the given object to find * the closest related type with a registered serializer or deserializer, depending on the action. diff --git a/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt b/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt index 023fde4c7..7726501a3 100644 --- a/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/PrefixCommand.kt @@ -26,7 +26,7 @@ import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required import com.lambda.command.CommandRegistry import com.lambda.command.LambdaCommand -import com.lambda.config.Setting +import com.lambda.config.settings.CharSetting import com.lambda.util.CommunicationUtils.info import com.lambda.util.extension.CommandBuilder import com.lambda.util.text.buildText @@ -51,7 +51,7 @@ object PrefixCommand : LambdaCommand( } val prefixChar = prefix.first() @Suppress("unchecked_cast") - (CommandRegistry::prefix.getDelegate() as? Setting<*, Char>)?.trySetValue(prefixChar) + (CommandRegistry::prefix.getDelegate() as? CharSetting)?.trySetValue(prefixChar) return@executeWithResult success() } } diff --git a/src/main/kotlin/com/lambda/config/BaseEditor.kt b/src/main/kotlin/com/lambda/config/BaseEditor.kt index f1fe02df7..3ebb9da2a 100644 --- a/src/main/kotlin/com/lambda/config/BaseEditor.kt +++ b/src/main/kotlin/com/lambda/config/BaseEditor.kt @@ -56,7 +56,7 @@ object ConfigEditor { @SettingEditorDsl context(editContext: EditContext.ConfigEditContext) fun forEachSetting(block: BasicEditBuilder.() -> Unit) { - val settings = mutableListOf>() + val settings = mutableListOf>() editContext.c.forEachSetting { _, single -> settings.add(single.setting) } BasicEditBuilder(settings).apply(block) } @@ -69,7 +69,7 @@ object ConfigEditor { @SettingEditorDsl context(editContext: EditContext.BlockEditContext) fun forEachSetting(block: BasicEditBuilder.() -> Unit) { - val settings = mutableListOf>() + val settings = mutableListOf>() editContext.c.forEachSettingBlock(editContext.block.layer) { _, single -> settings.add(single.setting) } BasicEditBuilder(settings).apply(block) } @@ -81,9 +81,8 @@ object ConfigEditor { @SettingEditorDsl context(_: EditContext) - fun SettingProperty.edit(edits: TypedEditBuilder.(SettingCore) -> Unit) { - val delegate = setting - TypedEditBuilder(listOf(delegate)).edits(delegate.originalCore) + fun SettingProperty.edit(edits: TypedEditBuilder.() -> Unit) { + TypedEditBuilder(listOf(setting)).edits() } @SettingEditorDsl @@ -129,7 +128,7 @@ object ConfigEditor { } open class BasicEditBuilder internal constructor( - open val settings: Collection> + open val settings: Collection> ) { @SettingEditorDsl fun hide() { @@ -152,12 +151,12 @@ object ConfigEditor { } class TypedEditBuilder internal constructor( - override val settings: Collection, T>> + override val settings: Collection> ) : BasicEditBuilder(settings) { @SettingEditorDsl fun defaultValue(value: T) = settings.forEach { - it.value = value + it.originalCore.value = value it.originalCore.defaultValue = value } } @@ -195,7 +194,7 @@ object ConfigEditor { } private val SettingProperty.setting - get() = this.delegate as? Setting, T> + get() = this.delegate as? Setting ?: throw IllegalStateException("Setting delegate did not match the given type") private val SettingBlockProperty.settingBlock diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index 3cd4b9a56..5037a787f 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -67,15 +67,15 @@ abstract class Config( final override val name: String, configCategory: ConfigCategory ) : Nameable { - internal val settingLayers = SettingLayer.Root() + internal val settingLayers = SettingLayer.Root() internal val settingBlockLayers = BlockLayer.Root() - private val registrationQueue = ArrayDeque() + private val registrationQueue = ArrayDeque() - init { - if (configs.any { it.name == name }) throw IllegalStateException("Configs with name $name already exists.") - enqueueProperties(this::class, emptyList(), emptyList()) - configCategory.configs.add(this) - } + init { + if (configs.any { it.name == name }) throw IllegalStateException("Configs with name $name already exists.") + enqueueProperties(this::class, emptyList(), emptyList()) + configCategory.configs.add(this) + } private fun enqueueProperties(klass: KClass<*>, outerPath: List, outerBlockPath: List) { var childBlockIndex = 0 @@ -163,205 +163,201 @@ abstract class Config( } @SettingDsl - fun setting( - name: String, - defaultValue: Boolean, - description: String = "", - visibility: () -> Boolean = { true }, - ) = setting(name, description, BooleanSetting(defaultValue), visibility) + fun setting( + name: String, + defaultValue: Boolean, + description: String = "", + visibility: () -> Boolean = { true }, + ) = setting { layer -> BooleanSetting(name, description, this, layer, visibility, defaultValue) } @SettingDsl - fun > setting( - name: String, - defaultValue: T, - description: String = "", - visibility: () -> Boolean = { true }, - ) = setting(name, description,EnumSetting(defaultValue), visibility) + fun > setting( + name: String, + defaultValue: T, + description: String = "", + visibility: () -> Boolean = { true }, + ) = setting { layer -> EnumSetting(name, description, this, layer, visibility, defaultValue) } @SettingDsl - fun setting( - name: String, - defaultValue: Char, - description: String = "", - visibility: () -> Boolean = { true }, - ) = setting(name, description, CharSetting(defaultValue), visibility) + fun setting( + name: String, + defaultValue: Char, + description: String = "", + visibility: () -> Boolean = { true }, + ) = setting { layer -> CharSetting(name, description, this, layer, defaultValue, visibility) } @SettingDsl - fun setting( - name: String, - defaultValue: String, - multiline: Boolean = false, - flags: Int = ImGuiInputTextFlags.None, - description: String = "", - visibility: () -> Boolean = { true }, - ) = setting(name, description, StringSetting(defaultValue, multiline, flags), visibility) + fun setting( + name: String, + defaultValue: String, + multiline: Boolean = false, + flags: Int = ImGuiInputTextFlags.None, + description: String = "", + visibility: () -> Boolean = { true }, + ) = setting { layer -> StringSetting(name, description, this, layer, defaultValue, visibility, multiline, flags) } @SettingDsl @JvmName("collectionSetting1") - fun setting( - name: String, - defaultValue: Collection, - immutableCollection: Collection = Registries.BLOCK.toList(), - description: String = "", - visibility: () -> Boolean = { true }, - ) = setting(name, description, BlockCollectionSetting(immutableCollection, defaultValue.toMutableList()), visibility) + fun setting( + name: String, + defaultValue: Collection, + immutableCollection: Collection = Registries.BLOCK.toList(), + description: String = "", + visibility: () -> Boolean = { true }, + ) = setting { layer -> BlockCollectionSetting(name, description, this, layer, visibility, immutableCollection, defaultValue.toMutableList()) } @SettingDsl @JvmName("collectionSetting2") - fun setting( - name: String, - defaultValue: Collection, - immutableCollection: Collection = Registries.ITEM.toList(), - description: String = "", - visibility: () -> Boolean = { true }, - ) = setting(name, description, ItemCollectionSetting(immutableCollection, defaultValue.toMutableList()), visibility) + fun setting( + name: String, + defaultValue: Collection, + immutableCollection: Collection = Registries.ITEM.toList(), + description: String = "", + visibility: () -> Boolean = { true }, + ) = setting { layer -> ItemCollectionSetting(name, description, this, layer, visibility, immutableCollection, defaultValue.toMutableList()) } @SettingDsl @JvmName("collectionSetting3") - inline fun setting( - name: String, - defaultValue: Collection, - immutableList: Collection = defaultValue, - description: String = "", - displayClassName: Boolean = false, - serialize: Boolean = false, - noinline visibility: () -> Boolean = { true }, - ) = setting( - name, - description, - if (displayClassName) ClassCollectionSetting(immutableList, defaultValue.toMutableList()) - else CollectionSetting(defaultValue.toMutableList(), immutableList, typeFactory.constructCollectionType(Collection::class.java, T::class.java), serialize), - visibility - ) + inline fun setting( + name: String, + defaultValue: Collection, + immutableList: Collection = defaultValue, + description: String = "", + displayClassName: Boolean = false, + serialize: Boolean = false, + noinline visibility: () -> Boolean = { true }, + ) = setting { layer -> + if (displayClassName) + ClassCollectionSetting(name, description, this, layer, visibility, immutableList, defaultValue.toMutableList()) + else + CollectionSetting(name, description, this, layer, visibility, defaultValue.toMutableList(), immutableList, typeFactory.constructCollectionType(Collection::class.java, T::class.java), serialize) + } @SettingDsl - // ToDo: Actually implement maps inline fun setting( - name: String, - defaultValue: Map, - description: String = "", - noinline visibility: () -> Boolean = { true }, - ) = setting( - name, - description, - MapSetting( - defaultValue.toMutableMap(), - typeFactory.constructMapType(MutableMap::class.java, K::class.java, V::class.java) - ), - visibility - ) + name: String, + defaultValue: Map, + description: String = "", + noinline visibility: () -> Boolean = { true }, + ) = setting { layer -> + MapSetting( + name, description, this, layer, visibility, + defaultValue.toMutableMap(), + typeFactory.constructMapType(MutableMap::class.java, K::class.java, V::class.java) + ) + } @SettingDsl - fun setting( - name: String, - defaultValue: Double, - range: ClosedRange, - step: Double = 1.0, - description: String = "", - unit: String = "", - visibility: () -> Boolean = { true }, - ) = setting(name, description, DoubleSetting(defaultValue, range, step, unit), visibility) + fun setting( + name: String, + defaultValue: Double, + range: ClosedRange, + step: Double = 1.0, + description: String = "", + unit: String = "", + visibility: () -> Boolean = { true }, + ) = setting { layer -> DoubleSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } @SettingDsl - fun setting( - name: String, - defaultValue: Float, - range: ClosedRange, - step: Float = 1f, - description: String = "", - unit: String = "", - visibility: () -> Boolean = { true }, - ) = setting(name, description, FloatSetting(defaultValue, range, step, unit), visibility) + fun setting( + name: String, + defaultValue: Float, + range: ClosedRange, + step: Float = 1f, + description: String = "", + unit: String = "", + visibility: () -> Boolean = { true }, + ) = setting { layer -> FloatSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } @SettingDsl - fun setting( - name: String, - defaultValue: Int, - range: ClosedRange, - step: Int = 1, - description: String = "", - unit: String = "", - visibility: () -> Boolean = { true }, - ) = setting(name, description, IntegerSetting(defaultValue, range, step, unit), visibility) + fun setting( + name: String, + defaultValue: Int, + range: ClosedRange, + step: Int = 1, + description: String = "", + unit: String = "", + visibility: () -> Boolean = { true }, + ) = setting { layer -> IntegerSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } @SettingDsl - fun setting( - name: String, - defaultValue: Long, - range: ClosedRange, - step: Long = 1, - description: String = "", - unit: String = "", - visibility: () -> Boolean = { true }, - ) = setting(name, description, LongSetting(defaultValue, range, step, unit), visibility) + fun setting( + name: String, + defaultValue: Long, + range: ClosedRange, + step: Long = 1, + description: String = "", + unit: String = "", + visibility: () -> Boolean = { true }, + ) = setting { layer -> LongSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } @SettingDsl - fun setting( - name: String, - defaultValue: Bind, - description: String = "", - alwaysListening: Boolean = false, - screenCheck: Boolean = true, - visibility: () -> Boolean = { true }, - ) = setting(name, description, KeybindSetting(defaultValue, this as? Muteable, alwaysListening, screenCheck), visibility) + fun setting( + name: String, + defaultValue: Bind, + description: String = "", + alwaysListening: Boolean = false, + screenCheck: Boolean = true, + visibility: () -> Boolean = { true }, + ) = setting { layer -> KeybindSetting(name, description, this, layer, visibility, defaultValue, this as? Muteable, alwaysListening, screenCheck) } @SettingDsl - fun setting( - name: String, - defaultValue: KeyCode, - description: String = "", - alwaysListening: Boolean = false, - screenCheck: Boolean = true, - visibility: () -> Boolean = { true }, - ) = setting(name, description, KeybindSetting(defaultValue, this as? Muteable, alwaysListening, screenCheck), visibility) + fun setting( + name: String, + defaultValue: KeyCode, + description: String = "", + alwaysListening: Boolean = false, + screenCheck: Boolean = true, + visibility: () -> Boolean = { true }, + ) = setting { layer -> KeybindSetting(name, description, this, layer, visibility, defaultValue, this as? Muteable, alwaysListening, screenCheck) } @SettingDsl - fun setting( - name: String, - defaultValue: Color, - description: String = "", - visibility: () -> Boolean = { true }, - ) = setting(name, description, ColorSetting(defaultValue), visibility) + fun setting( + name: String, + defaultValue: Color, + description: String = "", + visibility: () -> Boolean = { true }, + ) = setting { layer -> ColorSetting(name, description, this, layer, visibility, defaultValue) } @SettingDsl - fun setting( - name: String, - defaultValue: Vec3d, - description: String = "", - visibility: () -> Boolean = { true }, - ) = setting(name, description, Vec3dSetting(defaultValue), visibility) + fun setting( + name: String, + defaultValue: Vec3d, + description: String = "", + visibility: () -> Boolean = { true }, + ) = setting { layer -> Vec3dSetting(name, description, this, layer, visibility, defaultValue) } @SettingDsl - fun setting( - name: String, - defaultValue: BlockPos.Mutable, - description: String = "", - visibility: () -> Boolean = { true }, - ) = setting(name, description, BlockPosSetting(defaultValue), visibility) + fun setting( + name: String, + defaultValue: BlockPos.Mutable, + description: String = "", + visibility: () -> Boolean = { true }, + ) = setting { layer -> BlockPosSetting(name, description, this, layer, visibility, defaultValue) } @SettingDsl - fun setting( - name: String, - defaultValue: BlockPos, - description: String = "", - visibility: () -> Boolean = { true }, - ) = setting(name, description, BlockPosSetting(defaultValue), visibility) + fun setting( + name: String, + defaultValue: BlockPos, + description: String = "", + visibility: () -> Boolean = { true }, + ) = setting { layer -> BlockPosSetting(name, description, this, layer, visibility, defaultValue) } @SettingDsl - fun setting( - name: String, - defaultValue: Block, - description: String = "", - visibility: () -> Boolean = { true }, - ) = setting(name, description, BlockSetting(defaultValue), visibility) + fun setting( + name: String, + defaultValue: Block, + description: String = "", + visibility: () -> Boolean = { true }, + ) = setting { layer -> BlockSetting(name, description, this, layer, visibility, defaultValue) } @SettingDsl - fun setting( - name: String, - defaultValue: () -> Unit, - description: String = "", - visibility: () -> Boolean = { true } - ) = setting(name, description, FunctionSetting(defaultValue), visibility) + fun R, R> setting( + name: String, + defaultValue: T, + description: String = "", + visibility: () -> Boolean = { true } + ) = setting { layer -> FunctionSetting(name, description, defaultValue, this, layer, visibility) } @SettingDsl fun settingBlock(settingBlock: T): SettingBlockWrapper = @@ -387,7 +383,7 @@ abstract class Config( } @PublishedApi - internal fun , R : Any> setting(name: String, description: String, settingCore: T, visibility: () -> Boolean): Setting { + internal fun , R> setting(settingSupplier: (single: SettingLayer.Single) -> T): T { val layerSpecInfo = try { registrationQueue.removeFirst() } catch (_: NoSuchElementException) { @@ -421,9 +417,8 @@ abstract class Config( } } - if (currentSettingLayer.layers.any { - it.name == name - }) throw IllegalStateException("Duplicate layer name ('$name') within ${currentSettingLayer.name}") + if (currentSettingLayer.layers.any { it.name == name }) + throw IllegalStateException("Duplicate layer name ('$name') within ${currentSettingLayer.name}") var currentBlockLayer: BlockLayer = settingBlockLayers layerSpecInfo.settingBlockSpecs.forEach { index -> @@ -436,15 +431,7 @@ abstract class Config( } } - val layer = SettingLayer.Single( - name, - currentSettingLayer, - currentBlockLayer, - description, - settingCore, - this@Config, - visibility - ) + val layer = SettingLayer.Single(currentSettingLayer, currentBlockLayer, settingSupplier) currentSettingLayer.layers.add(layer) currentBlockLayer.settingLayers.add(layer) return layer.setting @@ -459,44 +446,41 @@ abstract class Config( val name: String val parent: SettingLayer? - sealed class Multiple( - override val name: String, - val multipleType: MultipleLayerType, - val layers: MutableList, - override val parent: Multiple? - ) : SettingLayer, Nameable - - class Root : Multiple( - "Root", - MultipleLayerType.Root, - mutableListOf(), - null - ) - - class Tab( - name: String, - layers: MutableList, - parent: Multiple - ) : Multiple(name, MultipleLayerType.Tab, layers, parent) - - class Group( - name: String, - layers: MutableList, - parent: Multiple - ) : Multiple(name, MultipleLayerType.Group, layers, parent) - - class Single, R : Any>( - override val name: String, - override val parent: Multiple, - val blockLayer: BlockLayer, - description: String, - settingCore: T, - config: Config, - visibility: () -> Boolean, + sealed class Multiple( + override val name: String, + val multipleType: MultipleLayerType, + val layers: MutableList, + override val parent: Multiple? + ) : SettingLayer, Nameable + + class Root : Multiple( + "Root", + MultipleLayerType.Root, + mutableListOf(), + null + ) + + class Tab( + name: String, + layers: MutableList, + parent: Multiple + ) : Multiple(name, MultipleLayerType.Tab, layers, parent) + + class Group( + name: String, + layers: MutableList, + parent: Multiple + ) : Multiple(name, MultipleLayerType.Group, layers, parent) + + class Single, R>( + override val parent: Multiple, + val blockLayer: BlockLayer, + settingSupplier: (Single) -> T ) : SettingLayer { - val setting = Setting(name, description, settingCore, config, this, visibility) - } - } + val setting = settingSupplier(this) + override val name = setting.name + } + } sealed class BlockLayer { open val parent: BlockLayer? = null @@ -510,7 +494,7 @@ abstract class Config( class Block( override val parent: BlockLayer? ) : BlockLayer() { - var settingBlock: SettingBlockWrapper<*>? = null + lateinit var settingBlock: SettingBlockWrapper<*> } } diff --git a/src/main/kotlin/com/lambda/config/Setting.kt b/src/main/kotlin/com/lambda/config/Setting.kt index e8176b07d..2477442fa 100644 --- a/src/main/kotlin/com/lambda/config/Setting.kt +++ b/src/main/kotlin/com/lambda/config/Setting.kt @@ -89,10 +89,10 @@ import kotlin.reflect.KProperty * @property type The type reflection of the setting. */ @Suppress("unused") -class Setting, R>( +abstract class Setting( override val name: String, override val description: String, - var core: T, + var core: SettingCore, val config: Config, val layer: SettingLayer.Single<*, *>, var visibility: () -> Boolean @@ -100,46 +100,59 @@ class Setting, R>( val originalCore = core var disabled = { false } - var value by this + open var value by this - private val listeners = mutableListOf>() + val listeners = mutableListOf>() - val isModified get() = originalCore.isModified + open val isModified get() = originalCore.value != originalCore.defaultValue - operator fun getValue(thisRef: Any?, property: KProperty<*>) = core.coreValue - operator fun setValue(thisRef: Any?, property: KProperty<*>, value: R) { - val oldValue = core.coreValue - core.coreValue = value + open operator fun getValue(thisRef: Any?, property: KProperty<*>) = core.value + open operator fun setValue(thisRef: Any?, property: KProperty<*>, newValue: T) { + val oldValue = originalCore.value + originalCore.value = newValue listeners.forEach { - if (it.requiresValueChange && oldValue == value) return@forEach - it.execute(oldValue, value) + if (it.requiresValueChange && oldValue == newValue) return@forEach + it.execute(oldValue, newValue) } } fun reset(silent: Boolean = false) { - if (!silent && value == core.defaultValue) { + if (!silent && originalCore.value == originalCore.defaultValue) { ConfigCommand.info(notChangedMessage()) return } - if (!silent) ConfigCommand.info(resetMessage(value, core.defaultValue)) - value = core.defaultValue + if (!silent) ConfigCommand.info(resetMessage(value, originalCore.defaultValue)) + value = originalCore.defaultValue } fun restoreOriginalCore() { core = originalCore } - fun ImGuiBuilder.buildLayout() = with(core) { buildLayout() } - fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) = with(core) { buildCommand(registry) } + abstract fun ImGuiBuilder.buildLayout() - class ValueListener(val requiresValueChange: Boolean, val execute: (from: T, to: T) -> Unit) + open fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { + required(string("value as JSON")) { value -> + executeWithResult { + val valueString = value().value() + val previous = originalCore.value + try { + this@Setting.value = mapper.readValue(valueString, this@Setting.value?.javaClass) + } catch (_: Throwable) { + return@executeWithResult failure("Failed to deserialize $valueString as a ${type::class.simpleName} for $name in ${config.name}.") + } + ConfigCommand.info(setMessage(previous, originalCore.value)) + return@executeWithResult success() + } + } + } /** * Will only register changes of the variable, not the content of the variable! * E.g., if the variable is a list, it will only register if the list reference changes, not if the content of the list changes. */ @SettingDsl - fun onValueChange(block: SafeContext.(from: R, to: R) -> Unit) = apply { + fun onValueChange(block: SafeContext.(from: T, to: T) -> Unit) = apply { listeners.add(ValueListener(true) { from, to -> runSafe { block(from, to) @@ -148,12 +161,12 @@ class Setting, R>( } @SettingDsl - fun onValueChangeUnsafe(block: (from: R, to: R) -> Unit) = apply { + fun onValueChangeUnsafe(block: (from: T, to: T) -> Unit) = apply { listeners.add(ValueListener(true, block)) } @SettingDsl - fun onValueSet(block: (from: R, to: R) -> Unit) = apply { + fun onValueSet(block: (from: T, to: T) -> Unit) = apply { listeners.add(ValueListener(false, block)) } @@ -162,31 +175,31 @@ class Setting, R>( disabled = predicate } - fun trySetValue(newValue: R) { - if (newValue == value) { + fun trySetValue(newValue: T) { + if (newValue == originalCore.value) { ConfigCommand.info(notChangedMessage()) } else { - val previous = value + val previous = originalCore.value value = newValue ConfigCommand.info(setMessage(previous, newValue)) } } - fun setMessage(previousValue: R, newValue: R) = buildText { + fun setMessage(previousValue: T, newValue: T) = buildText { literal("Set ") changedMessage(previousValue, newValue) val commandPath = getConfigCommandPath().joinToString("->", postfix = "->").takeIf { it != "->" } ?: "" clickEvent(ClickEvents.suggestCommand("${CommandRegistry.prefix}${ConfigCommand.commandName} reset ${config.commandName} $commandPath$commandName")) { hoverEvent(HoverEvents.showText(buildText { literal("Click to reset to default value ") - highlighted(core.defaultValue.toString()) + highlighted(originalCore.defaultValue.toString()) })) { highlighted(" [Reset]") } } } - private fun resetMessage(previousValue: R, newValue: R) = buildText { + private fun resetMessage(previousValue: T, newValue: T) = buildText { literal("Reset ") changedMessage(previousValue, newValue) } @@ -195,11 +208,11 @@ class Setting, R>( literal("No changes made to ") highlighted(name) literal(" as it is already set to ") - highlighted(value.toString()) + highlighted(originalCore.value.toString()) literal(".") } - private fun TextBuilder.changedMessage(previousValue: R, newValue: R) { + private fun TextBuilder.changedMessage(previousValue: T, newValue: T) { highlighted(config.name) literal(" > ") highlighted(name) @@ -230,57 +243,14 @@ class Setting, R>( }.asReversed() override fun toString() = "Setting $name: $value" -} - -abstract class SettingCore( - var defaultValue: T -) { - /** - * The core value. Setting this variable bypasses all setting callbacks for value changes and is only used - * by the serialization logic when loading from the config files. This isn't considered changing the setting, rather - * applying its default value. For example, When setting the cores value inside the [buildLayout] or [buildCommand] methods, - * the [settingValue] should be used so the appropriate callbacks are invoked. - */ - open var coreValue = defaultValue - - /** - * A wrapper for the [coreValue] used to invoke the [setting]'s value-change callbacks - */ - context(setting: Setting<*, T>) - protected var settingValue - get() = coreValue - set(value) { - setting.value = value - } - open val isModified get() = coreValue != defaultValue - - /** - * A function invoked to build the core's gui interface. - */ - context(setting: Setting<*, T>) - abstract fun ImGuiBuilder.buildLayout() - - /** - * Builds the core's command using the [com.lambda.brigadier.BrigadierDsl] - */ - context(setting: Setting<*, T>) - open fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { - required(string("value as JSON")) { value -> - executeWithResult { - val valueString = value().value() - val previous = settingValue - try { - settingValue = mapper.readValue(valueString, settingValue?.javaClass) - } catch (_: Throwable) { - return@executeWithResult failure("Failed to deserialize $valueString as a ${type::class.simpleName} for $name in ${setting.config.name}.") - } - ConfigCommand.info(setting.setMessage(previous, this@SettingCore.coreValue)) - return@executeWithResult success() - } - } - } + class ValueListener(val requiresValueChange: Boolean, val execute: (from: T, to: T) -> Unit) } +class SettingCore( + var defaultValue: T, + var value: T = defaultValue, +) + @DslMarker annotation class SettingDsl \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt index fca93ce2a..e324f8c3f 100644 --- a/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt @@ -75,7 +75,7 @@ class MutableAutomationConfig : IMutableAutomationConfig { if (single.setting.core::class != otherSetting.core::class) throw IllegalStateException("Settings with the same name do not have the same type.") @Suppress("UNCHECKED_CAST") - (single.setting as Setting, Any>).core = otherSetting.core as SettingCore + (single.setting as Setting).core = otherSetting.core as SettingCore } } backingAutomationConfig = value diff --git a/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingSerializer.kt index 76fda4a2a..c609f4100 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingSerializer.kt @@ -22,7 +22,7 @@ package com.lambda.config.serializers import com.fasterxml.jackson.core.JsonParseException import com.lambda.config.Deserializer import com.lambda.config.Serializer -import com.lambda.config.SettingCore +import com.lambda.config.Setting import com.lambda.config.settings.collections.ClassCollectionSetting import com.lambda.util.ReflectionUtils.className import tools.jackson.core.JsonGenerator @@ -33,7 +33,7 @@ import tools.jackson.databind.SerializationContext object ClassCollectionSettingSerializer : Serializer>(ClassCollectionSetting::class.java) { override fun serialize(setting: ClassCollectionSetting<*>, gen: JsonGenerator, ctxt: SerializationContext) { gen.writeStartArray() - setting.coreValue.forEach { element -> + setting.originalCore.value.forEach { element -> gen.writeString(element.className) } gen.writeEndArray() @@ -45,8 +45,8 @@ object ClassCollectionSettingDeserializer : Deserializer): ClassCollectionSetting<*> = - settingCore.apply { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, setting: ClassCollectionSetting<*>): ClassCollectionSetting<*> = + setting.apply { val arrayNode = mapper.readTree(p) if (!arrayNode.isArray) throw JsonParseException("ClassCollectionSetting's serialized value is not an array.") val classNames = mutableListOf() @@ -56,8 +56,8 @@ object ClassCollectionSettingDeserializer : Deserializer).coreValue = classNames.mapNotNull { className -> - settingCore.immutableCollection.find { it.className == className } + (setting as Setting).originalCore.value = classNames.mapNotNull { className -> + setting.immutableCollection.find { it.className == className } } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/CollectionSettingSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/CollectionSettingSerializer.kt index c48457599..f2c1d6229 100644 --- a/src/main/kotlin/com/lambda/config/serializers/CollectionSettingSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/CollectionSettingSerializer.kt @@ -30,10 +30,10 @@ import tools.jackson.databind.SerializationContext object CollectionSettingSerializer : FallbackSerializer>(CollectionSetting::class.java) { override fun serialize(setting: CollectionSetting<*>, gen: JsonGenerator, ctxt: SerializationContext) { - if (setting.serialize) mapper.writeValue(gen, setting.coreValue) + if (setting.serialize) mapper.writeValue(gen, setting.originalCore.value) else { gen.writeStartArray() - setting.coreValue.forEach { element -> + setting.originalCore.value.forEach { element -> gen.writeString(element.toString()) } gen.writeEndArray() @@ -66,6 +66,6 @@ object CollectionSettingDeserializer : FallbackDeserializer } @Suppress("unchecked_cast") - (this as CollectionSetting).coreValue = newValue + (this as CollectionSetting).originalCore.value = newValue } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt index 64dcb95e7..8a8559d11 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt @@ -25,7 +25,7 @@ import com.lambda.config.Config.SettingLayer import com.lambda.config.ConfigCategory import com.lambda.config.FallbackDeserializer import com.lambda.config.FallbackSerializer -import com.lambda.config.SettingCore +import com.lambda.config.Setting import com.lambda.config.migration.ConfigMigrationHandler import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser @@ -134,20 +134,20 @@ object SingleFallbackDeserializer : FallbackDeserializer>(SettingCore::class.java) { - override fun serialize(core: SettingCore<*>, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writePOJO(core.coreValue) +object SettingCoreFallbackSerializer : FallbackSerializer>(Setting::class.java) { + override fun serialize(setting: Setting<*>, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writePOJO(setting.originalCore.value) } } -object SettingCoreFallbackDeserializer : FallbackDeserializer>(SettingCore::class.java) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SettingCore<*> { +object SettingCoreFallbackDeserializer : FallbackDeserializer>(Setting::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Setting<*> { throw initFromJsonException("SettingCore") } - override fun deserialize(p: JsonParser, ctxt: DeserializationContext, core: SettingCore<*>) = - core.apply { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, setting: Setting<*>) = + setting.apply { @Suppress("unchecked_cast") - (this as SettingCore).coreValue = mapper.treeToValue(mapper.readTree(p), coreValue.javaClass) + (this as Setting).originalCore.value = mapper.treeToValue(mapper.readTree(p), originalCore.value.javaClass) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/FunctionSettingSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/FunctionSettingSerializer.kt index 7dd14355f..61a03e092 100644 --- a/src/main/kotlin/com/lambda/config/serializers/FunctionSettingSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/FunctionSettingSerializer.kt @@ -27,16 +27,16 @@ import tools.jackson.core.JsonParser import tools.jackson.databind.DeserializationContext import tools.jackson.databind.SerializationContext -object FunctionSettingSerializer : Serializer>(FunctionSetting::class.java) { - override fun serialize(functionSetting: FunctionSetting<*>, gen: JsonGenerator, ctxt: SerializationContext) { +object FunctionSettingSerializer : Serializer>(FunctionSetting::class.java) { + override fun serialize(functionSetting: FunctionSetting<*, *>, gen: JsonGenerator, ctxt: SerializationContext) { gen.writeNull() } } -object FunctionSettingDeserializer : Deserializer>(FunctionSetting::class.java) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): FunctionSetting<*> { +object FunctionSettingDeserializer : Deserializer>(FunctionSetting::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): FunctionSetting<*, *> { throw initFromJsonException("FunctionSetting") } - override fun deserialize(p: JsonParser, ctxt: DeserializationContext, functionSetting: FunctionSetting<*>): FunctionSetting<*> = functionSetting + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, functionSetting: FunctionSetting<*, *>): FunctionSetting<*, *> = functionSetting } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/CharSetting.kt b/src/main/kotlin/com/lambda/config/settings/CharSetting.kt index b28f8de39..7eb3b9977 100644 --- a/src/main/kotlin/com/lambda/config/settings/CharSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/CharSetting.kt @@ -23,6 +23,8 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.argument.word import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.gui.dsl.ImGuiBuilder @@ -32,20 +34,23 @@ import net.minecraft.command.CommandRegistryAccess /** * @see [com.lambda.config.Config] */ -class CharSetting(defaultValue: Char) : SettingCore( - defaultValue -) { - context(_: Setting<*, Char>) +class CharSetting( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, Char>, + defaultValue: Char, + visibility: () -> Boolean +) : Setting(name, description, SettingCore(defaultValue), config, layer, visibility) { override fun ImGuiBuilder.buildLayout() {} - context(setting: Setting<*, Char>) - override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { - required(word(setting.name)) { parameter -> - executeWithResult { - val char = parameter().value().firstOrNull() ?: return@executeWithResult failure("Cant parse char type") - setting.trySetValue(char) - return@executeWithResult success() - } - } - } -} + override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { + required(word(name)) { parameter -> + executeWithResult { + val char = parameter().value().firstOrNull() ?: return@executeWithResult failure("Can't parse char type") + trySetValue(char) + return@executeWithResult success() + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/FunctionSetting.kt b/src/main/kotlin/com/lambda/config/settings/FunctionSetting.kt index 035f99847..3a9800d8d 100644 --- a/src/main/kotlin/com/lambda/config/settings/FunctionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/FunctionSetting.kt @@ -17,16 +17,22 @@ package com.lambda.config.settings +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.gui.dsl.ImGuiBuilder -open class FunctionSetting(defaultValue: () -> T) : SettingCore<() -> T>( - defaultValue -) { - context(setting: Setting<*, () -> T>) +class FunctionSetting R, R>( + name: String, + description: String, + defaultValue: T, + config: Config, + layer: SettingLayer.Single, T>, + visibility: () -> Boolean +) : Setting(name, description, SettingCore(defaultValue), config, layer, visibility) { override fun ImGuiBuilder.buildLayout() { - button(setting.name) { coreValue() } - lambdaTooltip(setting.description) + button(name) { value() } + lambdaTooltip(description) } } diff --git a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt index 265cd6792..0dc2e0ddd 100644 --- a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt @@ -17,6 +17,8 @@ package com.lambda.config.settings +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.ConfigEditor import com.lambda.config.Setting import com.lambda.config.SettingCore @@ -33,81 +35,82 @@ import java.util.* * @see [com.lambda.config.Config] */ abstract class NumericSetting( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, T>, defaultValue: T, + visibility: () -> Boolean, open var range: ClosedRange, open var step: T, var unit: String -) : SettingCore( - defaultValue -) where T : Number, T : Comparable { - override var coreValue: T - get() = super.coreValue +) : Setting(name, description, SettingCore(defaultValue), config, layer, visibility) where T : Number, T : Comparable { + override var value: T + get() = super.value set(newVal) { - super.coreValue = newVal.coerceIn(range) + super.value = newVal.coerceIn(range) } - private val formatter = NumberFormat.getNumberInstance(Locale.getDefault()) + private val formatter = NumberFormat.getNumberInstance(Locale.getDefault()) - override fun toString() = "${formatter.format(coreValue)}$unit" + override fun toString() = "${formatter.format(value)}$unit" - /** - * Subclasses must implement this to provide their specific slider widget. - */ - context(_: Setting<*, T>) - protected abstract fun ImGuiBuilder.buildSlider() + /** + * Subclasses must implement this to provide their specific slider widget. + */ + protected abstract fun ImGuiBuilder.buildSlider() - context(setting: Setting<*, T>) - override fun ImGuiBuilder.buildLayout() { - val showReset = setting.isModified - val resetButtonText = "R" - val valueString = this@NumericSetting.toString() + override fun ImGuiBuilder.buildLayout() { + val showReset = isModified + val resetButtonText = "R" + val valueString = this@NumericSetting.toString() - buildSlider() - lambdaTooltip(setting.description) + buildSlider() + lambdaTooltip(description) - val itemRectMin = ImGui.getItemRectMin() - val itemRectMax = ImGui.getItemRectMax() - val textHeight = ImGui.getTextLineHeight() - val textY = itemRectMin.y + (itemRectMax.y - itemRectMin.y - textHeight) / 2.0f - val labelWidth = calcTextSize(setting.name).x - val valueWidth = calcTextSize(valueString).x + val itemRectMin = ImGui.getItemRectMin() + val itemRectMax = ImGui.getItemRectMax() + val textHeight = ImGui.getTextLineHeight() + val textY = itemRectMin.y + (itemRectMax.y - itemRectMin.y - textHeight) / 2.0f + val labelWidth = calcTextSize(name).x + val valueWidth = calcTextSize(valueString).x - val labelEndPosX = itemRectMin.x + style.framePadding.x * 2 + labelWidth - val valueStartPosX = itemRectMax.x - style.framePadding.x * 2 - valueWidth + val labelEndPosX = itemRectMin.x + style.framePadding.x * 2 + labelWidth + val valueStartPosX = itemRectMax.x - style.framePadding.x * 2 - valueWidth - windowDrawList.addText(itemRectMin.x + style.framePadding.x * 2, textY, ImGui.getColorU32(ImGuiCol.Text), setting.name) - if (labelEndPosX < valueStartPosX) { - windowDrawList.addText(valueStartPosX, textY, ImGui.getColorU32(ImGuiCol.Text), valueString) - } + windowDrawList.addText(itemRectMin.x + style.framePadding.x * 2, textY, ImGui.getColorU32(ImGuiCol.Text), name) + if (labelEndPosX < valueStartPosX) { + windowDrawList.addText(valueStartPosX, textY, ImGui.getColorU32(ImGuiCol.Text), valueString) + } - sameLine(0.0f, style.itemSpacing.x) - if (showReset) { - button("$resetButtonText##${setting.name}") { - setting.reset() - } - onItemHover { - tooltip { text("Reset to default") } - } - } else { - dummy(calcTextSize(resetButtonText).x + style.framePadding.x * 2.0f, ImGui.getFrameHeight()) - } - } + sameLine(0.0f, style.itemSpacing.x) + if (showReset) { + button("$resetButtonText##$name") { + reset() + } + onItemHover { + tooltip { text("Reset to default") } + } + } else { + dummy(calcTextSize(resetButtonText).x + style.framePadding.x * 2.0f, ImGui.getFrameHeight()) + } + } - @Suppress("unchecked_cast", "unused") - companion object { - @SettingEditorDsl - fun ConfigEditor.TypedEditBuilder.range(range: ClosedRange) where T : Number, T : Comparable { - (settings as Collection>).forEach { it.range = range } - } + @Suppress("unchecked_cast", "unused") + companion object { + @SettingEditorDsl + fun ConfigEditor.TypedEditBuilder.range(range: ClosedRange) where T : Number, T : Comparable { + (settings as Collection>).forEach { it.range = range } + } - @SettingEditorDsl - fun ConfigEditor.TypedEditBuilder.step(step: T) where T : Number, T : Comparable { - (settings as Collection>).forEach { it.step = step } - } + @SettingEditorDsl + fun ConfigEditor.TypedEditBuilder.step(step: T) where T : Number, T : Comparable { + (settings as Collection>).forEach { it.step = step } + } - @SettingEditorDsl - fun ConfigEditor.TypedEditBuilder.unit(unit: String) where T : Number, T : Comparable { - (settings as Collection>).forEach { it.unit = unit} - } - } + @SettingEditorDsl + fun ConfigEditor.TypedEditBuilder.unit(unit: String) where T : Number, T : Comparable { + (settings as Collection>).forEach { it.unit = unit } + } + } } diff --git a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt index c7fb1acc4..0cc257304 100644 --- a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt @@ -21,6 +21,8 @@ import com.lambda.brigadier.argument.greedyString import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.ConfigEditor import com.lambda.config.Setting import com.lambda.config.SettingCore @@ -34,27 +36,29 @@ import net.minecraft.command.CommandRegistryAccess * @see [com.lambda.config.Config] */ class StringSetting( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, String>, defaultValue: String, + visibility: () -> Boolean, var multiline: Boolean = false, var flags: Int = ImGuiInputTextFlags.None, -) : SettingCore( - defaultValue -) { - context(setting: Setting<*, String>) +) : Setting(name, description, SettingCore(defaultValue), config, layer, visibility) { + override fun ImGuiBuilder.buildLayout() { if (multiline) { - inputTextMultiline(setting.name, ::coreValue, flags = flags) + inputTextMultiline(name, ::value, flags = flags) } else { - inputText(setting.name, setting::value, flags) + inputText(name, ::value, flags) } - lambdaTooltip(setting.description) + lambdaTooltip(description) } - context(setting: Setting<*, String>) override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { - required(greedyString(setting.name)) { parameter -> + required(greedyString(name)) { parameter -> execute { - setting.trySetValue(parameter().value()) + trySetValue(parameter().value()) } } } @@ -71,4 +75,4 @@ class StringSetting( (settings as Collection).forEach { it.flags = flags } } } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt index 9cbe9c2b4..84646e599 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt @@ -18,20 +18,30 @@ package com.lambda.config.settings.collections import com.lambda.Lambda.typeFactory -import com.lambda.config.Setting +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.serializers.BlockSerializer import com.lambda.gui.dsl.ImGuiBuilder import net.minecraft.block.Block class BlockCollectionSetting( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, MutableCollection>, + visibility: () -> Boolean, immutableCollection: Collection, defaultValue: MutableCollection, ) : CollectionSetting( + name, + description, + config, + layer, + visibility, defaultValue, immutableCollection, typeFactory.constructCollectionType(MutableCollection::class.java, Block::class.java), serialize = true, ) { - context(_: Setting<*, MutableCollection>) override fun ImGuiBuilder.buildLayout() = buildDualPane("block") { BlockSerializer.stringify(it) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt index b444e13aa..4e698db5f 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt @@ -18,7 +18,8 @@ package com.lambda.config.settings.collections import com.lambda.Lambda.typeFactory -import com.lambda.config.Setting +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.util.ReflectionUtils.className @@ -27,14 +28,23 @@ import com.lambda.util.ReflectionUtils.className * @see [com.lambda.config.Config] */ class ClassCollectionSetting( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, MutableCollection>, + visibility: () -> Boolean, immutableCollection: Collection, defaultValue: MutableCollection ) : CollectionSetting( + name, + description, + config, + layer, + visibility, defaultValue, immutableCollection, typeFactory.constructCollectionType(Collection::class.java, Any::class.java), serialize = false, ) { - context(_: Setting<*, MutableCollection>) override fun ImGuiBuilder.buildLayout() = buildDualPane("item") { it.className } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt index 15e77dfcf..da2ff0b19 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt @@ -17,6 +17,8 @@ package com.lambda.config.settings.collections +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.ConfigEditor import com.lambda.config.Setting import com.lambda.config.SettingCore @@ -45,46 +47,49 @@ import tools.jackson.databind.JavaType * @see [com.lambda.config.Config] */ open class CollectionSetting( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, MutableCollection>, + visibility: () -> Boolean, defaultValue: MutableCollection, var immutableCollection: Collection, val type: JavaType, val serialize: Boolean, -) : SettingCore>( - defaultValue -) { - override var coreValue: MutableCollection = defaultValue.toMutableList() +) : Setting>(name, description, SettingCore(defaultValue), config, layer, visibility) { + override var value: MutableCollection + get() = super.value set(newVal) { - field = newVal.toMutableList() + super.value = newVal.toMutableList() } - private var searchFilter = "" + private var searchFilter = "" - val selectListeners = mutableListOf Unit>() - val deselectListeners = mutableListOf Unit>() + val selectListeners = mutableListOf Unit>() + val deselectListeners = mutableListOf Unit>() - override val isModified get() = coreValue.size != defaultValue.size || defaultValue.any { !coreValue.contains(it) } + override val isModified: Boolean + get() = value.size != immutableCollection.size || immutableCollection.any { !value.contains(it) } - context(_: Setting<*, MutableCollection>) - override fun ImGuiBuilder.buildLayout() = buildDualPane("item") { it.toString() } + override fun ImGuiBuilder.buildLayout() = buildDualPane("item") { it.toString() } - context(setting: Setting<*, MutableCollection>) fun ImGuiBuilder.buildDualPane(itemName: String, toString: (R) -> String) { - val text = if (settingValue.size == 1) itemName else "${itemName}s" - val popupId = "##${setting.name}-collection-popup" + val text = if (value.size == 1) itemName else "${itemName}s" + val popupId = "##$name-collection-popup" - button("${setting.name}: ${settingValue.size} $text") { + button("$name: ${value.size} $text") { ImGui.openPopup(popupId) } ImGui.setNextWindowSizeConstraints(500f, 0f, Float.MAX_VALUE, io.displaySize.y * 0.5f) popupContextItem(popupId, ImGuiPopupFlags.None) { - inputText("##${setting.name}-SearchBox", ::searchFilter) + inputText("##$name-SearchBox", ::searchFilter) val q = searchFilter.trim() val filteredDeselected = immutableCollection - .filter { item -> !settingValue.contains(item) && (q.isEmpty() || toString(item).contains(q, ignoreCase = true)) } + .filter { item -> !value.contains(item) && (q.isEmpty() || toString(item).contains(q, ignoreCase = true)) } val filteredSelected = immutableCollection - .filter { item -> settingValue.contains(item) && (q.isEmpty() || toString(item).contains(q, ignoreCase = true)) } + .filter { item -> value.contains(item) && (q.isEmpty() || toString(item).contains(q, ignoreCase = true)) } val availableWidth = getContentRegionAvail().x val swapButtonWidth = 30f @@ -94,7 +99,7 @@ open class CollectionSetting( group { textDisabled("Deselected (${filteredDeselected.size})") child( - strId = "##${setting.name}-Deselected", + strId = "##$name-Deselected", width = paneWidth, height = paneHeight, childFlags = ImGuiChildFlags.Border or ImGuiChildFlags.ResizeX or ImGuiChildFlags.ResizeY, @@ -106,7 +111,7 @@ open class CollectionSetting( label = toString(v), flags = DontClosePopups ) { - settingValue.add(v) + value.add(v) runSafe { selectListeners.forEach { listener -> listener(v) } } } } @@ -120,17 +125,17 @@ open class CollectionSetting( group { cursorPosY += paneHeight / 2f button("<>", swapButtonWidth) { - val currentlySelected = settingValue.toList() + val currentlySelected = value.toList() val allItems = immutableCollection.toList() - settingValue.clear() + value.clear() allItems.forEach { item -> if (!currentlySelected.contains(item)) { - settingValue.add(item) + value.add(item) } } runSafe { currentlySelected.forEach { v -> deselectListeners.forEach { listener -> listener(v) } } - settingValue.forEach { v -> selectListeners.forEach { listener -> listener(v) } } + value.forEach { v -> selectListeners.forEach { listener -> listener(v) } } } } } @@ -140,7 +145,7 @@ open class CollectionSetting( group { textDisabled("Selected (${filteredSelected.size})") child( - strId = "##${setting.name}-Selected", + strId = "##$name-Selected", width = paneWidth, height = paneHeight, childFlags = ImGuiChildFlags.Border or ImGuiChildFlags.ResizeX or ImGuiChildFlags.ResizeY, @@ -152,7 +157,7 @@ open class CollectionSetting( label = toString(v), flags = DontClosePopups ) { - settingValue.remove(v) + value.remove(v) runSafe { deselectListeners.forEach { listener -> listener(v) } } } } @@ -166,19 +171,17 @@ open class CollectionSetting( @Suppress("unused") companion object { @SettingDsl - fun , R : Any> Setting>.onSelect(block: SafeContext.(R) -> Unit) = apply { - core.selectListeners.add(block) - } + fun , R : Any> T.onSelect(block: SafeContext.(R) -> Unit) = + apply { selectListeners.add(block) } @SettingDsl - fun , R : Any> Setting>.onDeselect(block: SafeContext.(R) -> Unit) = apply { - core.deselectListeners.add(block) - } + fun , R : Any> T.onDeselect(block: SafeContext.(R) -> Unit) = + apply { deselectListeners.add(block) } @Suppress("unchecked_cast") - @SettingEditorDsl - fun ConfigEditor.TypedEditBuilder>.immutableCollection(collection: Collection) { - (settings as Collection>).forEach { it.immutableCollection = collection } - } - } -} + @SettingEditorDsl + fun ConfigEditor.TypedEditBuilder>.immutableCollection(collection: Collection) { + (settings as Collection>).forEach { it.immutableCollection = collection } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt index 23422f002..7876c05e0 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt @@ -18,20 +18,26 @@ package com.lambda.config.settings.collections import com.lambda.Lambda.typeFactory -import com.lambda.config.Setting +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.serializers.ItemSerializer import com.lambda.gui.dsl.ImGuiBuilder import net.minecraft.item.Item class ItemCollectionSetting( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, MutableCollection>, + visibility: () -> Boolean, immutableCollection: Collection, defaultValue: MutableCollection ) : CollectionSetting( + name, description, config, layer, visibility, defaultValue, immutableCollection, typeFactory.constructCollectionType(Collection::class.java, Item::class.java), serialize = true, ) { - context(_: Setting<*, MutableCollection>) override fun ImGuiBuilder.buildLayout() = buildDualPane("item") { ItemSerializer.stringify(it) } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt index 93037c252..fa8f59332 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt @@ -17,20 +17,21 @@ package com.lambda.config.settings.collections +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.gui.dsl.ImGuiBuilder import tools.jackson.databind.JavaType -/** - * @see [com.lambda.config.Config] - */ class MapSetting( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, MutableMap>, + visibility: () -> Boolean, defaultValue: MutableMap, val type: JavaType -) : SettingCore>( - defaultValue -) { - context(_: Setting<*, MutableMap>) +) : Setting>(name, description, SettingCore(defaultValue), config, layer, visibility) { override fun ImGuiBuilder.buildLayout() {} -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt b/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt index 54647ad29..3b056c4d6 100644 --- a/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt @@ -21,30 +21,32 @@ import com.lambda.brigadier.argument.boolean import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandRegistryAccess -/** - * @see [com.lambda.config.Config] - */ -class BooleanSetting(defaultValue: Boolean) : SettingCore( - defaultValue -) { - context(setting: Setting<*, Boolean>) +class BooleanSetting( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, Boolean>, + visibility: () -> Boolean, + defaultValue: Boolean +) : Setting(name, description, SettingCore(defaultValue), config, layer, visibility) { override fun ImGuiBuilder.buildLayout() { - checkbox(setting.name, setting::value) - lambdaTooltip(setting.description) - } + checkbox(name, ::value) + lambdaTooltip(description) + } - context(setting: Setting<*, Boolean>) - override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { - required(boolean(setting.name)) { parameter -> - execute { - setting.trySetValue(parameter().value()) - } - } - } -} + override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { + required(boolean(name)) { parameter -> + execute { + trySetValue(parameter().value()) + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt b/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt index 1f51fae31..f3503bea8 100644 --- a/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt @@ -23,6 +23,8 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.argument.word import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.gui.dsl.ImGuiBuilder @@ -32,44 +34,44 @@ import com.lambda.util.extension.CommandBuilder import com.lambda.util.extension.displayValue import net.minecraft.command.CommandRegistryAccess -/** - * @see [com.lambda.config.Config] - */ -class EnumSetting>(defaultValue: T) : SettingCore( - defaultValue -) { - context(setting: Setting<*, T>) +class EnumSetting>( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, T>, + visibility: () -> Boolean, + defaultValue: T +) : Setting(name, description, SettingCore(defaultValue), config, layer, visibility) { override fun ImGuiBuilder.buildLayout() { - val values = settingValue.enumValues - val currentDisplay = settingValue.displayValue - val currentIndex = settingValue.ordinal + val values = value.enumValues + val currentDisplay = value.displayValue + val currentIndex = value.ordinal - combo("##${setting.name}", preview = "${setting.name}: $currentDisplay") { + combo("##$name", preview = "$name: $currentDisplay") { values.forEachIndexed { idx, v -> val isSelected = idx == currentIndex selectable(v.displayValue, isSelected) { - if (!isSelected) settingValue = values[idx % values.size] + if (!isSelected) value = values[idx % values.size] } (v as? Describable)?.let { lambdaTooltip(it.description) } } } - lambdaTooltip(setting.description) + lambdaTooltip(description) } - context(setting: Setting<*, T>) override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { - required(word(setting.name)) { parameter -> + required(word(name)) { parameter -> suggests { _, builder -> - settingValue.enumValues.forEach { builder.suggest(it.name.capitalize()) } + value.enumValues.forEach { builder.suggest(it.name.capitalize()) } builder.buildFuture() } executeWithResult { - val newValue = settingValue.enumValues.find { it.name.equals(parameter().value(), true) } + val newValue = value.enumValues.find { it.name.equals(parameter().value(), true) } ?: return@executeWithResult failure("Invalid value") - setting.trySetValue(newValue) + trySetValue(newValue) return@executeWithResult success() } } @@ -79,4 +81,4 @@ class EnumSetting>(defaultValue: T) : SettingCore( val > T.enumValues: Array get() = declaringJavaClass.enumConstants } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt index 067c2428b..32ddf2959 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt @@ -22,6 +22,8 @@ import com.lambda.brigadier.argument.integer import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.gui.dsl.ImGuiBuilder @@ -32,37 +34,37 @@ import com.lambda.util.world.raycast.RayCastUtils.blockResult import net.minecraft.command.CommandRegistryAccess import net.minecraft.util.math.BlockPos -/** - * @see [com.lambda.config.Config] - */ -class BlockPosSetting(defaultValue: BlockPos) : SettingCore( - defaultValue -) { - context(setting: Setting<*, BlockPos>) +class BlockPosSetting( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, BlockPos>, + visibility: () -> Boolean, + defaultValue: BlockPos +) : Setting(name, description, SettingCore(defaultValue), config, layer, visibility) { override fun ImGuiBuilder.buildLayout() { - button("Set##${setting.name}") { + button("Set##$name") { mc.crosshairTarget?.blockResult?.blockPos?.let { - settingValue = it + value = it } ?: info("No block under crosshair") } lambdaTooltip("Set the coordinates to the block you are currently looking at") sameLine() - treeNode(setting.name, id = setting.name) { - inputVec3i("##${setting.name}", settingValue) { settingValue = it.blockPos } + treeNode(name, id = name) { + inputVec3i("##$name", value) { value = it.blockPos } } - lambdaTooltip(setting.description) + lambdaTooltip(description) } - context(setting: Setting<*, BlockPos>) - override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { - required(integer("X", -30000000, 30000000)) { x -> - required(integer("Y", -64, 319)) { y -> - required(integer("Z", -30000000, 30000000)) { z -> - execute { - setting.trySetValue(BlockPos(x().value(), y().value(), z().value())) - } - } - } - } - } -} + override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { + required(integer("X", -30000000, 30000000)) { x -> + required(integer("Y", -64, 319)) { y -> + required(integer("Z", -30000000, 30000000)) { z -> + execute { + trySetValue(BlockPos(x().value(), y().value(), z().value())) + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt index edf99eeff..1147604ea 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt @@ -21,6 +21,8 @@ import com.lambda.brigadier.argument.blockState import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.gui.dsl.ImGuiBuilder @@ -28,21 +30,21 @@ import com.lambda.util.extension.CommandBuilder import net.minecraft.block.Block import net.minecraft.command.CommandRegistryAccess -/** - * @see [com.lambda.config.Config] - */ -class BlockSetting(defaultValue: Block) : SettingCore( - defaultValue -) { - context(_: Setting<*, Block>) - override fun ImGuiBuilder.buildLayout() {} +class BlockSetting( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, Block>, + visibility: () -> Boolean, + defaultValue: Block +) : Setting(name, description, SettingCore(defaultValue), config, layer, visibility) { + override fun ImGuiBuilder.buildLayout() {} - context(setting: Setting<*, Block>) - override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { - required(blockState(setting.name, registry)) { argument -> - execute { - setting.trySetValue(argument().value().blockState.block) - } - } - } -} + override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { + required(blockState(name, registry)) { argument -> + execute { + trySetValue(argument().value().blockState.block) + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt index 0d44a41c5..ca72ae6a8 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt @@ -22,6 +22,8 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.optional import com.lambda.brigadier.required +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.gui.dsl.ImGuiBuilder @@ -29,19 +31,19 @@ import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandRegistryAccess import java.awt.Color -/** - * @see [com.lambda.config.Config] - */ -class ColorSetting(defaultValue: Color) : SettingCore( - defaultValue -) { - context(setting: Setting<*, Color>) - override fun ImGuiBuilder.buildLayout() { - colorEdit(setting.name, setting::value) - lambdaTooltip(setting.description) +class ColorSetting( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, Color>, + visibility: () -> Boolean, + defaultValue: Color +) : Setting(name, description, SettingCore(defaultValue), config, layer, visibility) { + override fun ImGuiBuilder.buildLayout() { + colorEdit(name, ::value) + lambdaTooltip(description) } - context(setting: Setting<*, Color>) override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { required(integer("Red", 0, 255)) { red -> required(integer("Green", 0, 255)) { green -> @@ -49,11 +51,11 @@ class ColorSetting(defaultValue: Color) : SettingCore( optional(integer("Alpha", 0, 255)) { alpha -> execute { val alphaValue = alpha?.let { it().value() } ?: 255 - setting.trySetValue(Color(red().value(), green().value(), blue().value(), alphaValue)) + trySetValue(Color(red().value(), green().value(), blue().value(), alphaValue)) } } } } } } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt index 513458260..835d0c6d5 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt @@ -26,6 +26,8 @@ import com.lambda.brigadier.argument.word import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.optional import com.lambda.brigadier.required +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.config.SettingDsl @@ -54,15 +56,27 @@ import org.lwjgl.glfw.GLFW.GLFW_MOD_SHIFT import org.lwjgl.glfw.GLFW.GLFW_MOD_SUPER class KeybindSetting( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, Bind>, + visibility: () -> Boolean, defaultValue: Bind, private val muteable: Muteable?, private val alwaysListening: Boolean, private val screenCheck: Boolean -) : SettingCore( - defaultValue -), Muteable { - constructor(defaultValue: KeyCode, muteable: Muteable?, alwaysListen: Boolean, screenCheck: Boolean) - : this(Bind(defaultValue.code, 0, -1), muteable, alwaysListen, screenCheck) +) : Setting(name, description, SettingCore(defaultValue), config, layer, visibility), Muteable { + constructor( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, Bind>, + visibility: () -> Boolean, + defaultValue: KeyCode, + muteable: Muteable?, + alwaysListen: Boolean, + screenCheck: Boolean + ) : this(name, description, config, layer, visibility, Bind(defaultValue.code, 0, -1), muteable, alwaysListen, screenCheck) private val pressListeners = mutableListOf Unit>() private val repeatListeners = mutableListOf Unit>() @@ -81,7 +95,7 @@ class KeybindSetting( private fun SafeContext.onButtonEvent(event: ButtonEvent) { if (mc.options.commandKey.isPressed || (screenCheck && mc.currentScreen != null) || - !event.satisfies(coreValue)) return + !event.satisfies(value)) return if (event.isPressed) { if (event.isRepeated) repeatListeners.forEach { it(event) } @@ -89,12 +103,11 @@ class KeybindSetting( } else if (event.isReleased) releaseListeners.forEach { it(event) } } - context(setting: Setting<*, Bind>) override fun ImGuiBuilder.buildLayout() { - text(setting.name) + text(name) sameLine() - val bind = coreValue + val bind = value val preview = if (listening) "Press any key…" else bind.name @@ -114,7 +127,7 @@ class KeybindSetting( } lambdaTooltip { - if (!listening) setting.description.ifBlank { "Click to set. Esc cancels. Backspace/Delete unbinds." } + if (!listening) description.ifBlank { "Click to set. Esc cancels. Backspace/Delete unbinds." } else "Listening… Press a key to bind. Esc to cancel. Backspace/Delete to unbind." } @@ -125,7 +138,7 @@ class KeybindSetting( sameLine() withId("##Unbind-${this@KeybindSetting.hashCode()}") { smallButton("Unbind") { - settingValue = Bind.Empty + value = Bind.Empty listening = false } } @@ -136,7 +149,7 @@ class KeybindSetting( if (listening) { InputUtils.newMouseEvent() ?.let { - settingValue = Bind(0, it.modifiers, it.button) + value = Bind(0, it.modifiers, it.button) listening = false return } @@ -149,8 +162,8 @@ class KeybindSetting( if ((it.isPressed && !isModKey) || (it.isReleased && isModKey)) { when (it.translated) { KeyCode.Escape -> {} - KeyCode.Backspace, KeyCode.Delete -> coreValue = Bind.Empty - else -> coreValue = Bind(it.translated.code, it.modifiers, -1) + KeyCode.Backspace, KeyCode.Delete -> value = Bind.Empty + else -> value = Bind(it.translated.code, it.modifiers, -1) } listening = false @@ -161,12 +174,11 @@ class KeybindSetting( } } - context(setting: Setting<*, Bind>) override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { - required(word(setting.name)) { name -> + required(word(name)) { nameArg -> suggests { _, builder -> KeyCode.entries.forEach { builder.suggest(it.name.capitalize()) } - (1..10).forEach { builder.suggest(it) } + (1..10).forEach { builder.suggest(it.toString()) } builder.buildFuture() } optional(boolean("mouse button")) { isMouseButton -> @@ -175,20 +187,20 @@ class KeybindSetting( var bind = Bind.Empty if (isMouse) { val num = try { - name().value().toInt() + nameArg().value().toInt() } catch (_: NumberFormatException) { - return@executeWithResult failure("${name().value()} doesn't match with a mouse button") + return@executeWithResult failure("${nameArg().value()} doesn't match with a mouse button") } bind = Bind(0, 0, mouse = num) } else { bind = try { - Bind(KeyCode.valueOf(name().value()).code, 0) + Bind(KeyCode.valueOf(nameArg().value()).code, 0) } catch (_: IllegalArgumentException) { - return@executeWithResult failure("${name().value()} doesn't match with a bind") + return@executeWithResult failure("${nameArg().value()} doesn't match with a bind") } } - setting.trySetValue(bind) + trySetValue(bind) return@executeWithResult success() } } @@ -198,19 +210,13 @@ class KeybindSetting( @Suppress("unused") companion object { @SettingDsl - fun Setting.onPress(block: SafeContext.(ButtonEvent) -> Unit) = apply { - core.pressListeners.add(block) - } + fun KeybindSetting.onPress(block: SafeContext.(ButtonEvent) -> Unit) = apply { pressListeners.add(block) } @SettingDsl - fun Setting.onRepeat(block: SafeContext.(ButtonEvent) -> Unit) = apply { - core.repeatListeners.add(block) - } + fun KeybindSetting.onRepeat(block: SafeContext.(ButtonEvent) -> Unit) = apply { repeatListeners.add(block) } @SettingDsl - fun Setting.onRelease(block: SafeContext.(ButtonEvent) -> Unit) = apply { - core.releaseListeners.add(block) - } + fun KeybindSetting.onRelease(block: SafeContext.(ButtonEvent) -> Unit) = apply { releaseListeners.add(block) } } } diff --git a/src/main/kotlin/com/lambda/config/settings/complex/Vec3dSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/Vec3dSetting.kt index 0db002a87..ba505b566 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/Vec3dSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/Vec3dSetting.kt @@ -21,6 +21,8 @@ import com.lambda.brigadier.argument.double import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.gui.dsl.ImGuiBuilder @@ -28,25 +30,28 @@ import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandRegistryAccess import net.minecraft.util.math.Vec3d -class Vec3dSetting(defaultValue: Vec3d) : SettingCore( - defaultValue -) { - context(setting: Setting<*, Vec3d>) - override fun ImGuiBuilder.buildLayout() { - inputVec3d(setting.name, setting::value as Vec3d) // FixMe: what the fuck - lambdaTooltip(setting.description) +class Vec3dSetting( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, Vec3d>, + visibility: () -> Boolean, + defaultValue: Vec3d +) : Setting(name, description, SettingCore(defaultValue), config, layer, visibility) { + override fun ImGuiBuilder.buildLayout() { + inputVec3d(name, ::value as Vec3d) // FixMe: what the fuck + lambdaTooltip(description) } - context(setting: Setting<*, Vec3d>) override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { required(double("X", -30000000.0, 30000000.0)) { x -> required(double("Y", -64.0, 255.0)) { y -> required(double("Z", -30000000.0, 30000000.0)) { z -> execute { - setting.trySetValue(Vec3d(x().value(), y().value(), z().value())) + trySetValue(Vec3d(x().value(), y().value(), z().value())) } } } } } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt index 4311277cd..289d152f7 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt @@ -22,7 +22,8 @@ import com.lambda.brigadier.argument.double import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required -import com.lambda.config.Setting +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.settings.NumericSetting import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.type.ImInt @@ -35,34 +36,32 @@ import kotlin.math.roundToInt * @see [com.lambda.config.Config] */ class DoubleSetting( - defaultValue: Double, - override var range: ClosedRange, - override var step: Double, + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, Double>, + visibility: () -> Boolean, + defaultValue: Double, + override var range: ClosedRange, + override var step: Double, unit: String -) : NumericSetting( - defaultValue, - range, - step, - unit -) { - context(setting: Setting<*, Double>) +) : NumericSetting(name, description, config, layer, defaultValue, visibility, range, step, unit) { override fun ImGuiBuilder.buildSlider() { val maxIndex = ((range.endInclusive - range.start) / step).toInt() - val currentIndex = ((coreValue - range.start) / step).roundToInt() + val currentIndex = ((value - range.start) / step).roundToInt() val imInt = ImInt(currentIndex) - slider("##${setting.name}", imInt, 0, maxIndex, "") { - settingValue = (range.start + imInt.get() * step) + slider("##$name", imInt, 0, maxIndex, "") { + value = (range.start + imInt.get() * step) .roundToStep(step) .coerceIn(range) } } - context(setting: Setting<*, Double>) override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { - required(double(setting.name, range.start, range.endInclusive)) { parameter -> + required(double(name, range.start, range.endInclusive)) { parameter -> execute { - setting.trySetValue(parameter().value()) + trySetValue(parameter().value()) } } } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt index f866a213f..76d10bd15 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt @@ -21,7 +21,8 @@ import com.lambda.brigadier.argument.float import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required -import com.lambda.config.Setting +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.settings.NumericSetting import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.type.ImInt @@ -34,34 +35,32 @@ import kotlin.math.roundToInt * @see [com.lambda.config.Config] */ class FloatSetting( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, Float>, + visibility: () -> Boolean, defaultValue: Float, override var range: ClosedRange, override var step: Float = 1f, unit: String, -) : NumericSetting( - defaultValue, - range, - step, - unit -) { - context(setting: Setting<*, Float>) +) : NumericSetting(name, description, config, layer, defaultValue, visibility, range, step, unit) { override fun ImGuiBuilder.buildSlider() { val maxIndex = ((range.endInclusive - range.start) / step).toInt() - val currentIndex = ((coreValue - range.start) / step).roundToInt() + val currentIndex = ((value - range.start) / step).roundToInt() val imInt = ImInt(currentIndex) - slider("##${setting.name}", imInt, 0, maxIndex, "") { - settingValue = (range.start + imInt.get() * step) + slider("##$name", imInt, 0, maxIndex, "") { + value = (range.start + imInt.get() * step) .roundToStep(step) .coerceIn(range) } } - context(setting: Setting<*, Float>) override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { - required(float(setting.name, range.start, range.endInclusive)) { parameter -> + required(float(name, range.start, range.endInclusive)) { parameter -> execute { - setting.trySetValue(parameter().value()) + trySetValue(parameter().value()) } } } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/IntegerSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/IntegerSetting.kt index 09ad264b3..b17246d99 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/IntegerSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/IntegerSetting.kt @@ -21,7 +21,8 @@ import com.lambda.brigadier.argument.integer import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required -import com.lambda.config.Setting +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.settings.NumericSetting import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.util.extension.CommandBuilder @@ -31,27 +32,25 @@ import net.minecraft.command.CommandRegistryAccess * @see [com.lambda.config.Config] */ class IntegerSetting( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, Int>, + visibility: () -> Boolean, defaultValue: Int, override var range: ClosedRange, override var step: Int = 1, unit: String -) : NumericSetting( - defaultValue, - range, - step, - unit -) { - context(setting: Setting<*, Int>) +) : NumericSetting(name, description, config, layer, defaultValue, visibility, range, step, unit) { override fun ImGuiBuilder.buildSlider() { - slider("##${setting.name}", setting::value, range.start, range.endInclusive, "") + slider("##$name", ::value, range.start, range.endInclusive, "") } - context(setting: Setting<*, Int>) override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { - required(integer(setting.name, range.start, range.endInclusive)) { parameter -> + required(integer(name, range.start, range.endInclusive)) { parameter -> execute { - setting.trySetValue(parameter().value()) + trySetValue(parameter().value()) } } } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt index f74245dd5..b0d4b9ea0 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt @@ -21,7 +21,8 @@ import com.lambda.brigadier.argument.long import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required -import com.lambda.config.Setting +import com.lambda.config.Config +import com.lambda.config.Config.SettingLayer import com.lambda.config.settings.NumericSetting import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.type.ImInt @@ -32,33 +33,31 @@ import net.minecraft.command.CommandRegistryAccess * @see [com.lambda.config.Config] */ class LongSetting( + name: String, + description: String, + config: Config, + layer: SettingLayer.Single<*, Long>, + visibility: () -> Boolean, defaultValue: Long, override var range: ClosedRange, override var step: Long = 1, unit: String -) : NumericSetting( - defaultValue, - range, - step, - unit -) { - context(setting: Setting<*, Long>) +) : NumericSetting(name, description, config, layer, defaultValue, visibility, range, step, unit) { override fun ImGuiBuilder.buildSlider() { - // ToDo: No worky for super large numbers + // FixMe: No worky for super large numbers val maxIndex = ((range.endInclusive - range.start) / step).toInt() - val currentIndex = ((coreValue - range.start) / step).toInt() + val currentIndex = ((value - range.start) / step).toInt() val imInt = ImInt(currentIndex) - slider("##${setting.name}", imInt, 0, maxIndex, "") { - settingValue = (range.start + imInt.get() * step).coerceIn(range) + slider("##$name", imInt, 0, maxIndex, "") { + value = (range.start + imInt.get() * step).coerceIn(range) } } - context(setting: Setting<*, Long>) override fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) { - required(long(setting.name, range.start, range.endInclusive)) { parameter -> + required(long(name, range.start, range.endInclusive)) { parameter -> execute { - setting.trySetValue(parameter().value()) + trySetValue(parameter().value()) } } } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt index 36f67c63d..f4167b193 100644 --- a/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt +++ b/src/main/kotlin/com/lambda/gui/components/QuickSearch.kt @@ -102,7 +102,7 @@ object QuickSearch { } } - private class SettingResult(val setting: Setting<*, *>, val config: Config) : SearchResult { + private class SettingResult(val setting: Setting<*>, val config: Config) : SearchResult { override val breadcrumb: String by lazy { buildSettingBreadcrumb(config.name, setting) } override fun ImGuiBuilder.buildLayout() { @@ -300,7 +300,7 @@ object QuickSearch { } } - private fun buildSettingBreadcrumb(configName: String, setting: Setting<*, *>): String { + private fun buildSettingBreadcrumb(configName: String, setting: Setting<*>): String { val path = setting.getConfigCommandPath() return if (path.isEmpty()) configName else "$configName » ${path.joinToString(" » ")}" diff --git a/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt b/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt index 2981a337d..c5ae2788d 100644 --- a/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt +++ b/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt @@ -127,7 +127,7 @@ object SettingsWidget { } } - private fun ImGuiBuilder.drawSetting(setting: Setting<*, *>) { + private fun ImGuiBuilder.drawSetting(setting: Setting<*>) { if (!setting.visibility()) return if (setting.disabled()) ImGui.beginDisabled() with(setting) { buildLayout() } From 4d2d7f79fc710f9ae31d7643bfba5b63bbc489ca Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Tue, 2 Jun 2026 23:12:32 +0100 Subject: [PATCH 39/40] CollectionSetting isModified fix and JsonIncludeProperties for Bind --- src/main/kotlin/com/lambda/config/Config.kt | 44 +++++++++---------- .../config/{BaseEditor.kt => ConfigEditor.kt} | 0 src/main/kotlin/com/lambda/config/Setting.kt | 4 +- .../ClassCollectionSettingSerializer.kt | 5 +-- .../CollectionSettingSerializer.kt | 5 +-- .../config/serializers/ColorSerializer.kt | 3 +- .../ConfigCategoryFallbackSerializer.kt | 8 ++-- .../config/serializers/UuidSerializer.kt | 3 +- .../settings/collections/CollectionSetting.kt | 6 ++- .../config/settings/complex/KeybindSetting.kt | 4 +- 10 files changed, 40 insertions(+), 42 deletions(-) rename src/main/kotlin/com/lambda/config/{BaseEditor.kt => ConfigEditor.kt} (100%) diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index 5037a787f..275695e9e 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -168,7 +168,7 @@ abstract class Config( defaultValue: Boolean, description: String = "", visibility: () -> Boolean = { true }, - ) = setting { layer -> BooleanSetting(name, description, this, layer, visibility, defaultValue) } + ) = setting(name) { layer -> BooleanSetting(name, description, this, layer, visibility, defaultValue) } @SettingDsl fun > setting( @@ -176,7 +176,7 @@ abstract class Config( defaultValue: T, description: String = "", visibility: () -> Boolean = { true }, - ) = setting { layer -> EnumSetting(name, description, this, layer, visibility, defaultValue) } + ) = setting(name) { layer -> EnumSetting(name, description, this, layer, visibility, defaultValue) } @SettingDsl fun setting( @@ -184,7 +184,7 @@ abstract class Config( defaultValue: Char, description: String = "", visibility: () -> Boolean = { true }, - ) = setting { layer -> CharSetting(name, description, this, layer, defaultValue, visibility) } + ) = setting(name) { layer -> CharSetting(name, description, this, layer, defaultValue, visibility) } @SettingDsl fun setting( @@ -194,7 +194,7 @@ abstract class Config( flags: Int = ImGuiInputTextFlags.None, description: String = "", visibility: () -> Boolean = { true }, - ) = setting { layer -> StringSetting(name, description, this, layer, defaultValue, visibility, multiline, flags) } + ) = setting(name) { layer -> StringSetting(name, description, this, layer, defaultValue, visibility, multiline, flags) } @SettingDsl @JvmName("collectionSetting1") @@ -204,7 +204,7 @@ abstract class Config( immutableCollection: Collection = Registries.BLOCK.toList(), description: String = "", visibility: () -> Boolean = { true }, - ) = setting { layer -> BlockCollectionSetting(name, description, this, layer, visibility, immutableCollection, defaultValue.toMutableList()) } + ) = setting(name) { layer -> BlockCollectionSetting(name, description, this, layer, visibility, immutableCollection, defaultValue.toMutableList()) } @SettingDsl @JvmName("collectionSetting2") @@ -214,7 +214,7 @@ abstract class Config( immutableCollection: Collection = Registries.ITEM.toList(), description: String = "", visibility: () -> Boolean = { true }, - ) = setting { layer -> ItemCollectionSetting(name, description, this, layer, visibility, immutableCollection, defaultValue.toMutableList()) } + ) = setting(name) { layer -> ItemCollectionSetting(name, description, this, layer, visibility, immutableCollection, defaultValue.toMutableList()) } @SettingDsl @JvmName("collectionSetting3") @@ -226,7 +226,7 @@ abstract class Config( displayClassName: Boolean = false, serialize: Boolean = false, noinline visibility: () -> Boolean = { true }, - ) = setting { layer -> + ) = setting(name) { layer -> if (displayClassName) ClassCollectionSetting(name, description, this, layer, visibility, immutableList, defaultValue.toMutableList()) else @@ -239,7 +239,7 @@ abstract class Config( defaultValue: Map, description: String = "", noinline visibility: () -> Boolean = { true }, - ) = setting { layer -> + ) = setting(name) { layer -> MapSetting( name, description, this, layer, visibility, defaultValue.toMutableMap(), @@ -256,7 +256,7 @@ abstract class Config( description: String = "", unit: String = "", visibility: () -> Boolean = { true }, - ) = setting { layer -> DoubleSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } + ) = setting(name) { layer -> DoubleSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } @SettingDsl fun setting( @@ -267,7 +267,7 @@ abstract class Config( description: String = "", unit: String = "", visibility: () -> Boolean = { true }, - ) = setting { layer -> FloatSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } + ) = setting(name) { layer -> FloatSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } @SettingDsl fun setting( @@ -278,7 +278,7 @@ abstract class Config( description: String = "", unit: String = "", visibility: () -> Boolean = { true }, - ) = setting { layer -> IntegerSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } + ) = setting(name) { layer -> IntegerSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } @SettingDsl fun setting( @@ -289,7 +289,7 @@ abstract class Config( description: String = "", unit: String = "", visibility: () -> Boolean = { true }, - ) = setting { layer -> LongSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } + ) = setting(name) { layer -> LongSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } @SettingDsl fun setting( @@ -299,7 +299,7 @@ abstract class Config( alwaysListening: Boolean = false, screenCheck: Boolean = true, visibility: () -> Boolean = { true }, - ) = setting { layer -> KeybindSetting(name, description, this, layer, visibility, defaultValue, this as? Muteable, alwaysListening, screenCheck) } + ) = setting(name) { layer -> KeybindSetting(name, description, this, layer, visibility, defaultValue, this as? Muteable, alwaysListening, screenCheck) } @SettingDsl fun setting( @@ -309,7 +309,7 @@ abstract class Config( alwaysListening: Boolean = false, screenCheck: Boolean = true, visibility: () -> Boolean = { true }, - ) = setting { layer -> KeybindSetting(name, description, this, layer, visibility, defaultValue, this as? Muteable, alwaysListening, screenCheck) } + ) = setting(name) { layer -> KeybindSetting(name, description, this, layer, visibility, defaultValue, this as? Muteable, alwaysListening, screenCheck) } @SettingDsl fun setting( @@ -317,7 +317,7 @@ abstract class Config( defaultValue: Color, description: String = "", visibility: () -> Boolean = { true }, - ) = setting { layer -> ColorSetting(name, description, this, layer, visibility, defaultValue) } + ) = setting(name) { layer -> ColorSetting(name, description, this, layer, visibility, defaultValue) } @SettingDsl fun setting( @@ -325,7 +325,7 @@ abstract class Config( defaultValue: Vec3d, description: String = "", visibility: () -> Boolean = { true }, - ) = setting { layer -> Vec3dSetting(name, description, this, layer, visibility, defaultValue) } + ) = setting(name) { layer -> Vec3dSetting(name, description, this, layer, visibility, defaultValue) } @SettingDsl fun setting( @@ -333,7 +333,7 @@ abstract class Config( defaultValue: BlockPos.Mutable, description: String = "", visibility: () -> Boolean = { true }, - ) = setting { layer -> BlockPosSetting(name, description, this, layer, visibility, defaultValue) } + ) = setting(name) { layer -> BlockPosSetting(name, description, this, layer, visibility, defaultValue) } @SettingDsl fun setting( @@ -341,7 +341,7 @@ abstract class Config( defaultValue: BlockPos, description: String = "", visibility: () -> Boolean = { true }, - ) = setting { layer -> BlockPosSetting(name, description, this, layer, visibility, defaultValue) } + ) = setting(name) { layer -> BlockPosSetting(name, description, this, layer, visibility, defaultValue) } @SettingDsl fun setting( @@ -349,7 +349,7 @@ abstract class Config( defaultValue: Block, description: String = "", visibility: () -> Boolean = { true }, - ) = setting { layer -> BlockSetting(name, description, this, layer, visibility, defaultValue) } + ) = setting(name) { layer -> BlockSetting(name, description, this, layer, visibility, defaultValue) } @SettingDsl fun R, R> setting( @@ -357,7 +357,7 @@ abstract class Config( defaultValue: T, description: String = "", visibility: () -> Boolean = { true } - ) = setting { layer -> FunctionSetting(name, description, defaultValue, this, layer, visibility) } + ) = setting(name) { layer -> FunctionSetting(name, description, defaultValue, this, layer, visibility) } @SettingDsl fun settingBlock(settingBlock: T): SettingBlockWrapper = @@ -383,11 +383,11 @@ abstract class Config( } @PublishedApi - internal fun , R> setting(settingSupplier: (single: SettingLayer.Single) -> T): T { + internal fun , R> setting(name: String, settingSupplier: (single: SettingLayer.Single) -> T): T { val layerSpecInfo = try { registrationQueue.removeFirst() } catch (_: NoSuchElementException) { - throw IllegalStateException("Setting registered from an unknown location for config '$name'. Layer path was not queued before setting initialization") + throw IllegalStateException("Setting registered from an unknown location for config '${this@Config.name}'. Layer path was not queued before setting initialization") } var currentSettingLayer: SettingLayer.Multiple = settingLayers diff --git a/src/main/kotlin/com/lambda/config/BaseEditor.kt b/src/main/kotlin/com/lambda/config/ConfigEditor.kt similarity index 100% rename from src/main/kotlin/com/lambda/config/BaseEditor.kt rename to src/main/kotlin/com/lambda/config/ConfigEditor.kt diff --git a/src/main/kotlin/com/lambda/config/Setting.kt b/src/main/kotlin/com/lambda/config/Setting.kt index 2477442fa..c369b5eac 100644 --- a/src/main/kotlin/com/lambda/config/Setting.kt +++ b/src/main/kotlin/com/lambda/config/Setting.kt @@ -106,8 +106,8 @@ abstract class Setting( open val isModified get() = originalCore.value != originalCore.defaultValue - open operator fun getValue(thisRef: Any?, property: KProperty<*>) = core.value - open operator fun setValue(thisRef: Any?, property: KProperty<*>, newValue: T) { + operator fun getValue(thisRef: Any?, property: KProperty<*>) = core.value + operator fun setValue(thisRef: Any?, property: KProperty<*>, newValue: T) { val oldValue = originalCore.value originalCore.value = newValue listeners.forEach { diff --git a/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingSerializer.kt index c609f4100..cad9ca518 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ClassCollectionSettingSerializer.kt @@ -19,7 +19,6 @@ package com.lambda.config.serializers -import com.fasterxml.jackson.core.JsonParseException import com.lambda.config.Deserializer import com.lambda.config.Serializer import com.lambda.config.Setting @@ -48,10 +47,10 @@ object ClassCollectionSettingDeserializer : Deserializer): ClassCollectionSetting<*> = setting.apply { val arrayNode = mapper.readTree(p) - if (!arrayNode.isArray) throw JsonParseException("ClassCollectionSetting's serialized value is not an array.") + if (!arrayNode.isArray) throw IllegalStateException("ClassCollectionSetting's serialized value is not an array.") val classNames = mutableListOf() arrayNode.forEach { node -> - if (!node.isString) throw JsonParseException("ClassCollectionSetting's serialized array contains a non-string value.") + if (!node.isString) throw IllegalStateException("ClassCollectionSetting's serialized array contains a non-string value.") if (node.isString) classNames.add(node.stringValue()) } diff --git a/src/main/kotlin/com/lambda/config/serializers/CollectionSettingSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/CollectionSettingSerializer.kt index f2c1d6229..b87854d4f 100644 --- a/src/main/kotlin/com/lambda/config/serializers/CollectionSettingSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/CollectionSettingSerializer.kt @@ -19,7 +19,6 @@ package com.lambda.config.serializers -import com.fasterxml.jackson.core.JsonParseException import com.lambda.config.FallbackDeserializer import com.lambda.config.FallbackSerializer import com.lambda.config.settings.collections.CollectionSetting @@ -56,9 +55,9 @@ object CollectionSettingDeserializer : FallbackDeserializer newValue.addAll(deserialized) } else { val node = mapper.readTree(p) - if (!node.isArray) throw JsonParseException("CollectionSetting's serialized value is not an array.") + if (!node.isArray) throw IllegalStateException("CollectionSetting's serialized value is not an array.") node.forEach { element -> - if (!element.isString) throw JsonParseException("CollectionSetting's serialized array contains a non-string value. A CollectionSetting's JSON array must only contain strings if CollectionSetting.serialize is false.") + if (!element.isString) throw IllegalStateException("CollectionSetting's serialized array contains a non-string value. A CollectionSetting's JSON array must only contain strings if CollectionSetting.serialize is false.") val str = element.stringValue() val matched = immutableCollection.find { it.toString() == str } if (matched != null) newValue.add(matched) diff --git a/src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt index 0cef40d4b..10f69ce95 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ColorSerializer.kt @@ -19,7 +19,6 @@ package com.lambda.config.serializers -import com.fasterxml.jackson.core.JsonParseException import com.lambda.config.Deserializer import com.lambda.config.Serializer import com.lambda.config.Stringifiable @@ -43,7 +42,7 @@ object ColorDeserializer : Deserializer(Color::class.java) { return when (color.size) { 3 -> Color(color[0].toInt(), color[1].toInt(), color[2].toInt()) 4 -> Color(color[0].toInt(), color[1].toInt(), color[2].toInt(), color[3].toInt()) - else -> throw JsonParseException("Invalid color format") + else -> throw IllegalStateException("Invalid color format") } } } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt index 8a8559d11..8d8358d83 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt @@ -115,7 +115,7 @@ object MultipleFallbackDeserializer : FallbackDeserializer>(SettingLayer.Single::class.java) { override fun serialize(single: SettingLayer.Single<*, *>, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writePOJOProperty(single.name, single.setting.originalCore) + gen.writePOJOProperty(single.name, single.setting) } } @@ -127,20 +127,20 @@ object SingleFallbackDeserializer : FallbackDeserializer): SettingLayer.Single<*, *> = single.apply { try { - mapper.updateValue(setting.originalCore, mapper.readTree(p)) + mapper.updateValue(setting, mapper.readTree(p)) } catch (e: Throwable) { Log.error("Failed to deserialize setting '${name}'", e) } } } -object SettingCoreFallbackSerializer : FallbackSerializer>(Setting::class.java) { +object SettingFallbackSerializer : FallbackSerializer>(Setting::class.java) { override fun serialize(setting: Setting<*>, gen: JsonGenerator, ctxt: SerializationContext) { gen.writePOJO(setting.originalCore.value) } } -object SettingCoreFallbackDeserializer : FallbackDeserializer>(Setting::class.java) { +object SettingFallbackDeserializer : FallbackDeserializer>(Setting::class.java) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Setting<*> { throw initFromJsonException("SettingCore") } diff --git a/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt index 1501dae40..2d570821e 100644 --- a/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/UuidSerializer.kt @@ -19,7 +19,6 @@ package com.lambda.config.serializers -import com.fasterxml.jackson.core.JsonParseException import com.lambda.config.Deserializer import com.lambda.config.Serializer import com.lambda.config.Stringifiable @@ -44,7 +43,7 @@ object UuidDeserializer : Deserializer(UUID::class.java) { val rawId = when { jsonNode.isString -> jsonNode.stringValue() jsonNode.isObject && jsonNode.has("id") -> jsonNode.get("id").stringValue() - else -> throw JsonParseException("Cannot deserialize UUID from: $jsonNode") + else -> throw IllegalStateException("Cannot deserialize UUID from: $jsonNode") } val parsedId = if (rawId.length == 32) diff --git a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt index da2ff0b19..dfd33b6db 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt @@ -56,7 +56,7 @@ open class CollectionSetting( var immutableCollection: Collection, val type: JavaType, val serialize: Boolean, -) : Setting>(name, description, SettingCore(defaultValue), config, layer, visibility) { +) : Setting>(name, description, SettingCore(defaultValue, defaultValue.toMutableList()), config, layer, visibility) { override var value: MutableCollection get() = super.value set(newVal) { @@ -69,7 +69,9 @@ open class CollectionSetting( val deselectListeners = mutableListOf Unit>() override val isModified: Boolean - get() = value.size != immutableCollection.size || immutableCollection.any { !value.contains(it) } + get() = with(originalCore) { + value.size != defaultValue.size || defaultValue.any { !value.contains(it) } + } override fun ImGuiBuilder.buildLayout() = buildDualPane("item") { it.toString() } diff --git a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt index 835d0c6d5..cc08326fe 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt @@ -17,7 +17,7 @@ package com.lambda.config.settings.complex -import com.fasterxml.jackson.annotation.JsonIgnore +import com.fasterxml.jackson.annotation.JsonIncludeProperties import com.lambda.brigadier.CommandResult.Companion.failure import com.lambda.brigadier.CommandResult.Companion.success import com.lambda.brigadier.argument.boolean @@ -221,12 +221,12 @@ class KeybindSetting( } @Suppress("unused") +@JsonIncludeProperties("key", "modifiers", "mouse") data class Bind( val key: Int, val modifiers: Int, val mouse: Int = -1, ) { - @JsonIgnore val trueMods = buildList { if (modifiers and GLFW_MOD_SHIFT != 0) add(KeyCode.LeftShift) if (modifiers and GLFW_MOD_CONTROL != 0) add(KeyCode.LeftControl) From f611771fb2f9071d0297c3cf98032dd5ce2407d7 Mon Sep 17 00:00:00 2001 From: beanbag44 <107891830+beanbag44@users.noreply.github.com> Date: Thu, 4 Jun 2026 17:42:41 +0100 Subject: [PATCH 40/40] allow saving arbitrary properties to configs --- .../com/lambda/mixin/CrashReportMixin.java | 2 +- .../lambda/command/commands/ConfigCommand.kt | 2 +- src/main/kotlin/com/lambda/config/Config.kt | 392 ++++++++++-------- .../{SettingBlock.kt => ConfigBlock.kt} | 2 +- ...gBlockWrapper.kt => ConfigBlockWrapper.kt} | 5 +- src/main/kotlin/com/lambda/config/Property.kt | 25 ++ src/main/kotlin/com/lambda/config/Setting.kt | 13 +- .../{ConfigEditor.kt => SettingEditor.kt} | 72 ++-- .../config/automation/AutomationConfig.kt | 14 +- .../automation/IMutableAutomationConfig.kt | 2 +- .../lambda/config/migration/MigrationUtils.kt | 2 +- .../ConfigCategoryFallbackSerializer.kt | 144 +++++-- .../com/lambda/config/settings/CharSetting.kt | 2 +- .../lambda/config/settings/FunctionSetting.kt | 2 +- .../lambda/config/settings/NumericSetting.kt | 10 +- .../lambda/config/settings/StringSetting.kt | 8 +- .../config/settings/blocks/BreakSettings.kt | 63 ++- .../config/settings/blocks/BuildSettings.kt | 4 +- .../config/settings/blocks/EatSettings.kt | 4 +- .../settings/blocks/EntityColorSettings.kt | 4 +- .../blocks/EntitySelectionSettings.kt | 4 +- .../settings/blocks/FormatterSettings.kt | 4 +- .../config/settings/blocks/HotbarSettings.kt | 4 +- .../settings/blocks/InteractSettings.kt | 4 +- .../settings/blocks/InventorySettings.kt | 4 +- .../config/settings/blocks/OutlineSettings.kt | 4 +- .../settings/blocks/RotationSettings.kt | 4 +- .../settings/blocks/ScreenLineSettings.kt | 4 +- .../settings/blocks/ScreenTextSettings.kt | 4 +- .../settings/blocks/TargetingSettings.kt | 8 +- .../settings/blocks/WorldLineSettings.kt | 4 +- .../settings/blocks/WorldTextSettings.kt | 4 +- .../collections/BlockCollectionSetting.kt | 2 +- .../collections/ClassCollectionSetting.kt | 2 +- .../settings/collections/CollectionSetting.kt | 12 +- .../collections/ItemCollectionSetting.kt | 2 +- .../config/settings/collections/MapSetting.kt | 2 +- .../settings/comparable/BooleanSetting.kt | 2 +- .../config/settings/comparable/EnumSetting.kt | 2 +- .../settings/complex/BlockPosSetting.kt | 2 +- .../config/settings/complex/BlockSetting.kt | 2 +- .../config/settings/complex/ColorSetting.kt | 2 +- .../config/settings/complex/KeybindSetting.kt | 10 +- .../config/settings/complex/Vec3dSetting.kt | 2 +- .../config/settings/numeric/DoubleSetting.kt | 2 +- .../config/settings/numeric/FloatSetting.kt | 2 +- .../config/settings/numeric/IntegerSetting.kt | 2 +- .../config/settings/numeric/LongSetting.kt | 2 +- .../lambda/gui/components/SettingsWidget.kt | 2 +- .../kotlin/com/lambda/gui/dsl/ImGuiBuilder.kt | 17 - .../com/lambda/interaction/BaritoneHandler.kt | 6 +- .../com/lambda/module/hud/Coordinates.kt | 4 +- .../kotlin/com/lambda/module/hud/Rotation.kt | 4 +- .../lambda/module/modules/chat/AntiSpam.kt | 18 +- .../module/modules/chat/ChatTimestamp.kt | 6 +- .../lambda/module/modules/combat/AutoArmor.kt | 2 +- .../lambda/module/modules/combat/AutoTotem.kt | 2 +- .../module/modules/combat/CrystalAura.kt | 6 +- .../lambda/module/modules/combat/KillAura.kt | 8 +- .../module/modules/combat/PlayerTrap.kt | 4 +- .../lambda/module/modules/combat/Surround.kt | 4 +- .../modules/debug/SettingsTestModule.kt | 48 +-- .../lambda/module/modules/debug/SilentSwap.kt | 2 +- .../module/modules/movement/BetterFirework.kt | 4 +- .../modules/movement/ElytraAltitudeControl.kt | 2 +- .../module/modules/movement/ElytraFly.kt | 2 +- .../lambda/module/modules/movement/Speed.kt | 2 +- .../lambda/module/modules/player/AutoEat.kt | 2 +- .../lambda/module/modules/player/FastBreak.kt | 8 +- .../module/modules/player/InventoryTweaks.kt | 2 +- .../module/modules/player/PacketMine.kt | 8 +- .../module/modules/player/RotationLock.kt | 4 +- .../module/modules/player/StackReplenish.kt | 4 +- .../lambda/module/modules/player/ToolSaver.kt | 2 +- .../module/modules/render/BlockOutline.kt | 8 +- .../com/lambda/module/modules/render/ESP.kt | 12 +- .../lambda/module/modules/render/Freecam.kt | 4 +- .../module/modules/render/LightLevels.kt | 6 +- .../lambda/module/modules/render/Nametags.kt | 10 +- .../lambda/module/modules/render/NoRender.kt | 4 +- .../lambda/module/modules/render/RadiusESP.kt | 6 +- .../lambda/module/modules/render/Search.kt | 10 +- .../lambda/module/modules/render/Tracers.kt | 10 +- .../lambda/module/modules/world/AirPlace.kt | 2 +- .../lambda/module/modules/world/AutoPortal.kt | 10 +- .../module/modules/world/AutoVillagerCycle.kt | 2 +- .../module/modules/world/HighwayTools.kt | 2 +- .../com/lambda/module/modules/world/Nuker.kt | 2 +- .../lambda/module/modules/world/Scaffold.kt | 8 +- .../lambda/module/modules/world/StashMover.kt | 8 +- 90 files changed, 632 insertions(+), 519 deletions(-) rename src/main/kotlin/com/lambda/config/{SettingBlock.kt => ConfigBlock.kt} (96%) rename src/main/kotlin/com/lambda/config/{SettingBlockWrapper.kt => ConfigBlockWrapper.kt} (89%) create mode 100644 src/main/kotlin/com/lambda/config/Property.kt rename src/main/kotlin/com/lambda/config/{ConfigEditor.kt => SettingEditor.kt} (71%) diff --git a/src/main/java/com/lambda/mixin/CrashReportMixin.java b/src/main/java/com/lambda/mixin/CrashReportMixin.java index 86700228d..855308fe6 100644 --- a/src/main/java/com/lambda/mixin/CrashReportMixin.java +++ b/src/main/java/com/lambda/mixin/CrashReportMixin.java @@ -18,7 +18,7 @@ package com.lambda.mixin; import com.lambda.Lambda; -import com.lambda.config.Config.SettingLayer; +import com.lambda.config.SettingLayer; import com.lambda.module.Module; import com.lambda.module.ModuleRegistry; import com.lambda.util.DynamicExceptionKt; diff --git a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt index c92337abe..bfed0d23c 100644 --- a/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt +++ b/src/main/kotlin/com/lambda/command/commands/ConfigCommand.kt @@ -26,8 +26,8 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required import com.lambda.command.LambdaCommand -import com.lambda.config.Config.SettingLayer import com.lambda.config.ConfigLoader +import com.lambda.config.SettingLayer import com.lambda.util.CommunicationUtils.info import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandSource.suggestMatching diff --git a/src/main/kotlin/com/lambda/config/Config.kt b/src/main/kotlin/com/lambda/config/Config.kt index 275695e9e..3c3221961 100644 --- a/src/main/kotlin/com/lambda/config/Config.kt +++ b/src/main/kotlin/com/lambda/config/Config.kt @@ -49,6 +49,7 @@ import net.minecraft.registry.Registries import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Vec3d import java.awt.Color +import kotlin.collections.plus import kotlin.reflect.KClass import kotlin.reflect.KProperty import kotlin.reflect.full.declaredMemberProperties @@ -62,36 +63,29 @@ import kotlin.reflect.jvm.javaField * * @property settingLayers A set of [SettingCore]s that this config manages. */ -@Suppress("unused") abstract class Config( final override val name: String, configCategory: ConfigCategory ) : Nameable { internal val settingLayers = SettingLayer.Root() - internal val settingBlockLayers = BlockLayer.Root() + internal val settingBlockLayers = ConfigBlockLayer.Root() + internal val propertyLayers = PropertyLayer.Root() private val registrationQueue = ArrayDeque() init { if (configs.any { it.name == name }) throw IllegalStateException("Configs with name $name already exists.") - enqueueProperties(this::class, emptyList(), emptyList()) + enqueueConfigEntries(this::class, emptyList(), emptyList()) configCategory.configs.add(this) } - private fun enqueueProperties(klass: KClass<*>, outerPath: List, outerBlockPath: List) { + private fun enqueueConfigEntries(klass: KClass<*>, outerPath: List, outerBlockPath: List) { var childBlockIndex = 0 - forEachConfigProperty( + forEachConfigEntry( klass, - onSetting = { setting -> - registrationQueue.addLast( - LayerSpecInfo( - outerPath + buildPathFromAnnotations(setting), - outerBlockPath - ) - ) - }, + onSetting = { enqueuePrimitiveConfigEntry(it, outerPath, outerBlockPath, it.name) }, onSettingBlock = { settingBlock, blockClass -> val fullBlockPath = outerBlockPath + childBlockIndex - enqueueProperties( + enqueueConfigEntries( blockClass, outerPath + buildPathFromAnnotations(settingBlock), fullBlockPath @@ -99,18 +93,36 @@ abstract class Config( registrationQueue.addLast( LayerSpecInfo( emptyList(), - fullBlockPath + fullBlockPath, + settingBlock.name ) ) childBlockIndex++ - } + }, + onProperty = { enqueuePrimitiveConfigEntry(it, outerPath, outerBlockPath, it.name) } + ) + } + + private fun enqueuePrimitiveConfigEntry( + property: KProperty<*>, + outerPath: List, + outerBlockPath: List, + propertyName: String + ) { + registrationQueue.addLast( + LayerSpecInfo( + outerPath + buildPathFromAnnotations(property), + outerBlockPath, + propertyName + ) ) } - private fun forEachConfigProperty( + private fun forEachConfigEntry( klass: KClass<*>, - onSetting: (property: KProperty<*>) -> Unit = {}, - onSettingBlock: (property: KProperty<*>, blockClass: KClass<*>) -> Unit = { _, _ -> } + onSetting: (property: KProperty<*>) -> Unit, + onSettingBlock: (property: KProperty<*>, blockClass: KClass<*>) -> Unit, + onProperty: (property: KProperty<*>) -> Unit ) { val hierarchy = buildList { var current: KClass<*>? = klass @@ -136,10 +148,11 @@ abstract class Config( val fieldType = property.javaField?.type ?: return@forEach when { Setting::class.java.isAssignableFrom(fieldType) -> onSetting(property) - SettingBlockWrapper::class.java.isAssignableFrom(fieldType) -> { + ConfigBlockWrapper::class.java.isAssignableFrom(fieldType) -> { val blockClass = property.returnType.classifier as? KClass<*> if (blockClass != null) onSettingBlock(property, blockClass) } + Property::class.java.isAssignableFrom(fieldType) -> onProperty(property) } } } @@ -162,61 +175,61 @@ abstract class Config( } } - @SettingDsl + @ConfigEntryD5l fun setting( name: String, defaultValue: Boolean, description: String = "", - visibility: () -> Boolean = { true }, + visibility: () -> Boolean = { true } ) = setting(name) { layer -> BooleanSetting(name, description, this, layer, visibility, defaultValue) } - @SettingDsl + @ConfigEntryD5l fun > setting( name: String, defaultValue: T, description: String = "", - visibility: () -> Boolean = { true }, + visibility: () -> Boolean = { true } ) = setting(name) { layer -> EnumSetting(name, description, this, layer, visibility, defaultValue) } - @SettingDsl + @ConfigEntryD5l fun setting( name: String, defaultValue: Char, description: String = "", - visibility: () -> Boolean = { true }, + visibility: () -> Boolean = { true } ) = setting(name) { layer -> CharSetting(name, description, this, layer, defaultValue, visibility) } - @SettingDsl + @ConfigEntryD5l fun setting( name: String, defaultValue: String, multiline: Boolean = false, flags: Int = ImGuiInputTextFlags.None, description: String = "", - visibility: () -> Boolean = { true }, + visibility: () -> Boolean = { true } ) = setting(name) { layer -> StringSetting(name, description, this, layer, defaultValue, visibility, multiline, flags) } - @SettingDsl + @ConfigEntryD5l @JvmName("collectionSetting1") fun setting( name: String, defaultValue: Collection, immutableCollection: Collection = Registries.BLOCK.toList(), description: String = "", - visibility: () -> Boolean = { true }, + visibility: () -> Boolean = { true } ) = setting(name) { layer -> BlockCollectionSetting(name, description, this, layer, visibility, immutableCollection, defaultValue.toMutableList()) } - @SettingDsl + @ConfigEntryD5l @JvmName("collectionSetting2") fun setting( name: String, defaultValue: Collection, immutableCollection: Collection = Registries.ITEM.toList(), description: String = "", - visibility: () -> Boolean = { true }, + visibility: () -> Boolean = { true } ) = setting(name) { layer -> ItemCollectionSetting(name, description, this, layer, visibility, immutableCollection, defaultValue.toMutableList()) } - @SettingDsl + @ConfigEntryD5l @JvmName("collectionSetting3") inline fun setting( name: String, @@ -225,29 +238,26 @@ abstract class Config( description: String = "", displayClassName: Boolean = false, serialize: Boolean = false, - noinline visibility: () -> Boolean = { true }, + noinline visibility: () -> Boolean = { true } ) = setting(name) { layer -> - if (displayClassName) - ClassCollectionSetting(name, description, this, layer, visibility, immutableList, defaultValue.toMutableList()) - else - CollectionSetting(name, description, this, layer, visibility, defaultValue.toMutableList(), immutableList, typeFactory.constructCollectionType(Collection::class.java, T::class.java), serialize) + if (displayClassName) ClassCollectionSetting(name, description, this, layer, visibility, immutableList, defaultValue.toMutableList()) + else CollectionSetting(name, description, this, layer, visibility, defaultValue.toMutableList(), immutableList, typeFactory.constructCollectionType(Collection::class.java, T::class.java), serialize) } - @SettingDsl + @ConfigEntryD5l inline fun setting( name: String, defaultValue: Map, description: String = "", - noinline visibility: () -> Boolean = { true }, + noinline visibility: () -> Boolean = { true } ) = setting(name) { layer -> MapSetting( - name, description, this, layer, visibility, - defaultValue.toMutableMap(), + name, description, this, layer, visibility, defaultValue.toMutableMap(), typeFactory.constructMapType(MutableMap::class.java, K::class.java, V::class.java) ) } - @SettingDsl + @ConfigEntryD5l fun setting( name: String, defaultValue: Double, @@ -255,10 +265,10 @@ abstract class Config( step: Double = 1.0, description: String = "", unit: String = "", - visibility: () -> Boolean = { true }, + visibility: () -> Boolean = { true } ) = setting(name) { layer -> DoubleSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } - @SettingDsl + @ConfigEntryD5l fun setting( name: String, defaultValue: Float, @@ -266,10 +276,10 @@ abstract class Config( step: Float = 1f, description: String = "", unit: String = "", - visibility: () -> Boolean = { true }, + visibility: () -> Boolean = { true } ) = setting(name) { layer -> FloatSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } - @SettingDsl + @ConfigEntryD5l fun setting( name: String, defaultValue: Int, @@ -277,10 +287,10 @@ abstract class Config( step: Int = 1, description: String = "", unit: String = "", - visibility: () -> Boolean = { true }, + visibility: () -> Boolean = { true } ) = setting(name) { layer -> IntegerSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } - @SettingDsl + @ConfigEntryD5l fun setting( name: String, defaultValue: Long, @@ -288,70 +298,70 @@ abstract class Config( step: Long = 1, description: String = "", unit: String = "", - visibility: () -> Boolean = { true }, + visibility: () -> Boolean = { true } ) = setting(name) { layer -> LongSetting(name, description, this, layer, visibility, defaultValue, range, step, unit) } - @SettingDsl + @ConfigEntryD5l fun setting( name: String, defaultValue: Bind, description: String = "", alwaysListening: Boolean = false, screenCheck: Boolean = true, - visibility: () -> Boolean = { true }, + visibility: () -> Boolean = { true } ) = setting(name) { layer -> KeybindSetting(name, description, this, layer, visibility, defaultValue, this as? Muteable, alwaysListening, screenCheck) } - @SettingDsl + @ConfigEntryD5l fun setting( name: String, defaultValue: KeyCode, description: String = "", alwaysListening: Boolean = false, screenCheck: Boolean = true, - visibility: () -> Boolean = { true }, + visibility: () -> Boolean = { true } ) = setting(name) { layer -> KeybindSetting(name, description, this, layer, visibility, defaultValue, this as? Muteable, alwaysListening, screenCheck) } - @SettingDsl + @ConfigEntryD5l fun setting( name: String, defaultValue: Color, description: String = "", - visibility: () -> Boolean = { true }, + visibility: () -> Boolean = { true } ) = setting(name) { layer -> ColorSetting(name, description, this, layer, visibility, defaultValue) } - @SettingDsl + @ConfigEntryD5l fun setting( name: String, defaultValue: Vec3d, description: String = "", - visibility: () -> Boolean = { true }, + visibility: () -> Boolean = { true } ) = setting(name) { layer -> Vec3dSetting(name, description, this, layer, visibility, defaultValue) } - @SettingDsl + @ConfigEntryD5l fun setting( name: String, defaultValue: BlockPos.Mutable, description: String = "", - visibility: () -> Boolean = { true }, + visibility: () -> Boolean = { true } ) = setting(name) { layer -> BlockPosSetting(name, description, this, layer, visibility, defaultValue) } - @SettingDsl + @ConfigEntryD5l fun setting( name: String, defaultValue: BlockPos, description: String = "", - visibility: () -> Boolean = { true }, + visibility: () -> Boolean = { true } ) = setting(name) { layer -> BlockPosSetting(name, description, this, layer, visibility, defaultValue) } - @SettingDsl + @ConfigEntryD5l fun setting( name: String, defaultValue: Block, description: String = "", - visibility: () -> Boolean = { true }, + visibility: () -> Boolean = { true } ) = setting(name) { layer -> BlockSetting(name, description, this, layer, visibility, defaultValue) } - @SettingDsl + @ConfigEntryD5l fun R, R> setting( name: String, defaultValue: T, @@ -359,28 +369,63 @@ abstract class Config( visibility: () -> Boolean = { true } ) = setting(name) { layer -> FunctionSetting(name, description, defaultValue, this, layer, visibility) } - @SettingDsl - fun settingBlock(settingBlock: T): SettingBlockWrapper = - settingBlock - .let { settingBlock -> - val path = try { - registrationQueue.removeFirst().settingBlockSpecs - } catch (_: NoSuchElementException) { - throw IllegalStateException("Setting block registered from an unknown location for config '$name'. Layer path was not queued before setting block initialization") - } + @ConfigEntryD5l + fun configBlock( + configBlock: T + ): ConfigBlockWrapper { + val path = try { + registrationQueue.removeFirst().blockSpecs + } catch (_: NoSuchElementException) { + throw IllegalStateException("Setting block registered from an unknown location for config '$name'. Layer path was not queued before setting block initialization") + } + + var currentLayer: ConfigBlockLayer = settingBlockLayers + path.forEach { index -> + currentLayer = currentLayer.layers.getOrElse(index) { + ConfigBlockLayer.Block(currentLayer).also { currentLayer.layers.add(it) } + } + } - var currentLayer: BlockLayer = settingBlockLayers + return ConfigBlockWrapper(configBlock, currentLayer) + } - path.forEach { index -> - currentLayer = currentLayer.layers.getOrNull(index) - ?: throw IllegalStateException("Empty setting block registered in config '$name'. Setting blocks must have at least one setting in them") - } + @ConfigEntryD5l + fun property(value: T): Property { + val spec = try { + registrationQueue.removeFirst() + } catch (_: NoSuchElementException) { + throw IllegalStateException("Property registered from an unknown location for config '$name'. Layer path was not queued before property initialization") + } - SettingBlockWrapper(settingBlock, currentLayer) - .also { wrapper -> - (currentLayer as? BlockLayer.Block)?.settingBlock = wrapper + var currentLayer: PropertyLayer.Multiple = propertyLayers + spec.layerSpecs.forEach { spec -> + currentLayer = + currentLayer.layers + .asSequence() + .filter { it.name == spec.name } + .also { + it.forEach { layer -> + if (layer !is PropertyLayer.Multiple) + throw IllegalStateException("Multiple registered with a name '${layer.name}' matching a Single on the same layer") + } } - } + .filterIsInstance() + .firstOrNull() + ?: PropertyLayer.Multiple(spec.name).also { + currentLayer.layers.add(it) + } + } + + if (currentLayer.layers.any { it.name == spec.propertyName }) + throw IllegalStateException("Duplicate layer name ('${spec.propertyName}') within ${currentLayer.name}") + + return Property(value).also { + currentLayer.layers.add(PropertyLayer.Single(it, spec.propertyName)) + } + } + + @ConfigEntryD5l + fun property(valueSupplier: () -> T) = property(valueSupplier()) @PublishedApi internal fun , R> setting(name: String, settingSupplier: (single: SettingLayer.Single) -> T): T { @@ -391,8 +436,8 @@ abstract class Config( } var currentSettingLayer: SettingLayer.Multiple = settingLayers - layerSpecInfo.settingLayerSpecs.forEach { spec -> - val existing = currentSettingLayer.layers + layerSpecInfo.layerSpecs.forEach { spec -> + currentSettingLayer = currentSettingLayer.layers .asSequence() .filter { it.name == spec.name } .also { @@ -404,100 +449,34 @@ abstract class Config( } .filterIsInstance() .firstOrNull() - - if (existing != null) currentSettingLayer = existing - else { - val newSettingLayer = when (spec.type) { - MultipleLayerType.Tab -> SettingLayer.Tab(spec.name, mutableListOf(), currentSettingLayer) - MultipleLayerType.Group -> SettingLayer.Group(spec.name, mutableListOf(), currentSettingLayer) - MultipleLayerType.Root -> throw IllegalStateException("Multiple root setting layers. Only the base class root layer should ever be created") + ?: run { + when (spec.type) { + MultipleLayerType.Tab -> SettingLayer.Tab(spec.name, mutableListOf(), currentSettingLayer) + MultipleLayerType.Group -> SettingLayer.Group(spec.name, mutableListOf(), currentSettingLayer) + MultipleLayerType.Root -> throw IllegalStateException("Multiple root setting layers. Only the base class root layer should ever be created") + }.also { currentSettingLayer.layers.add(it) } } - currentSettingLayer.layers.add(newSettingLayer) - currentSettingLayer = newSettingLayer - } } if (currentSettingLayer.layers.any { it.name == name }) throw IllegalStateException("Duplicate layer name ('$name') within ${currentSettingLayer.name}") - var currentBlockLayer: BlockLayer = settingBlockLayers - layerSpecInfo.settingBlockSpecs.forEach { index -> - val existing = currentBlockLayer.layers.getOrNull(index) - if (existing != null) currentBlockLayer = existing - else { - val newBlockLayer = BlockLayer.Block(currentBlockLayer) - currentBlockLayer.layers.add(newBlockLayer) - currentBlockLayer = newBlockLayer - } + var currentBlockLayer: ConfigBlockLayer = settingBlockLayers + layerSpecInfo.blockSpecs.forEach { index -> + currentBlockLayer = + currentBlockLayer.layers.getOrElse(index) { + ConfigBlockLayer.Block(currentBlockLayer).also { + currentBlockLayer.layers.add(it) + } + } } - val layer = SettingLayer.Single(currentSettingLayer, currentBlockLayer, settingSupplier) + val layer = SettingLayer.Single(currentSettingLayer, settingSupplier) currentSettingLayer.layers.add(layer) currentBlockLayer.settingLayers.add(layer) return layer.setting } - enum class SettingLayerType { Root, Tab, Group, Single } - enum class MultipleLayerType { Root, Tab, Group } - private data class SettingLayerSpec(val type: MultipleLayerType, val name: String) - private data class LayerSpecInfo(val settingLayerSpecs: List, val settingBlockSpecs: List) - - sealed interface SettingLayer { - val name: String - val parent: SettingLayer? - - sealed class Multiple( - override val name: String, - val multipleType: MultipleLayerType, - val layers: MutableList, - override val parent: Multiple? - ) : SettingLayer, Nameable - - class Root : Multiple( - "Root", - MultipleLayerType.Root, - mutableListOf(), - null - ) - - class Tab( - name: String, - layers: MutableList, - parent: Multiple - ) : Multiple(name, MultipleLayerType.Tab, layers, parent) - - class Group( - name: String, - layers: MutableList, - parent: Multiple - ) : Multiple(name, MultipleLayerType.Group, layers, parent) - - class Single, R>( - override val parent: Multiple, - val blockLayer: BlockLayer, - settingSupplier: (Single) -> T - ) : SettingLayer { - val setting = settingSupplier(this) - override val name = setting.name - } - } - - sealed class BlockLayer { - open val parent: BlockLayer? = null - val layers = mutableListOf() - val settingLayers = mutableListOf>() - - class Root : BlockLayer() { - override val parent = null - } - - class Block( - override val parent: BlockLayer? - ) : BlockLayer() { - lateinit var settingBlock: SettingBlockWrapper<*> - } - } - internal fun forEachSetting( root: SettingLayer.Multiple = settingLayers, recurse: Boolean = true, @@ -520,12 +499,12 @@ abstract class Config( } internal fun forEachSettingBlock( - root: BlockLayer = settingBlockLayers, + root: ConfigBlockLayer = settingBlockLayers, recurse: Boolean = true, - onBlockLayer: ((path: List, block: BlockLayer.Block) -> Unit)? = null, + onBlockLayer: ((path: List, block: ConfigBlockLayer.Block) -> Unit)? = null, onSetting: ((path: List, single: SettingLayer.Single<*, *>) -> Unit)? = null ) { - fun internalForEach(layer: BlockLayer, path: List) { + fun internalForEach(layer: ConfigBlockLayer, path: List) { if (onSetting != null) layer.settingLayers.forEach { onSetting(path, it) } layer.layers.forEachIndexed { index, blockLayer -> val fullPath = path + index @@ -535,6 +514,81 @@ abstract class Config( } internalForEach(root, emptyList()) } + + private data class SettingLayerSpec(val type: MultipleLayerType, val name: String) + private data class LayerSpecInfo(val layerSpecs: List, val blockSpecs: List, val propertyName: String) +} + +enum class MultipleLayerType { Root, Tab, Group } + +sealed interface SettingLayer { + val name: String + val parent: SettingLayer? + + sealed class Multiple( + override val name: String, + val multipleType: MultipleLayerType, + val layers: MutableList, + override val parent: Multiple? + ) : SettingLayer, Nameable + + class Root : Multiple( + "Settings", + MultipleLayerType.Root, + mutableListOf(), + null + ) + + class Tab( + name: String, + layers: MutableList, + parent: Multiple + ) : Multiple(name, MultipleLayerType.Tab, layers, parent) + + class Group( + name: String, + layers: MutableList, + parent: Multiple + ) : Multiple(name, MultipleLayerType.Group, layers, parent) + + class Single, R>( + override val parent: Multiple, + settingSupplier: (Single) -> T + ) : SettingLayer { + val setting = settingSupplier(this) + override val name = setting.name + } +} + +sealed class ConfigBlockLayer { + open val parent: ConfigBlockLayer? = null + val layers = mutableListOf() + val settingLayers = mutableListOf>() + + class Root : ConfigBlockLayer() { + override val parent = null + } + + class Block( + override val parent: ConfigBlockLayer? + ) : ConfigBlockLayer() +} + +sealed class PropertyLayer { + abstract val name: String + + open class Multiple( + override val name: String + ) : PropertyLayer() { + val layers = mutableListOf() + } + + class Root : Multiple("Properties") + + class Single( + val property: Property<*>, + override val name: String + ) : PropertyLayer() } @Target(AnnotationTarget.PROPERTY) diff --git a/src/main/kotlin/com/lambda/config/SettingBlock.kt b/src/main/kotlin/com/lambda/config/ConfigBlock.kt similarity index 96% rename from src/main/kotlin/com/lambda/config/SettingBlock.kt rename to src/main/kotlin/com/lambda/config/ConfigBlock.kt index 1766e23ba..cee531f0f 100644 --- a/src/main/kotlin/com/lambda/config/SettingBlock.kt +++ b/src/main/kotlin/com/lambda/config/ConfigBlock.kt @@ -17,6 +17,6 @@ package com.lambda.config -interface SettingBlock { +interface ConfigBlock { val c: Config } \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/SettingBlockWrapper.kt b/src/main/kotlin/com/lambda/config/ConfigBlockWrapper.kt similarity index 89% rename from src/main/kotlin/com/lambda/config/SettingBlockWrapper.kt rename to src/main/kotlin/com/lambda/config/ConfigBlockWrapper.kt index 43ec194d0..313b2e890 100644 --- a/src/main/kotlin/com/lambda/config/SettingBlockWrapper.kt +++ b/src/main/kotlin/com/lambda/config/ConfigBlockWrapper.kt @@ -17,12 +17,11 @@ package com.lambda.config -import com.lambda.config.Config.BlockLayer import kotlin.reflect.KProperty -class SettingBlockWrapper( +class ConfigBlockWrapper( val settingBlock: T, - val layer: BlockLayer + val layer: ConfigBlockLayer ) { operator fun getValue(thisRef: Any?, property: KProperty<*>) = settingBlock operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {} diff --git a/src/main/kotlin/com/lambda/config/Property.kt b/src/main/kotlin/com/lambda/config/Property.kt new file mode 100644 index 000000000..946b17a02 --- /dev/null +++ b/src/main/kotlin/com/lambda/config/Property.kt @@ -0,0 +1,25 @@ +/* + * Copyright 2026 Lambda + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.lambda.config + +import kotlin.reflect.KProperty + +class Property(var value: T) { + operator fun getValue(thisRef: Any?, property: Any?) = value + operator fun setValue(thisRef: Any?, property: KProperty<*>, newValue: T) { value = newValue } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/Setting.kt b/src/main/kotlin/com/lambda/config/Setting.kt index c369b5eac..b080c1ca6 100644 --- a/src/main/kotlin/com/lambda/config/Setting.kt +++ b/src/main/kotlin/com/lambda/config/Setting.kt @@ -27,7 +27,6 @@ import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required import com.lambda.command.CommandRegistry import com.lambda.command.commands.ConfigCommand -import com.lambda.config.Config.SettingLayer import com.lambda.context.SafeContext import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.threading.runSafe @@ -151,7 +150,7 @@ abstract class Setting( * Will only register changes of the variable, not the content of the variable! * E.g., if the variable is a list, it will only register if the list reference changes, not if the content of the list changes. */ - @SettingDsl + @ConfigEntryD5l fun onValueChange(block: SafeContext.(from: T, to: T) -> Unit) = apply { listeners.add(ValueListener(true) { from, to -> runSafe { @@ -160,17 +159,17 @@ abstract class Setting( }) } - @SettingDsl + @ConfigEntryD5l fun onValueChangeUnsafe(block: (from: T, to: T) -> Unit) = apply { listeners.add(ValueListener(true, block)) } - @SettingDsl + @ConfigEntryD5l fun onValueSet(block: (from: T, to: T) -> Unit) = apply { listeners.add(ValueListener(false, block)) } - @SettingDsl + @ConfigEntryD5l fun disabled(predicate: () -> Boolean) = apply { disabled = predicate } @@ -237,7 +236,7 @@ abstract class Setting( var current: SettingLayer.Multiple = layer.parent while (true) { current = current.parent ?: break - if (current.multipleType == Config.MultipleLayerType.Root) break + if (current.multipleType == MultipleLayerType.Root) break add(current.commandName) } }.asReversed() @@ -253,4 +252,4 @@ class SettingCore( ) @DslMarker -annotation class SettingDsl \ No newline at end of file +annotation class ConfigEntryD5l \ No newline at end of file diff --git a/src/main/kotlin/com/lambda/config/ConfigEditor.kt b/src/main/kotlin/com/lambda/config/SettingEditor.kt similarity index 71% rename from src/main/kotlin/com/lambda/config/ConfigEditor.kt rename to src/main/kotlin/com/lambda/config/SettingEditor.kt index 3ebb9da2a..b43e0bf87 100644 --- a/src/main/kotlin/com/lambda/config/ConfigEditor.kt +++ b/src/main/kotlin/com/lambda/config/SettingEditor.kt @@ -19,8 +19,6 @@ package com.lambda.config -import com.lambda.config.Config.BlockLayer -import com.lambda.config.Config.SettingLayer import com.lambda.context.SafeContext import kotlin.reflect.KProperty0 import kotlin.reflect.jvm.isAccessible @@ -29,30 +27,28 @@ import kotlin.reflect.jvm.isAccessible annotation class SettingEditorDsl @SettingEditorDsl -fun T.withEdits(edits: context(EditContext.ConfigEditContext) T.() -> Unit): T { - with(EditContext.ConfigEditContext(this)) { edits() } - return this -} +fun T.withEdits( + edits: context(EditContext.ConfigEditContext) T.() -> Unit +) = apply { with(EditContext.ConfigEditContext(this)) { edits() } } @SettingEditorDsl context(c: Config) -fun SettingBlockWrapper.withEdits(edits: context(EditContext.BlockEditContext) T.() -> Unit): SettingBlockWrapper { - with(EditContext.BlockEditContext(c, this)) { this@withEdits.settingBlock.edits() } - return this -} +fun ConfigBlockWrapper.withEdits( + edits: context(EditContext.BlockEditContext) T.() -> Unit +) = apply { with(EditContext.BlockEditContext(c, this)) { this@withEdits.settingBlock.edits() } } @SettingEditorDsl -fun SettingBlockWrapper.withEdits(c: Config, edits: context(EditContext.BlockEditContext) T.() -> Unit): SettingBlockWrapper { - with(EditContext.BlockEditContext(c, this)) { this@withEdits.settingBlock.edits() } - return this -} +fun ConfigBlockWrapper.withEdits( + c: Config, + edits: context(EditContext.BlockEditContext) T.() -> Unit +) = with(c) { withEdits(edits) } sealed class EditContext(internal val c: Config) { class ConfigEditContext internal constructor(c: Config) : EditContext(c) - class BlockEditContext internal constructor(c: Config, internal val block: SettingBlockWrapper<*>) : EditContext(c) + class BlockEditContext internal constructor(c: Config, internal val block: ConfigBlockWrapper<*>) : EditContext(c) } -object ConfigEditor { +object SettingEditor { @SettingEditorDsl context(editContext: EditContext.ConfigEditContext) fun forEachSetting(block: BasicEditBuilder.() -> Unit) { @@ -63,7 +59,7 @@ object ConfigEditor { @SettingEditorDsl context(editContext: EditContext.ConfigEditContext) - fun hideAllBlocksExcept(vararg except: SettingBlockProperty, recursive: Boolean = true) = + fun hideAllBlocksExcept(vararg except: SettingBlockProperty, recursive: Boolean = true) = hideAllBlocksExcept(editContext.c.settingBlockLayers, *except, recursive = recursive) @SettingEditorDsl @@ -76,7 +72,10 @@ object ConfigEditor { @SettingEditorDsl context(editContext: EditContext.BlockEditContext) - fun hideAllBlocksExcept(vararg except: SettingBlockProperty, recursive: Boolean = true) = + fun hideAllBlocksExcept( + vararg except: SettingBlockProperty, + recursive: Boolean = true + ) = hideAllBlocksExcept(editContext.block.layer, *except, recursive = recursive) @SettingEditorDsl @@ -106,25 +105,30 @@ object ConfigEditor { @SettingEditorDsl context(_: EditContext) - fun hideBlock(settingBlock: SettingBlockProperty) { - settingBlock.settingBlock.layer.settingLayers.forEach(::hide) + fun hideBlock(settingBlock: SettingBlockProperty) { + settingBlock.configBlock.layer.settingLayers.forEach(::hide) } @SettingEditorDsl context(_: EditContext) - fun hideBlocks(vararg settingBlocks: SettingBlockProperty) = - settingBlocks.forEach { hideBlock(it) } + fun hideBlocks(vararg configBlocks: SettingBlockProperty) = + configBlocks.forEach { hideBlock(it) } @SettingEditorDsl context(_: EditContext) - fun hideBlockExcept(settingBlock: SettingBlockProperty, vararg except: SettingProperty, recursive: Boolean = true) { + fun hideBlockExcept( + settingBlock: SettingBlockProperty, + vararg except: SettingProperty, + recursive: Boolean = true + ) { val exceptSettings = except.map { it.setting } - fun processBlock(blockLayer: BlockLayer) { + fun processBlock(blockLayer: ConfigBlockLayer) { blockLayer.settingLayers.forEach { single -> if (single.setting !in exceptSettings) hide(single) } if (recursive) blockLayer.layers.forEach(::processBlock) } + processBlock(settingBlock.configBlock.layer) } open class BasicEditBuilder internal constructor( @@ -172,12 +176,16 @@ object ConfigEditor { parentLayer.parent?.layers?.remove(parentLayer) } - private fun hideAllBlocksExcept(root: BlockLayer, vararg except: SettingBlockProperty, recursive: Boolean) { - val exceptBlocks = except.map { it.settingBlock.layer } - fun processBlock(blockLayer: BlockLayer) { - val unProtected = blockLayer !in exceptBlocks - if (unProtected) blockLayer.settingLayers.forEach(::hide) - if (unProtected || !recursive) blockLayer.layers.forEach(::processBlock) + private fun hideAllBlocksExcept( + root: ConfigBlockLayer, + vararg except: SettingBlockProperty, + recursive: Boolean + ) { + val exceptBlocks = except.map { it.configBlock.layer } + fun processBlock(settingBlockLayer: ConfigBlockLayer) { + val unProtected = settingBlockLayer !in exceptBlocks + if (unProtected) settingBlockLayer.settingLayers.forEach(::hide) + if (unProtected || !recursive) settingBlockLayer.layers.forEach(::processBlock) } processBlock(root) } @@ -197,7 +205,7 @@ object ConfigEditor { get() = this.delegate as? Setting ?: throw IllegalStateException("Setting delegate did not match the given type") - private val SettingBlockProperty.settingBlock - get() = this.delegate as? SettingBlockWrapper + private val SettingBlockProperty.configBlock + get() = this.delegate as? ConfigBlockWrapper ?: throw IllegalStateException("SettingBlock delegate did not match the given type") } diff --git a/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt index 41f2b2687..5e4c4ff36 100644 --- a/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/AutomationConfig.kt @@ -39,13 +39,13 @@ open class AutomationConfig( name, configCategory ), Automated { - @Tab(BuildTab) override val buildConfig by settingBlock(BuildSettings(this)) - @Tab(BreakTab) override val breakConfig by settingBlock(BreakSettings(this)) - @Tab(InteractTab) override val interactConfig by settingBlock(InteractSettings(this)) - @Tab(RotationTab) override val rotationConfig by settingBlock(RotationSettings(this)) - @Tab(InventoryTab) override val inventoryConfig by settingBlock(InventorySettings(this)) - @Tab(HotbarTab) override val hotbarConfig by settingBlock(HotbarSettings(this)) - @Tab(EatTab) override val eatConfig by settingBlock(EatSettings(this)) + @Tab(BuildTab) override val buildConfig by configBlock(BuildSettings(this)) + @Tab(BreakTab) override val breakConfig by configBlock(BreakSettings(this)) + @Tab(InteractTab) override val interactConfig by configBlock(InteractSettings(this)) + @Tab(RotationTab) override val rotationConfig by configBlock(RotationSettings(this)) + @Tab(InventoryTab) override val inventoryConfig by configBlock(InventorySettings(this)) + @Tab(HotbarTab) override val hotbarConfig by configBlock(HotbarSettings(this)) + @Tab(EatTab) override val eatConfig by configBlock(EatSettings(this)) companion object { private const val BuildTab = "Build" diff --git a/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt index e324f8c3f..6cb3cd1d2 100644 --- a/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt +++ b/src/main/kotlin/com/lambda/config/automation/IMutableAutomationConfig.kt @@ -17,9 +17,9 @@ package com.lambda.config.automation -import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore +import com.lambda.config.SettingLayer import com.lambda.config.settings.blocks.BreakConfig import com.lambda.config.settings.blocks.BuildConfig import com.lambda.config.settings.blocks.EatConfig diff --git a/src/main/kotlin/com/lambda/config/migration/MigrationUtils.kt b/src/main/kotlin/com/lambda/config/migration/MigrationUtils.kt index 12fa3b23e..269a4a59e 100644 --- a/src/main/kotlin/com/lambda/config/migration/MigrationUtils.kt +++ b/src/main/kotlin/com/lambda/config/migration/MigrationUtils.kt @@ -18,8 +18,8 @@ package com.lambda.config.migration import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer import com.lambda.config.ConfigCategory +import com.lambda.config.SettingLayer import com.lambda.util.CommunicationUtils.logError import tools.jackson.databind.JsonNode import tools.jackson.databind.node.ObjectNode diff --git a/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt b/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt index 8d8358d83..bee75cfdc 100644 --- a/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt +++ b/src/main/kotlin/com/lambda/config/serializers/ConfigCategoryFallbackSerializer.kt @@ -21,11 +21,15 @@ package com.lambda.config.serializers import com.lambda.Lambda.Log import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer import com.lambda.config.ConfigCategory +import com.lambda.config.Deserializer import com.lambda.config.FallbackDeserializer import com.lambda.config.FallbackSerializer +import com.lambda.config.Property +import com.lambda.config.PropertyLayer +import com.lambda.config.Serializer import com.lambda.config.Setting +import com.lambda.config.SettingLayer import com.lambda.config.migration.ConfigMigrationHandler import tools.jackson.core.JsonGenerator import tools.jackson.core.JsonParser @@ -70,8 +74,15 @@ object ConfigCategoryFallbackDeserializer : FallbackDeserializer object ConfigFallbackSerializer : FallbackSerializer(Config::class.java) { override fun serialize(config: Config, gen: JsonGenerator, ctxt: SerializationContext) { gen.writeObjectPropertyStart(config.name) - .writePOJO(config.settingLayers) - .writeEndObject() + val serializedSettings = mapper.valueToTree(config.settingLayers) + if (!serializedSettings.isEmpty) { + gen.writeName(config.settingLayers.name) + gen.writeTree(serializedSettings) + } + if (config.propertyLayers.layers.isNotEmpty()) { + gen.writePOJO(config.propertyLayers) + } + gen.writeEndObject() } } @@ -81,57 +92,110 @@ object ConfigFallbackDeserializer : FallbackDeserializer(Config::class.j } override fun deserialize(p: JsonParser, ctxt: DeserializationContext, config: Config): Config = - config.apply { mapper.updateValue(settingLayers, mapper.readTree(p)) } + config.apply { + val configJson = mapper.readTree(p) + val settingsJson = configJson.get(settingLayers.name) + if (settingsJson != null && settingsJson.isObject) mapper.updateValue(settingLayers, settingsJson) + val propertiesJson = configJson.get(propertyLayers.name) + if (propertiesJson != null && propertiesJson.isObject) mapper.updateValue(propertyLayers, propertiesJson) + } } -object MultipleFallbackSerializer : FallbackSerializer(SettingLayer.Multiple::class.java) { - override fun serialize(multiple: SettingLayer.Multiple, gen: JsonGenerator, ctxt: SerializationContext) { - val notRoot = multiple !is SettingLayer.Root - if (notRoot) gen.writeObjectPropertyStart(multiple.name) - multiple.layers.forEach { layer -> - if (layer is SettingLayer.Single<*, *> && !layer.setting.isModified) return@forEach - val serialized = mapper.valueToTree(layer) - if (serialized.isObject && serialized.isEmpty) return@forEach - gen.writePOJOProperty(layer.name, serialized) +object MultipleSerializers { + object SettingLayerMultipleFallbackSerializer : FallbackSerializer(SettingLayer.Multiple::class.java) { + override fun serialize(multiple: SettingLayer.Multiple, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writeStartObject() + multiple.layers.forEach { layer -> + if (layer is SettingLayer.Single<*, *> && !layer.setting.isModified) return@forEach + val serialized = mapper.valueToTree(layer) + if (serialized.isObject && serialized.isEmpty) return@forEach + gen.writePOJOProperty(layer.name, serialized) + } + gen.writeEndObject() } - if (notRoot) gen.writeEndObject() } -} -object MultipleFallbackDeserializer : FallbackDeserializer(SettingLayer.Multiple::class.java) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SettingLayer.Multiple { - throw initFromJsonException("Multiple") + object SettingLayerMultipleFallbackDeserializer : FallbackDeserializer(SettingLayer.Multiple::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SettingLayer.Multiple { + throw initFromJsonException("SettingLayer.Multiple") + } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, multiple: SettingLayer.Multiple): SettingLayer.Multiple = + multiple.apply { + val multipleJson = mapper.readTree(p) + layers.forEach { layer -> + val layerJson = multipleJson.get(layer.name) ?: return@forEach + mapper.updateValue(layer, layerJson) + } + } } - override fun deserialize(p: JsonParser, ctxt: DeserializationContext, multiple: SettingLayer.Multiple): SettingLayer.Multiple = - multiple.apply { - val multipleJson = mapper.readTree(p) - layers.forEach { layer -> - val layerJson = multipleJson.get(layer.name) ?: return@forEach - mapper.updateValue(layer, layerJson) + object PropertyLayerMultipleFallbackSerializer : FallbackSerializer(PropertyLayer.Multiple::class.java) { + override fun serialize(multiple: PropertyLayer.Multiple, gen: JsonGenerator, ctxt: SerializationContext) { + if (multiple.layers.isEmpty()) return + gen.writeObjectPropertyStart(multiple.name) + multiple.layers.forEach { layer -> + gen.writePOJOProperty(layer.name, layer) } + gen.writeEndObject() + } + } + + object PropertyLayerMultipleFallbackDeserializer : FallbackDeserializer(PropertyLayer.Multiple::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): PropertyLayer.Multiple { + throw initFromJsonException("PropertyLayer.Multiple") } -} -object SingleFallbackSerializer : FallbackSerializer>(SettingLayer.Single::class.java) { - override fun serialize(single: SettingLayer.Single<*, *>, gen: JsonGenerator, ctxt: SerializationContext) { - gen.writePOJOProperty(single.name, single.setting) + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, multiple: PropertyLayer.Multiple) = + multiple.apply { + val multipleJson = mapper.readTree(p) + layers.forEach { layer -> + val layerJson = multipleJson.get(layer.name) ?: return@forEach + mapper.updateValue(layer, layerJson) + } + } } } -object SingleFallbackDeserializer : FallbackDeserializer>(SettingLayer.Single::class.java) { - override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SettingLayer.Single<*, *> { - throw initFromJsonException("Single") +object SingleSerializers { + object SettingLayerSingleFallbackSerializer : FallbackSerializer>(SettingLayer.Single::class.java) { + override fun serialize(single: SettingLayer.Single<*, *>, gen: JsonGenerator, ctxt: SerializationContext) { + gen.writePOJOProperty(single.name, single.setting) + } } - override fun deserialize(p: JsonParser, ctxt: DeserializationContext, single: SettingLayer.Single<*, *>): SettingLayer.Single<*, *> = - single.apply { - try { - mapper.updateValue(setting, mapper.readTree(p)) - } catch (e: Throwable) { - Log.error("Failed to deserialize setting '${name}'", e) + object SettingLayerSingleFallbackDeserializer : FallbackDeserializer>(SettingLayer.Single::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SettingLayer.Single<*, *> { + throw initFromJsonException("SettingLayer.Single") + } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, single: SettingLayer.Single<*, *>): SettingLayer.Single<*, *> = + single.apply { + try { + mapper.updateValue(setting, mapper.readTree(p)) + } catch (e: Throwable) { + Log.error("Failed to deserialize setting '${name}'", e) + } } + } + + object PropertyLayerSingleSerializer : Serializer(PropertyLayer.Single::class.java) { + override fun serialize(single: PropertyLayer.Single, gen: JsonGenerator, ctxt: SerializationContext?) { + gen.writePOJOProperty(single.name, single.property.value) } + } + + object PropertyLayerSingleDeserializer : Deserializer(PropertyLayer.Single::class.java) { + override fun deserialize(p: JsonParser, ctxt: DeserializationContext): PropertyLayer.Single { + throw initFromJsonException("PropertyLayer.Single") + } + + override fun deserialize(p: JsonParser, ctxt: DeserializationContext, single: PropertyLayer.Single) = + single.apply { + @Suppress("unchecked_cast") + (property as Property).value = ctxt.readValue(p, property.value.javaClass) + } + } } object SettingFallbackSerializer : FallbackSerializer>(Setting::class.java) { @@ -142,12 +206,12 @@ object SettingFallbackSerializer : FallbackSerializer>(Setting::class object SettingFallbackDeserializer : FallbackDeserializer>(Setting::class.java) { override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Setting<*> { - throw initFromJsonException("SettingCore") + throw initFromJsonException("Setting") } override fun deserialize(p: JsonParser, ctxt: DeserializationContext, setting: Setting<*>) = setting.apply { @Suppress("unchecked_cast") - (this as Setting).originalCore.value = mapper.treeToValue(mapper.readTree(p), originalCore.value.javaClass) + (this as Setting).originalCore.value = ctxt.readValue(p, originalCore.value.javaClass) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/lambda/config/settings/CharSetting.kt b/src/main/kotlin/com/lambda/config/settings/CharSetting.kt index 7eb3b9977..ddaa37003 100644 --- a/src/main/kotlin/com/lambda/config/settings/CharSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/CharSetting.kt @@ -24,9 +24,9 @@ import com.lambda.brigadier.argument.word import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore +import com.lambda.config.SettingLayer import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandRegistryAccess diff --git a/src/main/kotlin/com/lambda/config/settings/FunctionSetting.kt b/src/main/kotlin/com/lambda/config/settings/FunctionSetting.kt index 3a9800d8d..b4ca58e33 100644 --- a/src/main/kotlin/com/lambda/config/settings/FunctionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/FunctionSetting.kt @@ -18,9 +18,9 @@ package com.lambda.config.settings import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore +import com.lambda.config.SettingLayer import com.lambda.gui.dsl.ImGuiBuilder class FunctionSetting R, R>( diff --git a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt index 0dc2e0ddd..46a8ccbe8 100644 --- a/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/NumericSetting.kt @@ -18,11 +18,11 @@ package com.lambda.config.settings import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer -import com.lambda.config.ConfigEditor +import com.lambda.config.SettingEditor import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.config.SettingEditorDsl +import com.lambda.config.SettingLayer import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.ImGui import com.lambda.imgui.ImGui.calcTextSize @@ -99,17 +99,17 @@ abstract class NumericSetting( @Suppress("unchecked_cast", "unused") companion object { @SettingEditorDsl - fun ConfigEditor.TypedEditBuilder.range(range: ClosedRange) where T : Number, T : Comparable { + fun SettingEditor.TypedEditBuilder.range(range: ClosedRange) where T : Number, T : Comparable { (settings as Collection>).forEach { it.range = range } } @SettingEditorDsl - fun ConfigEditor.TypedEditBuilder.step(step: T) where T : Number, T : Comparable { + fun SettingEditor.TypedEditBuilder.step(step: T) where T : Number, T : Comparable { (settings as Collection>).forEach { it.step = step } } @SettingEditorDsl - fun ConfigEditor.TypedEditBuilder.unit(unit: String) where T : Number, T : Comparable { + fun SettingEditor.TypedEditBuilder.unit(unit: String) where T : Number, T : Comparable { (settings as Collection>).forEach { it.unit = unit } } } diff --git a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt index 0cc257304..5f160f9f6 100644 --- a/src/main/kotlin/com/lambda/config/settings/StringSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/StringSetting.kt @@ -22,11 +22,11 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer -import com.lambda.config.ConfigEditor +import com.lambda.config.SettingEditor import com.lambda.config.Setting import com.lambda.config.SettingCore import com.lambda.config.SettingEditorDsl +import com.lambda.config.SettingLayer import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.flag.ImGuiInputTextFlags import com.lambda.util.extension.CommandBuilder @@ -66,12 +66,12 @@ class StringSetting( @Suppress("unused", "unchecked_cast") companion object { @SettingEditorDsl - fun ConfigEditor.TypedEditBuilder.multiline(multiline: Boolean) { + fun SettingEditor.TypedEditBuilder.multiline(multiline: Boolean) { (settings as Collection).forEach { it.multiline = multiline } } @SettingEditorDsl - fun ConfigEditor.TypedEditBuilder.flags(flags: Int) { + fun SettingEditor.TypedEditBuilder.flags(flags: Int) { (settings as Collection).forEach { it.flags = flags } } } diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt index 08e304dc1..f00813cec 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/BreakSettings.kt @@ -18,9 +18,9 @@ package com.lambda.config.settings.blocks import com.lambda.config.Config -import com.lambda.config.ConfigEditor.hide +import com.lambda.config.SettingEditor.hide import com.lambda.config.Group -import com.lambda.config.SettingBlock +import com.lambda.config.ConfigBlock import com.lambda.config.settings.blocks.BreakConfig.AnimationMode import com.lambda.config.settings.blocks.BreakConfig.BreakConfirmationMode import com.lambda.config.settings.blocks.BreakConfig.BreakMode @@ -32,47 +32,46 @@ import com.lambda.event.events.TickEvent.Companion.ALL_STAGES import net.minecraft.registry.Registries import java.awt.Color -class BreakSettings(override val c: Config) : BreakConfig, SettingBlock { +class BreakSettings(override val c: Config) : BreakConfig, ConfigBlock { companion object { - const val GeneralGroup = "General" const val CosmeticGroup = "Cosmetic" } // General - @Group(GeneralGroup) override val breakMode by c.setting("Break Mode", BreakMode.Packet) - @Group(GeneralGroup) override val sorter by c.setting("Break Sorter", ActionConfig.SortMode.Tool, "The order in which breaks are performed") - @Group(GeneralGroup) override val rebreak by c.setting("Rebreak", true, "Re-breaks blocks after they've been broken once") + override val breakMode by c.setting("Break Mode", BreakMode.Packet) + override val sorter by c.setting("Break Sorter", ActionConfig.SortMode.Tool, "The order in which breaks are performed") + override val rebreak by c.setting("Rebreak", true, "Re-breaks blocks after they've been broken once") // Double break - @Group(GeneralGroup) override val doubleBreak by c.setting("Double Break", true, "Allows breaking two blocks at once") - @Group(GeneralGroup) override val unsafeCancels by c.setting("Unsafe Cancels", true, "Allows cancelling block breaking even if the server might continue breaking sever side, potentially causing unexpected state changes") { doubleBreak } + override val doubleBreak by c.setting("Double Break", true, "Allows breaking two blocks at once") + override val unsafeCancels by c.setting("Unsafe Cancels", true, "Allows cancelling block breaking even if the server might continue breaking sever side, potentially causing unexpected state changes") { doubleBreak } // Fixes / Delays - @Group(GeneralGroup) override val breakThreshold by c.setting("Break Threshold", 0.70f, 0.1f..1.0f, 0.01f, "The break amount at which the block is considered broken") - @Group(GeneralGroup) override val fudgeFactor by c.setting("Fudge Factor", 1, 0..5, 1, "The number of ticks to add to the break time, usually to account for server lag") - @Group(GeneralGroup) override val serverSwapTicks by c.setting("Server Swap", 0, 0..5, 1, "The number of ticks to give the server time to recognize the player attributes on the swapped item", " tick(s)") + override val breakThreshold by c.setting("Break Threshold", 0.70f, 0.1f..1.0f, 0.01f, "The break amount at which the block is considered broken") + override val fudgeFactor by c.setting("Fudge Factor", 1, 0..5, 1, "The number of ticks to add to the break time, usually to account for server lag") + override val serverSwapTicks by c.setting("Server Swap", 0, 0..5, 1, "The number of ticks to give the server time to recognize the player attributes on the swapped item", " tick(s)") // @Group(GeneralGroup) override val desyncFix by c.setting("Desync Fix", false, "Predicts if the players breaking will be slowed next tick as block break packets are processed using the players next position") { page == Page.General } - @Group(GeneralGroup) override val breakDelay by c.setting("Break Delay", 0, 0..6, 1, "The delay between breaking blocks", " tick(s)") + override val breakDelay by c.setting("Break Delay", 0, 0..6, 1, "The delay between breaking blocks", " tick(s)") // Timing - @Group(GeneralGroup) override val tickStageMask by c.setting("Break Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), "The sub-tick timing at which break actions can be performed", displayClassName = true) - @Group(GeneralGroup) override val swapMode by c.setting("Break Swap Mode", BreakConfig.SwapMode.End, "Decides when to swap to the best suited tool when breaking a block") - @Group(GeneralGroup) override val swing by c.setting("Swing Mode", SwingMode.Constant, "The times at which to swing the players hand") - @Group(GeneralGroup) override val swingType by c.setting("Break Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { swing != SwingMode.None } + override val tickStageMask by c.setting("Break Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), "The sub-tick timing at which break actions can be performed", displayClassName = true) + override val swapMode by c.setting("Break Swap Mode", BreakConfig.SwapMode.End, "Decides when to swap to the best suited tool when breaking a block") + override val swing by c.setting("Swing Mode", SwingMode.Constant, "The times at which to swing the players hand") + override val swingType by c.setting("Break Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { swing != SwingMode.None } // Rotate - @Group(GeneralGroup) override val rotate by c.setting("Rotate For Break", false, "Rotate towards block while breaking") + override val rotate by c.setting("Rotate For Break", false, "Rotate towards block while breaking") // Pending / Post - @Group(GeneralGroup) override val breakConfirmation by c.setting("Break Confirmation", BreakConfirmationMode.BreakThenAwait, "The style of confirmation used when breaking") - @Group(GeneralGroup) override val breaksPerTick by c.setting("Breaks Per Tick", 30, 1..30, 1, "Maximum instant block breaks per tick") - @Group(GeneralGroup) override val whitelistMode by c.setting("Whitelist Mode", WhitelistMode.None, "The type of block selection used") - @Group(GeneralGroup) override val whitelist by c.setting("Whitelist", mutableSetOf(), Registries.BLOCK.toSet(), "Only these selected blocks are allowed to be broken") { whitelistMode == WhitelistMode.Whitelist } - @Group(GeneralGroup) override val blacklist by c.setting("Blacklist", mutableSetOf(), Registries.BLOCK.toSet(), "These selected blocks are not allowed to be broken") { whitelistMode == WhitelistMode.Blacklist } - @Group(GeneralGroup) override val avoidFluids by c.setting("Avoid Fluids", true, "Avoids breaking blocks that would cause fluids to spill") - @Group(GeneralGroup) override val avoidSupporting by c.setting("Avoid Supporting", true, "Avoids breaking the block supporting the player") - @Group(GeneralGroup) override val fillFluids by c.setting("Fill Fluids", true, "Fills fluids in order to break blocks that would initially spill them") { avoidFluids } + override val breakConfirmation by c.setting("Break Confirmation", BreakConfirmationMode.BreakThenAwait, "The style of confirmation used when breaking") + override val breaksPerTick by c.setting("Breaks Per Tick", 30, 1..30, 1, "Maximum instant block breaks per tick") + override val whitelistMode by c.setting("Whitelist Mode", WhitelistMode.None, "The type of block selection used") + override val whitelist by c.setting("Whitelist", mutableSetOf(), Registries.BLOCK.toSet(), "Only these selected blocks are allowed to be broken") { whitelistMode == WhitelistMode.Whitelist } + override val blacklist by c.setting("Blacklist", mutableSetOf(), Registries.BLOCK.toSet(), "These selected blocks are not allowed to be broken") { whitelistMode == WhitelistMode.Blacklist } + override val avoidFluids by c.setting("Avoid Fluids", true, "Avoids breaking blocks that would cause fluids to spill") + override val avoidSupporting by c.setting("Avoid Supporting", true, "Avoids breaking the block supporting the player") + override val fillFluids by c.setting("Fill Fluids", true, "Fills fluids in order to break blocks that would initially spill them") { avoidFluids } // Tool - @Group(GeneralGroup) override val efficientOnly by c.setting("Efficient Tools Only", true, "Only use tools suitable for the given block (will get the item drop)") { swapMode.isEnabled() } - @Group(GeneralGroup) override val suitableToolsOnly by c.setting("Suitable Tools Only", true, "Only use tools suitable for the given block (will get the item drop)") { swapMode.isEnabled() } - @Group(GeneralGroup) override val forceSilkTouch by c.setting("Force Silk Touch", false, "Force silk touch when breaking blocks") { swapMode.isEnabled() } - @Group(GeneralGroup) override val forceFortunePickaxe by c.setting("Force Fortune Pickaxe", false, "Force fortune pickaxe when breaking blocks") { swapMode.isEnabled() } - @Group(GeneralGroup) override val minFortuneLevel by c.setting("Min Fortune Level", 1, 1..3, 1, "The minimum fortune level to use") { swapMode.isEnabled() && forceFortunePickaxe } + override val efficientOnly by c.setting("Efficient Tools Only", true, "Only use tools suitable for the given block (will get the item drop)") { swapMode.isEnabled() } + override val suitableToolsOnly by c.setting("Suitable Tools Only", true, "Only use tools suitable for the given block (will get the item drop)") { swapMode.isEnabled() } + override val forceSilkTouch by c.setting("Force Silk Touch", false, "Force silk touch when breaking blocks") { swapMode.isEnabled() } + override val forceFortunePickaxe by c.setting("Force Fortune Pickaxe", false, "Force fortune pickaxe when breaking blocks") { swapMode.isEnabled() } + override val minFortuneLevel by c.setting("Min Fortune Level", 1, 1..3, 1, "The minimum fortune level to use") { swapMode.isEnabled() && forceFortunePickaxe } // Cosmetics @Group(CosmeticGroup) override val sounds by c.setting("Break Sounds", true, "Plays the breaking sounds") @@ -89,7 +88,7 @@ class BreakSettings(override val c: Config) : BreakConfig, SettingBlock { @Group(CosmeticGroup) override val endFillColor by c.setting("End Fill Color", Color(0, 255, 0, 60), "The color of the fill at the end of breaking") { renders && dynamicFillColor && fill } // Outline @Group(CosmeticGroup) override val outline by c.setting("Outline", true, "Renders the lines of the box to display break progress") { renders } - @Group(CosmeticGroup) override val outlineConfig by c.settingBlock(WorldLineSettings(c)) + @Group(CosmeticGroup) override val outlineConfig by c.configBlock(WorldLineSettings(c)) .withEdits(c) { hide(::startColor, ::endColor) } diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/BuildSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/BuildSettings.kt index b84fb0362..7f2bf9760 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/BuildSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/BuildSettings.kt @@ -19,10 +19,10 @@ package com.lambda.config.settings.blocks import com.lambda.config.Config import com.lambda.config.Group -import com.lambda.config.SettingBlock +import com.lambda.config.ConfigBlock import kotlin.math.max -class BuildSettings(override val c: Config) : BuildConfig, SettingBlock { +class BuildSettings(override val c: Config) : BuildConfig, ConfigBlock { companion object { private const val GeneralGroup = "General" private const val PacketLimitsGroup = "Packet Limits" diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/EatSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/EatSettings.kt index 1b85871be..0b4daa0a2 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/EatSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/EatSettings.kt @@ -18,10 +18,10 @@ package com.lambda.config.settings.blocks import com.lambda.config.Config -import com.lambda.config.SettingBlock +import com.lambda.config.ConfigBlock import net.minecraft.item.Items -class EatSettings(override val c: Config) : EatConfig, SettingBlock { +class EatSettings(override val c: Config) : EatConfig, ConfigBlock { val nutritiousFoodDefaults = listOf(Items.APPLE, Items.BAKED_POTATO, Items.BEEF, Items.BEETROOT, Items.BEETROOT_SOUP, Items.BREAD, Items.CARROT, Items.CHICKEN, Items.CHORUS_FRUIT, Items.COD, Items.COOKED_BEEF, Items.COOKED_CHICKEN, Items.COOKED_COD, Items.COOKED_MUTTON, Items.COOKED_PORKCHOP, Items.COOKED_RABBIT, Items.COOKED_SALMON, Items.COOKIE, Items.DRIED_KELP, Items.ENCHANTED_GOLDEN_APPLE, Items.GOLDEN_APPLE, Items.GOLDEN_CARROT, Items.HONEY_BOTTLE, Items.MELON_SLICE, Items.MUSHROOM_STEW, Items.MUTTON, Items.POISONOUS_POTATO, Items.PORKCHOP, Items.POTATO, Items.PUFFERFISH, Items.PUMPKIN_PIE, Items.RABBIT, Items.RABBIT_STEW, Items.ROTTEN_FLESH, Items.SALMON, Items.SPIDER_EYE, Items.SUSPICIOUS_STEW, Items.SWEET_BERRIES, Items.GLOW_BERRIES, Items.TROPICAL_FISH) val resistanceFoodDefaults = listOf(Items.ENCHANTED_GOLDEN_APPLE) val regenerationFoodDefaults = listOf(Items.ENCHANTED_GOLDEN_APPLE, Items.GOLDEN_APPLE) diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/EntityColorSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/EntityColorSettings.kt index 1589c3681..f941377fe 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/EntityColorSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/EntityColorSettings.kt @@ -18,7 +18,7 @@ package com.lambda.config.settings.blocks import com.lambda.config.Config -import com.lambda.config.SettingBlock +import com.lambda.config.ConfigBlock import com.lambda.context.SafeContext import com.lambda.friend.FriendHandler.isFriend import com.lambda.util.EntityUtils.EntityGroup @@ -33,7 +33,7 @@ import net.minecraft.entity.Entity import net.minecraft.entity.player.PlayerEntity import java.awt.Color -class EntityColorSettings(override val c: Config) : SettingBlock, EntityColorsConfig { +class EntityColorSettings(override val c: Config) : ConfigBlock, EntityColorsConfig { override val useNaturalColors by c.setting("Use Natural Colors", false, "Uses an average color from the entities texture") override val playerColor by c.setting("Player Color", Color(255, 50, 50)) { !useNaturalColors } override val playerDistanceGradient by c.setting("Player Distance Gradient", true) diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/EntitySelectionSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/EntitySelectionSettings.kt index fa06d2ad9..5c4065bd8 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/EntitySelectionSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/EntitySelectionSettings.kt @@ -19,7 +19,7 @@ package com.lambda.config.settings.blocks import com.lambda.Lambda.mc import com.lambda.config.Config -import com.lambda.config.SettingBlock +import com.lambda.config.ConfigBlock import com.lambda.util.EntityUtils.blockEntityMap import com.lambda.util.EntityUtils.bossEntityMap import com.lambda.util.EntityUtils.decorationEntityMap @@ -33,7 +33,7 @@ import net.minecraft.block.entity.BlockEntity import net.minecraft.entity.Entity import net.minecraft.entity.SpawnGroup -class EntitySelectionSettings(override val c: Config) : SettingBlock, EntitySelectionConfig { +class EntitySelectionSettings(override val c: Config) : ConfigBlock, EntitySelectionConfig { override val self by c.setting("Self", false, "Render own player in third person") override val enablePlayerEntities by c.setting("Enable Player Entities", true) override val playerEntities by c.setting("Player Entities", playerEntityMap.values.toSet(), playerEntityMap.values.toSet(), "Player entities to omit from rendering") { enablePlayerEntities } diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/FormatterSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/FormatterSettings.kt index d91d42d21..580a1b3a1 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/FormatterSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/FormatterSettings.kt @@ -18,9 +18,9 @@ package com.lambda.config.settings.blocks import com.lambda.config.Config -import com.lambda.config.SettingBlock +import com.lambda.config.ConfigBlock -class FormatterSettings(override val c: Config) : FormatterConfig, SettingBlock { +class FormatterSettings(override val c: Config) : FormatterConfig, ConfigBlock { val localeEnum by c.setting("Locale", FormatterConfig.Locales.US, "The regional formatting used for numbers") override val locale get() = localeEnum.locale diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/HotbarSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/HotbarSettings.kt index ab3c07f4d..e340a0309 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/HotbarSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/HotbarSettings.kt @@ -18,11 +18,11 @@ package com.lambda.config.settings.blocks import com.lambda.config.Config -import com.lambda.config.SettingBlock +import com.lambda.config.ConfigBlock import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -class HotbarSettings(override val c: Config) : HotbarConfig, SettingBlock { +class HotbarSettings(override val c: Config) : HotbarConfig, ConfigBlock { override val swapMode by c.setting("Swap Mode", HotbarConfig.SwapMode.Temporary) override val keepTicks by c.setting("Keep Ticks", 1, 0..20, 1, "The number of ticks to keep the current hotbar selection active", " ticks") { swapMode == HotbarConfig.SwapMode.Temporary } override val swapDelay by c.setting("Swap Delay", 0, 0..3, 1, "The number of ticks delay before allowing another hotbar selection swap", " ticks") diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/InteractSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/InteractSettings.kt index 9e9ea0de0..16fc17a01 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/InteractSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/InteractSettings.kt @@ -18,11 +18,11 @@ package com.lambda.config.settings.blocks import com.lambda.config.Config -import com.lambda.config.SettingBlock +import com.lambda.config.ConfigBlock import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES -class InteractSettings(override val c: Config) : InteractConfig, SettingBlock { +class InteractSettings(override val c: Config) : InteractConfig, ConfigBlock { override val rotate by c.setting("Rotate For Interact", true, "Rotate towards block while placing") override val airPlace by c.setting("Air Place", InteractConfig.AirPlaceMode.Grim, "Allows for placing blocks without adjacent faces") override val axisRotateSetting by c.setting("Axis Rotate", true, "Overrides the Rotate For Place setting and rotates the player on each axis to air place rotational blocks") { airPlace.isEnabled } diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/InventorySettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/InventorySettings.kt index d83494ab2..a937670a7 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/InventorySettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/InventorySettings.kt @@ -19,11 +19,11 @@ package com.lambda.config.settings.blocks import com.lambda.config.Config import com.lambda.config.Group -import com.lambda.config.SettingBlock +import com.lambda.config.ConfigBlock import com.lambda.event.events.TickEvent.Companion.ALL_STAGES import com.lambda.util.item.ItemUtils -class InventorySettings(override val c: Config) : InventoryConfig, SettingBlock { +class InventorySettings(override val c: Config) : InventoryConfig, ConfigBlock { companion object { private const val ContainerGroup = "Container" private const val AccessGroup = "Access" diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/OutlineSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/OutlineSettings.kt index 63f304633..c15d6609d 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/OutlineSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/OutlineSettings.kt @@ -18,11 +18,11 @@ package com.lambda.config.settings.blocks import com.lambda.config.Config -import com.lambda.config.SettingBlock +import com.lambda.config.ConfigBlock import com.lambda.graphics.outline.OutlineStyle import java.awt.Color -class OutlineSettings(override val c: Config) : OutlineConfig, SettingBlock { +class OutlineSettings(override val c: Config) : OutlineConfig, ConfigBlock { val thicknessSetting by c.setting("Line Width", 25, 1..100, 1, "The width of the outline") override val thickness get() = thicknessSetting * 0.00005f diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/RotationSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/RotationSettings.kt index 33a0bef57..20ff8f6ec 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/RotationSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/RotationSettings.kt @@ -18,7 +18,7 @@ package com.lambda.config.settings.blocks import com.lambda.config.Config -import com.lambda.config.SettingBlock +import com.lambda.config.ConfigBlock import com.lambda.event.events.TickEvent import com.lambda.event.events.TickEvent.Companion.ALL_STAGES import com.lambda.interaction.managers.rotating.RotationMode @@ -29,7 +29,7 @@ import kotlin.math.ln import kotlin.math.sqrt import kotlin.random.Random -class RotationSettings(override val c: Config) : RotationConfig, SettingBlock { +class RotationSettings(override val c: Config) : RotationConfig, ConfigBlock { override var rotationMode by c.setting("Mode", RotationMode.Sync, "How the player is being rotated on interaction") /** How many ticks to keep the rotation before resetting */ diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/ScreenLineSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/ScreenLineSettings.kt index 42c3a4abf..7b6606ec5 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/ScreenLineSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/ScreenLineSettings.kt @@ -19,10 +19,10 @@ package com.lambda.config.settings.blocks import com.lambda.config.Config import com.lambda.config.Group -import com.lambda.config.SettingBlock +import com.lambda.config.ConfigBlock import java.awt.Color -class ScreenLineSettings(override val c: Config) : LineConfig, SettingBlock { +class ScreenLineSettings(override val c: Config) : LineConfig, ConfigBlock { companion object { private const val ColorGroup = "Color" private const val DashGroup = "Dash" diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/ScreenTextSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/ScreenTextSettings.kt index 6c807ad3b..207af7935 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/ScreenTextSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/ScreenTextSettings.kt @@ -19,10 +19,10 @@ package com.lambda.config.settings.blocks import com.lambda.config.Config import com.lambda.config.Group -import com.lambda.config.SettingBlock +import com.lambda.config.ConfigBlock import java.awt.Color -class ScreenTextSettings(override val c: Config) : TextConfig, SettingBlock { +class ScreenTextSettings(override val c: Config) : TextConfig, ConfigBlock { companion object { private const val OutlineGroup = "Outline" private const val GlowGroup = "Glow" diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt index 570b2c92e..f5da522a2 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/TargetingSettings.kt @@ -18,8 +18,8 @@ package com.lambda.config.settings.blocks import com.lambda.config.Config -import com.lambda.config.ConfigEditor.hide -import com.lambda.config.SettingBlock +import com.lambda.config.SettingEditor.hide +import com.lambda.config.ConfigBlock import com.lambda.config.withEdits import com.lambda.context.SafeContext import com.lambda.friend.FriendHandler.isFriend @@ -53,13 +53,13 @@ abstract class TargetingSettings( override val c: Config, defaultRange: Double, maxRange: Double, -) : TargetingConfig, SettingBlock { +) : TargetingConfig, ConfigBlock { /** * The range within which entities can be targeted. This value is config and constrained * between 1.0 and [maxRange]. */ override val targetingRange by c.setting("Targeting Range", defaultRange, 1.0..maxRange, 0.05) - override val targets by c.settingBlock(EntitySelectionSettings(c)) + override val targets by c.configBlock(EntitySelectionSettings(c)) .withEdits(c) { hide(::self, ::enableBlockEntities, ::blockEntities) } /** diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/WorldLineSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/WorldLineSettings.kt index c42dcdf6a..02b6ae075 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/WorldLineSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/WorldLineSettings.kt @@ -19,10 +19,10 @@ package com.lambda.config.settings.blocks import com.lambda.config.Config import com.lambda.config.Group -import com.lambda.config.SettingBlock +import com.lambda.config.ConfigBlock import java.awt.Color -class WorldLineSettings(override val c: Config) : LineConfig, SettingBlock { +class WorldLineSettings(override val c: Config) : LineConfig, ConfigBlock { companion object { private const val ColorGroup = "Color" private const val DashGroup = "Dash" diff --git a/src/main/kotlin/com/lambda/config/settings/blocks/WorldTextSettings.kt b/src/main/kotlin/com/lambda/config/settings/blocks/WorldTextSettings.kt index b6fda0f40..d0324387f 100644 --- a/src/main/kotlin/com/lambda/config/settings/blocks/WorldTextSettings.kt +++ b/src/main/kotlin/com/lambda/config/settings/blocks/WorldTextSettings.kt @@ -19,10 +19,10 @@ package com.lambda.config.settings.blocks import com.lambda.config.Config import com.lambda.config.Group -import com.lambda.config.SettingBlock +import com.lambda.config.ConfigBlock import java.awt.Color -class WorldTextSettings(override val c: Config) : TextConfig, SettingBlock { +class WorldTextSettings(override val c: Config) : TextConfig, ConfigBlock { companion object { private const val OutlineGroup = "Outline" private const val GlowGroup = "Glow" diff --git a/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt index 84646e599..5e37799f1 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/BlockCollectionSetting.kt @@ -19,7 +19,7 @@ package com.lambda.config.settings.collections import com.lambda.Lambda.typeFactory import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer +import com.lambda.config.SettingLayer import com.lambda.config.serializers.BlockSerializer import com.lambda.gui.dsl.ImGuiBuilder import net.minecraft.block.Block diff --git a/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt index 4e698db5f..25d55c368 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/ClassCollectionSetting.kt @@ -19,7 +19,7 @@ package com.lambda.config.settings.collections import com.lambda.Lambda.typeFactory import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer +import com.lambda.config.SettingLayer import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.util.ReflectionUtils.className diff --git a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt index dfd33b6db..544e6aa5d 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt @@ -18,12 +18,12 @@ package com.lambda.config.settings.collections import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer -import com.lambda.config.ConfigEditor +import com.lambda.config.SettingEditor import com.lambda.config.Setting import com.lambda.config.SettingCore -import com.lambda.config.SettingDsl +import com.lambda.config.ConfigEntryD5l import com.lambda.config.SettingEditorDsl +import com.lambda.config.SettingLayer import com.lambda.context.SafeContext import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.ImGui @@ -172,17 +172,17 @@ open class CollectionSetting( @Suppress("unused") companion object { - @SettingDsl + @ConfigEntryD5l fun , R : Any> T.onSelect(block: SafeContext.(R) -> Unit) = apply { selectListeners.add(block) } - @SettingDsl + @ConfigEntryD5l fun , R : Any> T.onDeselect(block: SafeContext.(R) -> Unit) = apply { deselectListeners.add(block) } @Suppress("unchecked_cast") @SettingEditorDsl - fun ConfigEditor.TypedEditBuilder>.immutableCollection(collection: Collection) { + fun SettingEditor.TypedEditBuilder>.immutableCollection(collection: Collection) { (settings as Collection>).forEach { it.immutableCollection = collection } } } diff --git a/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt index 7876c05e0..f90581def 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/ItemCollectionSetting.kt @@ -19,7 +19,7 @@ package com.lambda.config.settings.collections import com.lambda.Lambda.typeFactory import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer +import com.lambda.config.SettingLayer import com.lambda.config.serializers.ItemSerializer import com.lambda.gui.dsl.ImGuiBuilder import net.minecraft.item.Item diff --git a/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt b/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt index fa8f59332..fdb3ce0b6 100644 --- a/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/collections/MapSetting.kt @@ -18,9 +18,9 @@ package com.lambda.config.settings.collections import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore +import com.lambda.config.SettingLayer import com.lambda.gui.dsl.ImGuiBuilder import tools.jackson.databind.JavaType diff --git a/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt b/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt index 3b056c4d6..56efe8996 100644 --- a/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/comparable/BooleanSetting.kt @@ -22,9 +22,9 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore +import com.lambda.config.SettingLayer import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandRegistryAccess diff --git a/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt b/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt index f3503bea8..3bc9506c9 100644 --- a/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/comparable/EnumSetting.kt @@ -24,9 +24,9 @@ import com.lambda.brigadier.argument.word import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.required import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore +import com.lambda.config.SettingLayer import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.util.Describable import com.lambda.util.StringUtils.capitalize diff --git a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt index 32ddf2959..98cd82134 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/BlockPosSetting.kt @@ -23,9 +23,9 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore +import com.lambda.config.SettingLayer import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.util.BlockUtils.blockPos import com.lambda.util.CommunicationUtils.info diff --git a/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt index 1147604ea..161338255 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/BlockSetting.kt @@ -22,9 +22,9 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore +import com.lambda.config.SettingLayer import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.util.extension.CommandBuilder import net.minecraft.block.Block diff --git a/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt index ca72ae6a8..4af718f98 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/ColorSetting.kt @@ -23,9 +23,9 @@ import com.lambda.brigadier.execute import com.lambda.brigadier.optional import com.lambda.brigadier.required import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore +import com.lambda.config.SettingLayer import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandRegistryAccess diff --git a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt index cc08326fe..7160114f1 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt @@ -27,10 +27,10 @@ import com.lambda.brigadier.executeWithResult import com.lambda.brigadier.optional import com.lambda.brigadier.required import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore -import com.lambda.config.SettingDsl +import com.lambda.config.ConfigEntryD5l +import com.lambda.config.SettingLayer import com.lambda.context.SafeContext import com.lambda.event.Muteable import com.lambda.event.events.ButtonEvent @@ -209,13 +209,13 @@ class KeybindSetting( @Suppress("unused") companion object { - @SettingDsl + @ConfigEntryD5l fun KeybindSetting.onPress(block: SafeContext.(ButtonEvent) -> Unit) = apply { pressListeners.add(block) } - @SettingDsl + @ConfigEntryD5l fun KeybindSetting.onRepeat(block: SafeContext.(ButtonEvent) -> Unit) = apply { repeatListeners.add(block) } - @SettingDsl + @ConfigEntryD5l fun KeybindSetting.onRelease(block: SafeContext.(ButtonEvent) -> Unit) = apply { releaseListeners.add(block) } } } diff --git a/src/main/kotlin/com/lambda/config/settings/complex/Vec3dSetting.kt b/src/main/kotlin/com/lambda/config/settings/complex/Vec3dSetting.kt index ba505b566..4909fe47c 100644 --- a/src/main/kotlin/com/lambda/config/settings/complex/Vec3dSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/complex/Vec3dSetting.kt @@ -22,9 +22,9 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting import com.lambda.config.SettingCore +import com.lambda.config.SettingLayer import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.util.extension.CommandBuilder import net.minecraft.command.CommandRegistryAccess diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt index 289d152f7..02b1ba111 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/DoubleSetting.kt @@ -23,7 +23,7 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer +import com.lambda.config.SettingLayer import com.lambda.config.settings.NumericSetting import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.type.ImInt diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt index 76d10bd15..beeeba7a1 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/FloatSetting.kt @@ -22,7 +22,7 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer +import com.lambda.config.SettingLayer import com.lambda.config.settings.NumericSetting import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.type.ImInt diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/IntegerSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/IntegerSetting.kt index b17246d99..3998c5c99 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/IntegerSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/IntegerSetting.kt @@ -22,7 +22,7 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer +import com.lambda.config.SettingLayer import com.lambda.config.settings.NumericSetting import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.util.extension.CommandBuilder diff --git a/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt b/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt index b0d4b9ea0..46a92b0c1 100644 --- a/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt +++ b/src/main/kotlin/com/lambda/config/settings/numeric/LongSetting.kt @@ -22,7 +22,7 @@ import com.lambda.brigadier.argument.value import com.lambda.brigadier.execute import com.lambda.brigadier.required import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer +import com.lambda.config.SettingLayer import com.lambda.config.settings.NumericSetting import com.lambda.gui.dsl.ImGuiBuilder import com.lambda.imgui.type.ImInt diff --git a/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt b/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt index c5ae2788d..da4c1f749 100644 --- a/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt +++ b/src/main/kotlin/com/lambda/gui/components/SettingsWidget.kt @@ -18,8 +18,8 @@ package com.lambda.gui.components import com.lambda.config.Config -import com.lambda.config.Config.SettingLayer import com.lambda.config.Setting +import com.lambda.config.SettingLayer import com.lambda.config.automation.AutomationConfig import com.lambda.config.automation.IMutableAutomationConfig import com.lambda.config.automation.UserAutomationConfig diff --git a/src/main/kotlin/com/lambda/gui/dsl/ImGuiBuilder.kt b/src/main/kotlin/com/lambda/gui/dsl/ImGuiBuilder.kt index 2c027be27..e57d4d6a2 100644 --- a/src/main/kotlin/com/lambda/gui/dsl/ImGuiBuilder.kt +++ b/src/main/kotlin/com/lambda/gui/dsl/ImGuiBuilder.kt @@ -17,23 +17,6 @@ @file:Suppress("unused") -/* - * Copyright 2025 Lambda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - package com.lambda.gui.dsl import com.lambda.gui.components.ClickGuiLayout diff --git a/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt b/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt index 37ea6a9d8..45e8b7a53 100644 --- a/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt +++ b/src/main/kotlin/com/lambda/interaction/BaritoneHandler.kt @@ -23,7 +23,7 @@ import baritone.api.Settings import baritone.api.pathing.goals.Goal import com.lambda.config.Config import com.lambda.config.Group -import com.lambda.config.SettingBlock +import com.lambda.config.ConfigBlock import com.lambda.config.Tab import com.lambda.config.automation.AutomationConfig import com.lambda.config.categories.LambdaCategory @@ -46,7 +46,7 @@ object BaritoneHandler : Config( // val settings by baritoneSettings?.let { settingBlock(BaritoneConfigSettings(this, it)) } private const val RotationTab = "Rotation" - @Tab(RotationTab) override val rotationConfig by settingBlock(RotationSettings(this)) + @Tab(RotationTab) override val rotationConfig by configBlock(RotationSettings(this)) @JvmStatic val primary: IBaritone? = baritone?.primaryBaritone @@ -100,7 +100,7 @@ object BaritoneHandler : Config( class BaritoneConfigSettings( override val c: Config, private val bSettings: Settings - ) : SettingBlock { + ) : ConfigBlock { companion object { private const val GeneralTab = "General" private const val PathingTab = "Pathing" diff --git a/src/main/kotlin/com/lambda/module/hud/Coordinates.kt b/src/main/kotlin/com/lambda/module/hud/Coordinates.kt index 91aba6e57..1daadd6b1 100644 --- a/src/main/kotlin/com/lambda/module/hud/Coordinates.kt +++ b/src/main/kotlin/com/lambda/module/hud/Coordinates.kt @@ -17,7 +17,7 @@ package com.lambda.module.hud -import com.lambda.config.ConfigEditor.edit +import com.lambda.config.SettingEditor.edit import com.lambda.config.Tab import com.lambda.config.settings.blocks.FormatterSettings import com.lambda.config.withEdits @@ -43,7 +43,7 @@ object Coordinates : HudModule( private val showCurrentDimensionOnly by setting("Show Current Dimension Only", true) private const val CurrentDimensionTab = "Current Dimension" - @Tab(CurrentDimensionTab) private val formatter by settingBlock(FormatterSettings(this)) + @Tab(CurrentDimensionTab) private val formatter by configBlock(FormatterSettings(this)) .withEdits { ::timeFormat.edit { hide() } } // private val otherFormatter = FormatterSettings(this, Page.OtherDimension).apply { diff --git a/src/main/kotlin/com/lambda/module/hud/Rotation.kt b/src/main/kotlin/com/lambda/module/hud/Rotation.kt index f527c21e0..45d6bff61 100644 --- a/src/main/kotlin/com/lambda/module/hud/Rotation.kt +++ b/src/main/kotlin/com/lambda/module/hud/Rotation.kt @@ -17,7 +17,7 @@ package com.lambda.module.hud -import com.lambda.config.ConfigEditor.edit +import com.lambda.config.SettingEditor.edit import com.lambda.config.settings.blocks.FormatterSettings import com.lambda.config.withEdits import com.lambda.gui.dsl.ImGuiBuilder @@ -32,7 +32,7 @@ object Rotation : HudModule( description = "Show your rotation", tag = ModuleTag.Hud, ) { - private val formatter by settingBlock(FormatterSettings(this)) + private val formatter by configBlock(FormatterSettings(this)) .withEdits { ::timeFormat.edit { hide() } } diff --git a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt index b2076bcac..adf12879e 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt @@ -19,7 +19,7 @@ package com.lambda.module.modules.chat import com.lambda.config.Config import com.lambda.config.Group -import com.lambda.config.SettingBlock +import com.lambda.config.ConfigBlock import com.lambda.event.events.ChatEvent import com.lambda.event.listener.SafeListener.Companion.listen import com.lambda.friend.FriendHandler @@ -56,13 +56,13 @@ object AntiSpam : Module( private val ignoreSystem by setting("Ignore System", false) private val ignoreDms by setting("Ignore DMs", false) - @Group("Slurs") private val detectSlurs by settingBlock(ReplaceSettings("Slurs", this)) - @Group("Swears") private val detectSwears by settingBlock(ReplaceSettings("Swears", this)) - @Group("Sexual") private val detectSexual by settingBlock(ReplaceSettings("Sexual", this)) - @Group("Discord") private val detectDiscord by settingBlock(ReplaceSettings("Discord", this, ActionStrategy.Hide)) - @Group("Addresses") private val detectAddresses by settingBlock(ReplaceSettings("Addresses", this, ActionStrategy.Hide)) - @Group("Hex") private val detectHexBypass by settingBlock(ReplaceSettings("Hex", this, ActionStrategy.Hide)) - @Group("Colors") private val detectColors by settingBlock(ReplaceSettings("Colors", this, ActionStrategy.None)) + @Group("Slurs") private val detectSlurs by configBlock(ReplaceSettings("Slurs", this)) + @Group("Swears") private val detectSwears by configBlock(ReplaceSettings("Swears", this)) + @Group("Sexual") private val detectSexual by configBlock(ReplaceSettings("Sexual", this)) + @Group("Discord") private val detectDiscord by configBlock(ReplaceSettings("Discord", this, ActionStrategy.Hide)) + @Group("Addresses") private val detectAddresses by configBlock(ReplaceSettings("Addresses", this, ActionStrategy.Hide)) + @Group("Hex") private val detectHexBypass by configBlock(ReplaceSettings("Hex", this, ActionStrategy.Hide)) + @Group("Colors") private val detectColors by configBlock(ReplaceSettings("Colors", this, ActionStrategy.None)) init { listen { event -> @@ -120,7 +120,7 @@ object AntiSpam : Module( val name: String, override val c: Config, actionStrategy: ActionStrategy = ActionStrategy.Replace - ) : SettingBlock { + ) : ConfigBlock { val action by c.setting("$name Action Strategy", actionStrategy) val replace by c.setting("$name Replace Strategy", ReplaceStrategy.CensorAll) { action == ActionStrategy.Replace } diff --git a/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt b/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt index 9725e46dc..06220ae4d 100644 --- a/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt +++ b/src/main/kotlin/com/lambda/module/modules/chat/ChatTimestamp.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.chat -import com.lambda.config.ConfigEditor.editTyped -import com.lambda.config.ConfigEditor.hide +import com.lambda.config.SettingEditor.editTyped +import com.lambda.config.SettingEditor.hide import com.lambda.config.settings.blocks.FormatterConfig import com.lambda.config.settings.blocks.FormatterSettings import com.lambda.config.withEdits @@ -48,7 +48,7 @@ object ChatTimestamp : Module( .onValueChange { from, to -> if (to.colorIndex !in 0..15) color = from } private val javaColor: Color get() = Color(color.colorValue!! and 16777215) - val formatter by settingBlock(FormatterSettings(this)) + val formatter by configBlock(FormatterSettings(this)) .withEdits { hide(::localeEnum, ::sep, ::customSep, ::floatingPrecision) editTyped(::timeFormat) { defaultValue(FormatterConfig.Time.IsoLocalTime) } diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt index fa23dca86..ec45fc94e 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoArmor.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.combat -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress diff --git a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt index ad6bbbe03..3b23ff02f 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.combat -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.withEdits import com.lambda.context.SafeContext diff --git a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt index 70bcd546a..25ea7483b 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.combat -import com.lambda.config.ConfigEditor.hide -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.hide +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.Tab import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.TargetingSettings @@ -114,7 +114,7 @@ object CrystalAura : Module( @Tab(PredictionTab) private val placePredictions by setting("Place Predictions", 4, 1..20, 1) { prediction.onPlace } @Tab(PredictionTab) private val packetLifetime by setting("Packet Lifetime", 500L, 50L..1000L) { prediction.onPlace } - @Tab(PredictionTab) private val targetingSettings by settingBlock(TargetingSettings.CombatSettings(this, 10.0)) + @Tab(PredictionTab) private val targetingSettings by configBlock(TargetingSettings.CombatSettings(this, 10.0)) private val blueprint = mutableMapOf() private var activeOpportunity: Opportunity? = null diff --git a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt index b30c12a65..48a136a28 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt @@ -17,9 +17,9 @@ package com.lambda.module.modules.combat -import com.lambda.config.ConfigEditor.edit -import com.lambda.config.ConfigEditor.hide -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.edit +import com.lambda.config.SettingEditor.hide +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.Tab import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.TargetingSettings @@ -64,7 +64,7 @@ object KillAura : Module( @Tab(GeneralTab) private val hitDelay1 by setting("Hit Delay 1", 2.0, 0.0..20.0, 1.0) { attackMode == AttackMode.Delay } @Tab(GeneralTab) private val hitDelay2 by setting("Hit Delay 2", 6.0, 0.0..20.0, 1.0) { attackMode == AttackMode.Delay } - @Tab(TargetingTab) private val targetingSettings by settingBlock(TargetingSettings.CombatSettings(this)) + @Tab(TargetingTab) private val targetingSettings by configBlock(TargetingSettings.CombatSettings(this)) val target: Entity? get() = targetingSettings.target() diff --git a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt index 2783fdfbd..d52a378ac 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.combat -import com.lambda.config.ConfigEditor.editTyped -import com.lambda.config.ConfigEditor.hideBlock +import com.lambda.config.SettingEditor.editTyped +import com.lambda.config.SettingEditor.hideBlock import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.withEdits import com.lambda.context.SafeContext diff --git a/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt b/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt index ac5de6bd6..d1a6c7e2d 100644 --- a/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt +++ b/src/main/kotlin/com/lambda/module/modules/combat/Surround.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.combat -import com.lambda.config.ConfigEditor.editTyped -import com.lambda.config.ConfigEditor.hideBlock +import com.lambda.config.SettingEditor.editTyped +import com.lambda.config.SettingEditor.hideBlock import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.withEdits import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint diff --git a/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt b/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt index f4b543dac..45218ec98 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/SettingsTestModule.kt @@ -17,6 +17,9 @@ package com.lambda.module.modules.debug +import com.lambda.config.Config +import com.lambda.config.ConfigBlock +import com.lambda.config.Group import com.lambda.config.Tab import com.lambda.config.settings.blocks.ScreenLineSettings import com.lambda.config.settings.blocks.ScreenTextSettings @@ -36,39 +39,18 @@ object SettingsTestModule : Module( private const val WorldTextTab = "World Text" private const val ScreenTextTab = "Screen Text" - @Tab(WorldLineTab) private val worldLineConfig by settingBlock(WorldLineSettings(this)) - @Tab(ScreenLineTab) private val screenLineConfig by settingBlock(ScreenLineSettings(this)) - @Tab(WorldTextTab) private val worldTextConfig by settingBlock(WorldTextSettings(this)) - @Tab(ScreenTextTab) private val textConfig by settingBlock(ScreenTextSettings(this)) + private const val TestConfigBlockTab = "Test Config Block Tab" + private const val TestConfigBlockGroup = "Test Config Block Group" + @Tab(TestConfigBlockTab) @Group(TestConfigBlockGroup) private val testConfigBlock by configBlock(TestConfigBlock(this)) + @Tab(TestConfigBlockTab) private val testValue1 by property(1) -// private val renderer = ImmediateRenderer("SettingsTestRenderer") + @Tab(WorldLineTab) private val worldLineConfig by configBlock(WorldLineSettings(this)) + @Tab(ScreenLineTab) private val screenLineConfig by configBlock(ScreenLineSettings(this)) + @Tab(WorldTextTab) private val worldTextConfig by configBlock(WorldTextSettings(this)) + @Tab(ScreenTextTab) private val textConfig by configBlock(ScreenTextSettings(this)) +} -// init { -// listen { -// renderer.tick() -// renderer.shapes { -// val startPos = lerp(mc.tickDelta, player.prevPos, player.pos).offset(Direction.NORTH, 3.0) -// -// // Render line using config -// lineGradient( -// startPos, -// lineConfig.startColor, -// startPos.offset(Direction.EAST, 3.0), -// lineConfig.endColor, -// lineConfig.lineWidth, -// lineConfig.getDashStyle() -// ) -// -// // Render text using config -// worldText( -// "Configured Text", -// startPos.add(0.0, 1.0, 0.0), -// style = textConfig.getSDFStyle() -// ) -// } -// renderer.render() -// } -// -// onDisable { renderer.close() } -// } +class TestConfigBlock(override val c: Config) : ConfigBlock { + var testValue2 by c.property(2) + val testValue3 by c.property { 3 } } diff --git a/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt b/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt index 8df26bb1e..b1201be3d 100644 --- a/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt +++ b/src/main/kotlin/com/lambda/module/modules/debug/SilentSwap.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.debug -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.withEdits import com.lambda.event.events.PlayerEvent diff --git a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt index cfdbefd70..17c8556df 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt @@ -19,8 +19,8 @@ package com.lambda.module.modules.movement import com.lambda.Lambda import com.lambda.Lambda.mc -import com.lambda.config.ConfigEditor.edit -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.edit +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.complex.Bind import com.lambda.config.settings.complex.KeybindSetting.Companion.onPress diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt index 79e6b1910..19e5317b9 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraAltitudeControl.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.movement -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.Tab import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.withEdits diff --git a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt index af3e98b20..d1906f882 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/ElytraFly.kt @@ -18,7 +18,7 @@ package com.lambda.module.modules.movement import baritone.api.pathing.goals.GoalGetToBlock -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.Group import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.withEdits diff --git a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt index de2963895..6edc7ddd9 100644 --- a/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt +++ b/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.movement -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.withEdits import com.lambda.context.SafeContext diff --git a/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt b/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt index b8d1198c3..1524503f7 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.player -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.EatConfig.Companion.reasonEating import com.lambda.config.withEdits diff --git a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt index 780f0663e..1c2a047c5 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt @@ -17,10 +17,10 @@ package com.lambda.module.modules.player -import com.lambda.config.ConfigEditor.edit -import com.lambda.config.ConfigEditor.editTyped -import com.lambda.config.ConfigEditor.hide -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.edit +import com.lambda.config.SettingEditor.editTyped +import com.lambda.config.SettingEditor.hide +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.withEdits import com.lambda.event.events.PlayerEvent diff --git a/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt b/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt index 4201e0bdc..8b66bc16e 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/InventoryTweaks.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.player -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.withEdits import com.lambda.event.events.InventoryEvent diff --git a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt index 544ffa0b1..748eeee5b 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt @@ -17,10 +17,10 @@ package com.lambda.module.modules.player -import com.lambda.config.ConfigEditor.edit -import com.lambda.config.ConfigEditor.editTyped -import com.lambda.config.ConfigEditor.hide -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.edit +import com.lambda.config.SettingEditor.editTyped +import com.lambda.config.SettingEditor.hide +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.Group import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.BreakConfig diff --git a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt index a277c773d..505f9a400 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/RotationLock.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.player -import com.lambda.config.ConfigEditor.edit -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.edit +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.withEdits import com.lambda.event.events.TickEvent diff --git a/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt b/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt index e72162dc7..c56fa9586 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/StackReplenish.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.player -import com.lambda.config.ConfigEditor.hide -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.hide +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.withEdits import com.lambda.context.SafeContext diff --git a/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt b/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt index 52b94e364..32a6dc0e7 100644 --- a/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt +++ b/src/main/kotlin/com/lambda/module/modules/player/ToolSaver.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.player -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.withEdits import com.lambda.event.events.ContainerEvent diff --git a/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt b/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt index c8a362e2c..ddc79598c 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/BlockOutline.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.render -import com.lambda.config.ConfigEditor.forEachSetting -import com.lambda.config.ConfigEditor.hide +import com.lambda.config.SettingEditor.forEachSetting +import com.lambda.config.SettingEditor.hide import com.lambda.config.Group import com.lambda.config.settings.blocks.OutlineSettings import com.lambda.config.settings.blocks.WorldLineSettings @@ -58,7 +58,7 @@ object BlockOutline : Module( @Group(BoxFillGroup) private val fillColor by setting("Fill Color", Color(255, 255, 255, 20)) { fill && mode == Mode.Boxes } @Group(BoxOutlineGroup) private val boxOutline by setting("Box Outline", true) { mode == Mode.Boxes } @Group(BoxOutlineGroup) private val boxOutlineColor by setting("Box Outline Color", Color(255, 255, 255, 120)) { mode == Mode.Boxes && boxOutline } - @Group(BoxOutlineGroup) private val lineConfig by settingBlock(WorldLineSettings(this)) + @Group(BoxOutlineGroup) private val lineConfig by configBlock(WorldLineSettings(this)) .withEdits { hide(::startColor, ::endColor) forEachSetting { @@ -67,7 +67,7 @@ object BlockOutline : Module( } @Group(OutlineGroup) private val outlineColor by setting("Outline Color", boxOutlineColor) { mode == Mode.Outline } - @Group(OutlineGroup) private val outlineStyle by settingBlock(OutlineSettings(this)) + @Group(OutlineGroup) private val outlineStyle by configBlock(OutlineSettings(this)) .withEdits { forEachSetting { visibility { old -> { old() && mode == Mode.Outline } } diff --git a/src/main/kotlin/com/lambda/module/modules/render/ESP.kt b/src/main/kotlin/com/lambda/module/modules/render/ESP.kt index 11ba6255c..0f6381fd7 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/ESP.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/ESP.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.render -import com.lambda.config.ConfigEditor.forEachSetting -import com.lambda.config.ConfigEditor.hide +import com.lambda.config.SettingEditor.forEachSetting +import com.lambda.config.SettingEditor.hide import com.lambda.config.Group import com.lambda.config.Tab import com.lambda.config.settings.blocks.EntityColorSettings @@ -67,7 +67,7 @@ object ESP : Module( @Tab(GeneralTab) private val depthTest by setting("Depth Test", false, "Blend ESP renders into the world") //Shader Outline - @Tab(GeneralTab) private val outlineStyle by settingBlock(OutlineSettings(this)) + @Tab(GeneralTab) private val outlineStyle by configBlock(OutlineSettings(this)) .withEdits { forEachSetting { visibility { old -> { old() && mode == EspMode.Shader } } } } //Box @@ -77,14 +77,14 @@ object ESP : Module( @Tab(GeneralTab) @Group(BoxOutlineGroup) private var drawOutline: Boolean by setting("Box Outline", true, "Draw box outlines") { mode == EspMode.Box } .onValueChange { _, to -> if (!to && !drawFilled) drawFilled = true } @Tab(GeneralTab) @Group(BoxOutlineGroup) private val outlineAlpha by setting("Outline Alpha", 0.8, 0.0..1.0, 0.05) { mode == EspMode.Box && drawOutline } - @Tab(GeneralTab) @Group(BoxOutlineGroup) private val boxOutlineSettings by settingBlock(WorldLineSettings(this)) + @Tab(GeneralTab) @Group(BoxOutlineGroup) private val boxOutlineSettings by configBlock(WorldLineSettings(this)) .withEdits { forEachSetting { visibility { old -> { old() && mode == EspMode.Box && drawOutline } } } hide(::startColor, ::endColor) } - @Tab(EntitiesTab) private val entitySettings by settingBlock(EntitySelectionSettings(this)) - @Tab(ColorsTab) private val entityColors by settingBlock(EntityColorSettings(this)) + @Tab(EntitiesTab) private val entitySettings by configBlock(EntitySelectionSettings(this)) + @Tab(ColorsTab) private val entityColors by configBlock(EntityColorSettings(this)) init { immediateRenderer("EntityESP Immediate Renderer", depthTest = { depthTest }) { diff --git a/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt b/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt index a1af6172d..aa39a8b91 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Freecam.kt @@ -18,8 +18,8 @@ package com.lambda.module.modules.render import com.lambda.Lambda.mc -import com.lambda.config.ConfigEditor.edit -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.edit +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.withEdits import com.lambda.context.SafeContext diff --git a/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt b/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt index 1aaf8169e..dcd602154 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/LightLevels.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.render -import com.lambda.config.ConfigEditor.forEachSetting -import com.lambda.config.ConfigEditor.hide +import com.lambda.config.SettingEditor.forEachSetting +import com.lambda.config.SettingEditor.hide import com.lambda.config.Group import com.lambda.config.settings.blocks.WorldLineSettings import com.lambda.config.withEdits @@ -62,7 +62,7 @@ object LightLevels : Module( @Group(FillGroup) private val fill by setting("Fill", false) { renderMode == RenderMode.Square }.onValueChange(::refreshChunkedRenderer) @Group(FillGroup) private val fillAlpha by setting("Fill Alpha", 0.2, 0.0..1.0, 0.01) { renderMode == RenderMode.Square && fill }.onValueChange(::refreshChunkedRenderer) @Group(LineGroup) private val outline by setting("Outline", true) { renderMode == RenderMode.Square }.onValueChange(::refreshChunkedRenderer) - @Group(LineGroup) private val worldLineConfig by settingBlock(WorldLineSettings(this)) + @Group(LineGroup) private val worldLineConfig by configBlock(WorldLineSettings(this)) .withEdits { hide(::startColor, ::endColor) forEachSetting { diff --git a/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt b/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt index 7732031e4..9d94f16f1 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Nametags.kt @@ -18,8 +18,8 @@ package com.lambda.module.modules.render import com.lambda.Lambda.mc -import com.lambda.config.ConfigEditor.edit -import com.lambda.config.ConfigEditor.hide +import com.lambda.config.SettingEditor.edit +import com.lambda.config.SettingEditor.hide import com.lambda.config.Group import com.lambda.config.Tab import com.lambda.config.settings.blocks.EntitySelectionSettings @@ -75,18 +75,18 @@ object Nametags : Module( @Tab(GeneralTab) private val itemCount by setting("Item Count", true) @Tab(GeneralTab) private val durabilityMode by setting("Durability Mode", DurabilityMode.Text) { gear } - @Tab(EntityTab) private val entitySelectionSettings by settingBlock(EntitySelectionSettings(this)) + @Tab(EntityTab) private val entitySelectionSettings by configBlock(EntitySelectionSettings(this)) .withEdits { hide(::blockEntities) } private const val FriendGroup = "Friends" private const val OtherGroup = "Others" - @Tab(TextTab) @Group(FriendGroup) private val friendTextConfig by settingBlock(ScreenTextSettings(this)) + @Tab(TextTab) @Group(FriendGroup) private val friendTextConfig by configBlock(ScreenTextSettings(this)) .withEdits { hide(::sizeSetting) ::textColor.edit { defaultValue(Color(0, 255, 255, 255)) } } - @Tab(TextTab) @Group(OtherGroup) private val otherTextConfig by settingBlock(ScreenTextSettings(this)) + @Tab(TextTab) @Group(OtherGroup) private val otherTextConfig by configBlock(ScreenTextSettings(this)) .withEdits { hide(::sizeSetting) } @Tab(BackgroundTab) private val background by setting("Background", true) diff --git a/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt b/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt index 0211aaede..9c97cc621 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/NoRender.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.render -import com.lambda.config.ConfigEditor.editTyped +import com.lambda.config.SettingEditor.editTyped import com.lambda.config.Tab import com.lambda.config.settings.blocks.EntitySelectionSettings import com.lambda.config.withEdits @@ -73,7 +73,7 @@ object NoRender : Module( // RenderLayer.getArmorEntityGlint(), RenderLayer.getGlint(), RenderLayer.getGlintTranslucent(), RenderLayer.getEntityGlint() // @JvmStatic val noEnchantmentGlint by setting("No Enchantment Glint", false).group(Group.Entity) // @JvmStatic val noDeadEntities by setting("No Dead Entities", false).group(Group.Entity) - @Tab(EntityTab) private val entitySettings by settingBlock(EntitySelectionSettings(this)) + @Tab(EntityTab) private val entitySettings by configBlock(EntitySelectionSettings(this)) .withEdits { editTyped(::playerEntities, ::mobEntities, ::bossEntities) { defaultValue(mutableSetOf()) } } diff --git a/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt b/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt index 79ec12f02..25a195865 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/RadiusESP.kt @@ -17,8 +17,8 @@ package com.lambda.module.modules.render -import com.lambda.config.ConfigEditor.forEachSetting -import com.lambda.config.ConfigEditor.hide +import com.lambda.config.SettingEditor.forEachSetting +import com.lambda.config.SettingEditor.hide import com.lambda.config.Group import com.lambda.config.settings.blocks.WorldLineSettings import com.lambda.config.withEdits @@ -56,7 +56,7 @@ object RadiusESP : Module( @Group(RenderGroup) private var outline: Boolean by setting("Box Outline", true).onValueChange(::rebuildMesh) .onValueChange { _, to -> if (!to) fill = true } @Group(RenderGroup) private val fillAlpha by setting("Fill Alpha", 0.1, 0.0..1.0, 0.01).onValueChange(::rebuildMesh) - @Group(RenderGroup, OutlineGroup) private val worldLineConfig by settingBlock(WorldLineSettings(this)) + @Group(RenderGroup, OutlineGroup) private val worldLineConfig by configBlock(WorldLineSettings(this)) .withEdits { hide(::startColor, ::endColor) forEachSetting { diff --git a/src/main/kotlin/com/lambda/module/modules/render/Search.kt b/src/main/kotlin/com/lambda/module/modules/render/Search.kt index d71a84056..10378d419 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Search.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Search.kt @@ -17,9 +17,9 @@ package com.lambda.module.modules.render -import com.lambda.config.ConfigEditor.editTyped -import com.lambda.config.ConfigEditor.forEachSetting -import com.lambda.config.ConfigEditor.hide +import com.lambda.config.SettingEditor.editTyped +import com.lambda.config.SettingEditor.forEachSetting +import com.lambda.config.SettingEditor.hide import com.lambda.config.Group import com.lambda.config.settings.blocks.ScreenLineSettings import com.lambda.config.settings.blocks.WorldLineSettings @@ -87,7 +87,7 @@ object Search : Module( @Group(OutlineGroup) private val entityOutlineColor by setting("Entity Outline Color", Color(100, 150, 255, 128)) { outline && !useNaturalColor }.onValueChange(::rebuildMesh) @Group(OutlineGroup) private val blockOutlineMode by setting("Block Outline Mode", DirectionMask.OutlineMode.And, "Outline mode") { outline }.onValueChange(::rebuildMesh) - @Group(OutlineGroup) private val outlineConfig by settingBlock(WorldLineSettings(this)) + @Group(OutlineGroup) private val outlineConfig by configBlock(WorldLineSettings(this)) .withEdits { hide(::startColor, ::endColor) forEachSetting { @@ -96,7 +96,7 @@ object Search : Module( } } @Group(TracersGroup) private val tracers by setting("Tracers", true, "Draw a line from your cursor to the highlighted position") - @Group(TracersGroup) private val tracerConfig by settingBlock(ScreenLineSettings(this)) + @Group(TracersGroup) private val tracerConfig by configBlock(ScreenLineSettings(this)) .withEdits { forEachSetting { visibility { old -> { old() && tracers } } } editTyped(::startColor, ::endColor) { diff --git a/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt b/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt index 300d4be98..d68038cde 100644 --- a/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt +++ b/src/main/kotlin/com/lambda/module/modules/render/Tracers.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.render -import com.lambda.config.ConfigEditor.hide +import com.lambda.config.SettingEditor.hide import com.lambda.config.Group import com.lambda.config.Tab import com.lambda.config.settings.blocks.EntityColorSettings @@ -54,14 +54,14 @@ object Tracers : Module( private const val FriendsLineGroup = "Friends" private const val OthersLineGroup = "Others" - @Tab(GeneralTab) @Group(FriendsLineGroup) private val friendLineConfig by settingBlock(ScreenLineSettings(this)) + @Tab(GeneralTab) @Group(FriendsLineGroup) private val friendLineConfig by configBlock(ScreenLineSettings(this)) .withEdits { hide(::startColor, ::endColor) } - @Tab(GeneralTab) @Group(OthersLineGroup) private val otherLineConfig by settingBlock(ScreenLineSettings(this)) + @Tab(GeneralTab) @Group(OthersLineGroup) private val otherLineConfig by configBlock(ScreenLineSettings(this)) .withEdits { hide(::startColor, ::endColor) } - @Tab(EntityTab) private val entitySettings by settingBlock(EntitySelectionSettings(this)) + @Tab(EntityTab) private val entitySettings by configBlock(EntitySelectionSettings(this)) .withEdits { hide(::self, ::blockEntities) } - @Tab(ColorsTab) private val entityColors by settingBlock(EntityColorSettings(this)) + @Tab(ColorsTab) private val entityColors by configBlock(EntityColorSettings(this)) init { immediateRenderer("Tracers Immediate Renderer") { diff --git a/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt b/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt index b6c49b090..74fb9815b 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AirPlace.kt @@ -18,7 +18,7 @@ package com.lambda.module.modules.world import com.lambda.Lambda.mc -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.Group import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.complex.Bind diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt index 8e2547d3d..a25281f6c 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoPortal.kt @@ -18,10 +18,10 @@ package com.lambda.module.modules.world import baritone.api.pathing.goals.GoalBlock -import com.lambda.config.ConfigEditor.edit -import com.lambda.config.ConfigEditor.forEachSetting -import com.lambda.config.ConfigEditor.hide -import com.lambda.config.ConfigEditor.hideBlock +import com.lambda.config.SettingEditor.edit +import com.lambda.config.SettingEditor.forEachSetting +import com.lambda.config.SettingEditor.hide +import com.lambda.config.SettingEditor.hideBlock import com.lambda.config.Group import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.WorldLineSettings @@ -122,7 +122,7 @@ object AutoPortal : Module( @Group(RenderGroup) private val interpolate by setting("Interpolate", true, "Interpolates the portal renders from position to position") { renders } @Group(RenderGroup) private val depthTest by setting("Depth Test", false) { renders } @Group(RenderGroup, FillGroup) private val fillAlpha by setting("Fill Alpha", 0.3, 0.0..1.0, 0.01) { renders } - @Group(RenderGroup, OutlineGroup) private val outlineConfig by settingBlock(WorldLineSettings(this)) + @Group(RenderGroup, OutlineGroup) private val outlineConfig by configBlock(WorldLineSettings(this)) .withEdits { hide(::startColor, ::endColor) forEachSetting { diff --git a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt index 020c0262d..a3e0a597d 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/AutoVillagerCycle.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.world -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.Group import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.complex.Bind diff --git a/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt b/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt index 4f4771fb1..66a799d24 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/HighwayTools.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.world -import com.lambda.config.ConfigEditor.editTyped +import com.lambda.config.SettingEditor.editTyped import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.withEdits import com.lambda.interaction.BaritoneHandler diff --git a/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt b/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt index 39be4242b..2c45f3837 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Nuker.kt @@ -17,7 +17,7 @@ package com.lambda.module.modules.world -import com.lambda.config.ConfigEditor.editTyped +import com.lambda.config.SettingEditor.editTyped import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.withEdits import com.lambda.context.SafeContext diff --git a/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt b/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt index 097d113ec..85b63843c 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/Scaffold.kt @@ -17,10 +17,10 @@ package com.lambda.module.modules.world -import com.lambda.config.ConfigEditor.edit -import com.lambda.config.ConfigEditor.editTyped -import com.lambda.config.ConfigEditor.hide -import com.lambda.config.ConfigEditor.hideAllBlocksExcept +import com.lambda.config.SettingEditor.edit +import com.lambda.config.SettingEditor.editTyped +import com.lambda.config.SettingEditor.hide +import com.lambda.config.SettingEditor.hideAllBlocksExcept import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.InteractConfig import com.lambda.config.settings.complex.Bind diff --git a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt index b6b0a1f87..53422611b 100644 --- a/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt +++ b/src/main/kotlin/com/lambda/module/modules/world/StashMover.kt @@ -19,10 +19,10 @@ package com.lambda.module.modules.world import baritone.api.pathing.goals.GoalBlock import com.lambda.Lambda.mc -import com.lambda.config.ConfigEditor.edit -import com.lambda.config.ConfigEditor.editTyped -import com.lambda.config.ConfigEditor.hide -import com.lambda.config.ConfigEditor.hideBlock +import com.lambda.config.SettingEditor.edit +import com.lambda.config.SettingEditor.editTyped +import com.lambda.config.SettingEditor.hide +import com.lambda.config.SettingEditor.hideBlock import com.lambda.config.Tab import com.lambda.config.automation.AutomationConfig.Companion.setDefaultAutomationConfig import com.lambda.config.settings.blocks.InteractConfig