From 9f3d1a23907d0596a31ab479a5029566bceff6f3 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Mon, 5 Aug 2019 11:01:18 -0400 Subject: [PATCH] Fix Checkstyle, again --- .../client/ClientPlaySessionHandler.java | 125 +++++++++--------- 1 file changed, 63 insertions(+), 62 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java index 103389abb..32a67b755 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java @@ -157,73 +157,12 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { boolean isCommand = !packet.isAssumeCommand() && packet.getCommand().startsWith("/"); if (isCommand) { - return this.handleTabCompleteForCommand(packet); + return this.handleCommandTabComplete(packet); } else { return this.handleRegularTabComplete(packet); } } - private boolean handleTabCompleteForCommand(TabCompleteRequest packet) { - // In 1.13+, we need to do additional work for the richer suggestions available. - String command = packet.getCommand().substring(1); - int spacePos = command.indexOf(' '); - if (spacePos == -1) { - spacePos = command.length(); - } - - String commandLabel = command.substring(0, spacePos); - if (!server.getCommandManager().hasCommand(commandLabel)) { - if (player.getProtocolVersion().compareTo(MINECRAFT_1_13) < 0) { - // Outstanding tab completes are recorded for use with 1.12 clients and below to provide - // additional tab completion support. - outstandingTabComplete = packet; - } - return false; - } - - List suggestions = server.getCommandManager().offerSuggestions(player, command); - if (suggestions.isEmpty()) { - return false; - } - - List offers = new ArrayList<>(); - int longestLength = 0; - for (String suggestion : suggestions) { - offers.add(new Offer(suggestion)); - if (suggestion.length() > longestLength) { - longestLength = suggestion.length(); - } - } - - TabCompleteResponse resp = new TabCompleteResponse(); - resp.setTransactionId(packet.getTransactionId()); - - int startPos = packet.getCommand().lastIndexOf(' ') + 1; - int length; - if (startPos == 0) { - startPos = packet.getCommand().length() + 1; - length = longestLength; - } else { - length = packet.getCommand().length() - startPos; - } - - resp.setStart(startPos); - resp.setLength(length); - resp.getOffers().addAll(offers); - - player.getMinecraftConnection().write(resp); - return true; - } - - private boolean handleRegularTabComplete(TabCompleteRequest packet) { - if (player.getProtocolVersion().compareTo(MINECRAFT_1_13) < 0) { - // Outstanding tab completes are recorded for use with 1.12 clients and below to provide - // additional tab completion support. - outstandingTabComplete = packet; - } - return false; - } - @Override public boolean handle(PluginMessage packet) { VelocityServerConnection serverConn = player.getConnectedServer(); @@ -422,6 +361,68 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { return serverBossBars; } + + private boolean handleCommandTabComplete(TabCompleteRequest packet) { + // In 1.13+, we need to do additional work for the richer suggestions available. + String command = packet.getCommand().substring(1); + int spacePos = command.indexOf(' '); + if (spacePos == -1) { + spacePos = command.length(); + } + + String commandLabel = command.substring(0, spacePos); + if (!server.getCommandManager().hasCommand(commandLabel)) { + if (player.getProtocolVersion().compareTo(MINECRAFT_1_13) < 0) { + // Outstanding tab completes are recorded for use with 1.12 clients and below to provide + // additional tab completion support. + outstandingTabComplete = packet; + } + return false; + } + + List suggestions = server.getCommandManager().offerSuggestions(player, command); + if (suggestions.isEmpty()) { + return false; + } + + List offers = new ArrayList<>(); + int longestLength = 0; + for (String suggestion : suggestions) { + offers.add(new Offer(suggestion)); + if (suggestion.length() > longestLength) { + longestLength = suggestion.length(); + } + } + + TabCompleteResponse resp = new TabCompleteResponse(); + resp.setTransactionId(packet.getTransactionId()); + + int startPos = packet.getCommand().lastIndexOf(' ') + 1; + int length; + if (startPos == 0) { + startPos = packet.getCommand().length() + 1; + length = longestLength; + } else { + length = packet.getCommand().length() - startPos; + } + + resp.setStart(startPos); + resp.setLength(length); + resp.getOffers().addAll(offers); + + player.getMinecraftConnection().write(resp); + return true; + } + + private boolean handleRegularTabComplete(TabCompleteRequest packet) { + if (player.getProtocolVersion().compareTo(MINECRAFT_1_13) < 0) { + // Outstanding tab completes are recorded for use with 1.12 clients and below to provide + // additional tab completion support. + outstandingTabComplete = packet; + } + return false; + } + /** * Handles additional tab complete. *