From 2361f587dabf70cac333308d90aa09df0e71fced Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 7 Aug 2023 02:39:27 +0200 Subject: [PATCH] Don't send softEnumPackets when command suggestions are false (#4037) * Don't send SoftEnums if command suggestions are set to false, add system property to not send team suggestions * address review --- .../java/org/geysermc/geyser/scoreboard/Scoreboard.java | 6 ++++-- .../java/org/geysermc/geyser/session/GeyserSession.java | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/scoreboard/Scoreboard.java b/core/src/main/java/org/geysermc/geyser/scoreboard/Scoreboard.java index 5a70fddf5..c49e8afc4 100644 --- a/core/src/main/java/org/geysermc/geyser/scoreboard/Scoreboard.java +++ b/core/src/main/java/org/geysermc/geyser/scoreboard/Scoreboard.java @@ -52,6 +52,7 @@ import static org.geysermc.geyser.scoreboard.UpdateType.*; public final class Scoreboard { private static final boolean SHOW_SCOREBOARD_LOGS = Boolean.parseBoolean(System.getProperty("Geyser.ShowScoreboardLogs", "true")); + private static final boolean ADD_TEAM_SUGGESTIONS = Boolean.parseBoolean(System.getProperty("Geyser.AddTeamSuggestions", "true")); private final GeyserSession session; private final GeyserLogger logger; @@ -150,8 +151,9 @@ public final class Scoreboard { teams.put(teamName, team); // Update command parameters - is safe to send even if the command enum doesn't exist on the client (as of 1.19.51) - session.addCommandEnum("Geyser_Teams", team.getId()); - + if (ADD_TEAM_SUGGESTIONS) { + session.addCommandEnum("Geyser_Teams", team.getId()); + } return team; } diff --git a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java index 8960fb626..721fb0dfe 100644 --- a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java +++ b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java @@ -2008,6 +2008,10 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource { } private void softEnumPacket(String name, SoftEnumUpdateType type, String enums) { + // There is no need to send command enums if command suggestions are disabled + if (!this.geyser.getConfig().isCommandSuggestions()) { + return; + } UpdateSoftEnumPacket packet = new UpdateSoftEnumPacket(); packet.setType(type); packet.setSoftEnum(new CommandEnumData(name, Collections.singletonMap(enums, Collections.emptySet()), true));