From 1f7d14f6d1d33bfd6395bfc9b39da616e00e4542 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sun, 27 Jun 2021 21:18:52 -0400 Subject: [PATCH] Checkstyle and friends --- config/checkstyle/checkstyle.xml | 2 +- .../proxy/command/builtin/ServerCommand.java | 1 - .../connection/client/ConnectedPlayer.java | 6 +++++ .../proxy/util/ClosestLocaleMatcher.java | 22 +++++++++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 08a2b3736..eaf630f2a 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -42,7 +42,7 @@ - + diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java index e345794e4..0514c5213 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/builtin/ServerCommand.java @@ -118,7 +118,6 @@ public class ServerCommand implements SimpleCommand { playersTextComponent = Component.translatable("velocity.command.server-tooltip-players-online"); } playersTextComponent = playersTextComponent.args(Component.text(connectedPlayers)); - String playersText = server.getPlayersConnected().size() + " player(s) online"; if (serverInfo.getName().equals(currentPlayerServer)) { serverTextComponent = serverTextComponent.color(NamedTextColor.GREEN) .hoverEvent( diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index 8384f23ff..6a097a493 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -268,6 +268,12 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { return connection.getProtocolVersion(); } + /** + * Translates the message in the user's locale. + * + * @param message the message to translate + * @return the translated message + */ public Component translateMessage(Component message) { Locale locale = ClosestLocaleMatcher.INSTANCE .lookupClosest(this.settings == null ? Locale.getDefault() : this.settings.getLocale()); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/ClosestLocaleMatcher.java b/proxy/src/main/java/com/velocitypowered/proxy/util/ClosestLocaleMatcher.java index da3bc4e01..f0381a150 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/util/ClosestLocaleMatcher.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/util/ClosestLocaleMatcher.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2018 Velocity Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package com.velocitypowered.proxy.util; import com.github.benmanes.caffeine.cache.Caffeine; @@ -21,6 +38,11 @@ public class ClosestLocaleMatcher { }); } + /** + * Registers a known locale. + * + * @param locale locale to register + */ public void registerKnown(final Locale locale) { if (locale.getLanguage().equals(new Locale("zh").getLanguage())) { return;