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
This commit is contained in:
chris 2023-08-07 02:39:27 +02:00 committed by GitHub
parent b1f04a9012
commit 2361f587da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

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

View file

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