feat(mod): %policy command and clickgui lock

This commit is contained in:
loki5512344 2026-09-30 12:24:43 +02:00
parent 33cff90c82
commit fdc239db88
Signed by: boba
GPG key ID: 253067914055423B
2 changed files with 43 additions and 2 deletions

View file

@ -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;
}
}

View file

@ -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()
));