mirror of
https://github.com/PaperMC/Waterfall.git
synced 2025-02-26 08:41:28 +01:00
89 lines
4.3 KiB
Diff
89 lines
4.3 KiB
Diff
From 2dc230ec020d7ca2631a74149e6aea7bb3ce0509 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 1a7d8512..ad1704dd 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;
|
|
@@ -49,10 +50,25 @@ public class PluginMessage extends DefinedPacket
|
|
return "legacy:" + tag.toLowerCase( Locale.ROOT );
|
|
}
|
|
};
|
|
- //
|
|
+
|
|
private String tag;
|
|
private byte[] data;
|
|
|
|
+ // Waterfall start
|
|
+ public PluginMessage(String tag, ByteBuf data, boolean allowExtendedPacket) {
|
|
+ this(tag, ByteBufUtil.getBytes(data), allowExtendedPacket);
|
|
+ }
|
|
+
|
|
+ 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));
|
|
+ }
|
|
+ // Waterfall end
|
|
+
|
|
/**
|
|
* 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 8f52c50e..33c2c8ab 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
@@ -287,7 +287,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 != null && handshakeHandler.isServerForge() ) );
|
|
+ user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", brand, handshakeHandler != null && handshakeHandler.isServerForge() ) ); // Waterfall
|
|
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 64e9a764..f5b3f7a8 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
|
|
@@ -328,7 +328,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 2934cdef..91c1fbdb 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
|
|
@@ -55,7 +55,7 @@ import net.md_5.bungee.util.PacketLimiter;
|
|
public class PipelineUtils
|
|
{
|
|
|
|
- public static final AttributeKey<ListenerInfo> LISTENER = AttributeKey.valueOf( "ListerInfo" );
|
|
+ public static final AttributeKey<ListenerInfo> LISTENER = AttributeKey.newInstance( "ListerInfo" );
|
|
|
|
private static void setChannelInitializerHolders()
|
|
{
|
|
--
|
|
2.47.1.windows.2
|
|
|