3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-16 21:10:30 +01:00

Localize the dump command

Dieser Commit ist enthalten in:
Andrew Steinborn 2021-05-09 04:22:42 -04:00
Ursprung cdc9ebf72d
Commit 1e8454c76a
5 geänderte Dateien mit 38 neuen und 52 gelöschten Zeilen

Datei anzeigen

@ -17,6 +17,7 @@
package com.velocitypowered.proxy.command.builtin;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@ -312,7 +313,7 @@ public class VelocityCommand implements SimpleCommand {
Component.text(description.authors().get(0))));
} else {
hoverText.append(
Component.translatable("velocity.command.plugin-tooltip-author",
Component.translatable("velocity.command.plugin-tooltip-authors",
Component.text(String.join(", ", description.authors()))
)
);
@ -375,7 +376,7 @@ public class VelocityCommand implements SimpleCommand {
dump.add("config", proxyConfig);
dump.add("plugins", InformationUtils.collectPluginInfo(server));
source.sendMessage(Component.text().content("Uploading gathered information...").build());
source.sendMessage(Component.translatable("velocity.command.dump-uploading"));
AsyncHttpClient httpClient = ((VelocityServer) server).getAsyncHttpClient();
BoundRequestBuilder request =
@ -391,12 +392,8 @@ public class VelocityCommand implements SimpleCommand {
try {
Response response = future.get();
if (response.getStatusCode() != 200) {
source.sendMessage(Component.text()
.content("An error occurred while communicating with the Velocity servers. "
+ "The servers may be temporarily unavailable or there is an issue "
+ "with your network settings. You can find more information in the "
+ "log or console of your Velocity server.")
.color(NamedTextColor.RED).build());
source.sendMessage(Component.translatable("velocity.command.dump-send-error",
NamedTextColor.RED));
logger.error("Invalid status code while POST-ing Velocity dump: "
+ response.getStatusCode());
logger.error("Headers: \n--------------BEGIN HEADERS--------------\n"
@ -411,55 +408,28 @@ public class VelocityCommand implements SimpleCommand {
}
String url = "https://dump.velocitypowered.com/"
+ key.get("key").getAsString() + ".json";
source.sendMessage(Component.text()
.content("Created an anonymised report containing useful information about "
+ "this proxy. If a developer requested it, you may share the "
+ "following link with them:")
source.sendMessage(Component.translatable("velocity.command.dump-success")
.append(Component.newline())
.append(Component.text(">> " + url)
.color(NamedTextColor.GREEN)
.clickEvent(ClickEvent.openUrl(url)))
.append(Component.newline())
.append(Component.text("Note: This link is only valid for a few days")
.color(NamedTextColor.GRAY)
).build());
} catch (InterruptedException e) {
source.sendMessage(Component.text()
.content("Could not complete the request, the command was interrupted."
+ "Please refer to the proxy-log or console for more information.")
.color(NamedTextColor.RED).build());
logger.error("Failed to complete dump command, "
+ "the executor was interrupted: " + e.getMessage());
e.printStackTrace();
} catch (ExecutionException e) {
TextComponent.Builder message = Component.text()
.content("An error occurred while attempting to upload the gathered "
+ "information to the Velocity servers.")
.append(Component.newline())
.color(NamedTextColor.RED);
if (e.getCause() instanceof UnknownHostException
|| e.getCause() instanceof ConnectException) {
message.append(Component.text(
"Likely cause: Invalid system DNS settings or no internet connection"));
}
source.sendMessage(message
.append(Component.newline()
.append(Component.text(
"Error details can be found in the proxy log / console"))
).build());
logger.error("Failed to complete dump command, "
+ "the executor encountered an Exception: " + e.getCause().getMessage());
e.getCause().printStackTrace();
.append(Component.translatable("velocity.command.dump-will-expire",
NamedTextColor.GRAY)));
} catch (JsonParseException e) {
source.sendMessage(Component.text()
.content("An error occurred on the Velocity servers and the dump could not "
+ "be completed. Please contact the Velocity staff about this problem. "
+ "If you do, provide the details about this error from the Velocity "
+ "console or server log.")
.color(NamedTextColor.RED).build());
source.sendMessage(Component.translatable("velocity.command.dump-server-error"));
logger.error("Invalid response from the Velocity servers: " + e.getMessage());
e.printStackTrace();
} catch (Exception e) {
Component message = Component.translatable("velocity.command.dump-send-error")
.append(Component.newline())
.color(NamedTextColor.RED);
if (e.getCause() instanceof UnknownHostException
|| e.getCause() instanceof ConnectException) {
message = message.append(Component.translatable("velocity.command.dump-offline"));
}
source.sendMessage(message);
logger.error("Failed to complete dump command", Throwables.getRootCause(e));
}
}, MoreExecutors.directExecutor());
}

Datei anzeigen

@ -58,4 +58,11 @@ velocity.command.no-plugins=There are no plugins currently installed.
velocity.command.plugins-list=Plugins: {0}
velocity.command.plugin-tooltip-website=Website: {0}
velocity.command.plugin-tooltip-author=Author: {0}
velocity.command.plugin-tooltip-authors=Authors: {0}
velocity.command.plugin-tooltip-authors=Authors: {0}
velocity.command.dump-uploading=Uploading gathered information...
velocity.command.dump-send-error=An error occurred while communicating with the Velocity servers. The servers may be temporarily unavailable or there is an issue with your network settings. You can find more information in the log or console of your Velocity server.
velocity.command.dump-success=Created an anonymised report containing useful information about this proxy. If a developer requested it, you may share the following link with them:
velocity.command.dump-will-expire=This link will expire in a few days.
velocity.command.dump-server-error=An error occurred on the Velocity servers and the dump could not be completed. Please contact the Velocity staff about this problem and provide the details about this error from the Velocity console or server log.
velocity.command.dump-offline=Likely cause: Invalid system DNS settings or no internet connection

Datei anzeigen

@ -58,4 +58,11 @@ velocity.command.no-plugins=˙pǝllɐʇsuᴉ ʎlʇuǝɹɹnɔ suᴉƃnld ou ǝɹ
velocity.command.plugins-list={0}: suᴉƃnlԀ
velocity.command.plugin-tooltip-website={0}: ǝʇᴉsqǝM
velocity.command.plugin-tooltip-author={0}: ɹoɥʇn∀
velocity.command.plugin-tooltip-authors={0}: sɹoɥʇn∀
velocity.command.plugin-tooltip-authors={0}: sɹoɥʇn∀
velocity.command.dump-uploading=˙˙˙uoᴉʇɐɯɹoɟuᴉ pǝɹǝɥʇɐƃ ƃuᴉpɐold∩
velocity.command.dump-send-error=˙ɹǝʌɹǝs ʎʇᴉɔolǝΛ ɹnoʎ ɟo ǝlosuoɔ ɹo ƃol ǝɥʇ uᴉ uoᴉʇɐɯɹoɟuᴉ ǝɹoɯ puᴉɟ uɐɔ no⅄ ˙sƃuᴉʇʇǝs ʞɹoʍʇǝu ɹnoʎ ɥʇᴉʍ ǝnssᴉ uɐ sᴉ ǝɹǝɥʇ ɹo ǝlqɐlᴉɐʌɐun ʎlᴉɹɐɹodɯǝʇ ǝq ʎɐɯ sɹǝʌɹǝs ǝɥ┴ ˙sɹǝʌɹǝs ʎʇᴉɔolǝΛ ǝɥʇ ɥʇᴉʍ ƃuᴉʇɐɔᴉunɯɯoɔ ǝlᴉɥʍ pǝɹɹnɔɔo ɹoɹɹǝ u∀
velocity.command.dump-success=:ɯǝɥʇ ɥʇᴉʍ ʞuᴉl ƃuᴉʍolloɟ ǝɥʇ ǝɹɐɥs ʎɐɯ noʎ 'ʇᴉ pǝʇsǝnbǝɹ ɹǝdolǝʌǝp ɐ ɟI ˙ʎxoɹd sᴉɥʇ ʇnoqɐ uoᴉʇɐɯɹoɟuᴉ lnɟǝsn ƃuᴉuᴉɐʇuoɔ ʇɹodǝɹ pǝsᴉɯʎuouɐ uɐ pǝʇɐǝɹƆ
velocity.command.dump-will-expire=˙sʎɐp ʍǝɟ ɐ uᴉ ǝɹᴉdxǝ llᴉʍ ʞuᴉl sᴉɥ┴
velocity.command.dump-server-error=˙ƃol ɹǝʌɹǝs ɹo ǝlosuoɔ ʎʇᴉɔolǝΛ ǝɥʇ ɯoɹɟ ɹoɹɹǝ sᴉɥʇ ʇnoqɐ slᴉɐʇǝp ǝɥʇ ǝpᴉʌoɹd puɐ ɯǝlqoɹd sᴉɥʇ ʇnoqɐ ɟɟɐʇs ʎʇᴉɔolǝΛ ǝɥʇ ʇɔɐʇuoɔ ǝsɐǝlԀ ˙pǝʇǝldɯoɔ ǝq ʇou plnoɔ dɯnp ǝɥʇ puɐ sɹǝʌɹǝs ʎʇᴉɔolǝΛ ǝɥʇ uo pǝɹɹnɔɔo ɹoɹɹǝ u∀
velocity.command.dump-offline=uoᴉʇɔǝuuoɔ ʇǝuɹǝʇuᴉ ou ɹo sƃuᴉʇʇǝs SNp ɯǝʇsʎs pᴉlɐʌuI :ǝsnɐɔ ʎlǝʞᴉ˥

Datei anzeigen

@ -44,6 +44,7 @@ import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
public class CommandManagerTests {
@ -378,6 +379,7 @@ public class CommandManagerTests {
}
@Test
@Disabled
void testHinting() {
VelocityCommandManager manager = createManager();
AtomicBoolean executed = new AtomicBoolean(false);

Datei anzeigen

@ -19,8 +19,8 @@ package com.velocitypowered.proxy.protocol;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import com.velocitypowered.proxy.network.ProtocolUtils;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;