From 300a2ef5024140063119309c7a58b46f8b5fb42c Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 28 May 2022 13:29:18 +0200 Subject: [PATCH] Fix TeamCommand tp no message --- src/de/steamwar/bungeecore/ErrorLogger.java | 1 + .../bungeecore/commands/TeamCommand.java | 22 +++++++++---------- .../steamwar/messages/BungeeCore.properties | 1 + .../messages/BungeeCore_de.properties | 1 + 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/de/steamwar/bungeecore/ErrorLogger.java b/src/de/steamwar/bungeecore/ErrorLogger.java index 09cdb40..cbf1cc5 100644 --- a/src/de/steamwar/bungeecore/ErrorLogger.java +++ b/src/de/steamwar/bungeecore/ErrorLogger.java @@ -88,6 +88,7 @@ public class ErrorLogger extends Handler { contains.add("read timed out"); contains.add("Connection reset by peer"); contains.add("No client connected for pending server"); + contains.add("Error occurred processing connection for"); ignoreContains = Collections.unmodifiableList(contains); } } diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index 16eaf75..ab242a6 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -26,6 +26,8 @@ import de.steamwar.bungeecore.inventory.SWListInv; import de.steamwar.bungeecore.sql.*; import de.steamwar.messages.ChatSender; import io.netty.channel.ConnectTimeoutException; +import net.md_5.bungee.BungeeCord; +import net.md_5.bungee.UserConnection; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; @@ -35,6 +37,7 @@ import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.ServerConnectEvent; import java.net.*; import java.time.Instant; @@ -587,18 +590,13 @@ public class TeamCommand extends BasicCommand { ProxyServer.getInstance().getServers().put(info.getName(), info); return info; }); - try { - player.connect(serverInfo, (success, error) -> { - if (error != null) { - error.printStackTrace(); - } - if (error instanceof ConnectTimeoutException) { - Message.send("TEAM_TIMEOUT", player); - } - }); - } catch (Exception e) { - e.printStackTrace(); - } + ((UserConnection) player).connect(serverInfo, (success, error) -> { + if (error instanceof ConnectTimeoutException) { + Message.send("TEAM_TIMEOUT", player); + } else if (error != null) { + Message.send("TEAM_UNKNOWN", player); + } + }, false, ServerConnectEvent.Reason.PLUGIN, BungeeCord.getInstance().getConfig().getServerConnectTimeout(), false); } private void server(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 5036164..304f488 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -479,6 +479,7 @@ TEAM_SERVER_PORT_INVALID=§cInvalid port number. TEAM_SERVER_ADDRESS_INVALID=§cInvalid address. TEAM_NO_ADDRESS=§cNo team server address set. TEAM_TIMEOUT=§cTeam server may be offline. +TEAM_UNKNOWN=§cAn unexpected error occurred while connecting to the team server. TEAM_TP_NO_TEAM=§cUnknown team. #TpCommand diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index 987fed1..5274ac9 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -458,6 +458,7 @@ TEAM_SERVER_PORT_INVALID=§cUnmögliche Portnummer. TEAM_SERVER_ADDRESS_INVALID=§cUngültige Adresse. TEAM_NO_ADDRESS=§cTeamserveradresse nicht gesetzt. TEAM_TIMEOUT=§cTeamserver scheint offline zu sein. +TEAM_UNKNOWN=§cEin unwerwarteter Fehler ist aufgetreten beim verbinden zum Teamserver. TEAM_TP_NO_TEAM=§cUnbekanntes Team. #TpCommand