fix: commandspy on non-chipmunk servers

This commit is contained in:
Chayapak 2024-11-02 15:06:43 +07:00
parent 22c736c67d
commit 0fcc68c7a2
Signed by: ChomeNS
SSH key fingerprint: SHA256:0YoxhdyXsgbc0nfeB2N6FYE60mxMU7DS4uCUMaw2mvA

View file

@ -19,12 +19,14 @@ public class CommandSpyPlugin extends ChatPlugin.Listener {
private static final Style ENABLED_STYLE = Style.style(NamedTextColor.YELLOW); private static final Style ENABLED_STYLE = Style.style(NamedTextColor.YELLOW);
private static final Style DISABLED_STYLE = Style.style(NamedTextColor.AQUA); private static final Style DISABLED_STYLE = Style.style(NamedTextColor.AQUA);
private static final Component COMMANDSPY_ENABLED_COMPONENT = Component private static final Component COMMANDSPY_ENABLED_COMPONENT = Component.text("Successfully enabled CommandSpy");
private static final Component COMMANDSPY_DISABLED_COMPONENT = Component.text("Successfully disabled CommandSpy");
private static final Component COMMANDSPY_ENABLED_COMPONENT_CHIPMUNK = Component
.empty() .empty()
.append(Component.text("Successfully ")) .append(Component.text("Successfully "))
.append(Component.text("enabled")) .append(Component.text("enabled"))
.append(Component.text(" CommandSpy")); .append(Component.text(" CommandSpy"));
private static final Component COMMANDSPY_DISABLED_COMPONENT = Component private static final Component COMMANDSPY_DISABLED_COMPONENT_CHIPMUNK = Component
.empty() .empty()
.append(Component.text("Successfully ")) .append(Component.text("Successfully "))
.append(Component.text("disabled")) .append(Component.text("disabled"))
@ -42,8 +44,8 @@ public class CommandSpyPlugin extends ChatPlugin.Listener {
public void systemMessageReceived (Component component, boolean overlay) { public void systemMessageReceived (Component component, boolean overlay) {
if (overlay || !(component instanceof final TextComponent t_component)) return; if (overlay || !(component instanceof final TextComponent t_component)) return;
if (component.equals(COMMANDSPY_ENABLED_COMPONENT)) { this.enabled = true; return; } if (component.equals(COMMANDSPY_ENABLED_COMPONENT) || component.equals(COMMANDSPY_ENABLED_COMPONENT_CHIPMUNK)) { this.enabled = true; return; }
if (component.equals(COMMANDSPY_DISABLED_COMPONENT)) { this.enabled = false; return; } if (component.equals(COMMANDSPY_DISABLED_COMPONENT) || component.equals(COMMANDSPY_DISABLED_COMPONENT_CHIPMUNK)) { this.enabled = false; return; }
final boolean enabled = component.style().equals(ENABLED_STYLE); final boolean enabled = component.style().equals(ENABLED_STYLE);
if (!enabled && !component.style().equals(DISABLED_STYLE)) return; if (!enabled && !component.style().equals(DISABLED_STYLE)) return;