Minecraft 1.13-pre7 support
This commit is contained in:
parent
ceb9ea1e52
commit
b1cc72e212
@ -17,4 +17,4 @@ Binaries
|
||||
--------
|
||||
Precompiled binaries are available for end users on [Jenkins](https://www.spigotmc.org/go/bungeecord-dl).
|
||||
|
||||
(c) 2012-2017 SpigotMC Pty. Ltd.
|
||||
(c) 2012-2018 SpigotMC Pty. Ltd.
|
||||
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-API</name>
|
||||
|
@ -154,16 +154,6 @@ public abstract class ProxyServer
|
||||
*/
|
||||
public abstract void stop(String reason);
|
||||
|
||||
/**
|
||||
* Start this instance so that it may accept connections.
|
||||
*
|
||||
* @throws Exception any exception thrown during startup causing the
|
||||
* instance to fail to boot
|
||||
* @deprecated not API, will be removed in a future version
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void start() throws Exception;
|
||||
|
||||
/**
|
||||
* Register a channel for use with plugin messages. This is required by some
|
||||
* server / client implementations.
|
||||
|
@ -56,6 +56,10 @@ public interface ServerInfo
|
||||
* Send data by any available means to this server. This data may be queued
|
||||
* and there is no guarantee of its timely arrival.
|
||||
*
|
||||
* In recent Minecraft versions channel names must contain a colon separator
|
||||
* and consist of [a-z0-9/._-]. This will be enforced in a future version.
|
||||
* The "BungeeCord" channel is an exception and may only take this form.
|
||||
*
|
||||
* @param channel the channel to send this data via
|
||||
* @param data the data to send
|
||||
*/
|
||||
@ -64,6 +68,10 @@ public interface ServerInfo
|
||||
/**
|
||||
* Send data by any available means to this server.
|
||||
*
|
||||
* In recent Minecraft versions channel names must contain a colon separator
|
||||
* and consist of [a-z0-9/._-]. This will be enforced in a future version.
|
||||
* The "BungeeCord" channel is an exception and may only take this form.
|
||||
*
|
||||
* @param channel the channel to send this data via
|
||||
* @param data the data to send
|
||||
* @param queue hold the message for later sending if it cannot be sent
|
||||
|
@ -140,6 +140,10 @@ public interface ProxiedPlayer extends Connection, CommandSender
|
||||
/**
|
||||
* Send a plugin message to this player.
|
||||
*
|
||||
* In recent Minecraft versions channel names must contain a colon separator
|
||||
* and consist of [a-z0-9/._-]. This will be enforced in a future version.
|
||||
* The "BungeeCord" channel is an exception and may only take this form.
|
||||
*
|
||||
* @param channel the channel to send this data via
|
||||
* @param data the data to send
|
||||
*/
|
||||
|
@ -18,6 +18,10 @@ public interface Server extends Connection
|
||||
/**
|
||||
* Send data by any available means to this server.
|
||||
*
|
||||
* In recent Minecraft versions channel names must contain a colon separator
|
||||
* and consist of [a-z0-9/._-]. This will be enforced in a future version.
|
||||
* The "BungeeCord" channel is an exception and may only take this form.
|
||||
*
|
||||
* @param channel the channel to send this data via
|
||||
* @param data the data to send
|
||||
*/
|
||||
|
@ -19,7 +19,7 @@ public class Team
|
||||
private byte friendlyFire;
|
||||
private String nameTagVisibility;
|
||||
private String collisionRule;
|
||||
private byte color;
|
||||
private int color;
|
||||
private Set<String> players = new HashSet<>();
|
||||
|
||||
public Collection<String> getPlayers()
|
||||
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-bootstrap</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Bootstrap</name>
|
||||
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Chat</name>
|
||||
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-config</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Config</name>
|
||||
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-event</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Event</name>
|
||||
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-log</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Log</name>
|
||||
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-module</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-module-cmd-alert</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>cmd_alert</name>
|
||||
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-module</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-module-cmd-find</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>cmd_find</name>
|
||||
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-module</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-module-cmd-list</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>cmd_list</name>
|
||||
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-module</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-module-cmd-send</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>cmd_send</name>
|
||||
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-module</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-module-cmd-server</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>cmd_server</name>
|
||||
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-module</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>BungeeCord Modules</name>
|
||||
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-module</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-module-reconnect-yaml</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>reconnect_yaml</name>
|
||||
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-native</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Native</name>
|
||||
|
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>BungeeCord-Parent</name>
|
||||
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-protocol</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Protocol</name>
|
||||
|
@ -22,6 +22,8 @@ import net.md_5.bungee.protocol.packet.Handshake;
|
||||
import net.md_5.bungee.protocol.packet.EncryptionResponse;
|
||||
import net.md_5.bungee.protocol.packet.LegacyHandshake;
|
||||
import net.md_5.bungee.protocol.packet.LegacyPing;
|
||||
import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
|
||||
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
||||
import net.md_5.bungee.protocol.packet.LoginRequest;
|
||||
import net.md_5.bungee.protocol.packet.LoginSuccess;
|
||||
import net.md_5.bungee.protocol.packet.PingPacket;
|
||||
@ -148,4 +150,12 @@ public abstract class AbstractPacketHandler
|
||||
public void handle(BossBar bossBar) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(LoginPayloadRequest request) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(LoginPayloadResponse response) throws Exception
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ import net.md_5.bungee.protocol.packet.Handshake;
|
||||
import net.md_5.bungee.protocol.packet.KeepAlive;
|
||||
import net.md_5.bungee.protocol.packet.Kick;
|
||||
import net.md_5.bungee.protocol.packet.Login;
|
||||
import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
|
||||
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
||||
import net.md_5.bungee.protocol.packet.LoginRequest;
|
||||
import net.md_5.bungee.protocol.packet.LoginSuccess;
|
||||
import net.md_5.bungee.protocol.packet.PingPacket;
|
||||
@ -61,90 +63,104 @@ public enum Protocol
|
||||
KeepAlive.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x00 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x1F ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x1F )
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x1F ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x21 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
Login.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x01 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x23 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x23 )
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x23 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x25 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
Chat.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x02 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x0F ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x0F )
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x0F ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x0E )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
Respawn.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x07 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x33 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x34 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x35 )
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x35 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x38 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
BossBar.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x0C ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x0C )
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x0C ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x0C )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
PlayerListItem.class, // PlayerInfo
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x38 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x2D ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x2D ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x2E )
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x2E ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x30 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
TabCompleteResponse.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x3A ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x0E ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x0E )
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x0E ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x10 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
ScoreboardObjective.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x3B ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x3F ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x41 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x42 )
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x42 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x45 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
ScoreboardScore.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x3C ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x42 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x44 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x45 )
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x45 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x48 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
ScoreboardDisplay.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x3D ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x38 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x3A ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x3B )
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x3B ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x3E )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
Team.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x3E ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x41 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x43 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x44 )
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x44 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x47 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
PluginMessage.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x3F ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x18 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x18 )
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x18 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x19 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
Kick.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x40 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x1A ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x1A )
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x1A ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x1B )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
Title.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x45 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x47 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x48 )
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x48 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x4B )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
PlayerListHeaderFooter.class,
|
||||
@ -152,7 +168,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x48 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9_4, 0x47 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x49 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x4A )
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x4A ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x4E )
|
||||
);
|
||||
|
||||
TO_SERVER.registerPacket(
|
||||
@ -160,35 +177,40 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x00 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x0B ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x0C ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x0B )
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x0B ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x0E )
|
||||
);
|
||||
TO_SERVER.registerPacket(
|
||||
Chat.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x01 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x02 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x03 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x02 )
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x02 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x02 )
|
||||
);
|
||||
TO_SERVER.registerPacket(
|
||||
TabCompleteRequest.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x14 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x01 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x02 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x01 )
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x01 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x05 )
|
||||
);
|
||||
TO_SERVER.registerPacket(
|
||||
ClientSettings.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x15 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x04 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x05 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x04 )
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x04 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x04 )
|
||||
);
|
||||
TO_SERVER.registerPacket(
|
||||
PluginMessage.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x17 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x09 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12, 0x0A ),
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x09 )
|
||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x09 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x0A )
|
||||
);
|
||||
}
|
||||
},
|
||||
@ -221,30 +243,44 @@ public enum Protocol
|
||||
{
|
||||
|
||||
{
|
||||
TO_CLIENT.registerPacket(
|
||||
LoginPayloadRequest.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x00 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
Kick.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x00 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x01 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
EncryptionRequest.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x01 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x02 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
LoginSuccess.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x02 )
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x02 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x03 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
SetCompression.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x03 )
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x03 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x04 )
|
||||
);
|
||||
|
||||
TO_SERVER.registerPacket(
|
||||
LoginPayloadResponse.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x00 )
|
||||
);
|
||||
TO_SERVER.registerPacket(
|
||||
LoginRequest.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x00 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x01 )
|
||||
);
|
||||
TO_SERVER.registerPacket(
|
||||
EncryptionResponse.class,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x01 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x02 )
|
||||
);
|
||||
}
|
||||
};
|
||||
@ -327,7 +363,8 @@ public enum Protocol
|
||||
{
|
||||
linkedProtocols.put( ProtocolConstants.MINECRAFT_1_8, Arrays.asList(
|
||||
ProtocolConstants.MINECRAFT_1_9,
|
||||
ProtocolConstants.MINECRAFT_1_12
|
||||
ProtocolConstants.MINECRAFT_1_12,
|
||||
ProtocolConstants.MINECRAFT_1_13
|
||||
) );
|
||||
linkedProtocols.put( ProtocolConstants.MINECRAFT_1_9, Arrays.asList(
|
||||
ProtocolConstants.MINECRAFT_1_9_1,
|
||||
|
@ -17,12 +17,14 @@ public class ProtocolConstants
|
||||
public static final int MINECRAFT_1_12 = 335;
|
||||
public static final int MINECRAFT_1_12_1 = 338;
|
||||
public static final int MINECRAFT_1_12_2 = 340;
|
||||
public static final int MINECRAFT_1_13 = 389;
|
||||
public static final List<String> SUPPORTED_VERSIONS = Arrays.asList(
|
||||
"1.8.x",
|
||||
"1.9.x",
|
||||
"1.10.x",
|
||||
"1.11.x",
|
||||
"1.12.x"
|
||||
"1.12.x",
|
||||
"1.13.x"
|
||||
);
|
||||
public static final List<Integer> SUPPORTED_VERSION_IDS = Arrays.asList( ProtocolConstants.MINECRAFT_1_8,
|
||||
ProtocolConstants.MINECRAFT_1_9,
|
||||
@ -34,7 +36,8 @@ public class ProtocolConstants
|
||||
ProtocolConstants.MINECRAFT_1_11_1,
|
||||
ProtocolConstants.MINECRAFT_1_12,
|
||||
ProtocolConstants.MINECRAFT_1_12_1,
|
||||
ProtocolConstants.MINECRAFT_1_12_2
|
||||
ProtocolConstants.MINECRAFT_1_12_2,
|
||||
ProtocolConstants.MINECRAFT_1_13
|
||||
);
|
||||
|
||||
public enum Direction
|
||||
|
@ -0,0 +1,51 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
import net.md_5.bungee.protocol.OverflowPacketException;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class LoginPayloadRequest extends DefinedPacket
|
||||
{
|
||||
|
||||
private int id;
|
||||
private String channel;
|
||||
private byte[] data;
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf)
|
||||
{
|
||||
id = readVarInt( buf );
|
||||
channel = readString( buf );
|
||||
|
||||
int len = buf.readableBytes();
|
||||
if ( len > 1048576 )
|
||||
{
|
||||
throw new OverflowPacketException( "Payload may not be larger than 1048576 bytes" );
|
||||
}
|
||||
data = new byte[ len ];
|
||||
buf.readBytes( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf)
|
||||
{
|
||||
writeVarInt( id, buf );
|
||||
writeString( channel, buf );
|
||||
buf.writeBytes( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(AbstractPacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
import net.md_5.bungee.protocol.OverflowPacketException;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class LoginPayloadResponse extends DefinedPacket
|
||||
{
|
||||
|
||||
private int id;
|
||||
private byte[] data;
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf)
|
||||
{
|
||||
id = readVarInt( buf );
|
||||
|
||||
if ( buf.readBoolean() )
|
||||
{
|
||||
int len = buf.readableBytes();
|
||||
if ( len > 1048576 )
|
||||
{
|
||||
throw new OverflowPacketException( "Payload may not be larger than 1048576 bytes" );
|
||||
}
|
||||
data = new byte[ len ];
|
||||
buf.readBytes( data );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf)
|
||||
{
|
||||
writeVarInt( id, buf );
|
||||
if ( data != null )
|
||||
{
|
||||
buf.writeBoolean( true );
|
||||
buf.writeBytes( data );
|
||||
} else
|
||||
{
|
||||
buf.writeBoolean( false );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(AbstractPacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Predicate;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
@ -7,6 +8,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
import java.util.Locale;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -21,12 +23,37 @@ import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
public class PluginMessage extends DefinedPacket
|
||||
{
|
||||
|
||||
public static final Function<String, String> MODERNISE = new Function<String, String>()
|
||||
{
|
||||
@Override
|
||||
public String apply(String tag)
|
||||
{
|
||||
// Transform as per Bukkit
|
||||
if ( tag.equals( "BungeeCord" ) )
|
||||
{
|
||||
return "bungeecord:main";
|
||||
}
|
||||
if ( tag.equals( "bungeecord:main" ) )
|
||||
{
|
||||
return "BungeeCord";
|
||||
}
|
||||
|
||||
// Code that gets to here is UNLIKELY to be viable on the Bukkit side of side things,
|
||||
// but we keep it anyway. It will eventually be enforced API side.
|
||||
if ( tag.indexOf( ':' ) != -1 )
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
|
||||
return "bungeecord:legacy/" + tag.toLowerCase( Locale.ROOT );
|
||||
}
|
||||
};
|
||||
public static final Predicate<PluginMessage> SHOULD_RELAY = new Predicate<PluginMessage>()
|
||||
{
|
||||
@Override
|
||||
public boolean apply(PluginMessage input)
|
||||
{
|
||||
return ( input.getTag().equals( "REGISTER" ) || input.getTag().equals( "MC|Brand" ) ) && input.getData().length < Byte.MAX_VALUE;
|
||||
return ( input.getTag().equals( "REGISTER" ) || input.getTag().equals( "minecraft:register" ) || input.getTag().equals( "MC|Brand" ) || input.getTag().equals( "minecraft:brand" ) ) && input.getData().length < Byte.MAX_VALUE;
|
||||
}
|
||||
};
|
||||
//
|
||||
@ -41,7 +68,7 @@ public class PluginMessage extends DefinedPacket
|
||||
@Override
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
tag = readString( buf );
|
||||
tag = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? MODERNISE.apply( readString( buf ) ) : readString( buf );
|
||||
int maxSize = direction == ProtocolConstants.Direction.TO_SERVER ? Short.MAX_VALUE : 0x100000;
|
||||
Preconditions.checkArgument( buf.readableBytes() < maxSize );
|
||||
data = new byte[ buf.readableBytes() ];
|
||||
@ -51,7 +78,7 @@ public class PluginMessage extends DefinedPacket
|
||||
@Override
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
writeString( tag, buf );
|
||||
writeString( ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? MODERNISE.apply( tag ) : tag, buf );
|
||||
buf.writeBytes( data );
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Locale;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -18,7 +19,7 @@ public class ScoreboardObjective extends DefinedPacket
|
||||
|
||||
private String name;
|
||||
private String value;
|
||||
private String type;
|
||||
private HealthDisplay type;
|
||||
/**
|
||||
* 0 to create, 1 to remove, 2 to update display text.
|
||||
*/
|
||||
@ -32,7 +33,13 @@ public class ScoreboardObjective extends DefinedPacket
|
||||
if ( action == 0 || action == 2 )
|
||||
{
|
||||
value = readString( buf );
|
||||
type = readString( buf );
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
|
||||
{
|
||||
type = HealthDisplay.values()[readVarInt( buf )];
|
||||
} else
|
||||
{
|
||||
type = HealthDisplay.fromString( readString( buf ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +51,13 @@ public class ScoreboardObjective extends DefinedPacket
|
||||
if ( action == 0 || action == 2 )
|
||||
{
|
||||
writeString( value, buf );
|
||||
writeString( type, buf );
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
|
||||
{
|
||||
writeVarInt( type.ordinal(), buf );
|
||||
} else
|
||||
{
|
||||
writeString( type.toString(), buf );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,4 +66,21 @@ public class ScoreboardObjective extends DefinedPacket
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
|
||||
public enum HealthDisplay
|
||||
{
|
||||
|
||||
INTEGER, HEARTS;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return super.toString().toLowerCase( Locale.ROOT );
|
||||
}
|
||||
|
||||
public static HealthDisplay fromString(String s)
|
||||
{
|
||||
return valueOf( s.toUpperCase( Locale.ROOT ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -11,20 +10,41 @@ import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class TabCompleteRequest extends DefinedPacket
|
||||
{
|
||||
|
||||
private int transactionId;
|
||||
private String cursor;
|
||||
private boolean assumeCommand;
|
||||
private boolean hasPositon;
|
||||
private long position;
|
||||
|
||||
public TabCompleteRequest(int transactionId, String cursor)
|
||||
{
|
||||
this.transactionId = transactionId;
|
||||
this.cursor = cursor;
|
||||
}
|
||||
|
||||
public TabCompleteRequest(String cursor, boolean assumeCommand, boolean hasPosition, long position)
|
||||
{
|
||||
this.cursor = cursor;
|
||||
this.assumeCommand = assumeCommand;
|
||||
this.hasPositon = hasPosition;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
|
||||
{
|
||||
transactionId = readVarInt( buf );
|
||||
}
|
||||
cursor = readString( buf );
|
||||
|
||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 )
|
||||
{
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
|
||||
{
|
||||
assumeCommand = buf.readBoolean();
|
||||
@ -35,11 +55,19 @@ public class TabCompleteRequest extends DefinedPacket
|
||||
position = buf.readLong();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
|
||||
{
|
||||
writeVarInt( transactionId, buf );
|
||||
}
|
||||
writeString( cursor, buf );
|
||||
|
||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 )
|
||||
{
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
|
||||
{
|
||||
buf.writeBoolean( assumeCommand );
|
||||
@ -51,6 +79,7 @@ public class TabCompleteRequest extends DefinedPacket
|
||||
buf.writeLong( position );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(AbstractPacketHandler handler) throws Exception
|
||||
|
@ -2,37 +2,103 @@ package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class TabCompleteResponse extends DefinedPacket
|
||||
{
|
||||
|
||||
private int transactionId;
|
||||
private int start;
|
||||
private int length;
|
||||
private List<CommandMatch> matches;
|
||||
private List<String> commands;
|
||||
|
||||
@Override
|
||||
public void read(ByteBuf buf)
|
||||
public TabCompleteResponse(int transactionId, int start, int length, List<CommandMatch> matches)
|
||||
{
|
||||
commands = readStringArray( buf );
|
||||
this.transactionId = transactionId;
|
||||
this.start = start;
|
||||
this.length = length;
|
||||
this.matches = matches;
|
||||
}
|
||||
|
||||
public TabCompleteResponse(List<String> commands)
|
||||
{
|
||||
this.commands = commands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf)
|
||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
|
||||
{
|
||||
transactionId = readVarInt( buf );
|
||||
start = readVarInt( buf );
|
||||
length = readVarInt( buf );
|
||||
|
||||
int cnt = readVarInt( buf );
|
||||
matches = new LinkedList<>();
|
||||
for ( int i = 0; i < cnt; i++ )
|
||||
{
|
||||
String match = readString( buf );
|
||||
String tooltip = buf.readBoolean() ? readString( buf ) : null;
|
||||
|
||||
matches.add( new CommandMatch( match, tooltip ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 )
|
||||
{
|
||||
commands = readStringArray( buf );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||
{
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
|
||||
{
|
||||
writeVarInt( transactionId, buf );
|
||||
writeVarInt( start, buf );
|
||||
writeVarInt( length, buf );
|
||||
|
||||
writeVarInt( matches.size(), buf );
|
||||
for ( CommandMatch match : matches )
|
||||
{
|
||||
writeString( match.match, buf );
|
||||
buf.writeBoolean( match.tooltip != null );
|
||||
writeString( match.tooltip, buf );
|
||||
}
|
||||
}
|
||||
|
||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 )
|
||||
{
|
||||
writeStringArray( commands, buf );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(AbstractPacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class CommandMatch
|
||||
{
|
||||
|
||||
private String match;
|
||||
private String tooltip;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class Team extends DefinedPacket
|
||||
private String suffix;
|
||||
private String nameTagVisibility;
|
||||
private String collisionRule;
|
||||
private byte color;
|
||||
private int color;
|
||||
private byte friendlyFire;
|
||||
private String[] players;
|
||||
|
||||
@ -47,15 +47,23 @@ public class Team extends DefinedPacket
|
||||
if ( mode == 0 || mode == 2 )
|
||||
{
|
||||
displayName = readString( buf );
|
||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 )
|
||||
{
|
||||
prefix = readString( buf );
|
||||
suffix = readString( buf );
|
||||
}
|
||||
friendlyFire = buf.readByte();
|
||||
nameTagVisibility = readString( buf );
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
|
||||
{
|
||||
collisionRule = readString( buf );
|
||||
}
|
||||
color = buf.readByte();
|
||||
color = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? readVarInt( buf ) : buf.readByte();
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
|
||||
{
|
||||
prefix = readString( buf );
|
||||
suffix = readString( buf );
|
||||
}
|
||||
}
|
||||
if ( mode == 0 || mode == 3 || mode == 4 )
|
||||
{
|
||||
@ -76,16 +84,28 @@ public class Team extends DefinedPacket
|
||||
if ( mode == 0 || mode == 2 )
|
||||
{
|
||||
writeString( displayName, buf );
|
||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_13 )
|
||||
{
|
||||
writeString( prefix, buf );
|
||||
writeString( suffix, buf );
|
||||
}
|
||||
buf.writeByte( friendlyFire );
|
||||
writeString( nameTagVisibility, buf );
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
|
||||
{
|
||||
writeString( collisionRule, buf );
|
||||
}
|
||||
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
|
||||
{
|
||||
writeVarInt( color, buf );
|
||||
writeString( prefix, buf );
|
||||
writeString( suffix, buf );
|
||||
} else
|
||||
{
|
||||
buf.writeByte( color );
|
||||
}
|
||||
}
|
||||
if ( mode == 0 || mode == 3 || mode == 4 )
|
||||
{
|
||||
writeVarInt( players.length, buf );
|
||||
|
@ -0,0 +1,17 @@
|
||||
package net.md_5.bungee.protocol.packet;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PluginMessageTest
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testModerniseChannel()
|
||||
{
|
||||
Assert.assertEquals( "bungeecord:main", PluginMessage.MODERNISE.apply( "BungeeCord" ) );
|
||||
Assert.assertEquals( "BungeeCord", PluginMessage.MODERNISE.apply( "bungeecord:main" ) );
|
||||
Assert.assertEquals( "bungeecord:legacy/foo", PluginMessage.MODERNISE.apply( "FoO" ) );
|
||||
Assert.assertEquals( "foo:bar", PluginMessage.MODERNISE.apply( "foo:bar" ) );
|
||||
}
|
||||
}
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-proxy</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Proxy</name>
|
||||
|
@ -246,7 +246,6 @@ public class BungeeCord extends ProxyServer
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
|
||||
public void start() throws Exception
|
||||
{
|
||||
@ -616,8 +615,13 @@ public class BungeeCord extends ProxyServer
|
||||
return Collections.unmodifiableCollection( pluginChannels );
|
||||
}
|
||||
|
||||
public PluginMessage registerChannels()
|
||||
public PluginMessage registerChannels(int protocolVersion)
|
||||
{
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
|
||||
{
|
||||
return new PluginMessage( "minecraft:register", Util.format( Iterables.transform( pluginChannels, PluginMessage.MODERNISE ), "\00" ).getBytes( Charsets.UTF_8 ), false );
|
||||
}
|
||||
|
||||
return new PluginMessage( "REGISTER", Util.format( pluginChannels, "\00" ).getBytes( Charsets.UTF_8 ), false );
|
||||
}
|
||||
|
||||
|
@ -14,5 +14,4 @@ public class PacketConstants
|
||||
{
|
||||
0, 0, 0, 0, 0, 2
|
||||
}, false );
|
||||
public static final PluginMessage I_AM_BUNGEE = new PluginMessage( "BungeeCord", new byte[ 0 ], false );
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import io.netty.buffer.ByteBufAllocator;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
@ -30,7 +31,9 @@ import net.md_5.bungee.netty.ChannelWrapper;
|
||||
import net.md_5.bungee.netty.HandlerBoss;
|
||||
import net.md_5.bungee.netty.PacketHandler;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
import net.md_5.bungee.protocol.Protocol;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||
import net.md_5.bungee.protocol.packet.Handshake;
|
||||
import net.md_5.bungee.protocol.packet.Kick;
|
||||
@ -42,6 +45,7 @@ import net.md_5.bungee.protocol.packet.Respawn;
|
||||
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
||||
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||
import net.md_5.bungee.util.BufUtil;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class ServerConnector extends PacketHandler
|
||||
@ -118,6 +122,15 @@ public class ServerConnector extends PacketHandler
|
||||
user.getPendingConnects().remove( target );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketWrapper packet) throws Exception
|
||||
{
|
||||
if ( packet.packet == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "Unexpected packet received during server login process!\n" + BufUtil.dump( packet.buf, 64 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(LoginSuccess loginSuccess) throws Exception
|
||||
{
|
||||
@ -162,7 +175,7 @@ public class ServerConnector extends PacketHandler
|
||||
ServerConnectedEvent event = new ServerConnectedEvent( user, server );
|
||||
bungee.getPluginManager().callEvent( event );
|
||||
|
||||
ch.write( BungeeCord.getInstance().registerChannels() );
|
||||
ch.write( BungeeCord.getInstance().registerChannels( user.getPendingConnection().getVersion() ) );
|
||||
Queue<DefinedPacket> packetQueue = target.getPacketQueue();
|
||||
synchronized ( packetQueue )
|
||||
{
|
||||
@ -201,7 +214,7 @@ public class ServerConnector extends PacketHandler
|
||||
|
||||
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
||||
DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand );
|
||||
user.unsafe().sendPacket( new PluginMessage( "MC|Brand", DefinedPacket.toArray( brand ), handshakeHandler.isServerForge() ) );
|
||||
user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", DefinedPacket.toArray( brand ), handshakeHandler.isServerForge() ) );
|
||||
brand.release();
|
||||
|
||||
user.setDimension( login.getDimension() );
|
||||
@ -213,7 +226,7 @@ public class ServerConnector extends PacketHandler
|
||||
Scoreboard serverScoreboard = user.getServerSentScoreboard();
|
||||
for ( Objective objective : serverScoreboard.getObjectives() )
|
||||
{
|
||||
user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), objective.getType(), (byte) 1 ) );
|
||||
user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), ScoreboardObjective.HealthDisplay.fromString( objective.getType() ), (byte) 1 ) );
|
||||
}
|
||||
for ( Score score : serverScoreboard.getScores() )
|
||||
{
|
||||
|
@ -30,6 +30,7 @@ import net.md_5.bungee.netty.ChannelWrapper;
|
||||
import net.md_5.bungee.netty.PacketHandler;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.packet.BossBar;
|
||||
import net.md_5.bungee.protocol.packet.KeepAlive;
|
||||
import net.md_5.bungee.protocol.packet.PlayerListItem;
|
||||
@ -125,7 +126,7 @@ public class DownstreamBridge extends PacketHandler
|
||||
switch ( objective.getAction() )
|
||||
{
|
||||
case 0:
|
||||
serverScoreboard.addObjective( new Objective( objective.getName(), objective.getValue(), objective.getType() ) );
|
||||
serverScoreboard.addObjective( new Objective( objective.getName(), objective.getValue(), objective.getType().toString() ) );
|
||||
break;
|
||||
case 1:
|
||||
serverScoreboard.removeObjective( objective.getName() );
|
||||
@ -135,7 +136,7 @@ public class DownstreamBridge extends PacketHandler
|
||||
if ( oldObjective != null )
|
||||
{
|
||||
oldObjective.setValue( objective.getValue() );
|
||||
oldObjective.setType( objective.getType() );
|
||||
oldObjective.setType( objective.getType().toString() );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -231,7 +232,7 @@ public class DownstreamBridge extends PacketHandler
|
||||
throw CancelSendSignal.INSTANCE;
|
||||
}
|
||||
|
||||
if ( pluginMessage.getTag().equals( "MC|Brand" ) )
|
||||
if ( pluginMessage.getTag().equals( con.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand" ) )
|
||||
{
|
||||
ByteBuf brand = Unpooled.wrappedBuffer( pluginMessage.getData() );
|
||||
String serverBrand = DefinedPacket.readString( brand );
|
||||
@ -476,6 +477,12 @@ public class DownstreamBridge extends PacketHandler
|
||||
@Override
|
||||
public void handle(TabCompleteResponse tabCompleteResponse) throws Exception
|
||||
{
|
||||
if ( tabCompleteResponse.getCommands() == null )
|
||||
{
|
||||
// Passthrough on 1.13 style command responses - unclear of a sane way to process them at the moment, contributions welcome
|
||||
return;
|
||||
}
|
||||
|
||||
TabCompleteResponseEvent tabCompleteResponseEvent = new TabCompleteResponseEvent( server, con, tabCompleteResponse.getCommands() );
|
||||
|
||||
if ( !bungee.getPluginManager().callEvent( tabCompleteResponseEvent ).isCancelled() )
|
||||
|
@ -57,6 +57,7 @@ import net.md_5.bungee.protocol.packet.Handshake;
|
||||
import net.md_5.bungee.protocol.packet.Kick;
|
||||
import net.md_5.bungee.protocol.packet.LegacyHandshake;
|
||||
import net.md_5.bungee.protocol.packet.LegacyPing;
|
||||
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
||||
import net.md_5.bungee.protocol.packet.LoginRequest;
|
||||
import net.md_5.bungee.protocol.packet.LoginSuccess;
|
||||
import net.md_5.bungee.protocol.packet.PingPacket;
|
||||
@ -64,6 +65,7 @@ import net.md_5.bungee.protocol.packet.PluginMessage;
|
||||
import net.md_5.bungee.protocol.packet.StatusRequest;
|
||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||
import net.md_5.bungee.util.BoundedArrayList;
|
||||
import net.md_5.bungee.util.BufUtil;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
@ -129,6 +131,15 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
disconnect( ChatColor.RED + Util.exception( t ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketWrapper packet) throws Exception
|
||||
{
|
||||
if ( packet.packet == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "Unexpected packet received during login process!\n" + BufUtil.dump( packet.buf, 64 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PluginMessage pluginMessage) throws Exception
|
||||
{
|
||||
@ -532,6 +543,12 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
bungee.getPluginManager().callEvent( new LoginEvent( InitialHandler.this, complete ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(LoginPayloadResponse response) throws Exception
|
||||
{
|
||||
disconnect( "Unexpected custom LoginPayloadResponse" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(String reason)
|
||||
{
|
||||
|
@ -13,10 +13,12 @@ import net.md_5.bungee.netty.PacketHandler;
|
||||
import net.md_5.bungee.netty.PipelineUtils;
|
||||
import net.md_5.bungee.protocol.MinecraftDecoder;
|
||||
import net.md_5.bungee.protocol.MinecraftEncoder;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
import net.md_5.bungee.protocol.Protocol;
|
||||
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;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class PingHandler extends PacketHandler
|
||||
@ -48,6 +50,15 @@ public class PingHandler extends PacketHandler
|
||||
callback.done( null, t );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketWrapper packet) throws Exception
|
||||
{
|
||||
if ( packet.packet == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "Unexpected packet received during ping process!\n" + BufUtil.dump( packet.buf, 64 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
|
||||
public void handle(StatusResponse statusResponse) throws Exception
|
||||
|
@ -40,7 +40,7 @@ public class UpstreamBridge extends PacketHandler
|
||||
|
||||
BungeeCord.getInstance().addConnection( con );
|
||||
con.getTabListHandler().onConnect();
|
||||
con.unsafe().sendPacket( BungeeCord.getInstance().registerChannels() );
|
||||
con.unsafe().sendPacket( BungeeCord.getInstance().registerChannels( con.getPendingConnection().getVersion() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -166,8 +166,13 @@ public class UpstreamBridge extends PacketHandler
|
||||
|
||||
List<String> results = tabCompleteEvent.getSuggestions();
|
||||
if ( !results.isEmpty() )
|
||||
{
|
||||
// Unclear how to handle 1.13 commands at this point. Because we don't inject into the command packets we are unlikely to get this far unless
|
||||
// Bungee plugins are adding results for commands they don't own anyway
|
||||
if ( con.getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_13 )
|
||||
{
|
||||
con.unsafe().sendPacket( new TabCompleteResponse( results ) );
|
||||
}
|
||||
throw CancelSendSignal.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,8 @@ public abstract class EntityMap
|
||||
case ProtocolConstants.MINECRAFT_1_12_1:
|
||||
case ProtocolConstants.MINECRAFT_1_12_2:
|
||||
return EntityMap_1_12_1.INSTANCE;
|
||||
case ProtocolConstants.MINECRAFT_1_13:
|
||||
return EntityMap_1_13.INSTANCE;
|
||||
}
|
||||
throw new RuntimeException( "Version " + version + " has no entity map" );
|
||||
}
|
||||
@ -76,11 +78,21 @@ public abstract class EntityMap
|
||||
rewrite( packet, oldId, newId, serverboundInts, serverboundVarInts );
|
||||
}
|
||||
|
||||
public void rewriteServerbound(ByteBuf packet, int oldId, int newId, int protocolVersion)
|
||||
{
|
||||
rewriteServerbound( packet, oldId, newId );
|
||||
}
|
||||
|
||||
public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
|
||||
{
|
||||
rewrite( packet, oldId, newId, clientboundInts, clientboundVarInts );
|
||||
}
|
||||
|
||||
public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion)
|
||||
{
|
||||
rewriteClientbound( packet, oldId, newId );
|
||||
}
|
||||
|
||||
protected static void rewriteInt(ByteBuf packet, int oldId, int newId, int offset)
|
||||
{
|
||||
int readId = packet.getInt( offset );
|
||||
@ -111,6 +123,11 @@ public abstract class EntityMap
|
||||
}
|
||||
|
||||
protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, int metaIndex)
|
||||
{
|
||||
rewriteMetaVarInt( packet, oldId, newId, metaIndex, -1 );
|
||||
}
|
||||
|
||||
protected static void rewriteMetaVarInt(ByteBuf packet, int oldId, int newId, int metaIndex, int protocolVersion)
|
||||
{
|
||||
int readerIndex = packet.readerIndex();
|
||||
|
||||
@ -118,6 +135,37 @@ public abstract class EntityMap
|
||||
while ( ( index = packet.readUnsignedByte() ) != 0xFF )
|
||||
{
|
||||
int type = DefinedPacket.readVarInt( packet );
|
||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 )
|
||||
{
|
||||
switch ( type )
|
||||
{
|
||||
case 5: // optional chat
|
||||
if ( packet.readBoolean() )
|
||||
{
|
||||
DefinedPacket.readString( packet );
|
||||
}
|
||||
break;
|
||||
case 14: // particle
|
||||
int particleId = DefinedPacket.readVarInt( packet );
|
||||
switch ( particleId )
|
||||
{
|
||||
case 3:
|
||||
case 20:
|
||||
DefinedPacket.readVarInt( packet ); // block state
|
||||
break;
|
||||
case 11: // dust
|
||||
packet.skipBytes( 16 ); // float, float, float, flat
|
||||
break;
|
||||
case 27: // item
|
||||
readSkipSlot( packet );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
type--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
@ -141,24 +189,7 @@ public abstract class EntityMap
|
||||
DefinedPacket.readString( packet );
|
||||
break;
|
||||
case 5:
|
||||
if ( packet.readShort() != -1 )
|
||||
{
|
||||
packet.skipBytes( 3 ); // byte, short
|
||||
|
||||
int position = packet.readerIndex();
|
||||
if ( packet.readByte() != 0 )
|
||||
{
|
||||
packet.readerIndex( position );
|
||||
|
||||
try
|
||||
{
|
||||
new NBTInputStream( new ByteBufInputStream( packet ), false ).readTag();
|
||||
} catch ( IOException ex )
|
||||
{
|
||||
throw Throwables.propagate( ex );
|
||||
}
|
||||
}
|
||||
}
|
||||
readSkipSlot( packet );
|
||||
break;
|
||||
case 6:
|
||||
packet.skipBytes( 1 ); // boolean
|
||||
@ -204,6 +235,28 @@ public abstract class EntityMap
|
||||
packet.readerIndex( readerIndex );
|
||||
}
|
||||
|
||||
private static void readSkipSlot(ByteBuf packet)
|
||||
{
|
||||
if ( packet.readShort() != -1 )
|
||||
{
|
||||
packet.skipBytes( 3 ); // byte, short
|
||||
|
||||
int position = packet.readerIndex();
|
||||
if ( packet.readByte() != 0 )
|
||||
{
|
||||
packet.readerIndex( position );
|
||||
|
||||
try
|
||||
{
|
||||
new NBTInputStream( new ByteBufInputStream( packet ), false ).readTag();
|
||||
} catch ( IOException ex )
|
||||
{
|
||||
throw Throwables.propagate( ex );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handles simple packets
|
||||
private static void rewrite(ByteBuf packet, int oldId, int newId, boolean[] ints, boolean[] varints)
|
||||
{
|
||||
|
@ -0,0 +1,183 @@
|
||||
package net.md_5.bungee.entitymap;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.UserConnection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
class EntityMap_1_13 extends EntityMap
|
||||
{
|
||||
|
||||
static final EntityMap_1_13 INSTANCE = new EntityMap_1_13();
|
||||
|
||||
EntityMap_1_13()
|
||||
{
|
||||
addRewrite( 0x00, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Object : PacketPlayOutSpawnEntity
|
||||
addRewrite( 0x01, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Experience Orb : PacketPlayOutSpawnEntityExperienceOrb
|
||||
addRewrite( 0x03, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Mob : PacketPlayOutSpawnEntityLiving
|
||||
addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Painting : PacketPlayOutSpawnEntityPainting
|
||||
addRewrite( 0x05, ProtocolConstants.Direction.TO_CLIENT, true ); // Spawn Player : PacketPlayOutNamedEntitySpawn
|
||||
addRewrite( 0x06, ProtocolConstants.Direction.TO_CLIENT, true ); // Animation : PacketPlayOutAnimation
|
||||
addRewrite( 0x08, ProtocolConstants.Direction.TO_CLIENT, true ); // Block Break Animation : PacketPlayOutBlockBreakAnimation
|
||||
addRewrite( 0x1C, ProtocolConstants.Direction.TO_CLIENT, false ); // Entity Status : PacketPlayOutEntityStatus
|
||||
addRewrite( 0x27, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity : PacketPlayOutEntity
|
||||
addRewrite( 0x28, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Relative Move : PacketPlayOutRelEntityMove
|
||||
addRewrite( 0x29, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look and Relative Move : PacketPlayOutRelEntityMoveLook
|
||||
addRewrite( 0x2A, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Look : PacketPlayOutEntityLook
|
||||
addRewrite( 0x33, ProtocolConstants.Direction.TO_CLIENT, true ); // Use bed : PacketPlayOutBed
|
||||
addRewrite( 0x36, ProtocolConstants.Direction.TO_CLIENT, true ); // Remove Entity Effect : PacketPlayOutRemoveEntityEffect
|
||||
addRewrite( 0x39, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Head Look : PacketPlayOutEntityHeadRotation
|
||||
addRewrite( 0x3C, ProtocolConstants.Direction.TO_CLIENT, true ); // Camera : PacketPlayOutCamera
|
||||
addRewrite( 0x3F, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Metadata : PacketPlayOutEntityMetadata
|
||||
addRewrite( 0x40, ProtocolConstants.Direction.TO_CLIENT, false ); // Attach Entity : PacketPlayOutAttachEntity
|
||||
addRewrite( 0x41, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Velocity : PacketPlayOutEntityVelocity
|
||||
addRewrite( 0x42, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment : PacketPlayOutEntityEquipment
|
||||
addRewrite( 0x46, ProtocolConstants.Direction.TO_CLIENT, true ); // Set Passengers : PacketPlayOutMount
|
||||
addRewrite( 0x4F, ProtocolConstants.Direction.TO_CLIENT, true ); // Collect Item : PacketPlayOutCollect
|
||||
addRewrite( 0x50, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Teleport : PacketPlayOutEntityTeleport
|
||||
addRewrite( 0x52, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Properties : PacketPlayOutUpdateAttributes
|
||||
addRewrite( 0x53, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Effect : PacketPlayOutEntityEffect
|
||||
|
||||
addRewrite( 0x0D, ProtocolConstants.Direction.TO_SERVER, true ); // Use Entity : PacketPlayInUseEntity
|
||||
addRewrite( 0x19, ProtocolConstants.Direction.TO_SERVER, true ); // Entity Action : PacketPlayInEntityAction
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
||||
public void rewriteClientbound(ByteBuf packet, int oldId, int newId, int protocolVersion)
|
||||
{
|
||||
super.rewriteClientbound( packet, oldId, newId );
|
||||
|
||||
// Special cases
|
||||
int readerIndex = packet.readerIndex();
|
||||
int packetId = DefinedPacket.readVarInt( packet );
|
||||
int packetIdLength = packet.readerIndex() - readerIndex;
|
||||
int jumpIndex = packet.readerIndex();
|
||||
switch ( packetId )
|
||||
{
|
||||
case 0x40 /* Attach Entity : PacketPlayOutAttachEntity */:
|
||||
rewriteInt( packet, oldId, newId, readerIndex + packetIdLength + 4 );
|
||||
break;
|
||||
case 0x4F /* Collect Item : PacketPlayOutCollect */:
|
||||
DefinedPacket.readVarInt( packet );
|
||||
rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
||||
break;
|
||||
case 0x46 /* Set Passengers : PacketPlayOutMount */:
|
||||
DefinedPacket.readVarInt( packet );
|
||||
jumpIndex = packet.readerIndex();
|
||||
// Fall through on purpose to int array of IDs
|
||||
case 0x35 /* Destroy Entities : PacketPlayOutEntityDestroy */:
|
||||
int count = DefinedPacket.readVarInt( packet );
|
||||
int[] ids = new int[ count ];
|
||||
for ( int i = 0; i < count; i++ )
|
||||
{
|
||||
ids[i] = DefinedPacket.readVarInt( packet );
|
||||
}
|
||||
packet.readerIndex( jumpIndex );
|
||||
packet.writerIndex( jumpIndex );
|
||||
DefinedPacket.writeVarInt( count, packet );
|
||||
for ( int id : ids )
|
||||
{
|
||||
if ( id == oldId )
|
||||
{
|
||||
id = newId;
|
||||
} else if ( id == newId )
|
||||
{
|
||||
id = oldId;
|
||||
}
|
||||
DefinedPacket.writeVarInt( id, packet );
|
||||
}
|
||||
break;
|
||||
case 0x00 /* Spawn Object : PacketPlayOutSpawnEntity */:
|
||||
DefinedPacket.readVarInt( packet );
|
||||
DefinedPacket.readUUID( packet );
|
||||
int type = packet.readUnsignedByte();
|
||||
|
||||
if ( type == 60 || type == 90 || type == 91 )
|
||||
{
|
||||
if ( type == 60 || type == 91 )
|
||||
{
|
||||
oldId = oldId + 1;
|
||||
newId = newId + 1;
|
||||
}
|
||||
|
||||
packet.skipBytes( 26 ); // double, double, double, byte, byte
|
||||
int position = packet.readerIndex();
|
||||
int readId = packet.readInt();
|
||||
if ( readId == oldId )
|
||||
{
|
||||
packet.setInt( position, newId );
|
||||
} else if ( readId == newId )
|
||||
{
|
||||
packet.setInt( position, oldId );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x05 /* Spawn Player : PacketPlayOutNamedEntitySpawn */:
|
||||
DefinedPacket.readVarInt( packet ); // Entity ID
|
||||
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
||||
UUID uuid = DefinedPacket.readUUID( packet );
|
||||
ProxiedPlayer player;
|
||||
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
||||
{
|
||||
int previous = packet.writerIndex();
|
||||
packet.readerIndex( readerIndex );
|
||||
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
||||
DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
||||
packet.writerIndex( previous );
|
||||
}
|
||||
break;
|
||||
case 0x2F /* Combat Event : PacketPlayOutCombatEvent */:
|
||||
int event = packet.readUnsignedByte();
|
||||
if ( event == 1 /* End Combat*/ )
|
||||
{
|
||||
DefinedPacket.readVarInt( packet );
|
||||
rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
||||
} else if ( event == 2 /* Entity Dead */ )
|
||||
{
|
||||
int position = packet.readerIndex();
|
||||
rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
||||
packet.readerIndex( position );
|
||||
DefinedPacket.readVarInt( packet );
|
||||
rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
||||
}
|
||||
break;
|
||||
case 0x3F /* EntityMetadata : PacketPlayOutEntityMetadata */:
|
||||
DefinedPacket.readVarInt( packet ); // Entity ID
|
||||
rewriteMetaVarInt( packet, oldId + 1, newId + 1, 6, protocolVersion ); // fishing hook
|
||||
rewriteMetaVarInt( packet, oldId, newId, 7, protocolVersion ); // fireworks (et al)
|
||||
break;
|
||||
}
|
||||
packet.readerIndex( readerIndex );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rewriteServerbound(ByteBuf packet, int oldId, int newId)
|
||||
{
|
||||
super.rewriteServerbound( packet, oldId, newId );
|
||||
// Special cases
|
||||
int readerIndex = packet.readerIndex();
|
||||
int packetId = DefinedPacket.readVarInt( packet );
|
||||
int packetIdLength = packet.readerIndex() - readerIndex;
|
||||
|
||||
if ( packetId == 0x28 /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
||||
{
|
||||
UUID uuid = DefinedPacket.readUUID( packet );
|
||||
ProxiedPlayer player;
|
||||
if ( ( player = BungeeCord.getInstance().getPlayer( uuid ) ) != null )
|
||||
{
|
||||
int previous = packet.writerIndex();
|
||||
packet.readerIndex( readerIndex );
|
||||
packet.writerIndex( readerIndex + packetIdLength );
|
||||
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
||||
packet.writerIndex( previous );
|
||||
}
|
||||
}
|
||||
packet.readerIndex( readerIndex );
|
||||
}
|
||||
}
|
15
proxy/src/main/java/net/md_5/bungee/util/BufUtil.java
Normal file
15
proxy/src/main/java/net/md_5/bungee/util/BufUtil.java
Normal file
@ -0,0 +1,15 @@
|
||||
package net.md_5.bungee.util;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
public class BufUtil
|
||||
{
|
||||
|
||||
public static String dump(ByteBuf buf, int maxLen)
|
||||
{
|
||||
return ByteBufUtil.hexDump( buf, 0, Math.min( buf.writerIndex(), maxLen ) );
|
||||
}
|
||||
}
|
@ -6,13 +6,13 @@
|
||||
<parent>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-query</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<version>1.13-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Query</name>
|
||||
|
Loading…
Reference in New Issue
Block a user