mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-12-11 11:34:18 +01:00
0dc74bb242
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing BungeeCord Changes: dfd847f7 Update native libraries a1fee720 Deprecate string join 963854f8 Remove use of internal gson API 2ef5e700 #3451: Improve length field prepending on bungee -> server connection 2e6f0dd4 #3450: Use readRetainedSlice method instead of slice+retain+skip
87 lines
4.3 KiB
Diff
87 lines
4.3 KiB
Diff
From aa69ee55cd4bb1acb430cb17153c6e1bd6f0fe40 Mon Sep 17 00:00:00 2001
|
|
From: Techcable <Techcable@techcable.net>
|
|
Date: Tue, 3 May 2016 20:31:52 -0700
|
|
Subject: [PATCH] Don't access a ByteBuf's underlying array
|
|
|
|
It returns the underlying array storage, and does *not* return a view of the buffer as an array
|
|
|
|
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java
|
|
index 70b292f0..91f71c09 100644
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/PluginMessage.java
|
|
@@ -3,6 +3,7 @@ package net.md_5.bungee.protocol.packet;
|
|
import com.google.common.base.Function;
|
|
import com.google.common.base.Preconditions;
|
|
import io.netty.buffer.ByteBuf;
|
|
+import io.netty.buffer.ByteBufUtil; // Waterfall
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.DataInput;
|
|
import java.io.DataInputStream;
|
|
@@ -47,10 +48,23 @@ public class PluginMessage extends DefinedPacket
|
|
return "legacy:" + tag.toLowerCase( Locale.ROOT );
|
|
}
|
|
};
|
|
- //
|
|
+
|
|
+ public PluginMessage(String tag, ByteBuf data, boolean allowExtendedPacket) {
|
|
+ this(tag, ByteBufUtil.getBytes(data), allowExtendedPacket);
|
|
+ }
|
|
+
|
|
private String tag;
|
|
private byte[] data;
|
|
|
|
+ public void setData(byte[] data) {
|
|
+ this.data = Preconditions.checkNotNull(data, "Null data");
|
|
+ }
|
|
+
|
|
+ public void setData(ByteBuf buf) {
|
|
+ Preconditions.checkNotNull(buf, "Null buffer");
|
|
+ setData(ByteBufUtil.getBytes(buf));
|
|
+ }
|
|
+
|
|
/**
|
|
* Allow this packet to be sent as an "extended" packet.
|
|
*/
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
index 3be014b2..e00c5659 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
@@ -249,7 +249,7 @@ public class ServerConnector extends PacketHandler
|
|
{
|
|
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
|
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand );
|
|
- user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", DefinedPacket.toArray( brand ), handshakeHandler.isServerForge() ) );
|
|
+ user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", brand, handshakeHandler.isServerForge() ) );
|
|
brand.release();
|
|
}
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
index 05cdf684..cc0edeb8 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
@@ -293,7 +293,7 @@ public class DownstreamBridge extends PacketHandler
|
|
|
|
brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
|
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")" + " <- " + serverBrand, brand );
|
|
- pluginMessage.setData( DefinedPacket.toArray( brand ) );
|
|
+ pluginMessage.setData( brand );
|
|
brand.release();
|
|
// changes in the packet are ignored so we need to send it manually
|
|
con.unsafe().sendPacket( pluginMessage );
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
|
|
index 5b9c35d1..2d6885a9 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
|
|
@@ -50,7 +50,7 @@ import net.md_5.bungee.protocol.Varint21LengthFieldPrepender;
|
|
public class PipelineUtils
|
|
{
|
|
|
|
- public static final AttributeKey<ListenerInfo> LISTENER = AttributeKey.valueOf( "ListerInfo" );
|
|
+ public static final AttributeKey<ListenerInfo> LISTENER = AttributeKey.newInstance( "ListerInfo" );
|
|
public static final ChannelInitializer<Channel> SERVER_CHILD = new ChannelInitializer<Channel>()
|
|
{
|
|
@Override
|
|
--
|
|
2.40.0
|
|
|