mirror of
https://github.com/PaperMC/Waterfall.git
synced 2025-04-17 17:26:14 +02:00
Updated Source
This commit is contained in:
parent
083dd1ec02
commit
1420ba7edd
@ -1,4 +1,4 @@
|
||||
From e8604a4c597b305d1484d4240c76c6ec5f7af37b Mon Sep 17 00:00:00 2001
|
||||
From 016322bb87441fd19dec8ae7b125e23e9b7c8f1e Mon Sep 17 00:00:00 2001
|
||||
From: Juan Cruz Linsalata <LinsaFTW@users.noreply.github.com>
|
||||
Date: Sat, 15 Aug 2020 15:19:22 -0300
|
||||
Subject: [PATCH] FlameCord Initial Patch
|
||||
@ -7866,7 +7866,7 @@ index 585afa36..b162d05f 100644
|
||||
}
|
||||
}
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
||||
index 13deb6c9..4adb858b 100644
|
||||
index 13deb6c9..a8586706 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
||||
@@ -1,8 +1,5 @@
|
||||
@ -7954,7 +7954,7 @@ index 13deb6c9..4adb858b 100644
|
||||
}
|
||||
};
|
||||
@Getter
|
||||
@@ -116,581 +116,561 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
@@ -116,581 +116,572 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
private String extraDataInHandshake = "";
|
||||
|
||||
@Override
|
||||
@ -8204,24 +8204,31 @@ index 13deb6c9..4adb858b 100644
|
||||
+ // be on the
|
||||
// safe side, always send legacy descriptions for < 1.9 clients.
|
||||
- JsonElement element = gson.toJsonTree(pingResult.getResponse());
|
||||
+ // FlameCord start - Return if the response is null
|
||||
+ // FlameCord - Use response instead of pingResult.getResponse()
|
||||
+ // FlameCord - Return if the response is null
|
||||
+ final ServerPing response = pingResult.getResponse();
|
||||
+ if (response == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // FlameCord end - Return if the response is null
|
||||
+ final JsonElement element = gson.toJsonTree(response);
|
||||
Preconditions.checkArgument(element.isJsonObject(), "Response is not a JSON object");
|
||||
- JsonObject object = element.getAsJsonObject();
|
||||
- object.addProperty("description", pingResult.getResponse().getDescription());
|
||||
+ final JsonObject object = element.getAsJsonObject();
|
||||
object.addProperty("description", pingResult.getResponse().getDescription());
|
||||
+ object.addProperty("description", response.getDescription());
|
||||
|
||||
unsafe.sendPacket(new StatusResponse(gson.toJson(element)));
|
||||
- } else
|
||||
- {
|
||||
- unsafe.sendPacket( new StatusResponse( gson.toJson( pingResult.getResponse() ) ) );
|
||||
+ } else {
|
||||
+ unsafe.sendPacket(new StatusResponse(gson.toJson(pingResult.getResponse())));
|
||||
+ // FlameCord - Use response instead of pingResult.getResponse()
|
||||
+ // FlameCord - Return if the response is null
|
||||
+ final ServerPing response = pingResult.getResponse();
|
||||
+ if (response == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+ unsafe.sendPacket(new StatusResponse(gson.toJson(response)));
|
||||
}
|
||||
// Travertine end
|
||||
}
|
||||
@ -8317,12 +8324,16 @@ index 13deb6c9..4adb858b 100644
|
||||
}
|
||||
|
||||
- this.virtualHost = InetSocketAddress.createUnresolved( handshake.getHost(), handshake.getPort() );
|
||||
-
|
||||
- bungee.getPluginManager().callEvent( new PlayerHandshakeEvent( InitialHandler.this, handshake ) );
|
||||
+ this.virtualHost = InetSocketAddress.createUnresolved(host, handshake.getPort());
|
||||
+ // FlameCord end - Changed "handshake.getHost()" to host
|
||||
+ bungee.getPluginManager().callEvent(new PlayerHandshakeEvent(InitialHandler.this, handshake));
|
||||
|
||||
- bungee.getPluginManager().callEvent( new PlayerHandshakeEvent( InitialHandler.this, handshake ) );
|
||||
+ // FlameCord - Return if the connection is not connected anymore
|
||||
+ if (!InitialHandler.this.ch.isClosed()) {
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
- switch ( handshake.getRequestedProtocol() )
|
||||
- {
|
||||
+ switch (handshake.getRequestedProtocol()) {
|
||||
@ -8515,11 +8526,11 @@ index 13deb6c9..4adb858b 100644
|
||||
|
||||
- String preventProxy = ( BungeeCord.getInstance().config.isPreventProxyConnections() && getSocketAddress() instanceof InetSocketAddress ) ? "&ip=" + URLEncoder.encode( getAddress().getAddress().getHostAddress(), "UTF-8" ) : "";
|
||||
- String authURL = String.format( MOJANG_AUTH_URL, encName, encodedHash, preventProxy );
|
||||
+ String preventProxy = (BungeeCord.getInstance().config.isPreventProxyConnections()
|
||||
+ final String preventProxy = (BungeeCord.getInstance().config.isPreventProxyConnections()
|
||||
+ && getSocketAddress() instanceof InetSocketAddress)
|
||||
+ ? "&ip=" + URLEncoder.encode(getAddress().getAddress().getHostAddress(), "UTF-8")
|
||||
+ : "";
|
||||
+ String authURL = String.format(MOJANG_AUTH_URL, encName, encodedHash, preventProxy);
|
||||
+ final String authURL = String.format(MOJANG_AUTH_URL, encName, encodedHash, preventProxy);
|
||||
|
||||
- Callback<String> handler = new Callback<String>()
|
||||
- {
|
||||
@ -8847,19 +8858,21 @@ index 13deb6c9..4adb858b 100644
|
||||
}
|
||||
}
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java
|
||||
index 6cd71071..2b69b46e 100644
|
||||
index 6cd71071..6048c2a1 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java
|
||||
@@ -1,6 +1,8 @@
|
||||
@@ -1,7 +1,10 @@
|
||||
package net.md_5.bungee.connection;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
+
|
||||
+import dev._2lstudios.flamecord.FlameCord;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
+import io.netty.channel.ChannelPipeline;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
@@ -12,6 +14,7 @@ import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.BungeeServerInfo;
|
||||
@@ -12,6 +15,7 @@ import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.netty.ChannelWrapper;
|
||||
import net.md_5.bungee.netty.PacketHandler;
|
||||
import net.md_5.bungee.netty.PipelineUtils;
|
||||
@ -8867,7 +8880,7 @@ index 6cd71071..2b69b46e 100644
|
||||
import net.md_5.bungee.protocol.MinecraftDecoder;
|
||||
import net.md_5.bungee.protocol.MinecraftEncoder;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
@@ -21,11 +24,9 @@ import net.md_5.bungee.protocol.packet.Handshake;
|
||||
@@ -21,11 +25,9 @@ import net.md_5.bungee.protocol.packet.Handshake;
|
||||
import net.md_5.bungee.protocol.packet.StatusRequest;
|
||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||
import net.md_5.bungee.util.BufUtil;
|
||||
@ -8880,22 +8893,24 @@ index 6cd71071..2b69b46e 100644
|
||||
|
||||
private final ServerInfo target;
|
||||
private final Callback<ServerPing> callback;
|
||||
@@ -33,49 +34,53 @@ public class PingHandler extends PacketHandler
|
||||
@@ -33,49 +35,55 @@ public class PingHandler extends PacketHandler
|
||||
private ChannelWrapper channel;
|
||||
|
||||
@Override
|
||||
- public void connected(ChannelWrapper channel) throws Exception
|
||||
- {
|
||||
+ public void connected(ChannelWrapper channel) throws Exception {
|
||||
+ public void connected(final ChannelWrapper channel) throws Exception {
|
||||
this.channel = channel;
|
||||
- MinecraftEncoder encoder = new MinecraftEncoder( Protocol.HANDSHAKE, false, protocol );
|
||||
+ MinecraftEncoder encoder = new MinecraftEncoder(Protocol.HANDSHAKE, false, protocol);
|
||||
+ final MinecraftEncoder encoder = new MinecraftEncoder(Protocol.HANDSHAKE, false, protocol);
|
||||
+ // FlameCord - Use pipeline instead of channel.getHandle().pipeline()
|
||||
+ final ChannelPipeline pipeline = channel.getHandle().pipeline();
|
||||
|
||||
- channel.getHandle().pipeline().addAfter( PipelineUtils.FRAME_DECODER, PipelineUtils.PACKET_DECODER, new MinecraftDecoder( Protocol.STATUS, false, ProxyServer.getInstance().getProtocolVersion() ) );
|
||||
- channel.getHandle().pipeline().addAfter( PipelineUtils.FRAME_PREPENDER, PipelineUtils.PACKET_ENCODER, encoder );
|
||||
+ channel.getHandle().pipeline().addAfter(PipelineUtils.FRAME_DECODER, PipelineUtils.PACKET_DECODER,
|
||||
+ pipeline.addAfter(PipelineUtils.FRAME_DECODER, PipelineUtils.PACKET_DECODER,
|
||||
+ new MinecraftDecoder(Protocol.STATUS, false, ProxyServer.getInstance().getProtocolVersion()));
|
||||
+ channel.getHandle().pipeline().addAfter(PipelineUtils.FRAME_PREPENDER, PipelineUtils.PACKET_ENCODER, encoder);
|
||||
+ pipeline.addAfter(PipelineUtils.FRAME_PREPENDER, PipelineUtils.PACKET_ENCODER, encoder);
|
||||
|
||||
- channel.write( new Handshake( protocol, target.getAddress().getHostString(), target.getAddress().getPort(), 1 ) );
|
||||
+ channel.write(new Handshake(protocol, target.getAddress().getHostString(), target.getAddress().getPort(), 1));
|
||||
@ -8910,7 +8925,7 @@ index 6cd71071..2b69b46e 100644
|
||||
- public void exception(Throwable t) throws Exception
|
||||
- {
|
||||
- callback.done( null, t );
|
||||
+ public void exception(Throwable t) throws Exception {
|
||||
+ public void exception(final Throwable t) throws Exception {
|
||||
+ callback.done(null, t);
|
||||
}
|
||||
|
||||
@ -8920,7 +8935,7 @@ index 6cd71071..2b69b46e 100644
|
||||
- if ( packet.packet == null )
|
||||
- {
|
||||
- throw new QuietException( "Unexpected packet received during ping process! " + BufUtil.dump( packet.buf, 16 ) );
|
||||
+ public void handle(PacketWrapper packet) throws Exception {
|
||||
+ public void handle(final PacketWrapper packet) throws Exception {
|
||||
+ if (packet.packet == null) {
|
||||
+ // FlameCord - Toggle Dumping packet info
|
||||
+ if (FlameCord.getInstance().getFlameCordConfiguration().isLoggerDump()) {
|
||||
@ -8942,10 +8957,10 @@ index 6cd71071..2b69b46e 100644
|
||||
- ServerPing serverPing = gson.fromJson( statusResponse.getResponse(), ServerPing.class );
|
||||
- ( (BungeeServerInfo) target ).cachePing( serverPing );
|
||||
- callback.done( serverPing, null );
|
||||
+ public void handle(StatusResponse statusResponse) throws Exception {
|
||||
+ Gson gson = protocol == ProtocolConstants.MINECRAFT_1_7_2 ? BungeeCord.getInstance().gsonLegacy
|
||||
+ public void handle(final StatusResponse statusResponse) throws Exception {
|
||||
+ final Gson gson = protocol == ProtocolConstants.MINECRAFT_1_7_2 ? BungeeCord.getInstance().gsonLegacy
|
||||
+ : BungeeCord.getInstance().gson; // Travertine
|
||||
+ ServerPing serverPing = gson.fromJson(statusResponse.getResponse(), ServerPing.class);
|
||||
+ final ServerPing serverPing = gson.fromJson(statusResponse.getResponse(), ServerPing.class);
|
||||
+ ((BungeeServerInfo) target).cachePing(serverPing);
|
||||
+ callback.done(serverPing, null);
|
||||
channel.close();
|
||||
@ -9783,7 +9798,7 @@ index 8c5cc949..de83bb2c 100644
|
||||
|
||||
return null;
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
|
||||
index 6dc5633f..f1e0f606 100644
|
||||
index 6dc5633f..bfe7e95c 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
|
||||
@@ -5,6 +5,8 @@ import io.netty.channel.Channel;
|
||||
@ -9805,7 +9820,7 @@ index 6dc5633f..f1e0f606 100644
|
||||
|
||||
private final Channel ch;
|
||||
@Getter
|
||||
@@ -29,120 +30,110 @@ public class ChannelWrapper
|
||||
@@ -29,120 +30,112 @@ public class ChannelWrapper
|
||||
@Getter
|
||||
private volatile boolean closing;
|
||||
|
||||
@ -9892,8 +9907,10 @@ index 6dc5633f..f1e0f606 100644
|
||||
- {
|
||||
- ch.flush();
|
||||
+ if (packet != null && ch.isActive()) {
|
||||
+ ch.writeAndFlush(packet).addListeners(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE,
|
||||
+ ChannelFutureListener.CLOSE);
|
||||
+ // FlameCord - Dont fire exception on failure
|
||||
+ // ch.writeAndFlush(packet).addListeners(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE,
|
||||
+ // ChannelFutureListener.CLOSE);
|
||||
+ ch.writeAndFlush(packet).addListeners(ChannelFutureListener.CLOSE);
|
||||
+ } else {
|
||||
+ // FlameCord - Disable flushing as it's not really necessary
|
||||
+ // ch.flush();
|
||||
|
Loading…
Reference in New Issue
Block a user