Compare commits
1 Commits
5a1e342e0d
...
patch-loop
Author | SHA1 | Date | |
---|---|---|---|
6949470e3b
|
63
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
63
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -1,63 +0,0 @@
|
|||||||
name: Bug inside BungeeCord
|
|
||||||
description: Create a bug report about a problem inside BungeeCord.
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
#### Report a bug inside bungeecord
|
|
||||||
Issues happening with forks of BungeeCord should **not** be reported here.
|
|
||||||
- type: input
|
|
||||||
id: bungee-version
|
|
||||||
attributes:
|
|
||||||
label: Bungeecord version
|
|
||||||
description: The output of the /bungee command (or just the bungee build number) (execute in bungeecord console for easy text copy)
|
|
||||||
placeholder: e.g. git:BungeeCord-Bootstrap:1.xx-SNAPSHOT:xxxxxxx:xxxx
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: input
|
|
||||||
id: server-version
|
|
||||||
attributes:
|
|
||||||
label: Server version
|
|
||||||
description: The output of the /version command (execute in server console for easy text copy)
|
|
||||||
placeholder: "e.g. git-Spigot-xxxxxxx-xxxxxxx (MC: 1.x.x)"
|
|
||||||
- type: input
|
|
||||||
id: client-version
|
|
||||||
attributes:
|
|
||||||
label: Client version
|
|
||||||
description: Minecraft Client Version
|
|
||||||
placeholder: e.g. 1.18.2
|
|
||||||
- type: textarea
|
|
||||||
id: bungee-plugins
|
|
||||||
attributes:
|
|
||||||
label: Bungeecord plugins
|
|
||||||
description: Please list all BungeeCord plugins you are using.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
id: the-bug
|
|
||||||
attributes:
|
|
||||||
label: The bug
|
|
||||||
description: Please describe the bug. Include **details** you find neccessary. If you just have a question, please ask it in [SpigotMC Forums](https://www.spigotmc.org) and not here.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
id: logs
|
|
||||||
attributes:
|
|
||||||
label: Log output (links)
|
|
||||||
description: Please put your log output inbetween three backticks (```` ``` ````). Upload your log files to [gist.github.com](https://gist.github.com) and put them in here.
|
|
||||||
placeholder: |
|
|
||||||
```
|
|
||||||
log output
|
|
||||||
```
|
|
||||||
- type: checkboxes
|
|
||||||
id: checkboxes
|
|
||||||
attributes:
|
|
||||||
label: Checking
|
|
||||||
options:
|
|
||||||
- label: I am using BungeeCord and **not a fork**. Issues with forks should not be reported here.
|
|
||||||
required: true
|
|
||||||
- label: I think this is **not** an issue with a bungeecord plugin.
|
|
||||||
required: true
|
|
||||||
- label: I have not read these checkboxes and therefore I just ticked them all.
|
|
||||||
- label: This is not a question or plugin creation help request.
|
|
||||||
required: true
|
|
14
.github/ISSUE_TEMPLATE/config.yml
vendored
14
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,14 +0,0 @@
|
|||||||
blank_issues_enabled: false
|
|
||||||
contact_links:
|
|
||||||
- name: Configuration help
|
|
||||||
url: https://www.spigotmc.org/forums/bungeecord-help.70/create-thread
|
|
||||||
about: Help for configuring bungeecord will only be answered in spigotmc.org forums.
|
|
||||||
- name: I have a problem with a bungee plugin
|
|
||||||
url: https://www.spigotmc.org/forums/bungeecord-plugin-help.71/create-thread
|
|
||||||
about: Help about plugins can be recieved in spigotmc.org forums.
|
|
||||||
- name: Questions and discussions
|
|
||||||
url: https://www.spigotmc.org/forums/bungeecord-discussion.21/create-thread
|
|
||||||
about: spigotmc.org forums are the best place to ask your questions regarding bungeecord.
|
|
||||||
- name: Plugin creation help
|
|
||||||
url: https://www.spigotmc.org/forums/bungeecord-plugin-development.23/create-thread
|
|
||||||
about: Plugin creation help for bungee plugins can be recieved in spigotmc.org forums.
|
|
36
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
36
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
@@ -1,36 +0,0 @@
|
|||||||
name: Feature request
|
|
||||||
description: Suggest a feature which bungeecord should include.
|
|
||||||
body:
|
|
||||||
- type: textarea
|
|
||||||
id: the-feature
|
|
||||||
attributes:
|
|
||||||
label: Feature description
|
|
||||||
description: Please describe your feature or improvement. Please include **details**.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
id: goal
|
|
||||||
attributes:
|
|
||||||
label: Goal of the feature
|
|
||||||
description: What is the goal of your feature?
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: textarea
|
|
||||||
id: alternatives
|
|
||||||
attributes:
|
|
||||||
label: Unfitting alternatives
|
|
||||||
description: What alternatives have you considered and why are they not sufficient for your use case?
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: checkboxes
|
|
||||||
id: checkboxes
|
|
||||||
attributes:
|
|
||||||
label: Checking
|
|
||||||
options:
|
|
||||||
- label: This is not a question or plugin creation help request.
|
|
||||||
required: true
|
|
||||||
- label: This is a **feature or improvement request**.
|
|
||||||
required: true
|
|
||||||
- label: I have not read these checkboxes and therefore I just ticked them all.
|
|
||||||
- label: I did not use this form to report a bug.
|
|
||||||
required: true
|
|
28
.github/dependabot.yml
vendored
28
.github/dependabot.yml
vendored
@@ -1,28 +0,0 @@
|
|||||||
version: 2
|
|
||||||
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: "maven"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "daily"
|
|
||||||
open-pull-requests-limit: 50
|
|
||||||
ignore:
|
|
||||||
# Synchronised with Minecraft
|
|
||||||
- dependency-name: "com.google.code.gson:gson"
|
|
||||||
# 9.x has performance issues (see, eg, checkstyle/checkstyle#10934) and 10.x is incompatible
|
|
||||||
- dependency-name: "com.puppycrawl.tools:checkstyle"
|
|
||||||
# Newer versions have issues, see #1909 and #2050
|
|
||||||
- dependency-name: "jline:jline"
|
|
||||||
# Later versions of these Maven dependencies are incompatible and require careful management - see SPIGOT-7400
|
|
||||||
- dependency-name: "org.apache.maven.resolver:maven-resolver-connector-basic"
|
|
||||||
- dependency-name: "org.apache.maven.resolver:maven-resolver-transport-http"
|
|
||||||
- dependency-name: "org.apache.maven:maven-resolver-provider"
|
|
||||||
# Used with maven-resolver dependencies; 2.0 update breaks other providers
|
|
||||||
- dependency-name: "org.slf4j:slf4j-api"
|
|
||||||
update-types: ["version-update:semver-major"]
|
|
||||||
|
|
||||||
- package-ecosystem: "github-actions"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "daily"
|
|
||||||
open-pull-requests-limit: 50
|
|
10
.github/workflows/maven.yml
vendored
10
.github/workflows/maven.yml
vendored
@@ -4,20 +4,18 @@ on: [push, pull_request]
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
matrix:
|
||||||
java: [8, 11, 17, 21]
|
java: [8, 11]
|
||||||
|
|
||||||
name: Java ${{ matrix.java }}
|
name: Java ${{ matrix.java }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-java@v3
|
- uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
distribution: zulu
|
|
||||||
java-version: ${{ matrix.java }}
|
java-version: ${{ matrix.java }}
|
||||||
- run: java -version && mvn --version
|
- run: java -version && mvn --version
|
||||||
- run: mvn --activate-profiles dist --no-transfer-progress package
|
- run: mvn --activate-profiles dist --no-transfer-progress package
|
||||||
|
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -1,6 +0,0 @@
|
|||||||
[submodule "native/mbedtls"]
|
|
||||||
path = native/mbedtls
|
|
||||||
url = https://github.com/ARMmbed/mbedtls.git
|
|
||||||
[submodule "native/zlib"]
|
|
||||||
path = native/zlib
|
|
||||||
url = https://github.com/cloudflare/zlib.git
|
|
@@ -23,4 +23,4 @@ Binaries
|
|||||||
--------
|
--------
|
||||||
Precompiled binaries are available for end users on [Jenkins](https://www.spigotmc.org/go/bungeecord-dl).
|
Precompiled binaries are available for end users on [Jenkins](https://www.spigotmc.org/go/bungeecord-dl).
|
||||||
|
|
||||||
(c) 2012-2023 SpigotMC Pty. Ltd.
|
(c) 2012-2020 SpigotMC Pty. Ltd.
|
||||||
|
28
api/pom.xml
28
api/pom.xml
@@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-api</artifactId>
|
<artifactId>bungeecord-api</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-API</name>
|
<name>BungeeCord-API</name>
|
||||||
@@ -46,33 +46,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty</groupId>
|
<groupId>io.netty</groupId>
|
||||||
<artifactId>netty-transport-native-unix-common</artifactId>
|
<artifactId>netty-transport-native-unix-common</artifactId>
|
||||||
|
<version>${netty.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.maven</groupId>
|
|
||||||
<artifactId>maven-resolver-provider</artifactId>
|
|
||||||
<version>3.8.5</version>
|
|
||||||
<!-- not part of the API proper -->
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.maven.resolver</groupId>
|
|
||||||
<artifactId>maven-resolver-connector-basic</artifactId>
|
|
||||||
<version>1.7.3</version>
|
|
||||||
<!-- not part of the API proper -->
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.maven.resolver</groupId>
|
|
||||||
<artifactId>maven-resolver-transport-http</artifactId>
|
|
||||||
<version>1.7.3</version>
|
|
||||||
<!-- not part of the API proper -->
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.yaml</groupId>
|
<groupId>org.yaml</groupId>
|
||||||
<artifactId>snakeyaml</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
<version>2.2</version>
|
<version>1.26</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@@ -7,7 +7,6 @@ import java.net.InetSocketAddress;
|
|||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,17 +68,6 @@ public class Util
|
|||||||
return String.format( "0x%02X", i );
|
return String.format( "0x%02X", i );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Formats an char as a unicode value.
|
|
||||||
*
|
|
||||||
* @param c the character to format
|
|
||||||
* @return the unicode representation of the character
|
|
||||||
*/
|
|
||||||
public static String unicode(char c)
|
|
||||||
{
|
|
||||||
return "\\u" + String.format( "%04x", (int) c ).toUpperCase( Locale.ROOT );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a pretty one line version of a {@link Throwable}. Useful for
|
* Constructs a pretty one line version of a {@link Throwable}. Useful for
|
||||||
* debugging.
|
* debugging.
|
||||||
@@ -88,24 +76,11 @@ public class Util
|
|||||||
* @return a string representing information about the {@link Throwable}
|
* @return a string representing information about the {@link Throwable}
|
||||||
*/
|
*/
|
||||||
public static String exception(Throwable t)
|
public static String exception(Throwable t)
|
||||||
{
|
|
||||||
return exception( t, true );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a pretty one line version of a {@link Throwable}. Useful for
|
|
||||||
* debugging.
|
|
||||||
*
|
|
||||||
* @param t the {@link Throwable} to format.
|
|
||||||
* @param includeLineNumbers whether to include line numbers
|
|
||||||
* @return a string representing information about the {@link Throwable}
|
|
||||||
*/
|
|
||||||
public static String exception(Throwable t, boolean includeLineNumbers)
|
|
||||||
{
|
{
|
||||||
// TODO: We should use clear manually written exceptions
|
// TODO: We should use clear manually written exceptions
|
||||||
StackTraceElement[] trace = t.getStackTrace();
|
StackTraceElement[] trace = t.getStackTrace();
|
||||||
return t.getClass().getSimpleName() + " : " + t.getMessage()
|
return t.getClass().getSimpleName() + " : " + t.getMessage()
|
||||||
+ ( ( includeLineNumbers && trace.length > 0 ) ? " @ " + t.getStackTrace()[0].getClassName() + ":" + t.getStackTrace()[0].getLineNumber() : "" );
|
+ ( ( trace.length > 0 ) ? " @ " + t.getStackTrace()[0].getClassName() + ":" + t.getStackTrace()[0].getLineNumber() : "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String csv(Iterable<?> objects)
|
public static String csv(Iterable<?> objects)
|
||||||
@@ -113,16 +88,6 @@ public class Util
|
|||||||
return format( objects, ", " );
|
return format( objects, ", " );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a string of objects, each separated by a separator.
|
|
||||||
*
|
|
||||||
* @param objects the objects to join
|
|
||||||
* @param separators the separator
|
|
||||||
* @return joined string
|
|
||||||
* @see String#join(java.lang.CharSequence, java.lang.Iterable)
|
|
||||||
* @deprecated use {@link String} join methods
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static String format(Iterable<?> objects, String separators)
|
public static String format(Iterable<?> objects, String separators)
|
||||||
{
|
{
|
||||||
return Joiner.on( separators ).join( objects );
|
return Joiner.on( separators ).join( objects );
|
||||||
|
@@ -28,13 +28,18 @@ public abstract class AbstractReconnectHandler implements ReconnectHandler
|
|||||||
|
|
||||||
public static ServerInfo getForcedHost(PendingConnection con)
|
public static ServerInfo getForcedHost(PendingConnection con)
|
||||||
{
|
{
|
||||||
String forced = ( con.getVirtualHost() == null ) ? null : con.getListener().getForcedHosts().get( con.getVirtualHost().getHostString() );
|
if ( con.getVirtualHost() == null )
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String forced = con.getListener().getForcedHosts().get( con.getVirtualHost().getHostString() );
|
||||||
|
|
||||||
if ( forced == null && con.getListener().isForceDefault() )
|
if ( forced == null && con.getListener().isForceDefault() )
|
||||||
{
|
{
|
||||||
forced = con.getListener().getDefaultServer();
|
forced = con.getListener().getDefaultServer();
|
||||||
}
|
}
|
||||||
return ( forced == null ) ? null : ProxyServer.getInstance().getServerInfo( forced );
|
return ProxyServer.getInstance().getServerInfo( forced );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract ServerInfo getStoredServer(ProxiedPlayer player);
|
protected abstract ServerInfo getStoredServer(ProxiedPlayer player);
|
||||||
|
@@ -1,10 +1,9 @@
|
|||||||
package net.md_5.bungee.api;
|
package net.md_5.bungee.api;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import com.google.common.io.BaseEncoding;
|
import com.google.common.io.BaseEncoding;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
|
import com.google.gson.internal.bind.TypeAdapters;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonToken;
|
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@@ -27,26 +26,13 @@ public class Favicon
|
|||||||
@Override
|
@Override
|
||||||
public void write(JsonWriter out, Favicon value) throws IOException
|
public void write(JsonWriter out, Favicon value) throws IOException
|
||||||
{
|
{
|
||||||
if ( value == null )
|
TypeAdapters.STRING.write( out, value == null ? null : value.getEncoded() );
|
||||||
{
|
|
||||||
out.nullValue();
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
out.value( value.getEncoded() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Favicon read(JsonReader in) throws IOException
|
public Favicon read(JsonReader in) throws IOException
|
||||||
{
|
{
|
||||||
JsonToken peek = in.peek();
|
String enc = TypeAdapters.STRING.read( in );
|
||||||
if ( peek == JsonToken.NULL )
|
|
||||||
{
|
|
||||||
in.nextNull();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String enc = in.nextString();
|
|
||||||
return enc == null ? null : create( enc );
|
return enc == null ? null : create( enc );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -73,7 +59,6 @@ public class Favicon
|
|||||||
*/
|
*/
|
||||||
public static Favicon create(BufferedImage image)
|
public static Favicon create(BufferedImage image)
|
||||||
{
|
{
|
||||||
Preconditions.checkArgument( image != null, "image is null" );
|
|
||||||
// check size
|
// check size
|
||||||
if ( image.getWidth() != 64 || image.getHeight() != 64 )
|
if ( image.getWidth() != 64 || image.getHeight() != 64 )
|
||||||
{
|
{
|
||||||
|
@@ -15,7 +15,7 @@ import net.md_5.bungee.api.event.ServerConnectEvent;
|
|||||||
import net.md_5.bungee.api.score.Scoreboard;
|
import net.md_5.bungee.api.score.Scoreboard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a player whose connection is being connected to somewhere else,
|
* Represents a player who's connection is being connected to somewhere else,
|
||||||
* whether it be a remote or embedded server.
|
* whether it be a remote or embedded server.
|
||||||
*/
|
*/
|
||||||
public interface ProxiedPlayer extends Connection, CommandSender
|
public interface ProxiedPlayer extends Connection, CommandSender
|
||||||
@@ -57,7 +57,8 @@ public interface ProxiedPlayer extends Connection, CommandSender
|
|||||||
String getDisplayName();
|
String getDisplayName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets this player's display name to be used by proxy commands and plugins.
|
* Sets this players display name to be used as their nametag and tab list
|
||||||
|
* name.
|
||||||
*
|
*
|
||||||
* @param name the name to set
|
* @param name the name to set
|
||||||
*/
|
*/
|
||||||
|
@@ -8,7 +8,7 @@ import net.md_5.bungee.api.ServerPing;
|
|||||||
import net.md_5.bungee.api.connection.PendingConnection;
|
import net.md_5.bungee.api.connection.PendingConnection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the proxy is queried for status from the server list.
|
* Called when the proxy is pinged with packet 0xFE from the server list.
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@ToString(callSuper = false)
|
@ToString(callSuper = false)
|
||||||
|
@@ -9,13 +9,6 @@ import net.md_5.bungee.api.config.ServerInfo;
|
|||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.plugin.Event;
|
import net.md_5.bungee.api.plugin.Event;
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the player is disconnected from a server, for example during
|
|
||||||
* server switching.
|
|
||||||
*
|
|
||||||
* If the player is kicked from a server, {@link ServerKickEvent} will be called
|
|
||||||
* instead.
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@ToString(callSuper = false)
|
@ToString(callSuper = false)
|
||||||
|
@@ -1,123 +0,0 @@
|
|||||||
package net.md_5.bungee.api.plugin;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLClassLoader;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
|
|
||||||
import org.eclipse.aether.DefaultRepositorySystemSession;
|
|
||||||
import org.eclipse.aether.RepositorySystem;
|
|
||||||
import org.eclipse.aether.artifact.Artifact;
|
|
||||||
import org.eclipse.aether.artifact.DefaultArtifact;
|
|
||||||
import org.eclipse.aether.collection.CollectRequest;
|
|
||||||
import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
|
|
||||||
import org.eclipse.aether.graph.Dependency;
|
|
||||||
import org.eclipse.aether.impl.DefaultServiceLocator;
|
|
||||||
import org.eclipse.aether.repository.LocalRepository;
|
|
||||||
import org.eclipse.aether.repository.RemoteRepository;
|
|
||||||
import org.eclipse.aether.repository.RepositoryPolicy;
|
|
||||||
import org.eclipse.aether.resolution.ArtifactResult;
|
|
||||||
import org.eclipse.aether.resolution.DependencyRequest;
|
|
||||||
import org.eclipse.aether.resolution.DependencyResolutionException;
|
|
||||||
import org.eclipse.aether.resolution.DependencyResult;
|
|
||||||
import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
|
|
||||||
import org.eclipse.aether.spi.connector.transport.TransporterFactory;
|
|
||||||
import org.eclipse.aether.transfer.AbstractTransferListener;
|
|
||||||
import org.eclipse.aether.transfer.TransferCancelledException;
|
|
||||||
import org.eclipse.aether.transfer.TransferEvent;
|
|
||||||
import org.eclipse.aether.transport.http.HttpTransporterFactory;
|
|
||||||
|
|
||||||
class LibraryLoader
|
|
||||||
{
|
|
||||||
|
|
||||||
private final Logger logger;
|
|
||||||
private final RepositorySystem repository;
|
|
||||||
private final DefaultRepositorySystemSession session;
|
|
||||||
private final List<RemoteRepository> repositories;
|
|
||||||
|
|
||||||
public LibraryLoader(Logger logger)
|
|
||||||
{
|
|
||||||
this.logger = logger;
|
|
||||||
|
|
||||||
DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
|
|
||||||
locator.addService( RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class );
|
|
||||||
locator.addService( TransporterFactory.class, HttpTransporterFactory.class );
|
|
||||||
|
|
||||||
this.repository = locator.getService( RepositorySystem.class );
|
|
||||||
this.session = MavenRepositorySystemUtils.newSession();
|
|
||||||
|
|
||||||
session.setChecksumPolicy( RepositoryPolicy.CHECKSUM_POLICY_FAIL );
|
|
||||||
session.setLocalRepositoryManager( repository.newLocalRepositoryManager( session, new LocalRepository( "libraries" ) ) );
|
|
||||||
session.setTransferListener( new AbstractTransferListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void transferStarted(TransferEvent event) throws TransferCancelledException
|
|
||||||
{
|
|
||||||
logger.log( Level.INFO, "Downloading {0}", event.getResource().getRepositoryUrl() + event.getResource().getResourceName() );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
session.setReadOnly();
|
|
||||||
|
|
||||||
this.repositories = repository.newResolutionRepositories( session, Arrays.asList( new RemoteRepository.Builder( "central", "default", "https://repo.maven.apache.org/maven2" ).build() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClassLoader createLoader(PluginDescription desc)
|
|
||||||
{
|
|
||||||
if ( desc.getLibraries().isEmpty() )
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
logger.log( Level.INFO, "[{0}] Loading {1} libraries... please wait", new Object[]
|
|
||||||
{
|
|
||||||
desc.getName(), desc.getLibraries().size()
|
|
||||||
} );
|
|
||||||
|
|
||||||
List<Dependency> dependencies = new ArrayList<>();
|
|
||||||
for ( String library : desc.getLibraries() )
|
|
||||||
{
|
|
||||||
Artifact artifact = new DefaultArtifact( library );
|
|
||||||
Dependency dependency = new Dependency( artifact, null );
|
|
||||||
|
|
||||||
dependencies.add( dependency );
|
|
||||||
}
|
|
||||||
|
|
||||||
DependencyResult result;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
result = repository.resolveDependencies( session, new DependencyRequest( new CollectRequest( (Dependency) null, dependencies, repositories ), null ) );
|
|
||||||
} catch ( DependencyResolutionException ex )
|
|
||||||
{
|
|
||||||
throw new RuntimeException( "Error resolving libraries", ex );
|
|
||||||
}
|
|
||||||
|
|
||||||
List<URL> jarFiles = new ArrayList<>();
|
|
||||||
for ( ArtifactResult artifact : result.getArtifactResults() )
|
|
||||||
{
|
|
||||||
File file = artifact.getArtifact().getFile();
|
|
||||||
|
|
||||||
URL url;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
url = file.toURI().toURL();
|
|
||||||
} catch ( MalformedURLException ex )
|
|
||||||
{
|
|
||||||
throw new AssertionError( ex );
|
|
||||||
}
|
|
||||||
|
|
||||||
jarFiles.add( url );
|
|
||||||
logger.log( Level.INFO, "[{0}] Loaded library {1}", new Object[]
|
|
||||||
{
|
|
||||||
desc.getName(), file
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
URLClassLoader loader = new URLClassLoader( jarFiles.toArray( new URL[ 0 ] ) );
|
|
||||||
|
|
||||||
return loader;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,23 +1,12 @@
|
|||||||
package net.md_5.bungee.api.plugin;
|
package net.md_5.bungee.api.plugin;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.io.ByteStreams;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.security.CodeSigner;
|
|
||||||
import java.security.CodeSource;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
import java.util.jar.JarEntry;
|
|
||||||
import java.util.jar.JarFile;
|
|
||||||
import java.util.jar.Manifest;
|
|
||||||
import lombok.ToString;
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
|
||||||
@ToString(of = "desc")
|
|
||||||
final class PluginClassloader extends URLClassLoader
|
final class PluginClassloader extends URLClassLoader
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -25,10 +14,6 @@ final class PluginClassloader extends URLClassLoader
|
|||||||
//
|
//
|
||||||
private final ProxyServer proxy;
|
private final ProxyServer proxy;
|
||||||
private final PluginDescription desc;
|
private final PluginDescription desc;
|
||||||
private final JarFile jar;
|
|
||||||
private final Manifest manifest;
|
|
||||||
private final URL url;
|
|
||||||
private final ClassLoader libraryLoader;
|
|
||||||
//
|
//
|
||||||
private Plugin plugin;
|
private Plugin plugin;
|
||||||
|
|
||||||
@@ -37,18 +22,11 @@ final class PluginClassloader extends URLClassLoader
|
|||||||
ClassLoader.registerAsParallelCapable();
|
ClassLoader.registerAsParallelCapable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluginClassloader(ProxyServer proxy, PluginDescription desc, File file, ClassLoader libraryLoader) throws IOException
|
public PluginClassloader(ProxyServer proxy, PluginDescription desc, URL[] urls)
|
||||||
{
|
{
|
||||||
super( new URL[]
|
super( urls );
|
||||||
{
|
|
||||||
file.toURI().toURL()
|
|
||||||
} );
|
|
||||||
this.proxy = proxy;
|
this.proxy = proxy;
|
||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
this.jar = new JarFile( file );
|
|
||||||
this.manifest = jar.getManifest();
|
|
||||||
this.url = file.toURI().toURL();
|
|
||||||
this.libraryLoader = libraryLoader;
|
|
||||||
|
|
||||||
allLoaders.add( this );
|
allLoaders.add( this );
|
||||||
}
|
}
|
||||||
@@ -56,34 +34,17 @@ final class PluginClassloader extends URLClassLoader
|
|||||||
@Override
|
@Override
|
||||||
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
|
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
|
||||||
{
|
{
|
||||||
return loadClass0( name, resolve, true, true );
|
return loadClass0( name, resolve, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Class<?> loadClass0(String name, boolean resolve, boolean checkOther, boolean checkLibraries) throws ClassNotFoundException
|
private Class<?> loadClass0(String name, boolean resolve, boolean checkOther) throws ClassNotFoundException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Class<?> result = super.loadClass( name, resolve );
|
return super.loadClass( name, resolve );
|
||||||
|
|
||||||
// SPIGOT-6749: Library classes will appear in the above, but we don't want to return them to other plugins
|
|
||||||
if ( checkOther || result.getClassLoader() == this )
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
} catch ( ClassNotFoundException ex )
|
} catch ( ClassNotFoundException ex )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( checkLibraries && libraryLoader != null )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return libraryLoader.loadClass( name );
|
|
||||||
} catch ( ClassNotFoundException ex )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( checkOther )
|
if ( checkOther )
|
||||||
{
|
{
|
||||||
for ( PluginClassloader loader : allLoaders )
|
for ( PluginClassloader loader : allLoaders )
|
||||||
@@ -92,81 +53,16 @@ final class PluginClassloader extends URLClassLoader
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return loader.loadClass0( name, resolve, false, proxy.getPluginManager().isTransitiveDepend( desc, loader.desc ) );
|
return loader.loadClass0( name, resolve, false );
|
||||||
} catch ( ClassNotFoundException ex )
|
} catch ( ClassNotFoundException ex )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new ClassNotFoundException( name );
|
throw new ClassNotFoundException( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Class<?> findClass(String name) throws ClassNotFoundException
|
|
||||||
{
|
|
||||||
String path = name.replace( '.', '/' ).concat( ".class" );
|
|
||||||
JarEntry entry = jar.getJarEntry( path );
|
|
||||||
|
|
||||||
if ( entry != null )
|
|
||||||
{
|
|
||||||
byte[] classBytes;
|
|
||||||
|
|
||||||
try ( InputStream is = jar.getInputStream( entry ) )
|
|
||||||
{
|
|
||||||
classBytes = ByteStreams.toByteArray( is );
|
|
||||||
} catch ( IOException ex )
|
|
||||||
{
|
|
||||||
throw new ClassNotFoundException( name, ex );
|
|
||||||
}
|
|
||||||
|
|
||||||
int dot = name.lastIndexOf( '.' );
|
|
||||||
if ( dot != -1 )
|
|
||||||
{
|
|
||||||
String pkgName = name.substring( 0, dot );
|
|
||||||
if ( getPackage( pkgName ) == null )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if ( manifest != null )
|
|
||||||
{
|
|
||||||
definePackage( pkgName, manifest, url );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
definePackage( pkgName, null, null, null, null, null, null, null );
|
|
||||||
}
|
|
||||||
} catch ( IllegalArgumentException ex )
|
|
||||||
{
|
|
||||||
if ( getPackage( pkgName ) == null )
|
|
||||||
{
|
|
||||||
throw new IllegalStateException( "Cannot find package " + pkgName );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CodeSigner[] signers = entry.getCodeSigners();
|
|
||||||
CodeSource source = new CodeSource( url, signers );
|
|
||||||
|
|
||||||
return defineClass( name, classBytes, 0, classBytes.length, source );
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.findClass( name );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() throws IOException
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
super.close();
|
|
||||||
} finally
|
|
||||||
{
|
|
||||||
jar.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void init(Plugin plugin)
|
void init(Plugin plugin)
|
||||||
{
|
{
|
||||||
Preconditions.checkArgument( plugin != null, "plugin" );
|
Preconditions.checkArgument( plugin != null, "plugin" );
|
||||||
|
@@ -2,8 +2,6 @@ package net.md_5.bungee.api.plugin;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -50,8 +48,4 @@ public class PluginDescription
|
|||||||
* Optional description.
|
* Optional description.
|
||||||
*/
|
*/
|
||||||
private String description = null;
|
private String description = null;
|
||||||
/**
|
|
||||||
* Optional libraries.
|
|
||||||
*/
|
|
||||||
private List<String> libraries = new LinkedList<>();
|
|
||||||
}
|
}
|
||||||
|
@@ -4,12 +4,10 @@ import com.google.common.base.Preconditions;
|
|||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.google.common.eventbus.Subscribe;
|
import com.google.common.eventbus.Subscribe;
|
||||||
import com.google.common.graph.GraphBuilder;
|
|
||||||
import com.google.common.graph.Graphs;
|
|
||||||
import com.google.common.graph.MutableGraph;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -33,7 +31,6 @@ import net.md_5.bungee.api.ProxyServer;
|
|||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.event.EventBus;
|
import net.md_5.bungee.event.EventBus;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
import org.yaml.snakeyaml.LoaderOptions;
|
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
import org.yaml.snakeyaml.constructor.Constructor;
|
import org.yaml.snakeyaml.constructor.Constructor;
|
||||||
import org.yaml.snakeyaml.introspector.PropertyUtils;
|
import org.yaml.snakeyaml.introspector.PropertyUtils;
|
||||||
@@ -52,8 +49,6 @@ public final class PluginManager
|
|||||||
private final Yaml yaml;
|
private final Yaml yaml;
|
||||||
private final EventBus eventBus;
|
private final EventBus eventBus;
|
||||||
private final Map<String, Plugin> plugins = new LinkedHashMap<>();
|
private final Map<String, Plugin> plugins = new LinkedHashMap<>();
|
||||||
private final MutableGraph<String> dependencyGraph = GraphBuilder.directed().build();
|
|
||||||
private final LibraryLoader libraryLoader;
|
|
||||||
private final Map<String, Command> commandMap = new HashMap<>();
|
private final Map<String, Command> commandMap = new HashMap<>();
|
||||||
private Map<String, PluginDescription> toLoad = new HashMap<>();
|
private Map<String, PluginDescription> toLoad = new HashMap<>();
|
||||||
private final Multimap<Plugin, Command> commandsByPlugin = ArrayListMultimap.create();
|
private final Multimap<Plugin, Command> commandsByPlugin = ArrayListMultimap.create();
|
||||||
@@ -65,24 +60,13 @@ public final class PluginManager
|
|||||||
this.proxy = proxy;
|
this.proxy = proxy;
|
||||||
|
|
||||||
// Ignore unknown entries in the plugin descriptions
|
// Ignore unknown entries in the plugin descriptions
|
||||||
Constructor yamlConstructor = new Constructor( new LoaderOptions() );
|
Constructor yamlConstructor = new Constructor();
|
||||||
PropertyUtils propertyUtils = yamlConstructor.getPropertyUtils();
|
PropertyUtils propertyUtils = yamlConstructor.getPropertyUtils();
|
||||||
propertyUtils.setSkipMissingProperties( true );
|
propertyUtils.setSkipMissingProperties( true );
|
||||||
yamlConstructor.setPropertyUtils( propertyUtils );
|
yamlConstructor.setPropertyUtils( propertyUtils );
|
||||||
yaml = new Yaml( yamlConstructor );
|
yaml = new Yaml( yamlConstructor );
|
||||||
|
|
||||||
eventBus = new EventBus( proxy.getLogger() );
|
eventBus = new EventBus( proxy.getLogger() );
|
||||||
|
|
||||||
LibraryLoader libraryLoader = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
libraryLoader = new LibraryLoader( proxy.getLogger() );
|
|
||||||
} catch ( NoClassDefFoundError ex )
|
|
||||||
{
|
|
||||||
// Provided depends were not added back
|
|
||||||
proxy.getLogger().warning( "Could not initialize LibraryLoader (missing dependencies?)" );
|
|
||||||
}
|
|
||||||
this.libraryLoader = libraryLoader;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -325,7 +309,6 @@ public final class PluginManager
|
|||||||
status = false;
|
status = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencyGraph.putEdge( plugin.getName(), dependName );
|
|
||||||
if ( !status )
|
if ( !status )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -337,7 +320,10 @@ public final class PluginManager
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
URLClassLoader loader = new PluginClassloader( proxy, plugin, plugin.getFile(), ( libraryLoader != null ) ? libraryLoader.createLoader( plugin ) : null );
|
URLClassLoader loader = new PluginClassloader( proxy, plugin, new URL[]
|
||||||
|
{
|
||||||
|
plugin.getFile().toURI().toURL()
|
||||||
|
} );
|
||||||
Class<?> main = loader.loadClass( plugin.getMain() );
|
Class<?> main = loader.loadClass( plugin.getMain() );
|
||||||
Plugin clazz = (Plugin) main.getDeclaredConstructor().newInstance();
|
Plugin clazz = (Plugin) main.getDeclaredConstructor().newInstance();
|
||||||
|
|
||||||
@@ -349,7 +335,7 @@ public final class PluginManager
|
|||||||
} );
|
} );
|
||||||
} catch ( Throwable t )
|
} catch ( Throwable t )
|
||||||
{
|
{
|
||||||
proxy.getLogger().log( Level.WARNING, "Error loading plugin " + plugin.getName(), t );
|
proxy.getLogger().log( Level.WARNING, "Error enabling plugin " + plugin.getName(), t );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,19 +463,4 @@ public final class PluginManager
|
|||||||
{
|
{
|
||||||
return Collections.unmodifiableCollection( commandMap.entrySet() );
|
return Collections.unmodifiableCollection( commandMap.entrySet() );
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isTransitiveDepend(PluginDescription plugin, PluginDescription depend)
|
|
||||||
{
|
|
||||||
Preconditions.checkArgument( plugin != null, "plugin" );
|
|
||||||
Preconditions.checkArgument( depend != null, "depend" );
|
|
||||||
|
|
||||||
if ( dependencyGraph.nodes().contains( plugin.getName() ) )
|
|
||||||
{
|
|
||||||
if ( Graphs.reachableNodes( dependencyGraph, plugin.getName() ).contains( depend.getName() ) )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-bootstrap</artifactId>
|
<artifactId>bungeecord-bootstrap</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Bootstrap</name>
|
<name>BungeeCord-Bootstrap</name>
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.2.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<archive>
|
<archive>
|
||||||
<manifestEntries>
|
<manifestEntries>
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.2.3</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
@@ -79,34 +79,4 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>jdk-9-release</id>
|
|
||||||
<activation>
|
|
||||||
<jdk>[9,)</jdk>
|
|
||||||
</activation>
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.release>6</maven.compiler.release>
|
|
||||||
</properties>
|
|
||||||
</profile>
|
|
||||||
<profile>
|
|
||||||
<id>jdk-12-release</id>
|
|
||||||
<activation>
|
|
||||||
<jdk>[12,)</jdk>
|
|
||||||
</activation>
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.release>7</maven.compiler.release>
|
|
||||||
</properties>
|
|
||||||
</profile>
|
|
||||||
<profile>
|
|
||||||
<id>jdk-20-release</id>
|
|
||||||
<activation>
|
|
||||||
<jdk>[20,)</jdk>
|
|
||||||
</activation>
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.release>8</maven.compiler.release>
|
|
||||||
</properties>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
</project>
|
</project>
|
||||||
|
@@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-chat</artifactId>
|
<artifactId>bungeecord-chat</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Chat</name>
|
<name>BungeeCord-Chat</name>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>2.10.1</version>
|
<version>2.8.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@@ -300,7 +300,7 @@ public final class ChatColor
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public static ChatColor[] values()
|
public static ChatColor[] values()
|
||||||
{
|
{
|
||||||
return BY_CHAR.values().toArray( new ChatColor[ 0 ] );
|
return BY_CHAR.values().toArray( new ChatColor[ BY_CHAR.values().size() ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -78,12 +78,6 @@ public abstract class BaseComponent
|
|||||||
@Getter
|
@Getter
|
||||||
private HoverEvent hoverEvent;
|
private HoverEvent hoverEvent;
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether this component rejects previous formatting
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
private transient boolean reset;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
*
|
*
|
||||||
|
@@ -57,7 +57,7 @@ public final class ComponentBuilder
|
|||||||
*/
|
*/
|
||||||
public ComponentBuilder(ComponentBuilder original)
|
public ComponentBuilder(ComponentBuilder original)
|
||||||
{
|
{
|
||||||
this( original.parts.toArray( new BaseComponent[ 0 ] ) );
|
this( original.parts.toArray( new BaseComponent[ original.parts.size() ] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -161,7 +161,7 @@ public final class ComponentBuilder
|
|||||||
previous = dummy;
|
previous = dummy;
|
||||||
dummy = null;
|
dummy = null;
|
||||||
}
|
}
|
||||||
if ( previous != null && !component.isReset() )
|
if ( previous != null )
|
||||||
{
|
{
|
||||||
component.copyFormatting( previous, retention, false );
|
component.copyFormatting( previous, retention, false );
|
||||||
}
|
}
|
||||||
@@ -454,32 +454,9 @@ public final class ComponentBuilder
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the component built by this builder. If this builder is
|
|
||||||
* empty, an empty text component will be returned.
|
|
||||||
*
|
|
||||||
* @return the component
|
|
||||||
*/
|
|
||||||
public BaseComponent build()
|
|
||||||
{
|
|
||||||
TextComponent base = new TextComponent();
|
|
||||||
if ( !parts.isEmpty() )
|
|
||||||
{
|
|
||||||
List<BaseComponent> cloned = new ArrayList<>( parts );
|
|
||||||
cloned.replaceAll( BaseComponent::duplicate );
|
|
||||||
base.setExtra( cloned );
|
|
||||||
}
|
|
||||||
return base;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the components needed to display the message created by this
|
* Returns the components needed to display the message created by this
|
||||||
* builder.git
|
* builder.git
|
||||||
* <p>
|
|
||||||
* <strong>NOTE:</strong> {@link #build()} is preferred as it will
|
|
||||||
* consolidate all components into a single BaseComponent with extra
|
|
||||||
* contents as opposed to an array of components which is non-standard
|
|
||||||
* and may result in unexpected behavior.
|
|
||||||
*
|
*
|
||||||
* @return the created components
|
* @return the created components
|
||||||
*/
|
*/
|
||||||
|
@@ -44,7 +44,7 @@ public final class TextComponent extends BaseComponent
|
|||||||
*/
|
*/
|
||||||
public static BaseComponent[] fromLegacyText(String message, ChatColor defaultColor)
|
public static BaseComponent[] fromLegacyText(String message, ChatColor defaultColor)
|
||||||
{
|
{
|
||||||
ArrayList<BaseComponent> components = new ArrayList<>();
|
ArrayList<BaseComponent> components = new ArrayList<BaseComponent>();
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
TextComponent component = new TextComponent();
|
TextComponent component = new TextComponent();
|
||||||
Matcher matcher = url.matcher( message );
|
Matcher matcher = url.matcher( message );
|
||||||
@@ -111,15 +111,15 @@ public final class TextComponent extends BaseComponent
|
|||||||
} else if ( format == ChatColor.MAGIC )
|
} else if ( format == ChatColor.MAGIC )
|
||||||
{
|
{
|
||||||
component.setObfuscated( true );
|
component.setObfuscated( true );
|
||||||
} else
|
} else if ( format == ChatColor.RESET )
|
||||||
|
{
|
||||||
|
format = defaultColor;
|
||||||
|
component = new TextComponent();
|
||||||
|
component.setColor( format );
|
||||||
|
} else
|
||||||
{
|
{
|
||||||
if ( format == ChatColor.RESET )
|
|
||||||
{
|
|
||||||
format = defaultColor;
|
|
||||||
}
|
|
||||||
component = new TextComponent();
|
component = new TextComponent();
|
||||||
component.setColor( format );
|
component.setColor( format );
|
||||||
component.setReset( true );
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -157,7 +157,7 @@ public final class TextComponent extends BaseComponent
|
|||||||
component.setText( builder.toString() );
|
component.setText( builder.toString() );
|
||||||
components.add( component );
|
components.add( component );
|
||||||
|
|
||||||
return components.toArray( new BaseComponent[ 0 ] );
|
return components.toArray( new BaseComponent[ components.size() ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -230,6 +230,6 @@ public final class TextComponent extends BaseComponent
|
|||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "TextComponent{text=" + text + ", " + super.toString() + '}';
|
return String.format( "TextComponent{text=%s, %s}", text, super.toString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,10 +30,6 @@ public final class TranslatableComponent extends BaseComponent
|
|||||||
* The components to substitute into the translation
|
* The components to substitute into the translation
|
||||||
*/
|
*/
|
||||||
private List<BaseComponent> with;
|
private List<BaseComponent> with;
|
||||||
/**
|
|
||||||
* The fallback, if the translation is not found
|
|
||||||
*/
|
|
||||||
private String fallback;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a translatable component from the original to clone it.
|
* Creates a translatable component from the original to clone it.
|
||||||
@@ -157,11 +153,6 @@ public final class TranslatableComponent extends BaseComponent
|
|||||||
{
|
{
|
||||||
String trans = TranslationRegistry.INSTANCE.translate( translate );
|
String trans = TranslationRegistry.INSTANCE.translate( translate );
|
||||||
|
|
||||||
if ( trans.equals( translate ) && fallback != null )
|
|
||||||
{
|
|
||||||
trans = fallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
Matcher matcher = format.matcher( trans );
|
Matcher matcher = format.matcher( trans );
|
||||||
int position = 0;
|
int position = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@@ -23,12 +23,6 @@ public class Text extends Content
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Text(BaseComponent value)
|
|
||||||
{
|
|
||||||
// For legacy serialization reasons, this has to be an array of components
|
|
||||||
this( new BaseComponent[]{value} );
|
|
||||||
}
|
|
||||||
|
|
||||||
public Text(String value)
|
public Text(String value)
|
||||||
{
|
{
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
@@ -22,6 +22,14 @@ public class BaseComponentSerializer
|
|||||||
|
|
||||||
protected void deserialize(JsonObject object, BaseComponent component, JsonDeserializationContext context)
|
protected void deserialize(JsonObject object, BaseComponent component, JsonDeserializationContext context)
|
||||||
{
|
{
|
||||||
|
if ( object.has( "color" ) )
|
||||||
|
{
|
||||||
|
component.setColor( ChatColor.of( object.get( "color" ).getAsString() ) );
|
||||||
|
}
|
||||||
|
if ( object.has( "font" ) )
|
||||||
|
{
|
||||||
|
component.setFont( object.get( "font" ).getAsString() );
|
||||||
|
}
|
||||||
if ( object.has( "bold" ) )
|
if ( object.has( "bold" ) )
|
||||||
{
|
{
|
||||||
component.setBold( object.get( "bold" ).getAsBoolean() );
|
component.setBold( object.get( "bold" ).getAsBoolean() );
|
||||||
@@ -42,14 +50,14 @@ public class BaseComponentSerializer
|
|||||||
{
|
{
|
||||||
component.setObfuscated( object.get( "obfuscated" ).getAsBoolean() );
|
component.setObfuscated( object.get( "obfuscated" ).getAsBoolean() );
|
||||||
}
|
}
|
||||||
if ( object.has( "color" ) )
|
|
||||||
{
|
|
||||||
component.setColor( ChatColor.of( object.get( "color" ).getAsString() ) );
|
|
||||||
}
|
|
||||||
if ( object.has( "insertion" ) )
|
if ( object.has( "insertion" ) )
|
||||||
{
|
{
|
||||||
component.setInsertion( object.get( "insertion" ).getAsString() );
|
component.setInsertion( object.get( "insertion" ).getAsString() );
|
||||||
}
|
}
|
||||||
|
if ( object.has( "extra" ) )
|
||||||
|
{
|
||||||
|
component.setExtra( Arrays.asList( context.<BaseComponent[]>deserialize( object.get( "extra" ), BaseComponent[].class ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
//Events
|
//Events
|
||||||
if ( object.has( "clickEvent" ) )
|
if ( object.has( "clickEvent" ) )
|
||||||
@@ -85,7 +93,7 @@ public class BaseComponentSerializer
|
|||||||
{
|
{
|
||||||
components = new BaseComponent[]
|
components = new BaseComponent[]
|
||||||
{
|
{
|
||||||
context.deserialize( contents, BaseComponent.class )
|
context.deserialize( contents, BaseComponent.class )
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
hoverEvent = new HoverEvent( action, components );
|
hoverEvent = new HoverEvent( action, components );
|
||||||
@@ -113,15 +121,6 @@ public class BaseComponentSerializer
|
|||||||
component.setHoverEvent( hoverEvent );
|
component.setHoverEvent( hoverEvent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( object.has( "font" ) )
|
|
||||||
{
|
|
||||||
component.setFont( object.get( "font" ).getAsString() );
|
|
||||||
}
|
|
||||||
if ( object.has( "extra" ) )
|
|
||||||
{
|
|
||||||
component.setExtra( Arrays.asList( context.<BaseComponent[]>deserialize( object.get( "extra" ), BaseComponent[].class ) ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void serialize(JsonObject object, BaseComponent component, JsonSerializationContext context)
|
protected void serialize(JsonObject object, BaseComponent component, JsonSerializationContext context)
|
||||||
@@ -136,6 +135,14 @@ public class BaseComponentSerializer
|
|||||||
{
|
{
|
||||||
Preconditions.checkArgument( !ComponentSerializer.serializedComponents.get().contains( component ), "Component loop" );
|
Preconditions.checkArgument( !ComponentSerializer.serializedComponents.get().contains( component ), "Component loop" );
|
||||||
ComponentSerializer.serializedComponents.get().add( component );
|
ComponentSerializer.serializedComponents.get().add( component );
|
||||||
|
if ( component.getColorRaw() != null )
|
||||||
|
{
|
||||||
|
object.addProperty( "color", component.getColorRaw().getName() );
|
||||||
|
}
|
||||||
|
if ( component.getFontRaw() != null )
|
||||||
|
{
|
||||||
|
object.addProperty( "font", component.getFontRaw() );
|
||||||
|
}
|
||||||
if ( component.isBoldRaw() != null )
|
if ( component.isBoldRaw() != null )
|
||||||
{
|
{
|
||||||
object.addProperty( "bold", component.isBoldRaw() );
|
object.addProperty( "bold", component.isBoldRaw() );
|
||||||
@@ -156,15 +163,16 @@ public class BaseComponentSerializer
|
|||||||
{
|
{
|
||||||
object.addProperty( "obfuscated", component.isObfuscatedRaw() );
|
object.addProperty( "obfuscated", component.isObfuscatedRaw() );
|
||||||
}
|
}
|
||||||
if ( component.getColorRaw() != null )
|
|
||||||
{
|
|
||||||
object.addProperty( "color", component.getColorRaw().getName() );
|
|
||||||
}
|
|
||||||
if ( component.getInsertion() != null )
|
if ( component.getInsertion() != null )
|
||||||
{
|
{
|
||||||
object.addProperty( "insertion", component.getInsertion() );
|
object.addProperty( "insertion", component.getInsertion() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( component.getExtra() != null )
|
||||||
|
{
|
||||||
|
object.add( "extra", context.serialize( component.getExtra() ) );
|
||||||
|
}
|
||||||
|
|
||||||
//Events
|
//Events
|
||||||
if ( component.getClickEvent() != null )
|
if ( component.getClickEvent() != null )
|
||||||
{
|
{
|
||||||
@@ -187,15 +195,6 @@ public class BaseComponentSerializer
|
|||||||
}
|
}
|
||||||
object.add( "hoverEvent", hoverEvent );
|
object.add( "hoverEvent", hoverEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( component.getFontRaw() != null )
|
|
||||||
{
|
|
||||||
object.addProperty( "font", component.getFontRaw() );
|
|
||||||
}
|
|
||||||
if ( component.getExtra() != null )
|
|
||||||
{
|
|
||||||
object.add( "extra", context.serialize( component.getExtra() ) );
|
|
||||||
}
|
|
||||||
} finally
|
} finally
|
||||||
{
|
{
|
||||||
ComponentSerializer.serializedComponents.get().remove( component );
|
ComponentSerializer.serializedComponents.get().remove( component );
|
||||||
|
@@ -27,6 +27,7 @@ import net.md_5.bungee.api.chat.hover.content.TextSerializer;
|
|||||||
public class ComponentSerializer implements JsonDeserializer<BaseComponent>
|
public class ComponentSerializer implements JsonDeserializer<BaseComponent>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private static final JsonParser JSON_PARSER = new JsonParser();
|
||||||
private static final Gson gson = new GsonBuilder().
|
private static final Gson gson = new GsonBuilder().
|
||||||
registerTypeAdapter( BaseComponent.class, new ComponentSerializer() ).
|
registerTypeAdapter( BaseComponent.class, new ComponentSerializer() ).
|
||||||
registerTypeAdapter( TextComponent.class, new TextComponentSerializer() ).
|
registerTypeAdapter( TextComponent.class, new TextComponentSerializer() ).
|
||||||
@@ -42,25 +43,9 @@ public class ComponentSerializer implements JsonDeserializer<BaseComponent>
|
|||||||
|
|
||||||
public static final ThreadLocal<Set<BaseComponent>> serializedComponents = new ThreadLocal<Set<BaseComponent>>();
|
public static final ThreadLocal<Set<BaseComponent>> serializedComponents = new ThreadLocal<Set<BaseComponent>>();
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse a JSON-compliant String as an array of base components. The input
|
|
||||||
* can be one of either an array of components, or a single component object.
|
|
||||||
* If the input is an array, each component will be parsed individually and
|
|
||||||
* returned in the order that they were parsed. If the input is a single
|
|
||||||
* component object, a single-valued array with the component will be returned.
|
|
||||||
* <p>
|
|
||||||
* <strong>NOTE:</strong> {@link #deserialize(String)} is preferred as it will
|
|
||||||
* parse only one component as opposed to an array of components which is non-
|
|
||||||
* standard behavior. This method is still appropriate for parsing multiple
|
|
||||||
* components at once, although such use case is rarely (if at all) exhibited
|
|
||||||
* in vanilla Minecraft.
|
|
||||||
*
|
|
||||||
* @param json the component json to parse
|
|
||||||
* @return an array of all parsed components
|
|
||||||
*/
|
|
||||||
public static BaseComponent[] parse(String json)
|
public static BaseComponent[] parse(String json)
|
||||||
{
|
{
|
||||||
JsonElement jsonElement = JsonParser.parseString( json );
|
JsonElement jsonElement = JSON_PARSER.parse( json );
|
||||||
|
|
||||||
if ( jsonElement.isJsonArray() )
|
if ( jsonElement.isJsonArray() )
|
||||||
{
|
{
|
||||||
@@ -74,26 +59,6 @@ public class ComponentSerializer implements JsonDeserializer<BaseComponent>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserialize a JSON-compliant String as a single component. The input is
|
|
||||||
* expected to be a JSON object that represents only one component.
|
|
||||||
*
|
|
||||||
* @param json the component json to parse
|
|
||||||
* @return the deserialized component
|
|
||||||
* @throws IllegalArgumentException if anything other than a JSON object is
|
|
||||||
* passed as input
|
|
||||||
*/
|
|
||||||
public static BaseComponent deserialize(String json)
|
|
||||||
{
|
|
||||||
JsonElement jsonElement = JsonParser.parseString( json );
|
|
||||||
if ( !jsonElement.isJsonObject() )
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException( "Malformatted JSON. Expected object, got array for input \"" + json + "\"." );
|
|
||||||
}
|
|
||||||
|
|
||||||
return gson.fromJson( jsonElement, BaseComponent.class );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toString(Object object)
|
public static String toString(Object object)
|
||||||
{
|
{
|
||||||
return gson.toJson( object );
|
return gson.toJson( object );
|
||||||
|
@@ -8,6 +8,8 @@ import com.google.gson.JsonParseException;
|
|||||||
import com.google.gson.JsonSerializationContext;
|
import com.google.gson.JsonSerializationContext;
|
||||||
import com.google.gson.JsonSerializer;
|
import com.google.gson.JsonSerializer;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.List;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
|
||||||
public class TextComponentSerializer extends BaseComponentSerializer implements JsonSerializer<TextComponent>, JsonDeserializer<TextComponent>
|
public class TextComponentSerializer extends BaseComponentSerializer implements JsonSerializer<TextComponent>, JsonDeserializer<TextComponent>
|
||||||
@@ -30,9 +32,13 @@ public class TextComponentSerializer extends BaseComponentSerializer implements
|
|||||||
@Override
|
@Override
|
||||||
public JsonElement serialize(TextComponent src, Type typeOfSrc, JsonSerializationContext context)
|
public JsonElement serialize(TextComponent src, Type typeOfSrc, JsonSerializationContext context)
|
||||||
{
|
{
|
||||||
|
List<BaseComponent> extra = src.getExtra();
|
||||||
JsonObject object = new JsonObject();
|
JsonObject object = new JsonObject();
|
||||||
serialize( object, src, context );
|
|
||||||
object.addProperty( "text", src.getText() );
|
object.addProperty( "text", src.getText() );
|
||||||
|
if ( src.hasFormatting() || ( extra != null && !extra.isEmpty() ) )
|
||||||
|
{
|
||||||
|
serialize( object, src, context );
|
||||||
|
}
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,11 +28,7 @@ public class TranslatableComponentSerializer extends BaseComponentSerializer imp
|
|||||||
component.setTranslate( object.get( "translate" ).getAsString() );
|
component.setTranslate( object.get( "translate" ).getAsString() );
|
||||||
if ( object.has( "with" ) )
|
if ( object.has( "with" ) )
|
||||||
{
|
{
|
||||||
component.setWith( Arrays.asList( context.deserialize( object.get( "with" ), BaseComponent[].class ) ) );
|
component.setWith( Arrays.asList( context.<BaseComponent[]>deserialize( object.get( "with" ), BaseComponent[].class ) ) );
|
||||||
}
|
|
||||||
if ( object.has( "fallback" ) )
|
|
||||||
{
|
|
||||||
component.setFallback( object.get( "fallback" ).getAsString() );
|
|
||||||
}
|
}
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
@@ -47,10 +43,6 @@ public class TranslatableComponentSerializer extends BaseComponentSerializer imp
|
|||||||
{
|
{
|
||||||
object.add( "with", context.serialize( src.getWith() ) );
|
object.add( "with", context.serialize( src.getWith() ) );
|
||||||
}
|
}
|
||||||
if ( src.getFallback() != null )
|
|
||||||
{
|
|
||||||
object.addProperty( "fallback", src.getFallback() );
|
|
||||||
}
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,6 @@
|
|||||||
package net.md_5.bungee.api.chat;
|
package net.md_5.bungee.api.chat;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.util.function.BiFunction;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.ObjIntConsumer;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.hover.content.Item;
|
import net.md_5.bungee.api.chat.hover.content.Item;
|
||||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
import net.md_5.bungee.api.chat.hover.content.Text;
|
||||||
@@ -23,24 +18,10 @@ public class ComponentsTest
|
|||||||
Assert.assertEquals( TextComponent.toLegacyText( parsed ), TextComponent.toLegacyText( components ) );
|
Assert.assertEquals( TextComponent.toLegacyText( parsed ), TextComponent.toLegacyText( components ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void testDissembleReassemble(BaseComponent component)
|
public static void testDissembleReassemble(String json)
|
||||||
{
|
{
|
||||||
String json = ComponentSerializer.toString( component );
|
|
||||||
BaseComponent[] parsed = ComponentSerializer.parse( json );
|
BaseComponent[] parsed = ComponentSerializer.parse( json );
|
||||||
Assert.assertEquals( TextComponent.toLegacyText( parsed ), TextComponent.toLegacyText( component ) );
|
Assert.assertEquals( json, ComponentSerializer.toString( parsed ) );
|
||||||
}
|
|
||||||
|
|
||||||
public static void testAssembleDissemble(String json, boolean modern)
|
|
||||||
{
|
|
||||||
if ( modern )
|
|
||||||
{
|
|
||||||
BaseComponent deserialized = ComponentSerializer.deserialize( json );
|
|
||||||
Assert.assertEquals( json, ComponentSerializer.toString( deserialized ) );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
BaseComponent[] parsed = ComponentSerializer.parse( json );
|
|
||||||
Assert.assertEquals( json, ComponentSerializer.toString( parsed ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -60,10 +41,8 @@ public class ComponentsTest
|
|||||||
{
|
{
|
||||||
textComponent
|
textComponent
|
||||||
} );
|
} );
|
||||||
testDissembleReassemble( textComponent );
|
json = "{\"text\":\"Test\",\"hoverEvent\":{\"action\":\"show_item\",\"value\":[{\"text\":\"{id:\\\"minecraft:netherrack\\\",Count:47b}\"}]}}";
|
||||||
json = "{\"hoverEvent\":{\"action\":\"show_item\",\"value\":[{\"text\":\"{id:\\\"minecraft:netherrack\\\",Count:47b}\"}]},\"text\":\"Test\"}";
|
testDissembleReassemble( json );
|
||||||
testAssembleDissemble( json, false );
|
|
||||||
testAssembleDissemble( json, true );
|
|
||||||
//////////
|
//////////
|
||||||
String hoverVal = "{\"text\":\"{id:\\\"minecraft:dirt\\\",Count:1b}\"}";
|
String hoverVal = "{\"text\":\"{id:\\\"minecraft:dirt\\\",Count:1b}\"}";
|
||||||
json = "{\"extra\":[{\"text\":\"[\"},{\"extra\":[{\"translate\":\"block.minecraft.dirt\"}],\"text\":\"\"},{\"text\":\"]\"}],\"hoverEvent\":{\"action\":\"show_item\",\"value\":[" + hoverVal + "]},\"text\":\"\"}";
|
json = "{\"extra\":[{\"text\":\"[\"},{\"extra\":[{\"translate\":\"block.minecraft.dirt\"}],\"text\":\"\"},{\"text\":\"]\"}],\"hoverEvent\":{\"action\":\"show_item\",\"value\":[" + hoverVal + "]},\"text\":\"\"}";
|
||||||
@@ -87,37 +66,18 @@ public class ComponentsTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyComponentBuilderCreate()
|
public void testEmptyComponentBuilder()
|
||||||
{
|
|
||||||
this.testEmptyComponentBuilder(
|
|
||||||
ComponentBuilder::create,
|
|
||||||
(components) -> Assert.assertEquals( components.length, 0 ),
|
|
||||||
(components, size) -> Assert.assertEquals( size, components.length )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testEmptyComponentBuilderBuild()
|
|
||||||
{
|
|
||||||
this.testEmptyComponentBuilder(
|
|
||||||
ComponentBuilder::build,
|
|
||||||
(component) -> Assert.assertNull( component.getExtra() ),
|
|
||||||
(component, size) -> Assert.assertEquals( component.getExtra().size(), size )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void testEmptyComponentBuilder(Function<ComponentBuilder, T> componentBuilder, Consumer<T> emptyAssertion, ObjIntConsumer<T> sizedAssertion)
|
|
||||||
{
|
{
|
||||||
ComponentBuilder builder = new ComponentBuilder();
|
ComponentBuilder builder = new ComponentBuilder();
|
||||||
|
|
||||||
T component = componentBuilder.apply( builder );
|
BaseComponent[] parts = builder.create();
|
||||||
emptyAssertion.accept( component );
|
Assert.assertEquals( parts.length, 0 );
|
||||||
|
|
||||||
for ( int i = 0; i < 3; i++ )
|
for ( int i = 0; i < 3; i++ )
|
||||||
{
|
{
|
||||||
builder.append( "part:" + i );
|
builder.append( "part:" + i );
|
||||||
component = componentBuilder.apply( builder );
|
parts = builder.create();
|
||||||
sizedAssertion.accept( component, i + 1 );
|
Assert.assertEquals( parts.length, i + 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +213,7 @@ public class ComponentsTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHoverEventContentsCreate()
|
public void testHoverEventContents()
|
||||||
{
|
{
|
||||||
// First do the text using the newer contents system
|
// First do the text using the newer contents system
|
||||||
HoverEvent hoverEvent = new HoverEvent(
|
HoverEvent hoverEvent = new HoverEvent(
|
||||||
@@ -262,53 +222,21 @@ public class ComponentsTest
|
|||||||
new Text( new ComponentBuilder( "Second" ).create() )
|
new Text( new ComponentBuilder( "Second" ).create() )
|
||||||
);
|
);
|
||||||
|
|
||||||
this.testHoverEventContents(
|
|
||||||
hoverEvent,
|
|
||||||
ComponentSerializer::parse,
|
|
||||||
(components) -> components[0].getHoverEvent(),
|
|
||||||
ComponentsTest::testDissembleReassemble // BaseComponent
|
|
||||||
);
|
|
||||||
|
|
||||||
// check the test still works with the value method
|
|
||||||
hoverEvent = new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Sample text" ).create() );
|
|
||||||
TextComponent component = new TextComponent( "Sample text" );
|
|
||||||
component.setHoverEvent( hoverEvent );
|
|
||||||
|
|
||||||
Assert.assertEquals( hoverEvent.getContents().size(), 1 );
|
|
||||||
Assert.assertTrue( hoverEvent.isLegacy() );
|
|
||||||
String serialized = ComponentSerializer.toString( component );
|
|
||||||
BaseComponent[] deserialized = ComponentSerializer.parse( serialized );
|
|
||||||
Assert.assertEquals( component.getHoverEvent(), deserialized[0].getHoverEvent() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testHoverEventContentsBuild()
|
|
||||||
{
|
|
||||||
// First do the text using the newer contents system
|
|
||||||
HoverEvent hoverEvent = new HoverEvent(
|
|
||||||
HoverEvent.Action.SHOW_TEXT,
|
|
||||||
new Text( new ComponentBuilder( "First" ).build() ),
|
|
||||||
new Text( new ComponentBuilder( "Second" ).build() )
|
|
||||||
);
|
|
||||||
|
|
||||||
this.testHoverEventContents(
|
|
||||||
hoverEvent,
|
|
||||||
ComponentSerializer::deserialize,
|
|
||||||
BaseComponent::getHoverEvent,
|
|
||||||
ComponentsTest::testDissembleReassemble // BaseComponent
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void testHoverEventContents(HoverEvent hoverEvent, Function<String, T> deserializer, Function<T, HoverEvent> hoverEventGetter, Consumer<T> dissembleReassembleTest)
|
|
||||||
{
|
|
||||||
TextComponent component = new TextComponent( "Sample text" );
|
TextComponent component = new TextComponent( "Sample text" );
|
||||||
component.setHoverEvent( hoverEvent );
|
component.setHoverEvent( hoverEvent );
|
||||||
Assert.assertEquals( hoverEvent.getContents().size(), 2 );
|
Assert.assertEquals( hoverEvent.getContents().size(), 2 );
|
||||||
Assert.assertFalse( hoverEvent.isLegacy() );
|
Assert.assertFalse( hoverEvent.isLegacy() );
|
||||||
|
|
||||||
String serialized = ComponentSerializer.toString( component );
|
String serialized = ComponentSerializer.toString( component );
|
||||||
T deserialized = deserializer.apply( serialized );
|
BaseComponent[] deserialized = ComponentSerializer.parse( serialized );
|
||||||
Assert.assertEquals( component.getHoverEvent(), hoverEventGetter.apply( deserialized ) );
|
Assert.assertEquals( component.getHoverEvent(), deserialized[0].getHoverEvent() );
|
||||||
|
|
||||||
|
// check the test still works with the value method
|
||||||
|
hoverEvent = new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Sample text" ).create() );
|
||||||
|
Assert.assertEquals( hoverEvent.getContents().size(), 1 );
|
||||||
|
Assert.assertTrue( hoverEvent.isLegacy() );
|
||||||
|
serialized = ComponentSerializer.toString( component );
|
||||||
|
deserialized = ComponentSerializer.parse( serialized );
|
||||||
|
Assert.assertEquals( component.getHoverEvent(), deserialized[0].getHoverEvent() );
|
||||||
|
|
||||||
// Test single content:
|
// Test single content:
|
||||||
String json = "{\"italic\":true,\"color\":\"gray\",\"translate\":\"chat.type.admin\",\"with\":[{\"text\":\"@\"}"
|
String json = "{\"italic\":true,\"color\":\"gray\",\"translate\":\"chat.type.admin\",\"with\":[{\"text\":\"@\"}"
|
||||||
@@ -320,28 +248,17 @@ public class ComponentsTest
|
|||||||
+ "\"/tell Name \"},\"hoverEvent\":{\"action\":\"show_entity\",\"contents\":"
|
+ "\"/tell Name \"},\"hoverEvent\":{\"action\":\"show_entity\",\"contents\":"
|
||||||
+ "{\"type\":\"minecraft:player\",\"id\":\"00000000-0000-0000-0000-00000000000000\",\"name\":"
|
+ "{\"type\":\"minecraft:player\",\"id\":\"00000000-0000-0000-0000-00000000000000\",\"name\":"
|
||||||
+ "{\"text\":\"Name\"}}},\"text\":\"Name\"}]}]}";
|
+ "{\"text\":\"Name\"}}},\"text\":\"Name\"}]}]}";
|
||||||
dissembleReassembleTest.accept( deserializer.apply( json ) );
|
testDissembleReassemble( ComponentSerializer.parse( json ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFormatRetentionCopyFormattingCreate()
|
public void testFormatRetentionCopyFormatting()
|
||||||
{
|
|
||||||
this.testFormatRetentionCopyFormatting( () -> new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Test" ).create() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFormatRetentionCopyFormattingBuild()
|
|
||||||
{
|
|
||||||
this.testFormatRetentionCopyFormatting( () -> new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text( new ComponentBuilder( "Test" ).build() ) ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void testFormatRetentionCopyFormatting(Supplier<HoverEvent> hoverEventSupplier)
|
|
||||||
{
|
{
|
||||||
TextComponent first = new TextComponent( "Hello" );
|
TextComponent first = new TextComponent( "Hello" );
|
||||||
first.setBold( true );
|
first.setBold( true );
|
||||||
first.setColor( ChatColor.RED );
|
first.setColor( ChatColor.RED );
|
||||||
first.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "test" ) );
|
first.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "test" ) );
|
||||||
first.setHoverEvent( hoverEventSupplier.get() );
|
first.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Test" ).create() ) );
|
||||||
|
|
||||||
TextComponent second = new TextComponent( " world" );
|
TextComponent second = new TextComponent( " world" );
|
||||||
second.copyFormatting( first, ComponentBuilder.FormatRetention.ALL, true );
|
second.copyFormatting( first, ComponentBuilder.FormatRetention.ALL, true );
|
||||||
@@ -352,44 +269,16 @@ public class ComponentsTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderCloneCreate()
|
public void testBuilderClone()
|
||||||
{
|
|
||||||
this.testBuilderClone( (builder) -> TextComponent.toLegacyText( builder.create() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBuilderCloneBuild()
|
|
||||||
{
|
|
||||||
this.testBuilderClone( (builder) -> TextComponent.toLegacyText( builder.build() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void testBuilderClone(Function<ComponentBuilder, String> legacyTextFunction)
|
|
||||||
{
|
{
|
||||||
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( ChatColor.RED ).append( "world" ).color( ChatColor.DARK_RED );
|
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( ChatColor.RED ).append( "world" ).color( ChatColor.DARK_RED );
|
||||||
ComponentBuilder cloned = new ComponentBuilder( builder );
|
ComponentBuilder cloned = new ComponentBuilder( builder );
|
||||||
|
|
||||||
Assert.assertEquals( legacyTextFunction.apply( builder ), legacyTextFunction.apply( cloned ) );
|
Assert.assertEquals( TextComponent.toLegacyText( builder.create() ), TextComponent.toLegacyText( cloned.create() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderAppendCreateMixedComponents()
|
public void testBuilderAppendMixedComponents()
|
||||||
{
|
|
||||||
this.testBuilderAppendMixedComponents(
|
|
||||||
ComponentBuilder::create,
|
|
||||||
(components, index) -> components[index]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBuilderAppendBuildMixedComponents()
|
|
||||||
{
|
|
||||||
this.testBuilderAppendMixedComponents(
|
|
||||||
ComponentBuilder::build,
|
|
||||||
(component, index) -> component.getExtra().get( index )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void testBuilderAppendMixedComponents(Function<ComponentBuilder, T> componentBuilder, BiFunction<T, Integer, BaseComponent> extraGetter)
|
|
||||||
{
|
{
|
||||||
ComponentBuilder builder = new ComponentBuilder( "Hello " );
|
ComponentBuilder builder = new ComponentBuilder( "Hello " );
|
||||||
TextComponent textComponent = new TextComponent( "world " );
|
TextComponent textComponent = new TextComponent( "world " );
|
||||||
@@ -402,11 +291,11 @@ public class ComponentsTest
|
|||||||
} );
|
} );
|
||||||
ScoreComponent scoreComponent = new ScoreComponent( "myscore", "myobjective" );
|
ScoreComponent scoreComponent = new ScoreComponent( "myscore", "myobjective" );
|
||||||
builder.append( scoreComponent ); // non array based BaseComponent append
|
builder.append( scoreComponent ); // non array based BaseComponent append
|
||||||
T component = componentBuilder.apply( builder );
|
BaseComponent[] components = builder.create();
|
||||||
Assert.assertEquals( "Hello ", extraGetter.apply( component, 0 ).toPlainText() );
|
Assert.assertEquals( "Hello ", components[0].toPlainText() );
|
||||||
Assert.assertEquals( textComponent.toPlainText(), extraGetter.apply( component, 1 ).toPlainText() );
|
Assert.assertEquals( textComponent.toPlainText(), components[1].toPlainText() );
|
||||||
Assert.assertEquals( translatableComponent.toPlainText(), extraGetter.apply( component, 2 ).toPlainText() );
|
Assert.assertEquals( translatableComponent.toPlainText(), components[2].toPlainText() );
|
||||||
Assert.assertEquals( scoreComponent.toPlainText(), extraGetter.apply( component, 3 ).toPlainText() );
|
Assert.assertEquals( scoreComponent.toPlainText(), components[3].toPlainText() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -420,80 +309,32 @@ public class ComponentsTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderAppendCreate()
|
public void testBuilderAppend()
|
||||||
{
|
|
||||||
this.testBuilderAppend(
|
|
||||||
() -> new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Hello world" ).create() ),
|
|
||||||
ComponentBuilder::create,
|
|
||||||
(components, index) -> components[index],
|
|
||||||
BaseComponent::toPlainText,
|
|
||||||
ChatColor.YELLOW + "Hello " + ChatColor.GREEN + "world!",
|
|
||||||
BaseComponent::toLegacyText
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBuilderAppendBuild()
|
|
||||||
{
|
|
||||||
this.testBuilderAppend(
|
|
||||||
() -> new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text( new ComponentBuilder( "Hello world" ).build() ) ),
|
|
||||||
ComponentBuilder::build,
|
|
||||||
(component, index) -> component.getExtra().get( index ),
|
|
||||||
(component) -> BaseComponent.toPlainText( component ),
|
|
||||||
// An extra format code is appended to the beginning because there is an empty TextComponent at the start of every component
|
|
||||||
ChatColor.WHITE.toString() + ChatColor.YELLOW + "Hello " + ChatColor.GREEN + "world!",
|
|
||||||
(component) -> BaseComponent.toLegacyText( component )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void testBuilderAppend(Supplier<HoverEvent> hoverEventSupplier, Function<ComponentBuilder, T> componentBuilder, BiFunction<T, Integer, BaseComponent> extraGetter, Function<T, String> toPlainTextFunction, String expectedLegacyText, Function<T, String> toLegacyTextFunction)
|
|
||||||
{
|
{
|
||||||
ClickEvent clickEvent = new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/help " );
|
ClickEvent clickEvent = new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/help " );
|
||||||
HoverEvent hoverEvent = hoverEventSupplier.get();
|
HoverEvent hoverEvent = new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Hello world" ).create() );
|
||||||
|
|
||||||
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( ChatColor.YELLOW );
|
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( ChatColor.YELLOW );
|
||||||
builder.append( new ComponentBuilder( "world!" ).color( ChatColor.GREEN ).event( hoverEvent ).event( clickEvent ).create() ); // Intentionally using create() to append multiple individual components
|
builder.append( new ComponentBuilder( "world!" ).color( ChatColor.GREEN ).event( hoverEvent ).event( clickEvent ).create() );
|
||||||
|
|
||||||
T component = componentBuilder.apply( builder );
|
BaseComponent[] components = builder.create();
|
||||||
|
|
||||||
Assert.assertEquals( extraGetter.apply( component, 1 ).getHoverEvent(), hoverEvent );
|
Assert.assertEquals( components[1].getHoverEvent(), hoverEvent );
|
||||||
Assert.assertEquals( extraGetter.apply( component, 1 ).getClickEvent(), clickEvent );
|
Assert.assertEquals( components[1].getClickEvent(), clickEvent );
|
||||||
Assert.assertEquals( "Hello world!", toPlainTextFunction.apply( component ) );
|
Assert.assertEquals( "Hello world!", BaseComponent.toPlainText( components ) );
|
||||||
Assert.assertEquals( expectedLegacyText, toLegacyTextFunction.apply( component ) );
|
Assert.assertEquals( ChatColor.YELLOW + "Hello " + ChatColor.GREEN + "world!", BaseComponent.toLegacyText( components ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderAppendLegacyCreate()
|
public void testBuilderAppendLegacy()
|
||||||
{
|
|
||||||
this.testBuilderAppendLegacy(
|
|
||||||
ComponentBuilder::create,
|
|
||||||
BaseComponent::toPlainText,
|
|
||||||
ChatColor.YELLOW + "Hello " + ChatColor.GREEN + "world!",
|
|
||||||
BaseComponent::toLegacyText
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBuilderAppendLegacyBuild()
|
|
||||||
{
|
|
||||||
this.testBuilderAppendLegacy(
|
|
||||||
ComponentBuilder::build,
|
|
||||||
(component) -> BaseComponent.toPlainText( component ),
|
|
||||||
// An extra format code is appended to the beginning because there is an empty TextComponent at the start of every component
|
|
||||||
ChatColor.WHITE.toString() + ChatColor.YELLOW + "Hello " + ChatColor.GREEN + "world!",
|
|
||||||
(component) -> BaseComponent.toLegacyText( component )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void testBuilderAppendLegacy(Function<ComponentBuilder, T> componentBuilder, Function<T, String> toPlainTextFunction, String expectedLegacyString, Function<T, String> toLegacyTextFunction)
|
|
||||||
{
|
{
|
||||||
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( ChatColor.YELLOW );
|
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( ChatColor.YELLOW );
|
||||||
builder.appendLegacy( "§aworld!" );
|
builder.appendLegacy( "§aworld!" );
|
||||||
|
|
||||||
T component = componentBuilder.apply( builder );
|
BaseComponent[] components = builder.create();
|
||||||
|
|
||||||
Assert.assertEquals( "Hello world!", toPlainTextFunction.apply( component ) );
|
Assert.assertEquals( "Hello world!", BaseComponent.toPlainText( components ) );
|
||||||
Assert.assertEquals( expectedLegacyString, toLegacyTextFunction.apply( component ) );
|
Assert.assertEquals( ChatColor.YELLOW + "Hello " + ChatColor.GREEN + "world!", BaseComponent.toLegacyText( components ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -556,114 +397,57 @@ public class ComponentsTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderCreate()
|
public void testBuilder()
|
||||||
{
|
{
|
||||||
this.testBuilder(
|
BaseComponent[] components = new ComponentBuilder( "Hello " ).color( ChatColor.RED ).
|
||||||
ComponentBuilder::create,
|
|
||||||
BaseComponent::toPlainText,
|
|
||||||
ChatColor.RED + "Hello " + ChatColor.BLUE + ChatColor.BOLD
|
|
||||||
+ "World" + ChatColor.YELLOW + ChatColor.BOLD + "!",
|
|
||||||
BaseComponent::toLegacyText
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBuilderBuild()
|
|
||||||
{
|
|
||||||
this.testBuilder(
|
|
||||||
ComponentBuilder::build,
|
|
||||||
(component) -> BaseComponent.toPlainText( component ),
|
|
||||||
// An extra format code is appended to the beginning because there is an empty TextComponent at the start of every component
|
|
||||||
ChatColor.WHITE.toString() + ChatColor.RED + "Hello " + ChatColor.BLUE + ChatColor.BOLD
|
|
||||||
+ "World" + ChatColor.YELLOW + ChatColor.BOLD + "!",
|
|
||||||
(component) -> BaseComponent.toLegacyText( component )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void testBuilder(Function<ComponentBuilder, T> componentBuilder, Function<T, String> toPlainTextFunction, String expectedLegacyString, Function<T, String> toLegacyTextFunction)
|
|
||||||
{
|
|
||||||
T component = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( ChatColor.RED ).
|
|
||||||
append( "World" ).bold( true ).color( ChatColor.BLUE ).
|
append( "World" ).bold( true ).color( ChatColor.BLUE ).
|
||||||
append( "!" ).color( ChatColor.YELLOW ) );
|
append( "!" ).color( ChatColor.YELLOW ).create();
|
||||||
|
|
||||||
Assert.assertEquals( "Hello World!", toPlainTextFunction.apply( component ) );
|
Assert.assertEquals( "Hello World!", BaseComponent.toPlainText( components ) );
|
||||||
Assert.assertEquals( expectedLegacyString, toLegacyTextFunction.apply( component ) );
|
Assert.assertEquals( ChatColor.RED + "Hello " + ChatColor.BLUE + ChatColor.BOLD
|
||||||
|
+ "World" + ChatColor.YELLOW + ChatColor.BOLD + "!", BaseComponent.toLegacyText( components ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderCreateReset()
|
public void testBuilderReset()
|
||||||
{
|
{
|
||||||
this.testBuilderReset(
|
BaseComponent[] components = new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
||||||
ComponentBuilder::create,
|
.append( "World" ).reset().create();
|
||||||
(components, index) -> components[index]
|
|
||||||
);
|
Assert.assertEquals( components[0].getColor(), ChatColor.RED );
|
||||||
|
Assert.assertEquals( components[1].getColor(), ChatColor.WHITE );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderBuildReset()
|
public void testBuilderFormatRetention()
|
||||||
{
|
{
|
||||||
this.testBuilderReset(
|
BaseComponent[] noneRetention = new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
||||||
ComponentBuilder::build,
|
.append( "World", ComponentBuilder.FormatRetention.NONE ).create();
|
||||||
(component, index) -> component.getExtra().get( index )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void testBuilderReset(Function<ComponentBuilder, T> componentBuilder, BiFunction<T, Integer, BaseComponent> extraGetter)
|
Assert.assertEquals( noneRetention[0].getColor(), ChatColor.RED );
|
||||||
{
|
Assert.assertEquals( noneRetention[1].getColor(), ChatColor.WHITE );
|
||||||
T component = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
|
||||||
.append( "World" ).reset() );
|
|
||||||
|
|
||||||
Assert.assertEquals( ChatColor.RED, extraGetter.apply( component, 0 ).getColor() );
|
HoverEvent testEvent = new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "test" ).create() );
|
||||||
Assert.assertEquals( ChatColor.WHITE, extraGetter.apply( component, 1 ).getColor() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
BaseComponent[] formattingRetention = new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
||||||
public void testBuilderCreateFormatRetention()
|
.event( testEvent ).append( "World", ComponentBuilder.FormatRetention.FORMATTING ).create();
|
||||||
{
|
|
||||||
this.testBuilderFormatRetention(
|
|
||||||
ComponentBuilder::create,
|
|
||||||
(components, index) -> components[index]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
Assert.assertEquals( formattingRetention[0].getColor(), ChatColor.RED );
|
||||||
public void testBuilderBuildFormatRetention()
|
Assert.assertEquals( formattingRetention[0].getHoverEvent(), testEvent );
|
||||||
{
|
Assert.assertEquals( formattingRetention[1].getColor(), ChatColor.RED );
|
||||||
this.testBuilderFormatRetention(
|
Assert.assertNull( formattingRetention[1].getHoverEvent() );
|
||||||
ComponentBuilder::build,
|
|
||||||
(component, index) -> component.getExtra().get( index )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> void testBuilderFormatRetention(Function<ComponentBuilder, T> componentBuilder, BiFunction<T, Integer, BaseComponent> extraGetter)
|
|
||||||
{
|
|
||||||
T noneRetention = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
|
||||||
.append( "World", ComponentBuilder.FormatRetention.NONE ) );
|
|
||||||
|
|
||||||
Assert.assertEquals( ChatColor.RED, extraGetter.apply( noneRetention, 0 ).getColor() );
|
|
||||||
Assert.assertEquals( ChatColor.WHITE, extraGetter.apply( noneRetention, 1 ).getColor() );
|
|
||||||
|
|
||||||
HoverEvent testEvent = new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text( new ComponentBuilder( "test" ).build() ) );
|
|
||||||
|
|
||||||
T formattingRetention = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
|
||||||
.event( testEvent ).append( "World", ComponentBuilder.FormatRetention.FORMATTING ) );
|
|
||||||
|
|
||||||
Assert.assertEquals( ChatColor.RED, extraGetter.apply( formattingRetention, 0 ).getColor() );
|
|
||||||
Assert.assertEquals( testEvent, extraGetter.apply( formattingRetention, 0 ).getHoverEvent() );
|
|
||||||
Assert.assertEquals( ChatColor.RED, extraGetter.apply( formattingRetention, 1 ).getColor() );
|
|
||||||
Assert.assertNull( extraGetter.apply( formattingRetention, 1 ).getHoverEvent() );
|
|
||||||
|
|
||||||
ClickEvent testClickEvent = new ClickEvent( ClickEvent.Action.OPEN_URL, "http://www.example.com" );
|
ClickEvent testClickEvent = new ClickEvent( ClickEvent.Action.OPEN_URL, "http://www.example.com" );
|
||||||
|
|
||||||
T eventRetention = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
BaseComponent[] eventRetention = new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
||||||
.event( testEvent ).event( testClickEvent ).append( "World", ComponentBuilder.FormatRetention.EVENTS ) );
|
.event( testEvent ).event( testClickEvent ).append( "World", ComponentBuilder.FormatRetention.EVENTS ).create();
|
||||||
|
|
||||||
Assert.assertEquals( ChatColor.RED, extraGetter.apply( eventRetention, 0 ).getColor() );
|
Assert.assertEquals( eventRetention[0].getColor(), ChatColor.RED );
|
||||||
Assert.assertEquals( testEvent, extraGetter.apply( eventRetention, 0 ).getHoverEvent() );
|
Assert.assertEquals( eventRetention[0].getHoverEvent(), testEvent );
|
||||||
Assert.assertEquals( testClickEvent, extraGetter.apply( eventRetention, 0 ).getClickEvent() );
|
Assert.assertEquals( eventRetention[0].getClickEvent(), testClickEvent );
|
||||||
Assert.assertEquals( ChatColor.WHITE, extraGetter.apply( eventRetention, 1 ).getColor() );
|
Assert.assertEquals( eventRetention[1].getColor(), ChatColor.WHITE );
|
||||||
Assert.assertEquals( testEvent, extraGetter.apply( eventRetention, 1 ).getHoverEvent() );
|
Assert.assertEquals( eventRetention[1].getHoverEvent(), testEvent );
|
||||||
Assert.assertEquals( testClickEvent, extraGetter.apply( eventRetention, 1 ).getClickEvent() );
|
Assert.assertEquals( eventRetention[1].getClickEvent(), testClickEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@@ -788,54 +572,7 @@ public class ComponentsTest
|
|||||||
Assert.assertArrayEquals( hexColored, reColored );
|
Assert.assertArrayEquals( hexColored, reColored );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
private String fromAndToLegacyText(String legacyText)
|
||||||
public void testLegacyResetInBuilderCreate()
|
|
||||||
{
|
|
||||||
this.testLegacyResetInBuilder(
|
|
||||||
ComponentBuilder::create,
|
|
||||||
ComponentSerializer::toString
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLegacyResetInBuilderBuild()
|
|
||||||
{
|
|
||||||
this.testLegacyResetInBuilder(
|
|
||||||
ComponentBuilder::build,
|
|
||||||
ComponentSerializer::toString
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* In legacy chat, colors and reset both reset all formatting.
|
|
||||||
* Make sure it works in combination with ComponentBuilder.
|
|
||||||
*/
|
|
||||||
private <T> void testLegacyResetInBuilder(Function<ComponentBuilder, T> componentBuilder, Function<T, String> componentSerializer)
|
|
||||||
{
|
|
||||||
ComponentBuilder builder = new ComponentBuilder();
|
|
||||||
BaseComponent[] a = TextComponent.fromLegacyText( "§4§n44444§rdd§6§l6666" );
|
|
||||||
|
|
||||||
String expected = "{\"extra\":[{\"underlined\":true,\"color\":\"dark_red\",\"text\":\"44444\"},{\"color\":"
|
|
||||||
+ "\"white\",\"text\":\"dd\"},{\"bold\":true,\"color\":\"gold\",\"text\":\"6666\"}],\"text\":\"\"}";
|
|
||||||
Assert.assertEquals( expected, ComponentSerializer.toString( a ) );
|
|
||||||
|
|
||||||
builder.append( a );
|
|
||||||
|
|
||||||
String test1 = componentSerializer.apply( componentBuilder.apply( builder ) );
|
|
||||||
Assert.assertEquals( expected, test1 );
|
|
||||||
|
|
||||||
BaseComponent[] b = TextComponent.fromLegacyText( "§rrrrr" );
|
|
||||||
builder.append( b );
|
|
||||||
|
|
||||||
String test2 = componentSerializer.apply( componentBuilder.apply( builder ) );
|
|
||||||
Assert.assertEquals(
|
|
||||||
"{\"extra\":[{\"underlined\":true,\"color\":\"dark_red\",\"text\":\"44444\"},"
|
|
||||||
+ "{\"color\":\"white\",\"text\":\"dd\"},{\"bold\":true,\"color\":\"gold\",\"text\":\"6666\"},"
|
|
||||||
+ "{\"color\":\"white\",\"text\":\"rrrr\"}],\"text\":\"\"}",
|
|
||||||
test2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String fromAndToLegacyText(String legacyText)
|
|
||||||
{
|
{
|
||||||
return BaseComponent.toLegacyText( TextComponent.fromLegacyText( legacyText ) );
|
return BaseComponent.toLegacyText( TextComponent.fromLegacyText( legacyText ) );
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,6 @@
|
|||||||
|
|
||||||
<!-- See http://checkstyle.sourceforge.net/config_filters.html -->
|
<!-- See http://checkstyle.sourceforge.net/config_filters.html -->
|
||||||
<module name="SuppressionCommentFilter"/>
|
<module name="SuppressionCommentFilter"/>
|
||||||
<module name="SuppressWarningsHolder"/>
|
|
||||||
|
|
||||||
<!-- See http://checkstyle.sourceforge.net/config_imports.html -->
|
<!-- See http://checkstyle.sourceforge.net/config_imports.html -->
|
||||||
<module name="AvoidStarImport"/>
|
<module name="AvoidStarImport"/>
|
||||||
@@ -55,11 +54,11 @@
|
|||||||
<module name="OperatorWrap"/>
|
<module name="OperatorWrap"/>
|
||||||
<module name="ParenPad">
|
<module name="ParenPad">
|
||||||
<property name="option" value="nospace"/>
|
<property name="option" value="nospace"/>
|
||||||
<property name="tokens" value="ANNOTATION, CTOR_DEF, METHOD_DEF, LAMBDA"/>
|
<property name="tokens" value="ANNOTATION, CTOR_DEF, METHOD_DEF"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="ParenPad">
|
<module name="ParenPad">
|
||||||
<property name="option" value="space"/>
|
<property name="option" value="space"/>
|
||||||
<property name="tokens" value="ANNOTATION_FIELD_DEF, CTOR_CALL, DOT, ENUM_CONSTANT_DEF, EXPR, LITERAL_CATCH, LITERAL_DO, LITERAL_FOR, LITERAL_IF, LITERAL_NEW, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_WHILE, METHOD_CALL, QUESTION, RESOURCE_SPECIFICATION, SUPER_CTOR_CALL, RECORD_DEF"/>
|
<property name="tokens" value="ANNOTATION_FIELD_DEF, CTOR_CALL, DOT, ENUM_CONSTANT_DEF, EXPR, LITERAL_CATCH, LITERAL_DO, LITERAL_FOR, LITERAL_IF, LITERAL_NEW, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_WHILE, METHOD_CALL, QUESTION, RESOURCE_SPECIFICATION, SUPER_CTOR_CALL, LAMBDA"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="SingleSpaceSeparator"/>
|
<module name="SingleSpaceSeparator"/>
|
||||||
<module name="TypecastParenPad"/>
|
<module name="TypecastParenPad"/>
|
||||||
@@ -85,6 +84,4 @@
|
|||||||
<module name="Indentation"/>
|
<module name="Indentation"/>
|
||||||
<module name="UpperEll"/>
|
<module name="UpperEll"/>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
<module name="SuppressWarningsFilter"/>
|
|
||||||
</module>
|
</module>
|
||||||
|
@@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-config</artifactId>
|
<artifactId>bungeecord-config</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Config</name>
|
<name>BungeeCord-Config</name>
|
||||||
@@ -22,14 +22,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>2.10.1</version>
|
<version>2.8.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.yaml</groupId>
|
<groupId>org.yaml</groupId>
|
||||||
<artifactId>snakeyaml</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
<version>2.2</version>
|
<version>1.26</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@@ -14,7 +14,6 @@ import java.util.Map;
|
|||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.yaml.snakeyaml.DumperOptions;
|
import org.yaml.snakeyaml.DumperOptions;
|
||||||
import org.yaml.snakeyaml.LoaderOptions;
|
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
import org.yaml.snakeyaml.constructor.Constructor;
|
import org.yaml.snakeyaml.constructor.Constructor;
|
||||||
import org.yaml.snakeyaml.nodes.Node;
|
import org.yaml.snakeyaml.nodes.Node;
|
||||||
@@ -30,10 +29,7 @@ public class YamlConfiguration extends ConfigurationProvider
|
|||||||
@Override
|
@Override
|
||||||
protected Yaml initialValue()
|
protected Yaml initialValue()
|
||||||
{
|
{
|
||||||
DumperOptions options = new DumperOptions();
|
Representer representer = new Representer()
|
||||||
options.setDefaultFlowStyle( DumperOptions.FlowStyle.BLOCK );
|
|
||||||
|
|
||||||
Representer representer = new Representer( options )
|
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
representers.put( Configuration.class, new Represent()
|
representers.put( Configuration.class, new Represent()
|
||||||
@@ -47,7 +43,10 @@ public class YamlConfiguration extends ConfigurationProvider
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return new Yaml( new Constructor( new LoaderOptions() ), representer, options );
|
DumperOptions options = new DumperOptions();
|
||||||
|
options.setDefaultFlowStyle( DumperOptions.FlowStyle.BLOCK );
|
||||||
|
|
||||||
|
return new Yaml( new Constructor(), representer, options );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-event</artifactId>
|
<artifactId>bungeecord-event</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Event</name>
|
<name>BungeeCord-Event</name>
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
package net.md_5.bungee.event;
|
package net.md_5.bungee.event;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
@@ -42,8 +41,6 @@ public class EventBus
|
|||||||
{
|
{
|
||||||
for ( EventHandlerMethod method : handlers )
|
for ( EventHandlerMethod method : handlers )
|
||||||
{
|
{
|
||||||
long start = System.nanoTime();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
method.invoke( event );
|
method.invoke( event );
|
||||||
@@ -57,15 +54,6 @@ public class EventBus
|
|||||||
{
|
{
|
||||||
logger.log( Level.WARNING, MessageFormat.format( "Error dispatching event {0} to listener {1}", event, method.getListener() ), ex.getCause() );
|
logger.log( Level.WARNING, MessageFormat.format( "Error dispatching event {0} to listener {1}", event, method.getListener() ), ex.getCause() );
|
||||||
}
|
}
|
||||||
|
|
||||||
long elapsed = System.nanoTime() - start;
|
|
||||||
if ( elapsed > 50000000 )
|
|
||||||
{
|
|
||||||
logger.log( Level.WARNING, "Plugin listener {0} took {1}ms to process event {2}!", new Object[]
|
|
||||||
{
|
|
||||||
method.getListener().getClass().getName(), elapsed / 1000000, event
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,8 +61,7 @@ public class EventBus
|
|||||||
private Map<Class<?>, Map<Byte, Set<Method>>> findHandlers(Object listener)
|
private Map<Class<?>, Map<Byte, Set<Method>>> findHandlers(Object listener)
|
||||||
{
|
{
|
||||||
Map<Class<?>, Map<Byte, Set<Method>>> handler = new HashMap<>();
|
Map<Class<?>, Map<Byte, Set<Method>>> handler = new HashMap<>();
|
||||||
Set<Method> methods = ImmutableSet.<Method>builder().add( listener.getClass().getMethods() ).add( listener.getClass().getDeclaredMethods() ).build();
|
for ( Method m : listener.getClass().getDeclaredMethods() )
|
||||||
for ( final Method m : methods )
|
|
||||||
{
|
{
|
||||||
EventHandler annotation = m.getAnnotation( EventHandler.class );
|
EventHandler annotation = m.getAnnotation( EventHandler.class );
|
||||||
if ( annotation != null )
|
if ( annotation != null )
|
||||||
@@ -88,8 +75,18 @@ public class EventBus
|
|||||||
} );
|
} );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Map<Byte, Set<Method>> prioritiesMap = handler.computeIfAbsent( params[0], k -> new HashMap<>() );
|
Map<Byte, Set<Method>> prioritiesMap = handler.get( params[0] );
|
||||||
Set<Method> priority = prioritiesMap.computeIfAbsent( annotation.priority(), k -> new HashSet<>() );
|
if ( prioritiesMap == null )
|
||||||
|
{
|
||||||
|
prioritiesMap = new HashMap<>();
|
||||||
|
handler.put( params[0], prioritiesMap );
|
||||||
|
}
|
||||||
|
Set<Method> priority = prioritiesMap.get( annotation.priority() );
|
||||||
|
if ( priority == null )
|
||||||
|
{
|
||||||
|
priority = new HashSet<>();
|
||||||
|
prioritiesMap.put( annotation.priority(), priority );
|
||||||
|
}
|
||||||
priority.add( m );
|
priority.add( m );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,11 +101,22 @@ public class EventBus
|
|||||||
{
|
{
|
||||||
for ( Map.Entry<Class<?>, Map<Byte, Set<Method>>> e : handler.entrySet() )
|
for ( Map.Entry<Class<?>, Map<Byte, Set<Method>>> e : handler.entrySet() )
|
||||||
{
|
{
|
||||||
Map<Byte, Map<Object, Method[]>> prioritiesMap = byListenerAndPriority.computeIfAbsent( e.getKey(), k -> new HashMap<>() );
|
Map<Byte, Map<Object, Method[]>> prioritiesMap = byListenerAndPriority.get( e.getKey() );
|
||||||
|
if ( prioritiesMap == null )
|
||||||
|
{
|
||||||
|
prioritiesMap = new HashMap<>();
|
||||||
|
byListenerAndPriority.put( e.getKey(), prioritiesMap );
|
||||||
|
}
|
||||||
for ( Map.Entry<Byte, Set<Method>> entry : e.getValue().entrySet() )
|
for ( Map.Entry<Byte, Set<Method>> entry : e.getValue().entrySet() )
|
||||||
{
|
{
|
||||||
Map<Object, Method[]> currentPriorityMap = prioritiesMap.computeIfAbsent( entry.getKey(), k -> new HashMap<>() );
|
Map<Object, Method[]> currentPriorityMap = prioritiesMap.get( entry.getKey() );
|
||||||
currentPriorityMap.put( listener, entry.getValue().toArray( new Method[ 0 ] ) );
|
if ( currentPriorityMap == null )
|
||||||
|
{
|
||||||
|
currentPriorityMap = new HashMap<>();
|
||||||
|
prioritiesMap.put( entry.getKey(), currentPriorityMap );
|
||||||
|
}
|
||||||
|
Method[] baked = new Method[ entry.getValue().size() ];
|
||||||
|
currentPriorityMap.put( listener, entry.getValue().toArray( baked ) );
|
||||||
}
|
}
|
||||||
bakeHandlers( e.getKey() );
|
bakeHandlers( e.getKey() );
|
||||||
}
|
}
|
||||||
@@ -186,7 +194,7 @@ public class EventBus
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while ( value++ < Byte.MAX_VALUE );
|
} while ( value++ < Byte.MAX_VALUE );
|
||||||
byEventBaked.put( eventClass, handlersList.toArray( new EventHandlerMethod[ 0 ] ) );
|
byEventBaked.put( eventClass, handlersList.toArray( new EventHandlerMethod[ handlersList.size() ] ) );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
byEventBaked.remove( eventClass );
|
byEventBaked.remove( eventClass );
|
||||||
|
@@ -1,26 +0,0 @@
|
|||||||
package net.md_5.bungee.event;
|
|
||||||
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class SubclassTest extends EventBusTest
|
|
||||||
{
|
|
||||||
|
|
||||||
private final CountDownLatch latch = new CountDownLatch( 1 );
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@Override
|
|
||||||
public void testNestedEvents()
|
|
||||||
{
|
|
||||||
super.testNestedEvents();
|
|
||||||
Assert.assertEquals( 0, latch.getCount() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
protected void extraListener(FirstEvent event)
|
|
||||||
{
|
|
||||||
Assert.assertEquals( 1, latch.getCount() );
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-log</artifactId>
|
<artifactId>bungeecord-log</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Log</name>
|
<name>BungeeCord-Log</name>
|
||||||
|
@@ -13,23 +13,19 @@ public class BungeeLogger extends Logger
|
|||||||
|
|
||||||
private final LogDispatcher dispatcher = new LogDispatcher( this );
|
private final LogDispatcher dispatcher = new LogDispatcher( this );
|
||||||
|
|
||||||
// CHECKSTYLE:OFF
|
|
||||||
@SuppressWarnings(
|
@SuppressWarnings(
|
||||||
{
|
{
|
||||||
"CallToPrintStackTrace", "CallToThreadStartDuringObjectConstruction"
|
"CallToPrintStackTrace", "CallToThreadStartDuringObjectConstruction"
|
||||||
})
|
})
|
||||||
// CHECKSTYLE:ON
|
|
||||||
@SuppressFBWarnings("SC_START_IN_CTOR")
|
@SuppressFBWarnings("SC_START_IN_CTOR")
|
||||||
public BungeeLogger(String loggerName, String filePattern, ConsoleReader reader)
|
public BungeeLogger(String loggerName, String filePattern, ConsoleReader reader)
|
||||||
{
|
{
|
||||||
super( loggerName, null );
|
super( loggerName, null );
|
||||||
setLevel( Level.ALL );
|
setLevel( Level.ALL );
|
||||||
setUseParentHandlers( false );
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FileHandler fileHandler = new FileHandler( filePattern, 1 << 24, 8, true );
|
FileHandler fileHandler = new FileHandler( filePattern, 1 << 24, 8, true );
|
||||||
fileHandler.setLevel( Level.parse( System.getProperty( "net.md_5.bungee.file-log-level", "INFO" ) ) );
|
|
||||||
fileHandler.setFormatter( new ConciseFormatter( false ) );
|
fileHandler.setFormatter( new ConciseFormatter( false ) );
|
||||||
addHandler( fileHandler );
|
addHandler( fileHandler );
|
||||||
|
|
||||||
|
@@ -1,29 +0,0 @@
|
|||||||
package net.md_5.bungee.log;
|
|
||||||
|
|
||||||
import java.util.logging.Handler;
|
|
||||||
import java.util.logging.LogRecord;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class LoggingForwardHandler extends Handler
|
|
||||||
{
|
|
||||||
|
|
||||||
private final Logger logger;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void publish(LogRecord record)
|
|
||||||
{
|
|
||||||
logger.log( record );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void flush()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() throws SecurityException
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module</artifactId>
|
<artifactId>bungeecord-module</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module-cmd-alert</artifactId>
|
<artifactId>bungeecord-module-cmd-alert</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>cmd_alert</name>
|
<name>cmd_alert</name>
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
package net.md_5.bungee.module.cmd.alert;
|
package net.md_5.bungee.module.cmd.alert;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
@@ -24,10 +23,10 @@ public class CommandAlert extends Command
|
|||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
if ( args[0].toLowerCase( Locale.ROOT ).startsWith( "&h" ) )
|
if ( args[0].startsWith( "&h" ) )
|
||||||
{
|
{
|
||||||
// Remove &h
|
// Remove &h
|
||||||
args[0] = args[0].substring( 2 );
|
args[0] = args[0].substring( 2, args[0].length() );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
builder.append( ProxyServer.getInstance().getTranslation( "alert" ) );
|
builder.append( ProxyServer.getInstance().getTranslation( "alert" ) );
|
||||||
|
@@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module</artifactId>
|
<artifactId>bungeecord-module</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module-cmd-find</artifactId>
|
<artifactId>bungeecord-module-cmd-find</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>cmd_find</name>
|
<name>cmd_find</name>
|
||||||
|
@@ -1,12 +1,7 @@
|
|||||||
package net.md_5.bungee.module.cmd.find;
|
package net.md_5.bungee.module.cmd.find;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
|
||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.command.PlayerCommand;
|
import net.md_5.bungee.command.PlayerCommand;
|
||||||
|
|
||||||
@@ -32,27 +27,8 @@ public class CommandFind extends PlayerCommand
|
|||||||
sender.sendMessage( ProxyServer.getInstance().getTranslation( "user_not_online" ) );
|
sender.sendMessage( ProxyServer.getInstance().getTranslation( "user_not_online" ) );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
boolean moduleLoaded = ProxyServer.getInstance().getPluginManager().getPlugin( "cmd_server" ) != null;
|
sender.sendMessage( ProxyServer.getInstance().getTranslation( "user_online_at", player.getName(), player.getServer().getInfo().getName() ) );
|
||||||
ServerInfo server = player.getServer().getInfo();
|
|
||||||
ComponentBuilder componentBuilder = new ComponentBuilder().appendLegacy( ProxyServer.getInstance().getTranslation( "user_online_at", player.getName(), server.getName() ) );
|
|
||||||
|
|
||||||
if ( moduleLoaded && server.canAccess( sender ) )
|
|
||||||
{
|
|
||||||
componentBuilder.event( new HoverEvent(
|
|
||||||
HoverEvent.Action.SHOW_TEXT,
|
|
||||||
new ComponentBuilder().appendLegacy( ProxyServer.getInstance().getTranslation( "click_to_connect" ) ).create() )
|
|
||||||
);
|
|
||||||
componentBuilder.event( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/server " + server.getName() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage( componentBuilder.create() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args)
|
|
||||||
{
|
|
||||||
return args.length == 1 ? super.onTabComplete( sender, args ) : Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,31 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project-shared-configuration>
|
|
||||||
<!--
|
|
||||||
This file contains additional configuration written by modules in the NetBeans IDE.
|
|
||||||
The configuration is intended to be shared among all the users of project and
|
|
||||||
therefore it is assumed to be part of version control checkout.
|
|
||||||
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
|
|
||||||
-->
|
|
||||||
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
|
|
||||||
<!--
|
|
||||||
Properties that influence various parts of the IDE, especially code formatting and the like.
|
|
||||||
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
|
|
||||||
That way multiple projects can share the same settings (useful for formatting rules for example).
|
|
||||||
Any value defined here will override the pom.xml file value but is only applicable to the current project.
|
|
||||||
-->
|
|
||||||
<org-netbeans-modules-editor-indent.CodeStyle.usedProfile>project</org-netbeans-modules-editor-indent.CodeStyle.usedProfile>
|
|
||||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement>
|
|
||||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement>
|
|
||||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement>
|
|
||||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinMethodCallParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinMethodCallParens>
|
|
||||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSwitchParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSwitchParens>
|
|
||||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinCatchParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinCatchParens>
|
|
||||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinTryParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinTryParens>
|
|
||||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSynchronizedParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSynchronizedParens>
|
|
||||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinArrayInitBrackets>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinArrayInitBrackets>
|
|
||||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinParens>
|
|
||||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinWhileParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinWhileParens>
|
|
||||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinIfParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinIfParens>
|
|
||||||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinForParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinForParens>
|
|
||||||
</properties>
|
|
||||||
</project-shared-configuration>
|
|
@@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>net.md-5</groupId>
|
|
||||||
<artifactId>bungeecord-module</artifactId>
|
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
|
||||||
<relativePath>../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
|
||||||
<artifactId>bungeecord-module-cmd-kick</artifactId>
|
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<name>cmd_kick</name>
|
|
||||||
<description>Provides the gkick command</description>
|
|
||||||
</project>
|
|
@@ -1,72 +0,0 @@
|
|||||||
package net.md_5.bungee.module.cmd.kick;
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Set;
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
import net.md_5.bungee.api.plugin.Command;
|
|
||||||
import net.md_5.bungee.api.plugin.TabExecutor;
|
|
||||||
|
|
||||||
public class CommandKick extends Command implements TabExecutor
|
|
||||||
{
|
|
||||||
|
|
||||||
public CommandKick()
|
|
||||||
{
|
|
||||||
super( "gkick", "bungeecord.command.kick" );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(CommandSender sender, String[] args)
|
|
||||||
{
|
|
||||||
if ( args.length == 0 )
|
|
||||||
{
|
|
||||||
sender.sendMessage( ProxyServer.getInstance().getTranslation( "username_needed" ) );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer( args[0] );
|
|
||||||
|
|
||||||
if ( player == null )
|
|
||||||
{
|
|
||||||
sender.sendMessage( TextComponent.fromLegacyText( ProxyServer.getInstance().getTranslation( "user_not_online" ) ) );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( args.length == 1 )
|
|
||||||
{
|
|
||||||
player.disconnect( TextComponent.fromLegacyText( ProxyServer.getInstance().getTranslation( "kick_message" ) ) );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
String[] reason = new String[ args.length - 1 ];
|
|
||||||
System.arraycopy( args, 1, reason, 0, reason.length );
|
|
||||||
player.disconnect( TextComponent.fromLegacyText( ChatColor.translateAlternateColorCodes( '&', Joiner.on( ' ' ).join( reason ) ) ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args)
|
|
||||||
{
|
|
||||||
if ( args.length == 1 )
|
|
||||||
{
|
|
||||||
Set<String> matches = new HashSet<>();
|
|
||||||
String search = args[0].toLowerCase( Locale.ROOT );
|
|
||||||
for ( ProxiedPlayer player : ProxyServer.getInstance().getPlayers() )
|
|
||||||
{
|
|
||||||
if ( player.getName().toLowerCase( Locale.ROOT ).startsWith( search ) )
|
|
||||||
{
|
|
||||||
matches.add( player.getName() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return matches;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
return ImmutableSet.of();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,13 +0,0 @@
|
|||||||
package net.md_5.bungee.module.cmd.kick;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
|
||||||
|
|
||||||
public class PluginKick extends Plugin
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable()
|
|
||||||
{
|
|
||||||
getProxy().getPluginManager().registerCommand( this, new CommandKick() );
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,5 +0,0 @@
|
|||||||
name: ${project.name}
|
|
||||||
main: net.md_5.bungee.module.cmd.kick.PluginKick
|
|
||||||
version: ${describe}
|
|
||||||
description: ${project.description}
|
|
||||||
author: ${module.author}
|
|
@@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module</artifactId>
|
<artifactId>bungeecord-module</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module-cmd-list</artifactId>
|
<artifactId>bungeecord-module-cmd-list</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>cmd_list</name>
|
<name>cmd_list</name>
|
||||||
|
@@ -1,21 +1,20 @@
|
|||||||
package net.md_5.bungee.module.cmd.list;
|
package net.md_5.bungee.module.cmd.list;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import net.md_5.bungee.Util;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.plugin.Command;
|
import net.md_5.bungee.api.plugin.Command;
|
||||||
import net.md_5.bungee.api.plugin.TabExecutor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command to list all players connected to the proxy.
|
* Command to list all players connected to the proxy.
|
||||||
*/
|
*/
|
||||||
public class CommandList extends Command implements TabExecutor
|
public class CommandList extends Command
|
||||||
{
|
{
|
||||||
|
|
||||||
public CommandList()
|
public CommandList()
|
||||||
@@ -26,8 +25,6 @@ public class CommandList extends Command implements TabExecutor
|
|||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args)
|
public void execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
boolean hideEmptyServers = ( args.length == 0 ) || !args[0].equalsIgnoreCase( "all" );
|
|
||||||
|
|
||||||
for ( ServerInfo server : ProxyServer.getInstance().getServers().values() )
|
for ( ServerInfo server : ProxyServer.getInstance().getServers().values() )
|
||||||
{
|
{
|
||||||
if ( !server.canAccess( sender ) )
|
if ( !server.canAccess( sender ) )
|
||||||
@@ -35,28 +32,16 @@ public class CommandList extends Command implements TabExecutor
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<ProxiedPlayer> serverPlayers = server.getPlayers();
|
|
||||||
if ( hideEmptyServers && serverPlayers.isEmpty() )
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> players = new ArrayList<>();
|
List<String> players = new ArrayList<>();
|
||||||
for ( ProxiedPlayer player : serverPlayers )
|
for ( ProxiedPlayer player : server.getPlayers() )
|
||||||
{
|
{
|
||||||
players.add( player.getDisplayName() );
|
players.add( player.getDisplayName() );
|
||||||
}
|
}
|
||||||
Collections.sort( players, String.CASE_INSENSITIVE_ORDER );
|
Collections.sort( players, String.CASE_INSENSITIVE_ORDER );
|
||||||
|
|
||||||
sender.sendMessage( ProxyServer.getInstance().getTranslation( "command_list", server.getName(), players.size(), String.join( ChatColor.RESET + ", ", players ) ) );
|
sender.sendMessage( ProxyServer.getInstance().getTranslation( "command_list", server.getName(), server.getPlayers().size(), Util.format( players, ChatColor.RESET + ", " ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage( ProxyServer.getInstance().getTranslation( "total_players", ProxyServer.getInstance().getOnlineCount() ) );
|
sender.sendMessage( ProxyServer.getInstance().getTranslation( "total_players", ProxyServer.getInstance().getOnlineCount() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args)
|
|
||||||
{
|
|
||||||
return ( args.length > 1 ) ? Collections.emptyList() : Collections.singletonList( "all" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module</artifactId>
|
<artifactId>bungeecord-module</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module-cmd-send</artifactId>
|
<artifactId>bungeecord-module-cmd-send</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>cmd_send</name>
|
<name>cmd_send</name>
|
||||||
|
@@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module</artifactId>
|
<artifactId>bungeecord-module</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module-cmd-server</artifactId>
|
<artifactId>bungeecord-module-cmd-server</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>cmd_server</name>
|
<name>cmd_server</name>
|
||||||
|
@@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module</artifactId>
|
<artifactId>bungeecord-module</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>BungeeCord Modules</name>
|
<name>BungeeCord Modules</name>
|
||||||
@@ -21,7 +21,6 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>cmd-alert</module>
|
<module>cmd-alert</module>
|
||||||
<module>cmd-find</module>
|
<module>cmd-find</module>
|
||||||
<module>cmd-kick</module>
|
|
||||||
<module>cmd-list</module>
|
<module>cmd-list</module>
|
||||||
<module>cmd-send</module>
|
<module>cmd-send</module>
|
||||||
<module>cmd-server</module>
|
<module>cmd-server</module>
|
||||||
|
@@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module</artifactId>
|
<artifactId>bungeecord-module</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-module-reconnect-yaml</artifactId>
|
<artifactId>bungeecord-module-reconnect-yaml</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>reconnect_yaml</name>
|
<name>reconnect_yaml</name>
|
||||||
|
@@ -1,14 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -eu
|
CXX="g++ -shared -fPIC -O3 -Wall -Werror -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/"
|
||||||
|
|
||||||
echo "Compiling mbedtls"
|
$CXX src/main/c/NativeCipherImpl.cpp -o src/main/resources/native-cipher.so -lcrypto
|
||||||
(cd mbedtls && make no_test)
|
$CXX src/main/c/NativeCompressImpl.cpp -o src/main/resources/native-compress.so -lz
|
||||||
|
|
||||||
echo "Compiling zlib"
|
|
||||||
(cd zlib && CFLAGS=-fPIC ./configure --static && make)
|
|
||||||
|
|
||||||
CXX="g++ -shared -fPIC -Wl,--wrap=memcpy -O3 -Wall -Werror -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/"
|
|
||||||
|
|
||||||
$CXX -Imbedtls/include src/main/c/NativeCipherImpl.cpp -o src/main/resources/native-cipher.so mbedtls/library/libmbedcrypto.a
|
|
||||||
$CXX -Izlib src/main/c/NativeCompressImpl.cpp -o src/main/resources/native-compress.so zlib/libz.a
|
|
||||||
|
Submodule native/mbedtls deleted from 8c89224991
@@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-native</artifactId>
|
<artifactId>bungeecord-native</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Native</name>
|
<name>BungeeCord-Native</name>
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty</groupId>
|
<groupId>io.netty</groupId>
|
||||||
<artifactId>netty-transport</artifactId>
|
<artifactId>netty-transport</artifactId>
|
||||||
|
<version>${netty.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@@ -1,15 +1,12 @@
|
|||||||
|
// Support for CentOS 6
|
||||||
|
__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <mbedtls/aes.h>
|
#include <mbedtls/aes.h>
|
||||||
#include "net_md_5_bungee_jni_cipher_NativeCipherImpl.h"
|
#include "net_md_5_bungee_jni_cipher_NativeCipherImpl.h"
|
||||||
|
|
||||||
// Support for CentOS 6
|
|
||||||
__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
|
|
||||||
extern "C" void *__wrap_memcpy(void *dest, const void *src, size_t n) {
|
|
||||||
return memcpy(dest, src, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef unsigned char byte;
|
typedef unsigned char byte;
|
||||||
|
|
||||||
struct crypto_context {
|
struct crypto_context {
|
||||||
|
@@ -1,15 +1,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#include "net_md_5_bungee_jni_zlib_NativeCompressImpl.h"
|
#include "net_md_5_bungee_jni_zlib_NativeCompressImpl.h"
|
||||||
|
|
||||||
// Support for CentOS 6
|
|
||||||
__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
|
|
||||||
extern "C" void *__wrap_memcpy(void *dest, const void *src, size_t n) {
|
|
||||||
return memcpy(dest, src, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef unsigned char byte;
|
typedef unsigned char byte;
|
||||||
|
|
||||||
static jfieldID consumedID;
|
static jfieldID consumedID;
|
||||||
|
@@ -6,19 +6,18 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.function.Supplier;
|
|
||||||
import net.md_5.bungee.jni.cipher.BungeeCipher;
|
import net.md_5.bungee.jni.cipher.BungeeCipher;
|
||||||
|
|
||||||
public final class NativeCode<T>
|
public final class NativeCode<T>
|
||||||
{
|
{
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final Supplier<? extends T> javaImpl;
|
private final Class<? extends T> javaImpl;
|
||||||
private final Supplier<? extends T> nativeImpl;
|
private final Class<? extends T> nativeImpl;
|
||||||
//
|
//
|
||||||
private boolean loaded;
|
private boolean loaded;
|
||||||
|
|
||||||
public NativeCode(String name, Supplier<? extends T> javaImpl, Supplier<? extends T> nativeImpl)
|
public NativeCode(String name, Class<? extends T> javaImpl, Class<? extends T> nativeImpl)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.javaImpl = javaImpl;
|
this.javaImpl = javaImpl;
|
||||||
@@ -27,7 +26,13 @@ public final class NativeCode<T>
|
|||||||
|
|
||||||
public T newInstance()
|
public T newInstance()
|
||||||
{
|
{
|
||||||
return ( loaded ) ? nativeImpl.get() : javaImpl.get();
|
try
|
||||||
|
{
|
||||||
|
return ( loaded ) ? nativeImpl.getDeclaredConstructor().newInstance() : javaImpl.getDeclaredConstructor().newInstance();
|
||||||
|
} catch ( ReflectiveOperationException ex )
|
||||||
|
{
|
||||||
|
throw new RuntimeException( "Error getting instance", ex );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean load()
|
public boolean load()
|
||||||
|
@@ -25,15 +25,9 @@ public class JavaCipher implements BungeeCipher
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JavaCipher()
|
public JavaCipher() throws GeneralSecurityException
|
||||||
{
|
{
|
||||||
try
|
this.cipher = Cipher.getInstance( "AES/CFB8/NoPadding" );
|
||||||
{
|
|
||||||
this.cipher = Cipher.getInstance( "AES/CFB8/NoPadding" );
|
|
||||||
} catch ( GeneralSecurityException ex )
|
|
||||||
{
|
|
||||||
throw new RuntimeException( ex );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Binary file not shown.
Binary file not shown.
@@ -26,7 +26,7 @@ public class NativeCipherTest
|
|||||||
private final SecretKey secret = new SecretKeySpec( new byte[ 16 ], "AES" );
|
private final SecretKey secret = new SecretKeySpec( new byte[ 16 ], "AES" );
|
||||||
private static final int BENCHMARK_COUNT = 4096;
|
private static final int BENCHMARK_COUNT = 4096;
|
||||||
//
|
//
|
||||||
private static final NativeCode<BungeeCipher> factory = new NativeCode<>( "native-cipher", JavaCipher::new, NativeCipher::new );
|
private static final NativeCode<BungeeCipher> factory = new NativeCode<>( "native-cipher", JavaCipher.class, NativeCipher.class );
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNative() throws Exception
|
public void testNative() throws Exception
|
||||||
|
@@ -15,7 +15,7 @@ import org.junit.Test;
|
|||||||
public class NativeZlibTest
|
public class NativeZlibTest
|
||||||
{
|
{
|
||||||
|
|
||||||
private final NativeCode<BungeeZlib> factory = new NativeCode<>( "native-compress", JavaZlib::new, NativeZlib::new );
|
private final NativeCode<BungeeZlib> factory = new NativeCode<>( "native-compress", JavaZlib.class, NativeZlib.class );
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void doTest() throws DataFormatException
|
public void doTest() throws DataFormatException
|
||||||
|
Submodule native/zlib deleted from 4e4e4c4fbd
130
pom.xml
130
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Parent</name>
|
<name>BungeeCord-Parent</name>
|
||||||
@@ -41,7 +41,6 @@
|
|||||||
<module>protocol</module>
|
<module>protocol</module>
|
||||||
<module>proxy</module>
|
<module>proxy</module>
|
||||||
<module>query</module>
|
<module>query</module>
|
||||||
<module>slf4j</module>
|
|
||||||
<module>native</module>
|
<module>native</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
@@ -72,34 +71,23 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<build.number>unknown</build.number>
|
<build.number>unknown</build.number>
|
||||||
<lombok.version>1.18.30</lombok.version>
|
<netty.version>4.1.53.Final</netty.version>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.netty</groupId>
|
|
||||||
<artifactId>netty-bom</artifactId>
|
|
||||||
<version>4.1.97.Final</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.13.2</version>
|
<version>4.13.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>32.1.2-jre</version>
|
<version>21.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -111,26 +99,17 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>${lombok.version}</version>
|
<version>1.18.10</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
<version>3.6.0</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>scriptus</artifactId>
|
<artifactId>scriptus</artifactId>
|
||||||
<version>0.5.0</version>
|
<version>0.4.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<format>git:${project.name}:${project.version}:%s:${build.number}</format>
|
<format>git:${project.name}:${project.version}:%s:${build.number}</format>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -143,15 +122,10 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.11.0</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.1.1</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>process-classes</phase>
|
<phase>process-classes</phase>
|
||||||
@@ -169,14 +143,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.puppycrawl.tools</groupId>
|
<groupId>com.puppycrawl.tools</groupId>
|
||||||
<artifactId>checkstyle</artifactId>
|
<artifactId>checkstyle</artifactId>
|
||||||
<version>8.45.1</version>
|
<version>8.36.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>animal-sniffer-maven-plugin</artifactId>
|
<artifactId>animal-sniffer-maven-plugin</artifactId>
|
||||||
<version>1.23</version>
|
<version>1.19</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>process-classes</phase>
|
<phase>process-classes</phase>
|
||||||
@@ -193,82 +167,10 @@
|
|||||||
</signature>
|
</signature>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-enforcer-plugin</artifactId>
|
|
||||||
<version>3.4.1</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>enforce</id>
|
|
||||||
<configuration>
|
|
||||||
<rules>
|
|
||||||
<dependencyConvergence>
|
|
||||||
<excludes>
|
|
||||||
<!-- org.apache.maven:maven-resolver-provider is inconsistent -->
|
|
||||||
<exclude>org.apache.commons:commons-lang3</exclude>
|
|
||||||
<!-- org.apache.maven:maven-resolver-transport-http is inconsistent -->
|
|
||||||
<exclude>org.apache.httpcomponents:httpcore</exclude>
|
|
||||||
</excludes>
|
|
||||||
</dependencyConvergence>
|
|
||||||
</rules>
|
|
||||||
</configuration>
|
|
||||||
<goals>
|
|
||||||
<!--<goal>enforce</goal>--> <!-- Disabled until maven-resolver is upgraded again. -->
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
|
||||||
<id>jdk-9-release</id>
|
|
||||||
<activation>
|
|
||||||
<jdk>[9,)</jdk>
|
|
||||||
</activation>
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.release>8</maven.compiler.release>
|
|
||||||
</properties>
|
|
||||||
</profile>
|
|
||||||
<profile>
|
|
||||||
<id>jdk-9-javadoc</id>
|
|
||||||
<activation>
|
|
||||||
<jdk>[9,)</jdk>
|
|
||||||
</activation>
|
|
||||||
<build>
|
|
||||||
<pluginManagement>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<additionalOptions>-html5</additionalOptions>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
<profile>
|
|
||||||
<id>jdk-15-javadoc</id>
|
|
||||||
<activation>
|
|
||||||
<jdk>[15,)</jdk>
|
|
||||||
</activation>
|
|
||||||
<build>
|
|
||||||
<pluginManagement>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<doclint>none</doclint>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
<profile>
|
<profile>
|
||||||
<id>dist</id>
|
<id>dist</id>
|
||||||
<build>
|
<build>
|
||||||
@@ -276,7 +178,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.2.1</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
@@ -289,7 +191,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok-maven-plugin</artifactId>
|
<artifactId>lombok-maven-plugin</artifactId>
|
||||||
<version>1.18.20.0</version>
|
<version>1.18.10.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
@@ -303,17 +205,11 @@
|
|||||||
<outputDirectory>${project.build.directory}/delombok</outputDirectory>
|
<outputDirectory>${project.build.directory}/delombok</outputDirectory>
|
||||||
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
|
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
|
||||||
</configuration>
|
</configuration>
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>${lombok.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<!-- Execute Javadoc once normally to catch any warnings -->
|
<!-- Execute Javadoc once normally to catch any warnings -->
|
||||||
<execution>
|
<execution>
|
||||||
@@ -351,7 +247,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-gpg-plugin</artifactId>
|
<artifactId>maven-gpg-plugin</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>1.6</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>verify</phase>
|
<phase>verify</phase>
|
||||||
|
@@ -6,13 +6,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-parent</artifactId>
|
<artifactId>bungeecord-parent</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-protocol</artifactId>
|
<artifactId>bungeecord-protocol</artifactId>
|
||||||
<version>1.20-R0.2-SNAPSHOT</version>
|
<version>1.16-R0.4-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>BungeeCord-Protocol</name>
|
<name>BungeeCord-Protocol</name>
|
||||||
@@ -49,6 +49,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty</groupId>
|
<groupId>io.netty</groupId>
|
||||||
<artifactId>netty-codec</artifactId>
|
<artifactId>netty-codec</artifactId>
|
||||||
|
<version>${netty.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@@ -2,16 +2,12 @@ package net.md_5.bungee.protocol;
|
|||||||
|
|
||||||
import net.md_5.bungee.protocol.packet.BossBar;
|
import net.md_5.bungee.protocol.packet.BossBar;
|
||||||
import net.md_5.bungee.protocol.packet.Chat;
|
import net.md_5.bungee.protocol.packet.Chat;
|
||||||
import net.md_5.bungee.protocol.packet.ClearTitles;
|
|
||||||
import net.md_5.bungee.protocol.packet.ClientChat;
|
|
||||||
import net.md_5.bungee.protocol.packet.ClientCommand;
|
|
||||||
import net.md_5.bungee.protocol.packet.ClientSettings;
|
import net.md_5.bungee.protocol.packet.ClientSettings;
|
||||||
import net.md_5.bungee.protocol.packet.ClientStatus;
|
import net.md_5.bungee.protocol.packet.ClientStatus;
|
||||||
import net.md_5.bungee.protocol.packet.Commands;
|
import net.md_5.bungee.protocol.packet.Commands;
|
||||||
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||||
import net.md_5.bungee.protocol.packet.EncryptionResponse;
|
import net.md_5.bungee.protocol.packet.EncryptionResponse;
|
||||||
import net.md_5.bungee.protocol.packet.EntityStatus;
|
import net.md_5.bungee.protocol.packet.EntityStatus;
|
||||||
import net.md_5.bungee.protocol.packet.FinishConfiguration;
|
|
||||||
import net.md_5.bungee.protocol.packet.GameState;
|
import net.md_5.bungee.protocol.packet.GameState;
|
||||||
import net.md_5.bungee.protocol.packet.Handshake;
|
import net.md_5.bungee.protocol.packet.Handshake;
|
||||||
import net.md_5.bungee.protocol.packet.KeepAlive;
|
import net.md_5.bungee.protocol.packet.KeepAlive;
|
||||||
@@ -19,7 +15,6 @@ import net.md_5.bungee.protocol.packet.Kick;
|
|||||||
import net.md_5.bungee.protocol.packet.LegacyHandshake;
|
import net.md_5.bungee.protocol.packet.LegacyHandshake;
|
||||||
import net.md_5.bungee.protocol.packet.LegacyPing;
|
import net.md_5.bungee.protocol.packet.LegacyPing;
|
||||||
import net.md_5.bungee.protocol.packet.Login;
|
import net.md_5.bungee.protocol.packet.Login;
|
||||||
import net.md_5.bungee.protocol.packet.LoginAcknowledged;
|
|
||||||
import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
|
import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
|
||||||
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
||||||
import net.md_5.bungee.protocol.packet.LoginRequest;
|
import net.md_5.bungee.protocol.packet.LoginRequest;
|
||||||
@@ -27,25 +22,18 @@ import net.md_5.bungee.protocol.packet.LoginSuccess;
|
|||||||
import net.md_5.bungee.protocol.packet.PingPacket;
|
import net.md_5.bungee.protocol.packet.PingPacket;
|
||||||
import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter;
|
import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter;
|
||||||
import net.md_5.bungee.protocol.packet.PlayerListItem;
|
import net.md_5.bungee.protocol.packet.PlayerListItem;
|
||||||
import net.md_5.bungee.protocol.packet.PlayerListItemRemove;
|
|
||||||
import net.md_5.bungee.protocol.packet.PlayerListItemUpdate;
|
|
||||||
import net.md_5.bungee.protocol.packet.PluginMessage;
|
import net.md_5.bungee.protocol.packet.PluginMessage;
|
||||||
import net.md_5.bungee.protocol.packet.Respawn;
|
import net.md_5.bungee.protocol.packet.Respawn;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
|
import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
||||||
import net.md_5.bungee.protocol.packet.ServerData;
|
|
||||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||||
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
|
||||||
import net.md_5.bungee.protocol.packet.StatusRequest;
|
import net.md_5.bungee.protocol.packet.StatusRequest;
|
||||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||||
import net.md_5.bungee.protocol.packet.Subtitle;
|
|
||||||
import net.md_5.bungee.protocol.packet.SystemChat;
|
|
||||||
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
||||||
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
||||||
import net.md_5.bungee.protocol.packet.Team;
|
import net.md_5.bungee.protocol.packet.Team;
|
||||||
import net.md_5.bungee.protocol.packet.Title;
|
import net.md_5.bungee.protocol.packet.Title;
|
||||||
import net.md_5.bungee.protocol.packet.TitleTimes;
|
|
||||||
import net.md_5.bungee.protocol.packet.ViewDistance;
|
import net.md_5.bungee.protocol.packet.ViewDistance;
|
||||||
|
|
||||||
public abstract class AbstractPacketHandler
|
public abstract class AbstractPacketHandler
|
||||||
@@ -87,18 +75,6 @@ public abstract class AbstractPacketHandler
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(ClientChat chat) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(SystemChat chat) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(ClientCommand command) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(Respawn respawn) throws Exception
|
public void handle(Respawn respawn) throws Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -119,14 +95,6 @@ public abstract class AbstractPacketHandler
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(PlayerListItemRemove playerListItem) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(PlayerListItemUpdate playerListItem) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(PlayerListHeaderFooter playerListHeaderFooter) throws Exception
|
public void handle(PlayerListHeaderFooter playerListHeaderFooter) throws Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -159,18 +127,6 @@ public abstract class AbstractPacketHandler
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(Subtitle title) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(TitleTimes title) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(ClearTitles title) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(PluginMessage pluginMessage) throws Exception
|
public void handle(PluginMessage pluginMessage) throws Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -222,20 +178,4 @@ public abstract class AbstractPacketHandler
|
|||||||
public void handle(GameState gameState) throws Exception
|
public void handle(GameState gameState) throws Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(ServerData serverData) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(LoginAcknowledged loginAcknowledged) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(StartConfiguration startConfiguration) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(FinishConfiguration finishConfiguration) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,82 +0,0 @@
|
|||||||
package net.md_5.bungee.protocol;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class ChatChain extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
private List<ChainLink> seen;
|
|
||||||
private List<ChainLink> received;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
seen = readLinks( buf );
|
|
||||||
if ( buf.readBoolean() )
|
|
||||||
{
|
|
||||||
received = readLinks( buf );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<ChainLink> readLinks(ByteBuf buf)
|
|
||||||
{
|
|
||||||
int cnt = readVarInt( buf );
|
|
||||||
Preconditions.checkArgument( cnt <= 5, "Too many entries" );
|
|
||||||
List<ChainLink> chain = new LinkedList<>();
|
|
||||||
for ( int i = 0; i < cnt; i++ )
|
|
||||||
{
|
|
||||||
chain.add( new ChainLink( readUUID( buf ), readArray( buf ) ) );
|
|
||||||
}
|
|
||||||
return chain;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
writeLinks( seen, buf );
|
|
||||||
if ( received != null )
|
|
||||||
{
|
|
||||||
buf.writeBoolean( true );
|
|
||||||
writeLinks( received, buf );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
buf.writeBoolean( false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void writeLinks(List<ChainLink> links, ByteBuf buf)
|
|
||||||
{
|
|
||||||
writeVarInt( links.size(), buf );
|
|
||||||
for ( ChainLink link : links )
|
|
||||||
{
|
|
||||||
writeUUID( link.sender, buf );
|
|
||||||
writeArray( link.signature, buf );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(AbstractPacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException( "Not supported." );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class ChainLink
|
|
||||||
{
|
|
||||||
|
|
||||||
private final UUID sender;
|
|
||||||
private final byte[] signature;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -9,15 +9,10 @@ import java.io.DataInputStream;
|
|||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.BitSet;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import se.llbit.nbt.ErrorTag;
|
|
||||||
import se.llbit.nbt.NamedTag;
|
import se.llbit.nbt.NamedTag;
|
||||||
import se.llbit.nbt.SpecificTag;
|
|
||||||
import se.llbit.nbt.Tag;
|
import se.llbit.nbt.Tag;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -26,55 +21,35 @@ public abstract class DefinedPacket
|
|||||||
|
|
||||||
public static void writeString(String s, ByteBuf buf)
|
public static void writeString(String s, ByteBuf buf)
|
||||||
{
|
{
|
||||||
writeString( s, buf, Short.MAX_VALUE );
|
if ( s.length() > Short.MAX_VALUE )
|
||||||
}
|
|
||||||
|
|
||||||
public static void writeString(String s, ByteBuf buf, int maxLength)
|
|
||||||
{
|
|
||||||
if ( s.length() > maxLength )
|
|
||||||
{
|
{
|
||||||
throw new OverflowPacketException( "Cannot send string longer than " + maxLength + " (got " + s.length() + " characters)" );
|
throw new OverflowPacketException( String.format( "Cannot send string longer than Short.MAX_VALUE (got %s characters)", s.length() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] b = s.getBytes( Charsets.UTF_8 );
|
byte[] b = s.getBytes( Charsets.UTF_8 );
|
||||||
if ( b.length > maxLength * 3 )
|
|
||||||
{
|
|
||||||
throw new OverflowPacketException( "Cannot send string longer than " + ( maxLength * 3 ) + " (got " + b.length + " bytes)" );
|
|
||||||
}
|
|
||||||
|
|
||||||
writeVarInt( b.length, buf );
|
writeVarInt( b.length, buf );
|
||||||
buf.writeBytes( b );
|
buf.writeBytes( b );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String readString(ByteBuf buf)
|
public static String readString(ByteBuf buf)
|
||||||
{
|
|
||||||
return readString( buf, Short.MAX_VALUE );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String readString(ByteBuf buf, int maxLen)
|
|
||||||
{
|
{
|
||||||
int len = readVarInt( buf );
|
int len = readVarInt( buf );
|
||||||
if ( len > maxLen * 3 )
|
if ( len > Short.MAX_VALUE )
|
||||||
{
|
{
|
||||||
throw new OverflowPacketException( "Cannot receive string longer than " + maxLen * 3 + " (got " + len + " bytes)" );
|
throw new OverflowPacketException( String.format( "Cannot receive string longer than Short.MAX_VALUE (got %s characters)", len ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
String s = buf.toString( buf.readerIndex(), len, Charsets.UTF_8 );
|
byte[] b = new byte[ len ];
|
||||||
buf.readerIndex( buf.readerIndex() + len );
|
buf.readBytes( b );
|
||||||
|
|
||||||
if ( s.length() > maxLen )
|
return new String( b, Charsets.UTF_8 );
|
||||||
{
|
|
||||||
throw new OverflowPacketException( "Cannot receive string longer than " + maxLen + " (got " + s.length() + " characters)" );
|
|
||||||
}
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeArray(byte[] b, ByteBuf buf)
|
public static void writeArray(byte[] b, ByteBuf buf)
|
||||||
{
|
{
|
||||||
if ( b.length > Short.MAX_VALUE )
|
if ( b.length > Short.MAX_VALUE )
|
||||||
{
|
{
|
||||||
throw new OverflowPacketException( "Cannot send byte array longer than Short.MAX_VALUE (got " + b.length + " bytes)" );
|
throw new OverflowPacketException( String.format( "Cannot send byte array longer than Short.MAX_VALUE (got %s bytes)", b.length ) );
|
||||||
}
|
}
|
||||||
writeVarInt( b.length, buf );
|
writeVarInt( b.length, buf );
|
||||||
buf.writeBytes( b );
|
buf.writeBytes( b );
|
||||||
@@ -98,7 +73,7 @@ public abstract class DefinedPacket
|
|||||||
int len = readVarInt( buf );
|
int len = readVarInt( buf );
|
||||||
if ( len > limit )
|
if ( len > limit )
|
||||||
{
|
{
|
||||||
throw new OverflowPacketException( "Cannot receive byte array longer than " + limit + " (got " + len + " bytes)" );
|
throw new OverflowPacketException( String.format( "Cannot receive byte array longer than %s (got %s bytes)", limit, len ) );
|
||||||
}
|
}
|
||||||
byte[] ret = new byte[ len ];
|
byte[] ret = new byte[ len ];
|
||||||
buf.readBytes( ret );
|
buf.readBytes( ret );
|
||||||
@@ -228,102 +203,14 @@ public abstract class DefinedPacket
|
|||||||
return new UUID( input.readLong(), input.readLong() );
|
return new UUID( input.readLong(), input.readLong() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeProperties(Property[] properties, ByteBuf buf)
|
public static Tag readTag(ByteBuf input)
|
||||||
{
|
{
|
||||||
if ( properties == null )
|
Tag tag = NamedTag.read( new DataInputStream( new ByteBufInputStream( input ) ) );
|
||||||
{
|
|
||||||
writeVarInt( 0, buf );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
writeVarInt( properties.length, buf );
|
|
||||||
for ( Property prop : properties )
|
|
||||||
{
|
|
||||||
writeString( prop.getName(), buf );
|
|
||||||
writeString( prop.getValue(), buf );
|
|
||||||
if ( prop.getSignature() != null )
|
|
||||||
{
|
|
||||||
buf.writeBoolean( true );
|
|
||||||
writeString( prop.getSignature(), buf );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
buf.writeBoolean( false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Property[] readProperties(ByteBuf buf)
|
|
||||||
{
|
|
||||||
Property[] properties = new Property[ DefinedPacket.readVarInt( buf ) ];
|
|
||||||
for ( int j = 0; j < properties.length; j++ )
|
|
||||||
{
|
|
||||||
String name = readString( buf );
|
|
||||||
String value = readString( buf );
|
|
||||||
if ( buf.readBoolean() )
|
|
||||||
{
|
|
||||||
properties[j] = new Property( name, value, DefinedPacket.readString( buf ) );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
properties[j] = new Property( name, value );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writePublicKey(PlayerPublicKey publicKey, ByteBuf buf)
|
|
||||||
{
|
|
||||||
if ( publicKey != null )
|
|
||||||
{
|
|
||||||
buf.writeBoolean( true );
|
|
||||||
buf.writeLong( publicKey.getExpiry() );
|
|
||||||
writeArray( publicKey.getKey(), buf );
|
|
||||||
writeArray( publicKey.getSignature(), buf );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
buf.writeBoolean( false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlayerPublicKey readPublicKey(ByteBuf buf)
|
|
||||||
{
|
|
||||||
if ( buf.readBoolean() )
|
|
||||||
{
|
|
||||||
return new PlayerPublicKey( buf.readLong(), readArray( buf, 512 ), readArray( buf, 4096 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Tag readTag(ByteBuf input, int protocolVersion)
|
|
||||||
{
|
|
||||||
DataInputStream in = new DataInputStream( new ByteBufInputStream( input ) );
|
|
||||||
Tag tag;
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
byte type = in.readByte();
|
|
||||||
if ( type == 0 )
|
|
||||||
{
|
|
||||||
return Tag.END;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
tag = SpecificTag.read( type, in );
|
|
||||||
}
|
|
||||||
} catch ( IOException ex )
|
|
||||||
{
|
|
||||||
tag = new ErrorTag( "IOException while reading tag type:\n" + ex.getMessage() );
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
tag = NamedTag.read( in );
|
|
||||||
}
|
|
||||||
Preconditions.checkArgument( !tag.isError(), "Error reading tag: %s", tag.error() );
|
Preconditions.checkArgument( !tag.isError(), "Error reading tag: %s", tag.error() );
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeTag(Tag tag, ByteBuf output, int protocolVersion)
|
public static void writeTag(Tag tag, ByteBuf output)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -334,53 +221,6 @@ public abstract class DefinedPacket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <E extends Enum<E>> void writeEnumSet(EnumSet<E> enumset, Class<E> oclass, ByteBuf buf)
|
|
||||||
{
|
|
||||||
E[] enums = oclass.getEnumConstants();
|
|
||||||
BitSet bits = new BitSet( enums.length );
|
|
||||||
|
|
||||||
for ( int i = 0; i < enums.length; ++i )
|
|
||||||
{
|
|
||||||
bits.set( i, enumset.contains( enums[i] ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
writeFixedBitSet( bits, enums.length, buf );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <E extends Enum<E>> EnumSet<E> readEnumSet(Class<E> oclass, ByteBuf buf)
|
|
||||||
{
|
|
||||||
E[] enums = oclass.getEnumConstants();
|
|
||||||
BitSet bits = readFixedBitSet( enums.length, buf );
|
|
||||||
EnumSet<E> set = EnumSet.noneOf( oclass );
|
|
||||||
|
|
||||||
for ( int i = 0; i < enums.length; ++i )
|
|
||||||
{
|
|
||||||
if ( bits.get( i ) )
|
|
||||||
{
|
|
||||||
set.add( enums[i] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BitSet readFixedBitSet(int i, ByteBuf buf)
|
|
||||||
{
|
|
||||||
byte[] bits = new byte[ ( i + 8 ) >> 3 ];
|
|
||||||
buf.readBytes( bits );
|
|
||||||
|
|
||||||
return BitSet.valueOf( bits );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void writeFixedBitSet(BitSet bits, int size, ByteBuf buf)
|
|
||||||
{
|
|
||||||
if ( bits.length() > size )
|
|
||||||
{
|
|
||||||
throw new OverflowPacketException( "BitSet too large (expected " + size + " got " + bits.size() + ")" );
|
|
||||||
}
|
|
||||||
buf.writeBytes( Arrays.copyOf( bits.toByteArray(), ( size + 8 ) >> 3 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void read(ByteBuf buf)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException( "Packet must implement read method" );
|
throw new UnsupportedOperationException( "Packet must implement read method" );
|
||||||
@@ -401,11 +241,6 @@ public abstract class DefinedPacket
|
|||||||
write( buf );
|
write( buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Protocol nextProtocol()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void handle(AbstractPacketHandler handler) throws Exception;
|
public abstract void handle(AbstractPacketHandler handler) throws Exception;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -1,11 +0,0 @@
|
|||||||
package net.md_5.bungee.protocol;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class Location
|
|
||||||
{
|
|
||||||
|
|
||||||
private final String dimension;
|
|
||||||
private final long pos;
|
|
||||||
}
|
|
@@ -5,14 +5,12 @@ import io.netty.channel.ChannelHandlerContext;
|
|||||||
import io.netty.handler.codec.MessageToMessageDecoder;
|
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
|
public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
|
||||||
{
|
{
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
@Setter
|
||||||
private Protocol protocol;
|
private Protocol protocol;
|
||||||
private final boolean server;
|
private final boolean server;
|
||||||
@@ -43,7 +41,7 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
|
|||||||
|
|
||||||
if ( in.isReadable() )
|
if ( in.isReadable() )
|
||||||
{
|
{
|
||||||
throw new BadPacketException( "Packet " + protocol + ":" + prot.getDirection() + "/" + packetId + " (" + packet.getClass().getSimpleName() + ") larger than expected, extra bytes: " + in.readableBytes() );
|
throw new BadPacketException( "Did not read all bytes from packet " + packet.getClass() + " " + packetId + " Protocol " + protocol + " Direction " + prot.getDirection() );
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
|
@@ -4,14 +4,12 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.MessageToByteEncoder;
|
import io.netty.handler.codec.MessageToByteEncoder;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class MinecraftEncoder extends MessageToByteEncoder<DefinedPacket>
|
public class MinecraftEncoder extends MessageToByteEncoder<DefinedPacket>
|
||||||
{
|
{
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
@Setter
|
||||||
private Protocol protocol;
|
private Protocol protocol;
|
||||||
private boolean server;
|
private boolean server;
|
||||||
|
@@ -1,12 +0,0 @@
|
|||||||
package net.md_5.bungee.protocol;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class PlayerPublicKey
|
|
||||||
{
|
|
||||||
|
|
||||||
private final long expiry;
|
|
||||||
private final byte[] key;
|
|
||||||
private final byte[] signature;
|
|
||||||
}
|
|
@@ -1,19 +0,0 @@
|
|||||||
package net.md_5.bungee.protocol;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class Property
|
|
||||||
{
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
private String value;
|
|
||||||
private String signature;
|
|
||||||
|
|
||||||
public Property(String name, String value)
|
|
||||||
{
|
|
||||||
this( name, value, null );
|
|
||||||
}
|
|
||||||
}
|
|
@@ -6,26 +6,21 @@ import gnu.trove.map.TIntObjectMap;
|
|||||||
import gnu.trove.map.TObjectIntMap;
|
import gnu.trove.map.TObjectIntMap;
|
||||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||||
import gnu.trove.map.hash.TObjectIntHashMap;
|
import gnu.trove.map.hash.TObjectIntHashMap;
|
||||||
import java.util.function.Supplier;
|
import java.lang.reflect.Constructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.md_5.bungee.protocol.packet.BossBar;
|
import net.md_5.bungee.protocol.packet.BossBar;
|
||||||
import net.md_5.bungee.protocol.packet.Chat;
|
import net.md_5.bungee.protocol.packet.Chat;
|
||||||
import net.md_5.bungee.protocol.packet.ClearTitles;
|
|
||||||
import net.md_5.bungee.protocol.packet.ClientChat;
|
|
||||||
import net.md_5.bungee.protocol.packet.ClientCommand;
|
|
||||||
import net.md_5.bungee.protocol.packet.ClientSettings;
|
import net.md_5.bungee.protocol.packet.ClientSettings;
|
||||||
import net.md_5.bungee.protocol.packet.Commands;
|
import net.md_5.bungee.protocol.packet.Commands;
|
||||||
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||||
import net.md_5.bungee.protocol.packet.EncryptionResponse;
|
import net.md_5.bungee.protocol.packet.EncryptionResponse;
|
||||||
import net.md_5.bungee.protocol.packet.EntityStatus;
|
import net.md_5.bungee.protocol.packet.EntityStatus;
|
||||||
import net.md_5.bungee.protocol.packet.FinishConfiguration;
|
|
||||||
import net.md_5.bungee.protocol.packet.GameState;
|
import net.md_5.bungee.protocol.packet.GameState;
|
||||||
import net.md_5.bungee.protocol.packet.Handshake;
|
import net.md_5.bungee.protocol.packet.Handshake;
|
||||||
import net.md_5.bungee.protocol.packet.KeepAlive;
|
import net.md_5.bungee.protocol.packet.KeepAlive;
|
||||||
import net.md_5.bungee.protocol.packet.Kick;
|
import net.md_5.bungee.protocol.packet.Kick;
|
||||||
import net.md_5.bungee.protocol.packet.Login;
|
import net.md_5.bungee.protocol.packet.Login;
|
||||||
import net.md_5.bungee.protocol.packet.LoginAcknowledged;
|
|
||||||
import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
|
import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
|
||||||
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
||||||
import net.md_5.bungee.protocol.packet.LoginRequest;
|
import net.md_5.bungee.protocol.packet.LoginRequest;
|
||||||
@@ -33,25 +28,18 @@ import net.md_5.bungee.protocol.packet.LoginSuccess;
|
|||||||
import net.md_5.bungee.protocol.packet.PingPacket;
|
import net.md_5.bungee.protocol.packet.PingPacket;
|
||||||
import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter;
|
import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter;
|
||||||
import net.md_5.bungee.protocol.packet.PlayerListItem;
|
import net.md_5.bungee.protocol.packet.PlayerListItem;
|
||||||
import net.md_5.bungee.protocol.packet.PlayerListItemRemove;
|
|
||||||
import net.md_5.bungee.protocol.packet.PlayerListItemUpdate;
|
|
||||||
import net.md_5.bungee.protocol.packet.PluginMessage;
|
import net.md_5.bungee.protocol.packet.PluginMessage;
|
||||||
import net.md_5.bungee.protocol.packet.Respawn;
|
import net.md_5.bungee.protocol.packet.Respawn;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
|
import net.md_5.bungee.protocol.packet.ScoreboardDisplay;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
import net.md_5.bungee.protocol.packet.ScoreboardObjective;
|
||||||
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
import net.md_5.bungee.protocol.packet.ScoreboardScore;
|
||||||
import net.md_5.bungee.protocol.packet.ServerData;
|
|
||||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||||
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
|
||||||
import net.md_5.bungee.protocol.packet.StatusRequest;
|
import net.md_5.bungee.protocol.packet.StatusRequest;
|
||||||
import net.md_5.bungee.protocol.packet.StatusResponse;
|
import net.md_5.bungee.protocol.packet.StatusResponse;
|
||||||
import net.md_5.bungee.protocol.packet.Subtitle;
|
|
||||||
import net.md_5.bungee.protocol.packet.SystemChat;
|
|
||||||
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
||||||
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
||||||
import net.md_5.bungee.protocol.packet.Team;
|
import net.md_5.bungee.protocol.packet.Team;
|
||||||
import net.md_5.bungee.protocol.packet.Title;
|
import net.md_5.bungee.protocol.packet.Title;
|
||||||
import net.md_5.bungee.protocol.packet.TitleTimes;
|
|
||||||
import net.md_5.bungee.protocol.packet.ViewDistance;
|
import net.md_5.bungee.protocol.packet.ViewDistance;
|
||||||
|
|
||||||
public enum Protocol
|
public enum Protocol
|
||||||
@@ -64,7 +52,6 @@ public enum Protocol
|
|||||||
{
|
{
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
Handshake.class,
|
Handshake.class,
|
||||||
Handshake::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -76,50 +63,33 @@ public enum Protocol
|
|||||||
{
|
{
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
KeepAlive.class,
|
KeepAlive.class,
|
||||||
KeepAlive::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x00 ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x00 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x1F ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x1F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_13, 0x21 ),
|
map( ProtocolConstants.MINECRAFT_1_13, 0x21 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x20 ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x20 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x21 ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x21 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16, 0x20 ),
|
map( ProtocolConstants.MINECRAFT_1_16, 0x20 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16_2, 0x1F ),
|
map( ProtocolConstants.MINECRAFT_1_16_2, 0x1F )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x21 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x1E ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x20 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x1F ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x23 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x24 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Login.class,
|
Login.class,
|
||||||
Login::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x01 ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x01 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x23 ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x23 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_13, 0x25 ),
|
map( ProtocolConstants.MINECRAFT_1_13, 0x25 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x26 ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x26 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16, 0x25 ),
|
map( ProtocolConstants.MINECRAFT_1_16, 0x25 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16_2, 0x24 ),
|
map( ProtocolConstants.MINECRAFT_1_16_2, 0x24 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x26 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x23 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x25 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x24 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x28 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x29 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket( Chat.class,
|
TO_CLIENT.registerPacket(
|
||||||
Chat::new,
|
Chat.class,
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x02 ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x02 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x0F ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x0F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_13, 0x0E ),
|
map( ProtocolConstants.MINECRAFT_1_13, 0x0E ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x0F ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x0F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16, 0x0E ),
|
map( ProtocolConstants.MINECRAFT_1_16, 0x0E )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x0F ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, -1 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Respawn.class,
|
Respawn.class,
|
||||||
Respawn::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x07 ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x07 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x33 ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x33 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_12, 0x34 ),
|
map( ProtocolConstants.MINECRAFT_1_12, 0x34 ),
|
||||||
@@ -128,28 +98,16 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x3A ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x3A ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x3B ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x3B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16, 0x3A ),
|
map( ProtocolConstants.MINECRAFT_1_16, 0x3A ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16_2, 0x39 ),
|
map( ProtocolConstants.MINECRAFT_1_16_2, 0x39 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x3D ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x3B ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x3E ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x3D ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x41 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x43 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
BossBar.class,
|
BossBar.class,
|
||||||
BossBar::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x0C ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x0C ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x0D ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x0D ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16, 0x0C ),
|
map( ProtocolConstants.MINECRAFT_1_16, 0x0C )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x0D ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x0A ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x0B ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0A )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
PlayerListItem.class, // PlayerInfo
|
PlayerListItem.class, // PlayerInfo
|
||||||
PlayerListItem::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x38 ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x38 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x2D ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x2D ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x2E ),
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x2E ),
|
||||||
@@ -157,183 +115,89 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x33 ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x33 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x34 ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x34 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16, 0x33 ),
|
map( ProtocolConstants.MINECRAFT_1_16, 0x33 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16_2, 0x32 ),
|
map( ProtocolConstants.MINECRAFT_1_16_2, 0x32 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x36 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x34 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x37 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, -1 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
TabCompleteResponse.class,
|
TabCompleteResponse.class,
|
||||||
TabCompleteResponse::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x3A ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x3A ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x0E ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x0E ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_13, 0x10 ),
|
map( ProtocolConstants.MINECRAFT_1_13, 0x10 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x11 ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x11 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16, 0x10 ),
|
map( ProtocolConstants.MINECRAFT_1_16, 0x10 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16_2, 0x0F ),
|
map( ProtocolConstants.MINECRAFT_1_16_2, 0x0F )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x11 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x0E ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x0D ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x0F ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x10 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ScoreboardObjective.class,
|
ScoreboardObjective.class,
|
||||||
ScoreboardObjective::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x3B ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x3B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x3F ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x3F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_12, 0x41 ),
|
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 ),
|
map( ProtocolConstants.MINECRAFT_1_13, 0x45 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x49 ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x49 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x4A ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x4A )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x53 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x56 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x54 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x58 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5A )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ScoreboardScore.class,
|
ScoreboardScore.class,
|
||||||
ScoreboardScore::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x3C ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x3C ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x42 ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x42 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_12, 0x44 ),
|
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 ),
|
map( ProtocolConstants.MINECRAFT_1_13, 0x48 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x4C ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x4C ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x4D ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x4D )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x56 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x59 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x57 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5B ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5D )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ScoreboardDisplay.class,
|
ScoreboardDisplay.class,
|
||||||
ScoreboardDisplay::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x3D ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x3D ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x38 ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x38 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_12, 0x3A ),
|
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 ),
|
map( ProtocolConstants.MINECRAFT_1_13, 0x3E ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x42 ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x42 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x43 ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x43 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x4C ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x4F ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x4D ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x51 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x53 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Team.class,
|
Team.class,
|
||||||
Team::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x3E ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x3E ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x41 ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x41 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_12, 0x43 ),
|
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 ),
|
map( ProtocolConstants.MINECRAFT_1_13, 0x47 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x4B ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x4B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x4C ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x4C )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x55 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x58 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x56 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5A ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5C )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
PluginMessage.class,
|
PluginMessage.class,
|
||||||
PluginMessage::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x3F ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x3F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x18 ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x18 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_13, 0x19 ),
|
map( ProtocolConstants.MINECRAFT_1_13, 0x19 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x18 ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x18 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x19 ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x19 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16, 0x18 ),
|
map( ProtocolConstants.MINECRAFT_1_16, 0x18 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16_2, 0x17 ),
|
map( ProtocolConstants.MINECRAFT_1_16_2, 0x17 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x18 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x15 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x16 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x15 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x17 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x18 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Kick.class,
|
Kick.class,
|
||||||
Kick::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x40 ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x40 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x1A ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x1A ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_13, 0x1B ),
|
map( ProtocolConstants.MINECRAFT_1_13, 0x1B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x1A ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x1A ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x1B ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x1B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16, 0x1A ),
|
map( ProtocolConstants.MINECRAFT_1_16, 0x1A ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16_2, 0x19 ),
|
map( ProtocolConstants.MINECRAFT_1_16_2, 0x19 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x1A ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x17 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x19 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x17 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x1A ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x1B )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Title.class,
|
Title.class,
|
||||||
Title::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x45 ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x45 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_12, 0x47 ),
|
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 ),
|
map( ProtocolConstants.MINECRAFT_1_13, 0x4B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x4F ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x4F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x50 ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x50 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16, 0x4F ),
|
map( ProtocolConstants.MINECRAFT_1_16, 0x4F )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x59 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_18, 0x5A ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5D ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x5B ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5F ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x61 )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
ClearTitles.class,
|
|
||||||
ClearTitles::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x10 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x0D ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x0C ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x0E ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0F )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
Subtitle.class,
|
|
||||||
Subtitle::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x57 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_18, 0x58 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5B ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x59 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5D ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x5F )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
TitleTimes.class,
|
|
||||||
TitleTimes::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x5A ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_18, 0x5B ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x5E ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x5C ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x60 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x62 )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
SystemChat.class,
|
|
||||||
SystemChat::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x5F ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x62 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x60 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x64 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x67 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
PlayerListHeaderFooter.class,
|
PlayerListHeaderFooter.class,
|
||||||
PlayerListHeaderFooter::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x47 ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x47 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x48 ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x48 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9_4, 0x47 ),
|
map( ProtocolConstants.MINECRAFT_1_9_4, 0x47 ),
|
||||||
@@ -342,187 +206,81 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_13, 0x4E ),
|
map( ProtocolConstants.MINECRAFT_1_13, 0x4E ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x53 ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x53 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x54 ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x54 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16, 0x53 ),
|
map( ProtocolConstants.MINECRAFT_1_16, 0x53 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x5E ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_18, 0x5F ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x60 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x63 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x61 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x65 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x68 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
EntityStatus.class,
|
EntityStatus.class,
|
||||||
EntityStatus::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x1A ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x1A ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x1B ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x1B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_13, 0x1C ),
|
map( ProtocolConstants.MINECRAFT_1_13, 0x1C ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x1B ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x1B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x1C ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x1C ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16, 0x1B ),
|
map( ProtocolConstants.MINECRAFT_1_16, 0x1B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16_2, 0x1A ),
|
map( ProtocolConstants.MINECRAFT_1_16_2, 0x1A )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x1B ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x18 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x1A ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x19 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x1C ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x1D )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Commands.class,
|
Commands.class,
|
||||||
Commands::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_13, 0x11 ),
|
map( ProtocolConstants.MINECRAFT_1_13, 0x11 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x12 ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x12 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16, 0x11 ),
|
map( ProtocolConstants.MINECRAFT_1_16, 0x11 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16_2, 0x10 ),
|
map( ProtocolConstants.MINECRAFT_1_16_2, 0x10 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x12 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x0F ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x0E ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x10 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x11 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
GameState.class,
|
GameState.class,
|
||||||
GameState::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x1F ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x1F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16, 0x1E ),
|
map( ProtocolConstants.MINECRAFT_1_16, 0x1E ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16_2, 0x1D ),
|
map( ProtocolConstants.MINECRAFT_1_16_2, 0x1D )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x1E ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x1B ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x1D ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x1C ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x1F ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x20 )
|
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ViewDistance.class,
|
ViewDistance.class,
|
||||||
ViewDistance::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x41 ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x41 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_15, 0x42 ),
|
map( ProtocolConstants.MINECRAFT_1_15, 0x42 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16, 0x41 ),
|
map( ProtocolConstants.MINECRAFT_1_16, 0x41 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x4A ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x49 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x4C ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x4B ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x4F ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x51 )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
ServerData.class,
|
|
||||||
ServerData::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x3F ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x42 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x41 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x45 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x47 )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
PlayerListItemRemove.class,
|
|
||||||
PlayerListItemRemove::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x35 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x39 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x3B )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
PlayerListItemUpdate.class,
|
|
||||||
PlayerListItemUpdate::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x36 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x3A ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x3C )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
StartConfiguration.class,
|
|
||||||
StartConfiguration::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x65 )
|
|
||||||
);
|
);
|
||||||
|
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
KeepAlive.class,
|
KeepAlive.class,
|
||||||
KeepAlive::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x00 ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x00 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x0B ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x0B ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_12, 0x0C ),
|
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 ),
|
map( ProtocolConstants.MINECRAFT_1_13, 0x0E ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x0F ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x0F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_16, 0x10 ),
|
map( ProtocolConstants.MINECRAFT_1_16, 0x10 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x0F ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x11 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x12 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x11 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x12 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x14 )
|
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket( Chat.class,
|
TO_SERVER.registerPacket(
|
||||||
Chat::new,
|
Chat.class,
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x01 ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x01 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x02 ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x02 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_12, 0x03 ),
|
map( ProtocolConstants.MINECRAFT_1_12, 0x03 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x02 ),
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x02 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x03 ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x03 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, -1 )
|
|
||||||
);
|
|
||||||
TO_SERVER.registerPacket(
|
|
||||||
ClientCommand.class,
|
|
||||||
ClientCommand::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x03 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x04 )
|
|
||||||
);
|
|
||||||
TO_SERVER.registerPacket(
|
|
||||||
ClientChat.class,
|
|
||||||
ClientChat::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x04 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x05 )
|
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
TabCompleteRequest.class,
|
TabCompleteRequest.class,
|
||||||
TabCompleteRequest::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x14 ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x14 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x01 ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x01 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_12, 0x02 ),
|
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 ),
|
map( ProtocolConstants.MINECRAFT_1_13, 0x05 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x06 ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x06 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x08 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x09 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x08 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x09 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0A )
|
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
ClientSettings.class,
|
ClientSettings.class,
|
||||||
ClientSettings::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x15 ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x15 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x04 ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x04 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_12, 0x05 ),
|
map( ProtocolConstants.MINECRAFT_1_12, 0x05 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_12_1, 0x04 ),
|
map( ProtocolConstants.MINECRAFT_1_12_1, 0x04 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x05 ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x05 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x07 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x08 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x07 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x08 ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x09 )
|
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
PluginMessage.class,
|
PluginMessage.class,
|
||||||
PluginMessage::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x17 ),
|
map( ProtocolConstants.MINECRAFT_1_8, 0x17 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_9, 0x09 ),
|
map( ProtocolConstants.MINECRAFT_1_9, 0x09 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_12, 0x0A ),
|
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 ),
|
map( ProtocolConstants.MINECRAFT_1_13, 0x0A ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_14, 0x0B ),
|
map( ProtocolConstants.MINECRAFT_1_14, 0x0B )
|
||||||
map( ProtocolConstants.MINECRAFT_1_17, 0x0A ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x0C ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x0D ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x0C ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x0D ),
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0F )
|
|
||||||
);
|
|
||||||
TO_SERVER.registerPacket(
|
|
||||||
StartConfiguration.class,
|
|
||||||
StartConfiguration::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0B )
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -533,23 +291,19 @@ public enum Protocol
|
|||||||
{
|
{
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
StatusResponse.class,
|
StatusResponse.class,
|
||||||
StatusResponse::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
PingPacket.class,
|
PingPacket.class,
|
||||||
PingPacket::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
||||||
);
|
);
|
||||||
|
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
StatusRequest.class,
|
StatusRequest.class,
|
||||||
StatusRequest::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
PingPacket.class,
|
PingPacket.class,
|
||||||
PingPacket::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -561,98 +315,37 @@ public enum Protocol
|
|||||||
{
|
{
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Kick.class,
|
Kick.class,
|
||||||
Kick::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
EncryptionRequest.class,
|
EncryptionRequest.class,
|
||||||
EncryptionRequest::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
LoginSuccess.class,
|
LoginSuccess.class,
|
||||||
LoginSuccess::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x02 )
|
map( ProtocolConstants.MINECRAFT_1_8, 0x02 )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
SetCompression.class,
|
SetCompression.class,
|
||||||
SetCompression::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x03 )
|
map( ProtocolConstants.MINECRAFT_1_8, 0x03 )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
LoginPayloadRequest.class,
|
LoginPayloadRequest.class,
|
||||||
LoginPayloadRequest::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_13, 0x04 )
|
map( ProtocolConstants.MINECRAFT_1_13, 0x04 )
|
||||||
);
|
);
|
||||||
|
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
LoginRequest.class,
|
LoginRequest.class,
|
||||||
LoginRequest::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
map( ProtocolConstants.MINECRAFT_1_8, 0x00 )
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
EncryptionResponse.class,
|
EncryptionResponse.class,
|
||||||
EncryptionResponse::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
map( ProtocolConstants.MINECRAFT_1_8, 0x01 )
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
LoginPayloadResponse.class,
|
LoginPayloadResponse.class,
|
||||||
LoginPayloadResponse::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_13, 0x02 )
|
map( ProtocolConstants.MINECRAFT_1_13, 0x02 )
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
|
||||||
LoginAcknowledged.class,
|
|
||||||
LoginAcknowledged::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x03 )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 3
|
|
||||||
CONFIGURATION
|
|
||||||
{
|
|
||||||
|
|
||||||
{
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
PluginMessage.class,
|
|
||||||
PluginMessage::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x00 )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
Kick.class,
|
|
||||||
Kick::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x01 )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
FinishConfiguration.class,
|
|
||||||
FinishConfiguration::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x02 )
|
|
||||||
);
|
|
||||||
TO_CLIENT.registerPacket(
|
|
||||||
KeepAlive.class,
|
|
||||||
KeepAlive::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x03 )
|
|
||||||
);
|
|
||||||
|
|
||||||
TO_SERVER.registerPacket(
|
|
||||||
ClientSettings.class,
|
|
||||||
ClientSettings::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x00 )
|
|
||||||
);
|
|
||||||
TO_SERVER.registerPacket(
|
|
||||||
PluginMessage.class,
|
|
||||||
PluginMessage::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x01 )
|
|
||||||
);
|
|
||||||
TO_SERVER.registerPacket(
|
|
||||||
FinishConfiguration.class,
|
|
||||||
FinishConfiguration::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x02 )
|
|
||||||
);
|
|
||||||
TO_SERVER.registerPacket(
|
|
||||||
KeepAlive.class,
|
|
||||||
KeepAlive::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x03 )
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/*========================================================================*/
|
/*========================================================================*/
|
||||||
@@ -701,8 +394,7 @@ public enum Protocol
|
|||||||
|
|
||||||
private final int protocolVersion;
|
private final int protocolVersion;
|
||||||
private final TObjectIntMap<Class<? extends DefinedPacket>> packetMap = new TObjectIntHashMap<>( MAX_PACKET_ID );
|
private final TObjectIntMap<Class<? extends DefinedPacket>> packetMap = new TObjectIntHashMap<>( MAX_PACKET_ID );
|
||||||
@SuppressWarnings("unchecked")
|
private final Constructor<? extends DefinedPacket>[] packetConstructors = new Constructor[ MAX_PACKET_ID ];
|
||||||
private final Supplier<? extends DefinedPacket>[] packetConstructors = new Supplier[ MAX_PACKET_ID ];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -756,49 +448,57 @@ public enum Protocol
|
|||||||
{
|
{
|
||||||
throw new BadPacketException( "Unsupported protocol version " + version );
|
throw new BadPacketException( "Unsupported protocol version " + version );
|
||||||
}
|
}
|
||||||
if ( id > MAX_PACKET_ID || id < 0 )
|
if ( id > MAX_PACKET_ID )
|
||||||
{
|
{
|
||||||
throw new BadPacketException( "Packet with id " + id + " outside of range" );
|
throw new BadPacketException( "Packet with id " + id + " outside of range " );
|
||||||
}
|
}
|
||||||
|
|
||||||
Supplier<? extends DefinedPacket> constructor = protocolData.packetConstructors[id];
|
Constructor<? extends DefinedPacket> constructor = protocolData.packetConstructors[id];
|
||||||
return ( constructor == null ) ? null : constructor.get();
|
try
|
||||||
|
{
|
||||||
|
return ( constructor == null ) ? null : constructor.newInstance();
|
||||||
|
} catch ( ReflectiveOperationException ex )
|
||||||
|
{
|
||||||
|
throw new BadPacketException( "Could not construct packet with id " + id, ex );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerPacket(Class<? extends DefinedPacket> packetClass, Supplier<? extends DefinedPacket> constructor, ProtocolMapping... mappings)
|
private void registerPacket(Class<? extends DefinedPacket> packetClass, ProtocolMapping... mappings)
|
||||||
{
|
{
|
||||||
int mappingIndex = 0;
|
try
|
||||||
ProtocolMapping mapping = mappings[mappingIndex];
|
|
||||||
for ( int protocol : ProtocolConstants.SUPPORTED_VERSION_IDS )
|
|
||||||
{
|
{
|
||||||
if ( protocol < mapping.protocolVersion )
|
Constructor<? extends DefinedPacket> constructor = packetClass.getDeclaredConstructor();
|
||||||
{
|
|
||||||
// This is a new packet, skip it till we reach the next protocol
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( mapping.protocolVersion < protocol && mappingIndex + 1 < mappings.length )
|
int mappingIndex = 0;
|
||||||
|
ProtocolMapping mapping = mappings[mappingIndex];
|
||||||
|
for ( int protocol : ProtocolConstants.SUPPORTED_VERSION_IDS )
|
||||||
{
|
{
|
||||||
// Mapping is non current, but the next one may be ok
|
if ( protocol < mapping.protocolVersion )
|
||||||
ProtocolMapping nextMapping = mappings[mappingIndex + 1];
|
|
||||||
|
|
||||||
if ( nextMapping.protocolVersion == protocol )
|
|
||||||
{
|
{
|
||||||
Preconditions.checkState( nextMapping.packetID != mapping.packetID, "Duplicate packet mapping (%s, %s)", mapping.protocolVersion, nextMapping.protocolVersion );
|
// This is a new packet, skip it till we reach the next protocol
|
||||||
|
continue;
|
||||||
mapping = nextMapping;
|
|
||||||
mappingIndex++;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( mapping.packetID < 0 )
|
if ( mapping.protocolVersion < protocol && mappingIndex + 1 < mappings.length )
|
||||||
{
|
{
|
||||||
break;
|
// Mapping is non current, but the next one may be ok
|
||||||
}
|
ProtocolMapping nextMapping = mappings[mappingIndex + 1];
|
||||||
|
if ( nextMapping.protocolVersion == protocol )
|
||||||
|
{
|
||||||
|
Preconditions.checkState( nextMapping.packetID != mapping.packetID, "Duplicate packet mapping (%s, %s)", mapping.protocolVersion, nextMapping.protocolVersion );
|
||||||
|
|
||||||
ProtocolData data = protocols.get( protocol );
|
mapping = nextMapping;
|
||||||
data.packetMap.put( packetClass, mapping.packetID );
|
mappingIndex++;
|
||||||
data.packetConstructors[mapping.packetID] = constructor;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ProtocolData data = protocols.get( protocol );
|
||||||
|
data.packetMap.put( packetClass, mapping.packetID );
|
||||||
|
data.packetConstructors[mapping.packetID] = constructor;
|
||||||
|
}
|
||||||
|
} catch ( NoSuchMethodException ex )
|
||||||
|
{
|
||||||
|
throw new BadPacketException( "No NoArgsConstructor for packet class " + packetClass );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,12 +1,11 @@
|
|||||||
package net.md_5.bungee.protocol;
|
package net.md_5.bungee.protocol;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ProtocolConstants
|
public class ProtocolConstants
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final boolean SNAPSHOT_SUPPORT = Boolean.getBoolean( "net.md_5.bungee.protocol.snapshot" );
|
|
||||||
public static final int MINECRAFT_1_8 = 47;
|
public static final int MINECRAFT_1_8 = 47;
|
||||||
public static final int MINECRAFT_1_9 = 107;
|
public static final int MINECRAFT_1_9 = 107;
|
||||||
public static final int MINECRAFT_1_9_1 = 108;
|
public static final int MINECRAFT_1_9_1 = 108;
|
||||||
@@ -34,85 +33,46 @@ public class ProtocolConstants
|
|||||||
public static final int MINECRAFT_1_16_2 = 751;
|
public static final int MINECRAFT_1_16_2 = 751;
|
||||||
public static final int MINECRAFT_1_16_3 = 753;
|
public static final int MINECRAFT_1_16_3 = 753;
|
||||||
public static final int MINECRAFT_1_16_4 = 754;
|
public static final int MINECRAFT_1_16_4 = 754;
|
||||||
public static final int MINECRAFT_1_17 = 755;
|
public static final List<String> SUPPORTED_VERSIONS = Arrays.asList(
|
||||||
public static final int MINECRAFT_1_17_1 = 756;
|
"1.8.x",
|
||||||
public static final int MINECRAFT_1_18 = 757;
|
"1.9.x",
|
||||||
public static final int MINECRAFT_1_18_2 = 758;
|
"1.10.x",
|
||||||
public static final int MINECRAFT_1_19 = 759;
|
"1.11.x",
|
||||||
public static final int MINECRAFT_1_19_1 = 760;
|
"1.12.x",
|
||||||
public static final int MINECRAFT_1_19_3 = 761;
|
"1.13.x",
|
||||||
public static final int MINECRAFT_1_19_4 = 762;
|
"1.14.x",
|
||||||
public static final int MINECRAFT_1_20 = 763;
|
"1.15.x",
|
||||||
public static final int MINECRAFT_1_20_2 = 764;
|
"1.16.x"
|
||||||
public static final List<String> SUPPORTED_VERSIONS;
|
);
|
||||||
public static final List<Integer> SUPPORTED_VERSION_IDS;
|
public static final List<Integer> SUPPORTED_VERSION_IDS = Arrays.asList(
|
||||||
|
ProtocolConstants.MINECRAFT_1_8,
|
||||||
static
|
ProtocolConstants.MINECRAFT_1_9,
|
||||||
{
|
ProtocolConstants.MINECRAFT_1_9_1,
|
||||||
ImmutableList.Builder<String> supportedVersions = ImmutableList.<String>builder().add(
|
ProtocolConstants.MINECRAFT_1_9_2,
|
||||||
"1.8.x",
|
ProtocolConstants.MINECRAFT_1_9_4,
|
||||||
"1.9.x",
|
ProtocolConstants.MINECRAFT_1_10,
|
||||||
"1.10.x",
|
ProtocolConstants.MINECRAFT_1_11,
|
||||||
"1.11.x",
|
ProtocolConstants.MINECRAFT_1_11_1,
|
||||||
"1.12.x",
|
ProtocolConstants.MINECRAFT_1_12,
|
||||||
"1.13.x",
|
ProtocolConstants.MINECRAFT_1_12_1,
|
||||||
"1.14.x",
|
ProtocolConstants.MINECRAFT_1_12_2,
|
||||||
"1.15.x",
|
ProtocolConstants.MINECRAFT_1_13,
|
||||||
"1.16.x",
|
ProtocolConstants.MINECRAFT_1_13_1,
|
||||||
"1.17.x",
|
ProtocolConstants.MINECRAFT_1_13_2,
|
||||||
"1.18.x",
|
ProtocolConstants.MINECRAFT_1_14,
|
||||||
"1.19.x",
|
ProtocolConstants.MINECRAFT_1_14_1,
|
||||||
"1.20.x"
|
ProtocolConstants.MINECRAFT_1_14_2,
|
||||||
);
|
ProtocolConstants.MINECRAFT_1_14_3,
|
||||||
ImmutableList.Builder<Integer> supportedVersionIds = ImmutableList.<Integer>builder().add(
|
ProtocolConstants.MINECRAFT_1_14_4,
|
||||||
ProtocolConstants.MINECRAFT_1_8,
|
ProtocolConstants.MINECRAFT_1_15,
|
||||||
ProtocolConstants.MINECRAFT_1_9,
|
ProtocolConstants.MINECRAFT_1_15_1,
|
||||||
ProtocolConstants.MINECRAFT_1_9_1,
|
ProtocolConstants.MINECRAFT_1_15_2,
|
||||||
ProtocolConstants.MINECRAFT_1_9_2,
|
ProtocolConstants.MINECRAFT_1_16,
|
||||||
ProtocolConstants.MINECRAFT_1_9_4,
|
ProtocolConstants.MINECRAFT_1_16_1,
|
||||||
ProtocolConstants.MINECRAFT_1_10,
|
ProtocolConstants.MINECRAFT_1_16_2,
|
||||||
ProtocolConstants.MINECRAFT_1_11,
|
ProtocolConstants.MINECRAFT_1_16_3,
|
||||||
ProtocolConstants.MINECRAFT_1_11_1,
|
ProtocolConstants.MINECRAFT_1_16_4
|
||||||
ProtocolConstants.MINECRAFT_1_12,
|
);
|
||||||
ProtocolConstants.MINECRAFT_1_12_1,
|
|
||||||
ProtocolConstants.MINECRAFT_1_12_2,
|
|
||||||
ProtocolConstants.MINECRAFT_1_13,
|
|
||||||
ProtocolConstants.MINECRAFT_1_13_1,
|
|
||||||
ProtocolConstants.MINECRAFT_1_13_2,
|
|
||||||
ProtocolConstants.MINECRAFT_1_14,
|
|
||||||
ProtocolConstants.MINECRAFT_1_14_1,
|
|
||||||
ProtocolConstants.MINECRAFT_1_14_2,
|
|
||||||
ProtocolConstants.MINECRAFT_1_14_3,
|
|
||||||
ProtocolConstants.MINECRAFT_1_14_4,
|
|
||||||
ProtocolConstants.MINECRAFT_1_15,
|
|
||||||
ProtocolConstants.MINECRAFT_1_15_1,
|
|
||||||
ProtocolConstants.MINECRAFT_1_15_2,
|
|
||||||
ProtocolConstants.MINECRAFT_1_16,
|
|
||||||
ProtocolConstants.MINECRAFT_1_16_1,
|
|
||||||
ProtocolConstants.MINECRAFT_1_16_2,
|
|
||||||
ProtocolConstants.MINECRAFT_1_16_3,
|
|
||||||
ProtocolConstants.MINECRAFT_1_16_4,
|
|
||||||
ProtocolConstants.MINECRAFT_1_17,
|
|
||||||
ProtocolConstants.MINECRAFT_1_17_1,
|
|
||||||
ProtocolConstants.MINECRAFT_1_18,
|
|
||||||
ProtocolConstants.MINECRAFT_1_18_2,
|
|
||||||
ProtocolConstants.MINECRAFT_1_19,
|
|
||||||
ProtocolConstants.MINECRAFT_1_19_1,
|
|
||||||
ProtocolConstants.MINECRAFT_1_19_3,
|
|
||||||
ProtocolConstants.MINECRAFT_1_19_4,
|
|
||||||
ProtocolConstants.MINECRAFT_1_20,
|
|
||||||
ProtocolConstants.MINECRAFT_1_20_2
|
|
||||||
);
|
|
||||||
|
|
||||||
if ( SNAPSHOT_SUPPORT )
|
|
||||||
{
|
|
||||||
// supportedVersions.add( "1.20.x" );
|
|
||||||
// supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_20_2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
SUPPORTED_VERSIONS = supportedVersions.build();
|
|
||||||
SUPPORTED_VERSION_IDS = supportedVersionIds.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Direction
|
public enum Direction
|
||||||
{
|
{
|
||||||
|
@@ -1,39 +0,0 @@
|
|||||||
package net.md_5.bungee.protocol;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import java.util.BitSet;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class SeenMessages extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
private int offset;
|
|
||||||
private BitSet acknowledged;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
offset = DefinedPacket.readVarInt( buf );
|
|
||||||
acknowledged = DefinedPacket.readFixedBitSet( 20, buf );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
DefinedPacket.writeVarInt( offset, buf );
|
|
||||||
DefinedPacket.writeFixedBitSet( acknowledged, 20, buf );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(AbstractPacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException( "Not supported." );
|
|
||||||
}
|
|
||||||
}
|
|
@@ -53,7 +53,8 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder
|
|||||||
{
|
{
|
||||||
if ( in.hasMemoryAddress() )
|
if ( in.hasMemoryAddress() )
|
||||||
{
|
{
|
||||||
out.add( in.readRetainedSlice( length ) );
|
out.add( in.slice( in.readerIndex(), length ).retain() );
|
||||||
|
in.skipBytes( length );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
if ( !DIRECT_WARNING )
|
if ( !DIRECT_WARNING )
|
||||||
|
@@ -1,25 +0,0 @@
|
|||||||
package net.md_5.bungee.protocol;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.channel.ChannelHandler;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
|
||||||
import io.netty.handler.codec.MessageToMessageEncoder;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepend length of the message as a Varint21 using an extra buffer for the length, avoiding copying packet data
|
|
||||||
*/
|
|
||||||
@ChannelHandler.Sharable
|
|
||||||
public class Varint21LengthFieldExtraBufPrepender extends MessageToMessageEncoder<ByteBuf>
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void encode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws Exception
|
|
||||||
{
|
|
||||||
int bodyLen = msg.readableBytes();
|
|
||||||
ByteBuf lenBuf = ctx.alloc().ioBuffer( Varint21LengthFieldPrepender.varintSize( bodyLen ) );
|
|
||||||
DefinedPacket.writeVarInt( bodyLen, lenBuf );
|
|
||||||
out.add( lenBuf );
|
|
||||||
out.add( msg.retain() );
|
|
||||||
}
|
|
||||||
}
|
|
@@ -5,9 +5,6 @@ import io.netty.channel.ChannelHandler;
|
|||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.MessageToByteEncoder;
|
import io.netty.handler.codec.MessageToByteEncoder;
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepend length of the message as a Varint21 by writing length and data to a new buffer
|
|
||||||
*/
|
|
||||||
@ChannelHandler.Sharable
|
@ChannelHandler.Sharable
|
||||||
public class Varint21LengthFieldPrepender extends MessageToByteEncoder<ByteBuf>
|
public class Varint21LengthFieldPrepender extends MessageToByteEncoder<ByteBuf>
|
||||||
{
|
{
|
||||||
@@ -23,7 +20,7 @@ public class Varint21LengthFieldPrepender extends MessageToByteEncoder<ByteBuf>
|
|||||||
out.writeBytes( msg );
|
out.writeBytes( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
static int varintSize(int paramInt)
|
private static int varintSize(int paramInt)
|
||||||
{
|
{
|
||||||
if ( ( paramInt & 0xFFFFFF80 ) == 0 )
|
if ( ( paramInt & 0xFFFFFF80 ) == 0 )
|
||||||
{
|
{
|
||||||
|
@@ -40,7 +40,7 @@ public class Chat extends DefinedPacket
|
|||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||||
{
|
{
|
||||||
message = readString( buf, ( direction == ProtocolConstants.Direction.TO_CLIENT ) ? 262144 : ( protocolVersion >= ProtocolConstants.MINECRAFT_1_11 ? 256 : 100 ) );
|
message = readString( buf );
|
||||||
if ( direction == ProtocolConstants.Direction.TO_CLIENT )
|
if ( direction == ProtocolConstants.Direction.TO_CLIENT )
|
||||||
{
|
{
|
||||||
position = buf.readByte();
|
position = buf.readByte();
|
||||||
@@ -54,7 +54,7 @@ public class Chat extends DefinedPacket
|
|||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||||
{
|
{
|
||||||
writeString( message, buf, ( direction == ProtocolConstants.Direction.TO_CLIENT ) ? 262144 : ( protocolVersion >= ProtocolConstants.MINECRAFT_1_11 ? 256 : 100 ) );
|
writeString( message, buf );
|
||||||
if ( direction == ProtocolConstants.Direction.TO_CLIENT )
|
if ( direction == ProtocolConstants.Direction.TO_CLIENT )
|
||||||
{
|
{
|
||||||
buf.writeByte( position );
|
buf.writeByte( position );
|
||||||
|
@@ -1,38 +0,0 @@
|
|||||||
package net.md_5.bungee.protocol.packet;
|
|
||||||
|
|
||||||
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.DefinedPacket;
|
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class ClearTitles extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
private boolean reset;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
reset = buf.readBoolean();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
buf.writeBoolean( reset );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(AbstractPacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,97 +0,0 @@
|
|||||||
package net.md_5.bungee.protocol.packet;
|
|
||||||
|
|
||||||
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.ChatChain;
|
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
||||||
import net.md_5.bungee.protocol.SeenMessages;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class ClientChat extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
private String message;
|
|
||||||
private long timestamp;
|
|
||||||
private long salt;
|
|
||||||
private byte[] signature;
|
|
||||||
private boolean signedPreview;
|
|
||||||
private ChatChain chain;
|
|
||||||
private SeenMessages seenMessages;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
message = readString( buf, 256 );
|
|
||||||
timestamp = buf.readLong();
|
|
||||||
salt = buf.readLong();
|
|
||||||
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
|
|
||||||
{
|
|
||||||
if ( buf.readBoolean() )
|
|
||||||
{
|
|
||||||
signature = new byte[ 256 ];
|
|
||||||
buf.readBytes( signature );
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
signature = readArray( buf );
|
|
||||||
}
|
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_19_3 )
|
|
||||||
{
|
|
||||||
signedPreview = buf.readBoolean();
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
|
|
||||||
{
|
|
||||||
seenMessages = new SeenMessages();
|
|
||||||
seenMessages.read( buf, direction, protocolVersion );
|
|
||||||
} else if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
|
|
||||||
{
|
|
||||||
chain = new ChatChain();
|
|
||||||
chain.read( buf, direction, protocolVersion );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
writeString( message, buf );
|
|
||||||
buf.writeLong( timestamp );
|
|
||||||
buf.writeLong( salt );
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
|
|
||||||
{
|
|
||||||
buf.writeBoolean( signature != null );
|
|
||||||
if ( signature != null )
|
|
||||||
{
|
|
||||||
buf.writeBytes( signature );
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
writeArray( signature, buf );
|
|
||||||
}
|
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_19_3 )
|
|
||||||
{
|
|
||||||
buf.writeBoolean( signedPreview );
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
|
|
||||||
{
|
|
||||||
seenMessages.write( buf, direction, protocolVersion );
|
|
||||||
} else if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
|
|
||||||
{
|
|
||||||
chain.write( buf, direction, protocolVersion );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(AbstractPacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,111 +0,0 @@
|
|||||||
package net.md_5.bungee.protocol.packet;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
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.ChatChain;
|
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
||||||
import net.md_5.bungee.protocol.SeenMessages;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class ClientCommand extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
private String command;
|
|
||||||
private long timestamp;
|
|
||||||
private long salt;
|
|
||||||
private Map<String, byte[]> signatures;
|
|
||||||
private boolean signedPreview;
|
|
||||||
private ChatChain chain;
|
|
||||||
private SeenMessages seenMessages;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
command = readString( buf, 256 );
|
|
||||||
timestamp = buf.readLong();
|
|
||||||
salt = buf.readLong();
|
|
||||||
|
|
||||||
int cnt = readVarInt( buf );
|
|
||||||
Preconditions.checkArgument( cnt <= 8, "Too many signatures" );
|
|
||||||
signatures = new HashMap<>( cnt );
|
|
||||||
for ( int i = 0; i < cnt; i++ )
|
|
||||||
{
|
|
||||||
String name = readString( buf, 16 );
|
|
||||||
byte[] signature;
|
|
||||||
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
|
|
||||||
{
|
|
||||||
signature = new byte[ 256 ];
|
|
||||||
buf.readBytes( signature );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
signature = readArray( buf );
|
|
||||||
}
|
|
||||||
signatures.put( name, signature );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_19_3 )
|
|
||||||
{
|
|
||||||
signedPreview = buf.readBoolean();
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
|
|
||||||
{
|
|
||||||
seenMessages = new SeenMessages();
|
|
||||||
seenMessages.read( buf, direction, protocolVersion );
|
|
||||||
} else if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
|
|
||||||
{
|
|
||||||
chain = new ChatChain();
|
|
||||||
chain.read( buf, direction, protocolVersion );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
writeString( command, buf );
|
|
||||||
buf.writeLong( timestamp );
|
|
||||||
buf.writeLong( salt );
|
|
||||||
|
|
||||||
writeVarInt( signatures.size(), buf );
|
|
||||||
for ( Map.Entry<String, byte[]> entry : signatures.entrySet() )
|
|
||||||
{
|
|
||||||
writeString( entry.getKey(), buf );
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
|
|
||||||
{
|
|
||||||
buf.writeBytes( entry.getValue() );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
writeArray( entry.getValue(), buf );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_19_3 )
|
|
||||||
{
|
|
||||||
buf.writeBoolean( signedPreview );
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
|
|
||||||
{
|
|
||||||
seenMessages.write( buf, direction, protocolVersion );
|
|
||||||
} else if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
|
|
||||||
{
|
|
||||||
chain.write( buf, direction, protocolVersion );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(AbstractPacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@@ -23,13 +23,11 @@ public class ClientSettings extends DefinedPacket
|
|||||||
private byte difficulty;
|
private byte difficulty;
|
||||||
private byte skinParts;
|
private byte skinParts;
|
||||||
private int mainHand;
|
private int mainHand;
|
||||||
private boolean disableTextFiltering;
|
|
||||||
private boolean allowServerListing;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||||
{
|
{
|
||||||
locale = readString( buf, 16 );
|
locale = readString( buf );
|
||||||
viewDistance = buf.readByte();
|
viewDistance = buf.readByte();
|
||||||
chatFlags = protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ? DefinedPacket.readVarInt( buf ) : buf.readUnsignedByte();
|
chatFlags = protocolVersion >= ProtocolConstants.MINECRAFT_1_9 ? DefinedPacket.readVarInt( buf ) : buf.readUnsignedByte();
|
||||||
chatColours = buf.readBoolean();
|
chatColours = buf.readBoolean();
|
||||||
@@ -38,14 +36,6 @@ public class ClientSettings extends DefinedPacket
|
|||||||
{
|
{
|
||||||
mainHand = DefinedPacket.readVarInt( buf );
|
mainHand = DefinedPacket.readVarInt( buf );
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_17 )
|
|
||||||
{
|
|
||||||
disableTextFiltering = buf.readBoolean();
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_18 )
|
|
||||||
{
|
|
||||||
allowServerListing = buf.readBoolean();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -66,14 +56,6 @@ public class ClientSettings extends DefinedPacket
|
|||||||
{
|
{
|
||||||
DefinedPacket.writeVarInt( mainHand, buf );
|
DefinedPacket.writeVarInt( mainHand, buf );
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_17 )
|
|
||||||
{
|
|
||||||
buf.writeBoolean( disableTextFiltering );
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_18 )
|
|
||||||
{
|
|
||||||
buf.writeBoolean( allowServerListing );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -36,7 +36,6 @@ import lombok.EqualsAndHashCode;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
import net.md_5.bungee.protocol.DefinedPacket;
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@@ -57,7 +56,7 @@ public class Commands extends DefinedPacket
|
|||||||
private RootCommandNode root;
|
private RootCommandNode root;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
int nodeCount = readVarInt( buf );
|
int nodeCount = readVarInt( buf );
|
||||||
NetworkNode[] nodes = new NetworkNode[ nodeCount ];
|
NetworkNode[] nodes = new NetworkNode[ nodeCount ];
|
||||||
@@ -80,7 +79,9 @@ public class Commands extends DefinedPacket
|
|||||||
break;
|
break;
|
||||||
case NODE_ARGUMENT:
|
case NODE_ARGUMENT:
|
||||||
String name = readString( buf );
|
String name = readString( buf );
|
||||||
argumentBuilder = RequiredArgumentBuilder.argument( name, ArgumentRegistry.read( buf, protocolVersion ) );
|
String parser = readString( buf );
|
||||||
|
|
||||||
|
argumentBuilder = RequiredArgumentBuilder.argument( name, ArgumentRegistry.read( parser, buf ) );
|
||||||
|
|
||||||
if ( ( flags & FLAG_SUGGESTIONS ) != 0 )
|
if ( ( flags & FLAG_SUGGESTIONS ) != 0 )
|
||||||
{
|
{
|
||||||
@@ -125,7 +126,7 @@ public class Commands extends DefinedPacket
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void write(ByteBuf buf)
|
||||||
{
|
{
|
||||||
Map<CommandNode, Integer> indexMap = new LinkedHashMap<>();
|
Map<CommandNode, Integer> indexMap = new LinkedHashMap<>();
|
||||||
Deque<CommandNode> nodeQueue = new ArrayDeque<>();
|
Deque<CommandNode> nodeQueue = new ArrayDeque<>();
|
||||||
@@ -209,7 +210,7 @@ public class Commands extends DefinedPacket
|
|||||||
ArgumentCommandNode argumentNode = (ArgumentCommandNode) node;
|
ArgumentCommandNode argumentNode = (ArgumentCommandNode) node;
|
||||||
|
|
||||||
writeString( argumentNode.getName(), buf );
|
writeString( argumentNode.getName(), buf );
|
||||||
ArgumentRegistry.write( argumentNode.getType(), buf, protocolVersion );
|
ArgumentRegistry.write( argumentNode.getType(), buf );
|
||||||
|
|
||||||
if ( argumentNode.getCustomSuggestions() != null )
|
if ( argumentNode.getCustomSuggestions() != null )
|
||||||
{
|
{
|
||||||
@@ -307,9 +308,6 @@ public class Commands extends DefinedPacket
|
|||||||
{
|
{
|
||||||
|
|
||||||
private static final Map<String, ArgumentSerializer> PROVIDERS = new HashMap<>();
|
private static final Map<String, ArgumentSerializer> PROVIDERS = new HashMap<>();
|
||||||
private static final ArgumentSerializer[] IDS_1_19;
|
|
||||||
private static final ArgumentSerializer[] IDS_1_19_3;
|
|
||||||
private static final ArgumentSerializer[] IDS_1_19_4;
|
|
||||||
private static final Map<Class<?>, ProperArgumentSerializer<?>> PROPER_PROVIDERS = new HashMap<>();
|
private static final Map<Class<?>, ProperArgumentSerializer<?>> PROPER_PROVIDERS = new HashMap<>();
|
||||||
//
|
//
|
||||||
private static final ArgumentSerializer<Void> VOID = new ArgumentSerializer<Void>()
|
private static final ArgumentSerializer<Void> VOID = new ArgumentSerializer<Void>()
|
||||||
@@ -353,7 +351,7 @@ public class Commands extends DefinedPacket
|
|||||||
buf.writeByte( t );
|
buf.writeByte( t );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private static final ArgumentSerializer<FloatArgumentType> FLOAT_RANGE = new ArgumentSerializer<FloatArgumentType>()
|
private static final ArgumentSerializer<FloatArgumentType> FLOAT = new ArgumentSerializer<FloatArgumentType>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected FloatArgumentType read(ByteBuf buf)
|
protected FloatArgumentType read(ByteBuf buf)
|
||||||
@@ -382,7 +380,7 @@ public class Commands extends DefinedPacket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private static final ArgumentSerializer<DoubleArgumentType> DOUBLE_RANGE = new ArgumentSerializer<DoubleArgumentType>()
|
private static final ArgumentSerializer<DoubleArgumentType> DOUBLE = new ArgumentSerializer<DoubleArgumentType>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected DoubleArgumentType read(ByteBuf buf)
|
protected DoubleArgumentType read(ByteBuf buf)
|
||||||
@@ -411,7 +409,7 @@ public class Commands extends DefinedPacket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private static final ArgumentSerializer<IntegerArgumentType> INTEGER_RANGE = new ArgumentSerializer<IntegerArgumentType>()
|
private static final ArgumentSerializer<IntegerArgumentType> INTEGER = new ArgumentSerializer<IntegerArgumentType>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected IntegerArgumentType read(ByteBuf buf)
|
protected IntegerArgumentType read(ByteBuf buf)
|
||||||
@@ -440,21 +438,7 @@ public class Commands extends DefinedPacket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private static final ArgumentSerializer<Integer> INTEGER = new ArgumentSerializer<Integer>()
|
private static final ArgumentSerializer<LongArgumentType> LONG = new ArgumentSerializer<LongArgumentType>()
|
||||||
{
|
|
||||||
@Override
|
|
||||||
protected Integer read(ByteBuf buf)
|
|
||||||
{
|
|
||||||
return buf.readInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void write(ByteBuf buf, Integer t)
|
|
||||||
{
|
|
||||||
buf.writeInt( t );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private static final ArgumentSerializer<LongArgumentType> LONG_RANGE = new ArgumentSerializer<LongArgumentType>()
|
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected LongArgumentType read(ByteBuf buf)
|
protected LongArgumentType read(ByteBuf buf)
|
||||||
@@ -508,310 +492,89 @@ public class Commands extends DefinedPacket
|
|||||||
writeVarInt( t.getType().ordinal(), buf );
|
writeVarInt( t.getType().ordinal(), buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getIntKey()
|
|
||||||
{
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getKey()
|
protected String getKey()
|
||||||
{
|
{
|
||||||
return "brigadier:string";
|
return "brigadier:string";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private static final ArgumentSerializer<String> RAW_STRING = new ArgumentSerializer<String>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
protected String read(ByteBuf buf)
|
|
||||||
{
|
|
||||||
return DefinedPacket.readString( buf );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void write(ByteBuf buf, String t)
|
|
||||||
{
|
|
||||||
DefinedPacket.writeString( t, buf );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
register( "brigadier:bool", VOID );
|
PROVIDERS.put( "brigadier:bool", VOID );
|
||||||
register( "brigadier:float", FLOAT_RANGE );
|
PROVIDERS.put( "brigadier:float", FLOAT );
|
||||||
register( "brigadier:double", DOUBLE_RANGE );
|
PROVIDERS.put( "brigadier:double", DOUBLE );
|
||||||
register( "brigadier:integer", INTEGER_RANGE );
|
PROVIDERS.put( "brigadier:integer", INTEGER );
|
||||||
register( "brigadier:long", LONG_RANGE );
|
PROVIDERS.put( "brigadier:long", LONG );
|
||||||
|
|
||||||
register( "brigadier:string", STRING );
|
PROVIDERS.put( "brigadier:string", STRING );
|
||||||
PROPER_PROVIDERS.put( StringArgumentType.class, STRING );
|
PROPER_PROVIDERS.put( StringArgumentType.class, STRING );
|
||||||
|
|
||||||
register( "minecraft:entity", BYTE );
|
PROVIDERS.put( "minecraft:entity", BYTE );
|
||||||
register( "minecraft:game_profile", VOID );
|
PROVIDERS.put( "minecraft:game_profile", VOID );
|
||||||
register( "minecraft:block_pos", VOID );
|
PROVIDERS.put( "minecraft:block_pos", VOID );
|
||||||
register( "minecraft:column_pos", VOID );
|
PROVIDERS.put( "minecraft:column_pos", VOID );
|
||||||
register( "minecraft:vec3", VOID );
|
PROVIDERS.put( "minecraft:vec3", VOID );
|
||||||
register( "minecraft:vec2", VOID );
|
PROVIDERS.put( "minecraft:vec2", VOID );
|
||||||
register( "minecraft:block_state", VOID );
|
PROVIDERS.put( "minecraft:block_state", VOID );
|
||||||
register( "minecraft:block_predicate", VOID );
|
PROVIDERS.put( "minecraft:block_predicate", VOID );
|
||||||
register( "minecraft:item_stack", VOID );
|
PROVIDERS.put( "minecraft:item_stack", VOID );
|
||||||
register( "minecraft:item_predicate", VOID );
|
PROVIDERS.put( "minecraft:item_predicate", VOID );
|
||||||
register( "minecraft:color", VOID );
|
PROVIDERS.put( "minecraft:color", VOID );
|
||||||
register( "minecraft:component", VOID );
|
PROVIDERS.put( "minecraft:component", VOID );
|
||||||
register( "minecraft:message", VOID );
|
PROVIDERS.put( "minecraft:message", VOID );
|
||||||
register( "minecraft:nbt_compound_tag", VOID ); // 1.14
|
PROVIDERS.put( "minecraft:nbt_compound_tag", VOID ); // 1.14
|
||||||
register( "minecraft:nbt_tag", VOID ); // 1.14
|
PROVIDERS.put( "minecraft:nbt_tag", VOID ); // 1.14
|
||||||
register( "minecraft:nbt_path", VOID );
|
PROVIDERS.put( "minecraft:nbt", VOID ); // 1.13
|
||||||
register( "minecraft:objective", VOID );
|
PROVIDERS.put( "minecraft:nbt_path", VOID );
|
||||||
register( "minecraft:objective_criteria", VOID );
|
PROVIDERS.put( "minecraft:objective", VOID );
|
||||||
register( "minecraft:operation", VOID );
|
PROVIDERS.put( "minecraft:objective_criteria", VOID );
|
||||||
register( "minecraft:particle", VOID );
|
PROVIDERS.put( "minecraft:operation", VOID );
|
||||||
register( "minecraft:angle", VOID ); // 1.16.2
|
PROVIDERS.put( "minecraft:particle", VOID );
|
||||||
register( "minecraft:rotation", VOID );
|
PROVIDERS.put( "minecraft:rotation", VOID );
|
||||||
register( "minecraft:scoreboard_slot", VOID );
|
PROVIDERS.put( "minecraft:scoreboard_slot", VOID );
|
||||||
register( "minecraft:score_holder", BYTE );
|
PROVIDERS.put( "minecraft:score_holder", BYTE );
|
||||||
register( "minecraft:swizzle", VOID );
|
PROVIDERS.put( "minecraft:swizzle", VOID );
|
||||||
register( "minecraft:team", VOID );
|
PROVIDERS.put( "minecraft:team", VOID );
|
||||||
register( "minecraft:item_slot", VOID );
|
PROVIDERS.put( "minecraft:item_slot", VOID );
|
||||||
register( "minecraft:resource_location", VOID );
|
PROVIDERS.put( "minecraft:resource_location", VOID );
|
||||||
register( "minecraft:mob_effect", VOID );
|
PROVIDERS.put( "minecraft:mob_effect", VOID );
|
||||||
register( "minecraft:function", VOID );
|
PROVIDERS.put( "minecraft:function", VOID );
|
||||||
register( "minecraft:entity_anchor", VOID );
|
PROVIDERS.put( "minecraft:entity_anchor", VOID );
|
||||||
register( "minecraft:int_range", VOID );
|
PROVIDERS.put( "minecraft:int_range", VOID );
|
||||||
register( "minecraft:float_range", VOID );
|
PROVIDERS.put( "minecraft:float_range", VOID );
|
||||||
register( "minecraft:item_enchantment", VOID );
|
PROVIDERS.put( "minecraft:item_enchantment", VOID );
|
||||||
register( "minecraft:entity_summon", VOID );
|
PROVIDERS.put( "minecraft:entity_summon", VOID );
|
||||||
register( "minecraft:dimension", VOID );
|
PROVIDERS.put( "minecraft:dimension", VOID );
|
||||||
register( "minecraft:time", VOID ); // 1.14
|
PROVIDERS.put( "minecraft:time", VOID ); // 1.14
|
||||||
register( "minecraft:resource_or_tag", RAW_STRING ); // 1.18.2
|
PROVIDERS.put( "minecraft:uuid", VOID ); // 1.16
|
||||||
register( "minecraft:resource", RAW_STRING ); // 1.18.2
|
PROVIDERS.put( "minecraft:test_argument", VOID ); // 1.16, debug
|
||||||
register( "minecraft:uuid", VOID ); // 1.16
|
PROVIDERS.put( "minecraft:test_class", VOID ); // 1.16, debug
|
||||||
|
PROVIDERS.put( "minecraft:angle", VOID ); // 1.16.2
|
||||||
register( "minecraft:nbt", VOID ); // 1.13 // removed
|
|
||||||
IDS_1_19 = new ArgumentSerializer[]
|
|
||||||
{
|
|
||||||
get( "brigadier:bool", VOID ),
|
|
||||||
get( "brigadier:float", FLOAT_RANGE ),
|
|
||||||
get( "brigadier:double", DOUBLE_RANGE ),
|
|
||||||
get( "brigadier:integer", INTEGER_RANGE ),
|
|
||||||
get( "brigadier:long", LONG_RANGE ),
|
|
||||||
get( "brigadier:string", STRING ),
|
|
||||||
get( "minecraft:entity", BYTE ),
|
|
||||||
get( "minecraft:game_profile", VOID ),
|
|
||||||
get( "minecraft:block_pos", VOID ),
|
|
||||||
get( "minecraft:column_pos", VOID ),
|
|
||||||
get( "minecraft:vec3", VOID ),
|
|
||||||
get( "minecraft:vec2", VOID ),
|
|
||||||
get( "minecraft:block_state", VOID ),
|
|
||||||
get( "minecraft:block_predicate", VOID ),
|
|
||||||
get( "minecraft:item_stack", VOID ),
|
|
||||||
get( "minecraft:item_predicate", VOID ),
|
|
||||||
get( "minecraft:color", VOID ),
|
|
||||||
get( "minecraft:component", VOID ),
|
|
||||||
get( "minecraft:message", VOID ),
|
|
||||||
get( "minecraft:nbt_compound_tag", VOID ),
|
|
||||||
get( "minecraft:nbt_tag", VOID ),
|
|
||||||
get( "minecraft:nbt_path", VOID ),
|
|
||||||
get( "minecraft:objective", VOID ),
|
|
||||||
get( "minecraft:objective_criteria", VOID ),
|
|
||||||
get( "minecraft:operation", VOID ),
|
|
||||||
get( "minecraft:particle", VOID ),
|
|
||||||
get( "minecraft:angle", VOID ),
|
|
||||||
get( "minecraft:rotation", VOID ),
|
|
||||||
get( "minecraft:scoreboard_slot", VOID ),
|
|
||||||
get( "minecraft:score_holder", BYTE ),
|
|
||||||
get( "minecraft:swizzle", VOID ),
|
|
||||||
get( "minecraft:team", VOID ),
|
|
||||||
get( "minecraft:item_slot", VOID ),
|
|
||||||
get( "minecraft:resource_location", VOID ),
|
|
||||||
get( "minecraft:mob_effect", VOID ),
|
|
||||||
get( "minecraft:function", VOID ),
|
|
||||||
get( "minecraft:entity_anchor", VOID ),
|
|
||||||
get( "minecraft:int_range", VOID ),
|
|
||||||
get( "minecraft:float_range", VOID ),
|
|
||||||
get( "minecraft:item_enchantment", VOID ),
|
|
||||||
get( "minecraft:entity_summon", VOID ),
|
|
||||||
get( "minecraft:dimension", VOID ),
|
|
||||||
get( "minecraft:time", VOID ),
|
|
||||||
get( "minecraft:resource_or_tag", RAW_STRING ),
|
|
||||||
get( "minecraft:resource", RAW_STRING ),
|
|
||||||
get( "minecraft:template_mirror", VOID ),
|
|
||||||
get( "minecraft:template_rotation", VOID ),
|
|
||||||
get( "minecraft:uuid", VOID ),
|
|
||||||
};
|
|
||||||
|
|
||||||
IDS_1_19_3 = new ArgumentSerializer[]
|
|
||||||
{
|
|
||||||
get( "brigadier:bool", VOID ),
|
|
||||||
get( "brigadier:float", FLOAT_RANGE ),
|
|
||||||
get( "brigadier:double", DOUBLE_RANGE ),
|
|
||||||
get( "brigadier:integer", INTEGER_RANGE ),
|
|
||||||
get( "brigadier:long", LONG_RANGE ),
|
|
||||||
get( "brigadier:string", STRING ),
|
|
||||||
get( "minecraft:entity", BYTE ),
|
|
||||||
get( "minecraft:game_profile", VOID ),
|
|
||||||
get( "minecraft:block_pos", VOID ),
|
|
||||||
get( "minecraft:column_pos", VOID ),
|
|
||||||
get( "minecraft:vec3", VOID ),
|
|
||||||
get( "minecraft:vec2", VOID ),
|
|
||||||
get( "minecraft:block_state", VOID ),
|
|
||||||
get( "minecraft:block_predicate", VOID ),
|
|
||||||
get( "minecraft:item_stack", VOID ),
|
|
||||||
get( "minecraft:item_predicate", VOID ),
|
|
||||||
get( "minecraft:color", VOID ),
|
|
||||||
get( "minecraft:component", VOID ),
|
|
||||||
get( "minecraft:message", VOID ),
|
|
||||||
get( "minecraft:nbt_compound_tag", VOID ),
|
|
||||||
get( "minecraft:nbt_tag", VOID ),
|
|
||||||
get( "minecraft:nbt_path", VOID ),
|
|
||||||
get( "minecraft:objective", VOID ),
|
|
||||||
get( "minecraft:objective_criteria", VOID ),
|
|
||||||
get( "minecraft:operation", VOID ),
|
|
||||||
get( "minecraft:particle", VOID ),
|
|
||||||
get( "minecraft:angle", VOID ),
|
|
||||||
get( "minecraft:rotation", VOID ),
|
|
||||||
get( "minecraft:scoreboard_slot", VOID ),
|
|
||||||
get( "minecraft:score_holder", BYTE ),
|
|
||||||
get( "minecraft:swizzle", VOID ),
|
|
||||||
get( "minecraft:team", VOID ),
|
|
||||||
get( "minecraft:item_slot", VOID ),
|
|
||||||
get( "minecraft:resource_location", VOID ),
|
|
||||||
get( "minecraft:function", VOID ),
|
|
||||||
get( "minecraft:entity_anchor", VOID ),
|
|
||||||
get( "minecraft:int_range", VOID ),
|
|
||||||
get( "minecraft:float_range", VOID ),
|
|
||||||
get( "minecraft:dimension", VOID ),
|
|
||||||
get( "minecraft:gamemode", VOID ),
|
|
||||||
get( "minecraft:time", VOID ),
|
|
||||||
get( "minecraft:resource_or_tag", RAW_STRING ),
|
|
||||||
get( "minecraft:resource_or_tag_key", RAW_STRING ),
|
|
||||||
get( "minecraft:resource", RAW_STRING ),
|
|
||||||
get( "minecraft:resource_key", RAW_STRING ),
|
|
||||||
get( "minecraft:template_mirror", VOID ),
|
|
||||||
get( "minecraft:template_rotation", VOID ),
|
|
||||||
get( "minecraft:uuid", VOID )
|
|
||||||
};
|
|
||||||
|
|
||||||
IDS_1_19_4 = new ArgumentSerializer[]
|
|
||||||
{
|
|
||||||
get( "brigadier:bool", VOID ),
|
|
||||||
get( "brigadier:float", FLOAT_RANGE ),
|
|
||||||
get( "brigadier:double", DOUBLE_RANGE ),
|
|
||||||
get( "brigadier:integer", INTEGER_RANGE ),
|
|
||||||
get( "brigadier:long", LONG_RANGE ),
|
|
||||||
get( "brigadier:string", STRING ),
|
|
||||||
get( "minecraft:entity", BYTE ),
|
|
||||||
get( "minecraft:game_profile", VOID ),
|
|
||||||
get( "minecraft:block_pos", VOID ),
|
|
||||||
get( "minecraft:column_pos", VOID ),
|
|
||||||
get( "minecraft:vec3", VOID ),
|
|
||||||
get( "minecraft:vec2", VOID ),
|
|
||||||
get( "minecraft:block_state", VOID ),
|
|
||||||
get( "minecraft:block_predicate", VOID ),
|
|
||||||
get( "minecraft:item_stack", VOID ),
|
|
||||||
get( "minecraft:item_predicate", VOID ),
|
|
||||||
get( "minecraft:color", VOID ),
|
|
||||||
get( "minecraft:component", VOID ),
|
|
||||||
get( "minecraft:message", VOID ),
|
|
||||||
get( "minecraft:nbt_compound_tag", VOID ),
|
|
||||||
get( "minecraft:nbt_tag", VOID ),
|
|
||||||
get( "minecraft:nbt_path", VOID ),
|
|
||||||
get( "minecraft:objective", VOID ),
|
|
||||||
get( "minecraft:objective_criteria", VOID ),
|
|
||||||
get( "minecraft:operation", VOID ),
|
|
||||||
get( "minecraft:particle", VOID ),
|
|
||||||
get( "minecraft:angle", VOID ),
|
|
||||||
get( "minecraft:rotation", VOID ),
|
|
||||||
get( "minecraft:scoreboard_slot", VOID ),
|
|
||||||
get( "minecraft:score_holder", BYTE ),
|
|
||||||
get( "minecraft:swizzle", VOID ),
|
|
||||||
get( "minecraft:team", VOID ),
|
|
||||||
get( "minecraft:item_slot", VOID ),
|
|
||||||
get( "minecraft:resource_location", VOID ),
|
|
||||||
get( "minecraft:function", VOID ),
|
|
||||||
get( "minecraft:entity_anchor", VOID ),
|
|
||||||
get( "minecraft:int_range", VOID ),
|
|
||||||
get( "minecraft:float_range", VOID ),
|
|
||||||
get( "minecraft:dimension", VOID ),
|
|
||||||
get( "minecraft:gamemode", VOID ),
|
|
||||||
get( "minecraft:time", INTEGER ),
|
|
||||||
get( "minecraft:resource_or_tag", RAW_STRING ),
|
|
||||||
get( "minecraft:resource_or_tag_key", RAW_STRING ),
|
|
||||||
get( "minecraft:resource", RAW_STRING ),
|
|
||||||
get( "minecraft:resource_key", RAW_STRING ),
|
|
||||||
get( "minecraft:template_mirror", VOID ),
|
|
||||||
get( "minecraft:template_rotation", VOID ),
|
|
||||||
get( "minecraft:uuid", VOID ),
|
|
||||||
get( "minecraft:heightmap", VOID )
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void register(String name, ArgumentSerializer serializer)
|
private static ArgumentType<?> read(String key, ByteBuf buf)
|
||||||
{
|
{
|
||||||
PROVIDERS.put( name, serializer );
|
ArgumentSerializer reader = PROVIDERS.get( key );
|
||||||
}
|
|
||||||
|
|
||||||
private static ArgumentSerializer get(String name, ArgumentSerializer serializer)
|
|
||||||
{
|
|
||||||
return serializer;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ArgumentType<?> read(ByteBuf buf, int protocolVersion)
|
|
||||||
{
|
|
||||||
Object key;
|
|
||||||
ArgumentSerializer reader;
|
|
||||||
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 )
|
|
||||||
{
|
|
||||||
key = readVarInt( buf );
|
|
||||||
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_4 )
|
|
||||||
{
|
|
||||||
reader = IDS_1_19_4[(Integer) key];
|
|
||||||
} else if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 )
|
|
||||||
{
|
|
||||||
reader = IDS_1_19_3[(Integer) key];
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
reader = IDS_1_19[(Integer) key];
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
key = readString( buf );
|
|
||||||
reader = PROVIDERS.get( (String) key );
|
|
||||||
}
|
|
||||||
|
|
||||||
Preconditions.checkArgument( reader != null, "No provider for argument " + key );
|
Preconditions.checkArgument( reader != null, "No provider for argument " + key );
|
||||||
|
|
||||||
Object val = reader.read( buf );
|
Object val = reader.read( buf );
|
||||||
return val != null && PROPER_PROVIDERS.containsKey( val.getClass() ) ? (ArgumentType<?>) val : new DummyType( key, reader, val );
|
return val != null && PROPER_PROVIDERS.containsKey( val.getClass() ) ? (ArgumentType<?>) val : new DummyType( key, reader, val );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void write(ArgumentType<?> arg, ByteBuf buf, int protocolVersion)
|
private static void write(ArgumentType<?> arg, ByteBuf buf)
|
||||||
{
|
{
|
||||||
ProperArgumentSerializer proper = PROPER_PROVIDERS.get( arg.getClass() );
|
ProperArgumentSerializer proper = PROPER_PROVIDERS.get( arg.getClass() );
|
||||||
if ( proper != null )
|
if ( proper != null )
|
||||||
{
|
{
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 )
|
writeString( proper.getKey(), buf );
|
||||||
{
|
|
||||||
writeVarInt( proper.getIntKey(), buf );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
writeString( proper.getKey(), buf );
|
|
||||||
}
|
|
||||||
proper.write( buf, arg );
|
proper.write( buf, arg );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
Preconditions.checkArgument( arg instanceof DummyType, "Non dummy arg " + arg.getClass() );
|
Preconditions.checkArgument( arg instanceof DummyType, "Non dummy arg " + arg.getClass() );
|
||||||
|
|
||||||
DummyType dummy = (DummyType) arg;
|
DummyType dummy = (DummyType) arg;
|
||||||
if ( dummy.key instanceof Integer )
|
writeString( dummy.key, buf );
|
||||||
{
|
|
||||||
writeVarInt( (Integer) dummy.key, buf );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
writeString( (String) dummy.key, buf );
|
|
||||||
}
|
|
||||||
dummy.serializer.write( buf, dummy.value );
|
dummy.serializer.write( buf, dummy.value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -820,7 +583,7 @@ public class Commands extends DefinedPacket
|
|||||||
private static class DummyType<T> implements ArgumentType<T>
|
private static class DummyType<T> implements ArgumentType<T>
|
||||||
{
|
{
|
||||||
|
|
||||||
private final Object key;
|
private final String key;
|
||||||
private final ArgumentSerializer<T> serializer;
|
private final ArgumentSerializer<T> serializer;
|
||||||
private final T value;
|
private final T value;
|
||||||
|
|
||||||
@@ -842,8 +605,6 @@ public class Commands extends DefinedPacket
|
|||||||
private abstract static class ProperArgumentSerializer<T> extends ArgumentSerializer<T>
|
private abstract static class ProperArgumentSerializer<T> extends ArgumentSerializer<T>
|
||||||
{
|
{
|
||||||
|
|
||||||
protected abstract int getIntKey();
|
|
||||||
|
|
||||||
protected abstract String getKey();
|
protected abstract String getKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,36 +18,19 @@ public class EncryptionResponse extends DefinedPacket
|
|||||||
|
|
||||||
private byte[] sharedSecret;
|
private byte[] sharedSecret;
|
||||||
private byte[] verifyToken;
|
private byte[] verifyToken;
|
||||||
private EncryptionData encryptionData;
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||||
{
|
{
|
||||||
sharedSecret = readArray( buf, 128 );
|
sharedSecret = readArray( buf, 128 );
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_19 || protocolVersion >= ProtocolConstants.MINECRAFT_1_19_3 || buf.readBoolean() )
|
verifyToken = readArray( buf, 128 );
|
||||||
{
|
|
||||||
verifyToken = readArray( buf, 128 );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
encryptionData = new EncryptionData( buf.readLong(), readArray( buf ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||||
{
|
{
|
||||||
writeArray( sharedSecret, buf );
|
writeArray( sharedSecret, buf );
|
||||||
if ( verifyToken != null )
|
writeArray( verifyToken, buf );
|
||||||
{
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 && protocolVersion <= ProtocolConstants.MINECRAFT_1_19_3 )
|
|
||||||
{
|
|
||||||
buf.writeBoolean( true );
|
|
||||||
}
|
|
||||||
writeArray( verifyToken, buf );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
buf.writeLong( encryptionData.getSalt() );
|
|
||||||
writeArray( encryptionData.getSignature(), buf );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -55,12 +38,4 @@ public class EncryptionResponse extends DefinedPacket
|
|||||||
{
|
{
|
||||||
handler.handle( this );
|
handler.handle( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class EncryptionData
|
|
||||||
{
|
|
||||||
|
|
||||||
private final long salt;
|
|
||||||
private final byte[] signature;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,37 +0,0 @@
|
|||||||
package net.md_5.bungee.protocol.packet;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
|
||||||
import net.md_5.bungee.protocol.Protocol;
|
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class FinishConfiguration extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Protocol nextProtocol()
|
|
||||||
{
|
|
||||||
return Protocol.GAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(AbstractPacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@@ -24,7 +24,7 @@ public class Handshake extends DefinedPacket
|
|||||||
public void read(ByteBuf buf)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
protocolVersion = readVarInt( buf );
|
protocolVersion = readVarInt( buf );
|
||||||
host = readString( buf, 255 );
|
host = readString( buf );
|
||||||
port = buf.readUnsignedShort();
|
port = buf.readUnsignedShort();
|
||||||
requestedProtocol = readVarInt( buf );
|
requestedProtocol = readVarInt( buf );
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package net.md_5.bungee.protocol.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -9,7 +10,6 @@ import lombok.EqualsAndHashCode;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
import net.md_5.bungee.protocol.DefinedPacket;
|
||||||
import net.md_5.bungee.protocol.Location;
|
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||||
import se.llbit.nbt.Tag;
|
import se.llbit.nbt.Tag;
|
||||||
|
|
||||||
@@ -33,14 +33,10 @@ public class Login extends DefinedPacket
|
|||||||
private int maxPlayers;
|
private int maxPlayers;
|
||||||
private String levelType;
|
private String levelType;
|
||||||
private int viewDistance;
|
private int viewDistance;
|
||||||
private int simulationDistance;
|
|
||||||
private boolean reducedDebugInfo;
|
private boolean reducedDebugInfo;
|
||||||
private boolean normalRespawn;
|
private boolean normalRespawn;
|
||||||
private boolean limitedCrafting;
|
|
||||||
private boolean debug;
|
private boolean debug;
|
||||||
private boolean flat;
|
private boolean flat;
|
||||||
private Location deathLocation;
|
|
||||||
private int portalCooldown;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||||
@@ -50,43 +46,33 @@ public class Login extends DefinedPacket
|
|||||||
{
|
{
|
||||||
hardcore = buf.readBoolean();
|
hardcore = buf.readBoolean();
|
||||||
}
|
}
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
gameMode = buf.readUnsignedByte();
|
||||||
{
|
|
||||||
gameMode = buf.readUnsignedByte();
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
||||||
{
|
{
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
previousGameMode = buf.readUnsignedByte();
|
||||||
{
|
|
||||||
previousGameMode = buf.readUnsignedByte();
|
|
||||||
}
|
|
||||||
|
|
||||||
worldNames = new HashSet<>();
|
worldNames = new HashSet<>();
|
||||||
int worldCount = readVarInt( buf );
|
int worldCount = readVarInt( buf );
|
||||||
|
Preconditions.checkArgument( worldCount < 128, "Too many worlds %s", worldCount );
|
||||||
|
|
||||||
for ( int i = 0; i < worldCount; i++ )
|
for ( int i = 0; i < worldCount; i++ )
|
||||||
{
|
{
|
||||||
worldNames.add( readString( buf ) );
|
worldNames.add( readString( buf ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
dimensions = readTag( buf );
|
||||||
{
|
|
||||||
dimensions = readTag( buf, protocolVersion );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
||||||
{
|
{
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16_2 && protocolVersion < ProtocolConstants.MINECRAFT_1_19 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16_2 )
|
||||||
{
|
{
|
||||||
dimension = readTag( buf, protocolVersion );
|
dimension = readTag( buf );
|
||||||
} else if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
} else
|
||||||
{
|
{
|
||||||
dimension = readString( buf );
|
dimension = readString( buf );
|
||||||
}
|
}
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
worldName = readString( buf );
|
||||||
{
|
|
||||||
worldName = readString( buf );
|
|
||||||
}
|
|
||||||
} else if ( protocolVersion > ProtocolConstants.MINECRAFT_1_9 )
|
} else if ( protocolVersion > ProtocolConstants.MINECRAFT_1_9 )
|
||||||
{
|
{
|
||||||
dimension = buf.readInt();
|
dimension = buf.readInt();
|
||||||
@@ -94,7 +80,7 @@ public class Login extends DefinedPacket
|
|||||||
{
|
{
|
||||||
dimension = (int) buf.readByte();
|
dimension = (int) buf.readByte();
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_15 && protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_15 )
|
||||||
{
|
{
|
||||||
seed = buf.readLong();
|
seed = buf.readLong();
|
||||||
}
|
}
|
||||||
@@ -117,10 +103,6 @@ public class Login extends DefinedPacket
|
|||||||
{
|
{
|
||||||
viewDistance = readVarInt( buf );
|
viewDistance = readVarInt( buf );
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_18 )
|
|
||||||
{
|
|
||||||
simulationDistance = readVarInt( buf );
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= 29 )
|
if ( protocolVersion >= 29 )
|
||||||
{
|
{
|
||||||
reducedDebugInfo = buf.readBoolean();
|
reducedDebugInfo = buf.readBoolean();
|
||||||
@@ -129,31 +111,11 @@ public class Login extends DefinedPacket
|
|||||||
{
|
{
|
||||||
normalRespawn = buf.readBoolean();
|
normalRespawn = buf.readBoolean();
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 )
|
|
||||||
{
|
|
||||||
limitedCrafting = buf.readBoolean();
|
|
||||||
dimension = readString( buf );
|
|
||||||
worldName = readString( buf );
|
|
||||||
seed = buf.readLong();
|
|
||||||
gameMode = buf.readUnsignedByte();
|
|
||||||
previousGameMode = buf.readByte();
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
||||||
{
|
{
|
||||||
debug = buf.readBoolean();
|
debug = buf.readBoolean();
|
||||||
flat = buf.readBoolean();
|
flat = buf.readBoolean();
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 )
|
|
||||||
{
|
|
||||||
if ( buf.readBoolean() )
|
|
||||||
{
|
|
||||||
deathLocation = new Location( readString( buf ), buf.readLong() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20 )
|
|
||||||
{
|
|
||||||
portalCooldown = readVarInt( buf );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -164,16 +126,10 @@ public class Login extends DefinedPacket
|
|||||||
{
|
{
|
||||||
buf.writeBoolean( hardcore );
|
buf.writeBoolean( hardcore );
|
||||||
}
|
}
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
buf.writeByte( gameMode );
|
||||||
{
|
|
||||||
buf.writeByte( gameMode );
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
||||||
{
|
{
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
buf.writeByte( previousGameMode );
|
||||||
{
|
|
||||||
buf.writeByte( previousGameMode );
|
|
||||||
}
|
|
||||||
|
|
||||||
writeVarInt( worldNames.size(), buf );
|
writeVarInt( worldNames.size(), buf );
|
||||||
for ( String world : worldNames )
|
for ( String world : worldNames )
|
||||||
@@ -181,25 +137,19 @@ public class Login extends DefinedPacket
|
|||||||
writeString( world, buf );
|
writeString( world, buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
writeTag( dimensions, buf );
|
||||||
{
|
|
||||||
writeTag( dimensions, buf, protocolVersion );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
||||||
{
|
{
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16_2 && protocolVersion < ProtocolConstants.MINECRAFT_1_19 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16_2 )
|
||||||
{
|
{
|
||||||
writeTag( (Tag) dimension, buf, protocolVersion );
|
writeTag( (Tag) dimension, buf );
|
||||||
} else if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
} else
|
||||||
{
|
{
|
||||||
writeString( (String) dimension, buf );
|
writeString( (String) dimension, buf );
|
||||||
}
|
}
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
writeString( worldName, buf );
|
||||||
{
|
|
||||||
writeString( worldName, buf );
|
|
||||||
}
|
|
||||||
} else if ( protocolVersion > ProtocolConstants.MINECRAFT_1_9 )
|
} else if ( protocolVersion > ProtocolConstants.MINECRAFT_1_9 )
|
||||||
{
|
{
|
||||||
buf.writeInt( (Integer) dimension );
|
buf.writeInt( (Integer) dimension );
|
||||||
@@ -209,10 +159,7 @@ public class Login extends DefinedPacket
|
|||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_15 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_15 )
|
||||||
{
|
{
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_20_2 )
|
buf.writeLong( seed );
|
||||||
{
|
|
||||||
buf.writeLong( seed );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_14 )
|
if ( protocolVersion < ProtocolConstants.MINECRAFT_1_14 )
|
||||||
{
|
{
|
||||||
@@ -233,10 +180,6 @@ public class Login extends DefinedPacket
|
|||||||
{
|
{
|
||||||
writeVarInt( viewDistance, buf );
|
writeVarInt( viewDistance, buf );
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_18 )
|
|
||||||
{
|
|
||||||
writeVarInt( simulationDistance, buf );
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= 29 )
|
if ( protocolVersion >= 29 )
|
||||||
{
|
{
|
||||||
buf.writeBoolean( reducedDebugInfo );
|
buf.writeBoolean( reducedDebugInfo );
|
||||||
@@ -245,36 +188,11 @@ public class Login extends DefinedPacket
|
|||||||
{
|
{
|
||||||
buf.writeBoolean( normalRespawn );
|
buf.writeBoolean( normalRespawn );
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 )
|
|
||||||
{
|
|
||||||
buf.writeBoolean( limitedCrafting );
|
|
||||||
writeString( (String) dimension, buf );
|
|
||||||
writeString( worldName, buf );
|
|
||||||
buf.writeLong( seed );
|
|
||||||
buf.writeByte( gameMode );
|
|
||||||
buf.writeByte( previousGameMode );
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_16 )
|
||||||
{
|
{
|
||||||
buf.writeBoolean( debug );
|
buf.writeBoolean( debug );
|
||||||
buf.writeBoolean( flat );
|
buf.writeBoolean( flat );
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 )
|
|
||||||
{
|
|
||||||
if ( deathLocation != null )
|
|
||||||
{
|
|
||||||
buf.writeBoolean( true );
|
|
||||||
writeString( deathLocation.getDimension(), buf );
|
|
||||||
buf.writeLong( deathLocation.getPos() );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
buf.writeBoolean( false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20 )
|
|
||||||
{
|
|
||||||
writeVarInt( portalCooldown, buf );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -1,37 +0,0 @@
|
|||||||
package net.md_5.bungee.protocol.packet;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
|
||||||
import net.md_5.bungee.protocol.Protocol;
|
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class LoginAcknowledged extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Protocol nextProtocol()
|
|
||||||
{
|
|
||||||
return Protocol.CONFIGURATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(AbstractPacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,15 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
package net.md_5.bungee.protocol.packet;
|
package net.md_5.bungee.protocol.packet;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.util.UUID;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
import net.md_5.bungee.protocol.DefinedPacket;
|
||||||
import net.md_5.bungee.protocol.PlayerPublicKey;
|
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@@ -19,51 +20,17 @@ public class LoginRequest extends DefinedPacket
|
|||||||
{
|
{
|
||||||
|
|
||||||
private String data;
|
private String data;
|
||||||
private PlayerPublicKey publicKey;
|
|
||||||
private UUID uuid;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void read(ByteBuf buf)
|
||||||
{
|
{
|
||||||
data = readString( buf, 16 );
|
data = readString( buf );
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 && protocolVersion < ProtocolConstants.MINECRAFT_1_19_3 )
|
|
||||||
{
|
|
||||||
publicKey = readPublicKey( buf );
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
|
|
||||||
{
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 || buf.readBoolean() )
|
|
||||||
{
|
|
||||||
uuid = readUUID( buf );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void write(ByteBuf buf)
|
||||||
{
|
{
|
||||||
writeString( data, buf );
|
writeString( data, buf );
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 && protocolVersion < ProtocolConstants.MINECRAFT_1_19_3 )
|
|
||||||
{
|
|
||||||
writePublicKey( publicKey, buf );
|
|
||||||
}
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19_1 )
|
|
||||||
{
|
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 )
|
|
||||||
{
|
|
||||||
writeUUID( uuid, buf );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
if ( uuid != null )
|
|
||||||
{
|
|
||||||
buf.writeBoolean( true );
|
|
||||||
writeUUID( uuid, buf );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
buf.writeBoolean( false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -8,7 +8,6 @@ import lombok.EqualsAndHashCode;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
import net.md_5.bungee.protocol.DefinedPacket;
|
||||||
import net.md_5.bungee.protocol.Property;
|
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -20,7 +19,6 @@ public class LoginSuccess extends DefinedPacket
|
|||||||
|
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
private String username;
|
private String username;
|
||||||
private Property[] properties;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||||
@@ -33,10 +31,6 @@ public class LoginSuccess extends DefinedPacket
|
|||||||
uuid = UUID.fromString( readString( buf ) );
|
uuid = UUID.fromString( readString( buf ) );
|
||||||
}
|
}
|
||||||
username = readString( buf );
|
username = readString( buf );
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 )
|
|
||||||
{
|
|
||||||
properties = readProperties( buf );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -50,10 +44,6 @@ public class LoginSuccess extends DefinedPacket
|
|||||||
writeString( uuid.toString(), buf );
|
writeString( uuid.toString(), buf );
|
||||||
}
|
}
|
||||||
writeString( username, buf );
|
writeString( username, buf );
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 )
|
|
||||||
{
|
|
||||||
writeProperties( properties, buf );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -7,8 +7,6 @@ import lombok.EqualsAndHashCode;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
import net.md_5.bungee.protocol.DefinedPacket;
|
||||||
import net.md_5.bungee.protocol.PlayerPublicKey;
|
|
||||||
import net.md_5.bungee.protocol.Property;
|
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@@ -33,17 +31,31 @@ public class PlayerListItem extends DefinedPacket
|
|||||||
{
|
{
|
||||||
case ADD_PLAYER:
|
case ADD_PLAYER:
|
||||||
item.username = DefinedPacket.readString( buf );
|
item.username = DefinedPacket.readString( buf );
|
||||||
item.properties = DefinedPacket.readProperties( buf );
|
item.properties = new String[ DefinedPacket.readVarInt( buf ) ][];
|
||||||
|
for ( int j = 0; j < item.properties.length; j++ )
|
||||||
|
{
|
||||||
|
String name = DefinedPacket.readString( buf );
|
||||||
|
String value = DefinedPacket.readString( buf );
|
||||||
|
if ( buf.readBoolean() )
|
||||||
|
{
|
||||||
|
item.properties[j] = new String[]
|
||||||
|
{
|
||||||
|
name, value, DefinedPacket.readString( buf )
|
||||||
|
};
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
item.properties[j] = new String[]
|
||||||
|
{
|
||||||
|
name, value
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
item.gamemode = DefinedPacket.readVarInt( buf );
|
item.gamemode = DefinedPacket.readVarInt( buf );
|
||||||
item.ping = DefinedPacket.readVarInt( buf );
|
item.ping = DefinedPacket.readVarInt( buf );
|
||||||
if ( buf.readBoolean() )
|
if ( buf.readBoolean() )
|
||||||
{
|
{
|
||||||
item.displayName = DefinedPacket.readString( buf );
|
item.displayName = DefinedPacket.readString( buf );
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 )
|
|
||||||
{
|
|
||||||
item.publicKey = readPublicKey( buf );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case UPDATE_GAMEMODE:
|
case UPDATE_GAMEMODE:
|
||||||
item.gamemode = DefinedPacket.readVarInt( buf );
|
item.gamemode = DefinedPacket.readVarInt( buf );
|
||||||
@@ -72,7 +84,20 @@ public class PlayerListItem extends DefinedPacket
|
|||||||
{
|
{
|
||||||
case ADD_PLAYER:
|
case ADD_PLAYER:
|
||||||
DefinedPacket.writeString( item.username, buf );
|
DefinedPacket.writeString( item.username, buf );
|
||||||
DefinedPacket.writeProperties( item.properties, buf );
|
DefinedPacket.writeVarInt( item.properties.length, buf );
|
||||||
|
for ( String[] prop : item.properties )
|
||||||
|
{
|
||||||
|
DefinedPacket.writeString( prop[0], buf );
|
||||||
|
DefinedPacket.writeString( prop[1], buf );
|
||||||
|
if ( prop.length >= 3 )
|
||||||
|
{
|
||||||
|
buf.writeBoolean( true );
|
||||||
|
DefinedPacket.writeString( prop[2], buf );
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
buf.writeBoolean( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
DefinedPacket.writeVarInt( item.gamemode, buf );
|
DefinedPacket.writeVarInt( item.gamemode, buf );
|
||||||
DefinedPacket.writeVarInt( item.ping, buf );
|
DefinedPacket.writeVarInt( item.ping, buf );
|
||||||
buf.writeBoolean( item.displayName != null );
|
buf.writeBoolean( item.displayName != null );
|
||||||
@@ -80,10 +105,6 @@ public class PlayerListItem extends DefinedPacket
|
|||||||
{
|
{
|
||||||
DefinedPacket.writeString( item.displayName, buf );
|
DefinedPacket.writeString( item.displayName, buf );
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_19 )
|
|
||||||
{
|
|
||||||
writePublicKey( item.publicKey, buf );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case UPDATE_GAMEMODE:
|
case UPDATE_GAMEMODE:
|
||||||
DefinedPacket.writeVarInt( item.gamemode, buf );
|
DefinedPacket.writeVarInt( item.gamemode, buf );
|
||||||
@@ -123,26 +144,20 @@ public class PlayerListItem extends DefinedPacket
|
|||||||
{
|
{
|
||||||
|
|
||||||
// ALL
|
// ALL
|
||||||
UUID uuid;
|
private UUID uuid;
|
||||||
|
|
||||||
// ADD_PLAYER
|
// ADD_PLAYER
|
||||||
String username;
|
private String username;
|
||||||
Property[] properties;
|
private String[][] properties;
|
||||||
|
|
||||||
UUID chatSessionId;
|
|
||||||
PlayerPublicKey publicKey;
|
|
||||||
|
|
||||||
// UPDATE_LISTED
|
|
||||||
Boolean listed;
|
|
||||||
|
|
||||||
// ADD_PLAYER & UPDATE_GAMEMODE
|
// ADD_PLAYER & UPDATE_GAMEMODE
|
||||||
Integer gamemode;
|
private int gamemode;
|
||||||
|
|
||||||
// ADD_PLAYER & UPDATE_LATENCY
|
// ADD_PLAYER & UPDATE_LATENCY
|
||||||
Integer ping;
|
private int ping;
|
||||||
|
|
||||||
// ADD_PLAYER & UPDATE_DISPLAY_NAME
|
// ADD_PLAYER & UPDATE_DISPLAY_NAME
|
||||||
String displayName;
|
private String displayName;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,45 +0,0 @@
|
|||||||
package net.md_5.bungee.protocol.packet;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import java.util.UUID;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class PlayerListItemRemove extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
private UUID[] uuids;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
uuids = new UUID[ DefinedPacket.readVarInt( buf ) ];
|
|
||||||
for ( int i = 0; i < uuids.length; i++ )
|
|
||||||
{
|
|
||||||
uuids[i] = DefinedPacket.readUUID( buf );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
DefinedPacket.writeVarInt( uuids.length, buf );
|
|
||||||
for ( UUID uuid : uuids )
|
|
||||||
{
|
|
||||||
DefinedPacket.writeUUID( uuid, buf );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(AbstractPacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,133 +0,0 @@
|
|||||||
package net.md_5.bungee.protocol.packet;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
|
||||||
import net.md_5.bungee.protocol.PlayerPublicKey;
|
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
||||||
import net.md_5.bungee.protocol.packet.PlayerListItem.Item;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class PlayerListItemUpdate extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
private EnumSet<Action> actions;
|
|
||||||
private Item[] items;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
actions = readEnumSet( PlayerListItemUpdate.Action.class, buf );
|
|
||||||
|
|
||||||
items = new Item[ DefinedPacket.readVarInt( buf ) ];
|
|
||||||
for ( int i = 0; i < items.length; i++ )
|
|
||||||
{
|
|
||||||
Item item = items[i] = new Item();
|
|
||||||
item.setUuid( DefinedPacket.readUUID( buf ) );
|
|
||||||
|
|
||||||
for ( Action action : actions )
|
|
||||||
{
|
|
||||||
switch ( action )
|
|
||||||
{
|
|
||||||
case ADD_PLAYER:
|
|
||||||
item.username = DefinedPacket.readString( buf );
|
|
||||||
item.properties = DefinedPacket.readProperties( buf );
|
|
||||||
break;
|
|
||||||
case INITIALIZE_CHAT:
|
|
||||||
if ( buf.readBoolean() )
|
|
||||||
{
|
|
||||||
item.chatSessionId = readUUID( buf );
|
|
||||||
item.publicKey = new PlayerPublicKey( buf.readLong(), readArray( buf, 512 ), readArray( buf, 4096 ) );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case UPDATE_GAMEMODE:
|
|
||||||
item.gamemode = DefinedPacket.readVarInt( buf );
|
|
||||||
break;
|
|
||||||
case UPDATE_LISTED:
|
|
||||||
item.listed = buf.readBoolean();
|
|
||||||
break;
|
|
||||||
case UPDATE_LATENCY:
|
|
||||||
item.ping = DefinedPacket.readVarInt( buf );
|
|
||||||
break;
|
|
||||||
case UPDATE_DISPLAY_NAME:
|
|
||||||
if ( buf.readBoolean() )
|
|
||||||
{
|
|
||||||
item.displayName = DefinedPacket.readString( buf );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
DefinedPacket.writeEnumSet( actions, PlayerListItemUpdate.Action.class, buf );
|
|
||||||
|
|
||||||
DefinedPacket.writeVarInt( items.length, buf );
|
|
||||||
for ( Item item : items )
|
|
||||||
{
|
|
||||||
DefinedPacket.writeUUID( item.uuid, buf );
|
|
||||||
for ( Action action : actions )
|
|
||||||
{
|
|
||||||
switch ( action )
|
|
||||||
{
|
|
||||||
case ADD_PLAYER:
|
|
||||||
DefinedPacket.writeString( item.username, buf );
|
|
||||||
DefinedPacket.writeProperties( item.properties, buf );
|
|
||||||
break;
|
|
||||||
case INITIALIZE_CHAT:
|
|
||||||
buf.writeBoolean( item.chatSessionId != null );
|
|
||||||
if ( item.chatSessionId != null )
|
|
||||||
{
|
|
||||||
writeUUID( item.chatSessionId, buf );
|
|
||||||
buf.writeLong( item.publicKey.getExpiry() );
|
|
||||||
writeArray( item.publicKey.getKey(), buf );
|
|
||||||
writeArray( item.publicKey.getSignature(), buf );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case UPDATE_GAMEMODE:
|
|
||||||
DefinedPacket.writeVarInt( item.gamemode, buf );
|
|
||||||
break;
|
|
||||||
case UPDATE_LISTED:
|
|
||||||
buf.writeBoolean( item.listed );
|
|
||||||
break;
|
|
||||||
case UPDATE_LATENCY:
|
|
||||||
DefinedPacket.writeVarInt( item.ping, buf );
|
|
||||||
break;
|
|
||||||
case UPDATE_DISPLAY_NAME:
|
|
||||||
buf.writeBoolean( item.displayName != null );
|
|
||||||
if ( item.displayName != null )
|
|
||||||
{
|
|
||||||
DefinedPacket.writeString( item.displayName, buf );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(AbstractPacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum Action
|
|
||||||
{
|
|
||||||
|
|
||||||
ADD_PLAYER,
|
|
||||||
INITIALIZE_CHAT,
|
|
||||||
UPDATE_GAMEMODE,
|
|
||||||
UPDATE_LISTED,
|
|
||||||
UPDATE_LATENCY,
|
|
||||||
UPDATE_DISPLAY_NAME;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -2,6 +2,7 @@ package net.md_5.bungee.protocol.packet;
|
|||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
@@ -47,6 +48,14 @@ public class PluginMessage extends DefinedPacket
|
|||||||
return "legacy:" + tag.toLowerCase( Locale.ROOT );
|
return "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( "minecraft:register" ) || input.getTag().equals( "MC|Brand" ) || input.getTag().equals( "minecraft:brand" ) ) && input.getData().length < Byte.MAX_VALUE;
|
||||||
|
}
|
||||||
|
};
|
||||||
//
|
//
|
||||||
private String tag;
|
private String tag;
|
||||||
private byte[] data;
|
private byte[] data;
|
||||||
@@ -59,9 +68,9 @@ public class PluginMessage extends DefinedPacket
|
|||||||
@Override
|
@Override
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
||||||
{
|
{
|
||||||
tag = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? MODERNISE.apply( readString( buf ) ) : readString( buf, 20 );
|
tag = ( protocolVersion >= ProtocolConstants.MINECRAFT_1_13 ) ? MODERNISE.apply( readString( buf ) ) : readString( buf );
|
||||||
int maxSize = ( direction == ProtocolConstants.Direction.TO_SERVER ) ? Short.MAX_VALUE : 0x100000;
|
int maxSize = direction == ProtocolConstants.Direction.TO_SERVER ? Short.MAX_VALUE : 0x100000;
|
||||||
Preconditions.checkArgument( buf.readableBytes() <= maxSize, "Payload too large" );
|
Preconditions.checkArgument( buf.readableBytes() < maxSize );
|
||||||
data = new byte[ buf.readableBytes() ];
|
data = new byte[ buf.readableBytes() ];
|
||||||
buf.readBytes( data );
|
buf.readBytes( data );
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user