From fdc239db8849630e4f89d7bd76213996505aef88 Mon Sep 17 00:00:00 2001 From: loki5512344 Date: Wed, 30 Sep 2026 12:24:43 +0200 Subject: [PATCH] feat(mod): %policy command and clickgui lock --- .../command/impl/platform/PolicyCommand.java | 38 +++++++++++++++++++ .../screen/modules/ModulesMenuResolver.java | 7 +++- 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 mod/src/main/java/dev/loki/lovisual/features/command/impl/platform/PolicyCommand.java diff --git a/mod/src/main/java/dev/loki/lovisual/features/command/impl/platform/PolicyCommand.java b/mod/src/main/java/dev/loki/lovisual/features/command/impl/platform/PolicyCommand.java new file mode 100644 index 0000000..f1c6bd0 --- /dev/null +++ b/mod/src/main/java/dev/loki/lovisual/features/command/impl/platform/PolicyCommand.java @@ -0,0 +1,38 @@ +package dev.loki.lovisual.features.command.impl.platform; + +import dev.loki.lovisual.features.command.core.CommandContext; +import dev.loki.lovisual.features.command.core.CommandInfo; +import dev.loki.lovisual.features.command.util.ClientCommand; +import dev.loki.lovisual.features.command.util.CommandOutput; +import dev.loki.lovisual.features.platform.serverpolicy.ServerPolicy; +import dev.loki.lovisual.features.platform.serverpolicy.ServerPolicyState; + +/** + * {@code %policy} — shows what the proxy currently demands of this client: + * nothing (not on a LoVisual proxy), or the active mode, denied modules, + * backend server and reason received on the {@code lovisual:policy} channel. + */ +@CommandInfo( + id = "policy", + usage = "%policy", + descriptionKey = "command.policy.description" +) +public final class PolicyCommand implements ClientCommand { + + @Override + public boolean execute(CommandContext ctx) { + ServerPolicy policy = ServerPolicyState.current(); + if (policy == null) { + CommandOutput.send("No server policy: not connected to a LoVisual proxy, or none configured."); + return true; + } + StringBuilder line = new StringBuilder("Server policy: ").append(policy.mode()); + line.append(policy.deny().isEmpty() + ? ", no denied modules" + : ", denies: " + String.join(", ", policy.deny())); + line.append(", server=").append(policy.server().isEmpty() ? "-" : policy.server()); + line.append(", reason=").append(policy.reason().isEmpty() ? "-" : policy.reason()); + CommandOutput.send(line.toString()); + return true; + } +} diff --git a/mod/src/main/java/dev/loki/lovisual/features/gui/clickgui/layout/screen/modules/ModulesMenuResolver.java b/mod/src/main/java/dev/loki/lovisual/features/gui/clickgui/layout/screen/modules/ModulesMenuResolver.java index 0f4f6bb..60ebccf 100644 --- a/mod/src/main/java/dev/loki/lovisual/features/gui/clickgui/layout/screen/modules/ModulesMenuResolver.java +++ b/mod/src/main/java/dev/loki/lovisual/features/gui/clickgui/layout/screen/modules/ModulesMenuResolver.java @@ -5,6 +5,8 @@ import dev.loki.lovisual.features.gui.clickgui.layout.screen.settings.implement. import dev.loki.lovisual.features.gui.clickgui.settings.core.Setting; import dev.loki.lovisual.features.module.core.Module; import dev.loki.lovisual.features.module.core.ModuleManager; +import dev.loki.lovisual.features.platform.serverpolicy.ServerPolicyState; +import net.minecraft.client.resources.language.I18n; import java.util.ArrayList; import java.util.Comparator; @@ -24,14 +26,15 @@ public enum ModulesMenuResolver { String bind = module.getKeyBindSetting() != null && module.getKeyBindSetting().getValue() != null ? module.getKeyBindSetting().getValue().get() : ""; + boolean locked = ServerPolicyState.isLocked(module.name()); out.add(new ModuleComponent.CardEntry( module.name(), module.getDisplayName(), - "", + locked ? I18n.get("lovisual.policy.locked", ServerPolicyState.reason()) : "", bind == null ? "" : bind, !module.getSettings().isEmpty(), module.isEnabled(), - true, + !locked, module.isShownInModuleList(), module.getAliases() ));